Thread (40 messages) 40 messages, 6 authors, 2021-12-13

Re: [PATCH 01/22] libperf: Add comments to perf_cpu_map.

flat view

From: John Garry <hidden>
Date: 2021-12-13 08:56:42
Also in: linux-perf-users, lkml

On 10/12/2021 19:08, Arnaldo Carvalho de Melo wrote:
quoted
quoted
quoted
+/**
+ * A sized, reference counted, sorted array of integers representing CPU
+ * numbers. This is commonly used to capture which CPUs a PMU is associated
+ * with.
+ */
   struct perf_cpu_map {
       refcount_t      refcnt;
+     /** Length of the map array. */
       int             nr;
I'd have /s/nr/len/, as it means the map length, as opposed to confusing nr meaning with number of cpus in the host or something else. And the new comment uses "Length" also.
quoted
quoted
quoted
+     /** The CPU values. */
       int             map[];
would simply more distinct names for the variables help instead of or in
addition to comments?
Well, in this case the typical usage doesn't help, as 'struct
perf_cpu_map' are being used simply as "map"
There are a lot of instances to change ... but I am all up for using consistent and well-meaning variable / argument names per type.
where it should be cpu_map,
so we would have:

	cpu_map->nr

And all should be obvious, no? Otherwise we would have redundant 'cpu',
like:

	cpu_map->nr_cpus

And 'map' should really be entries, so:

	cpu_map->entries[index];

Would be clear enough, o?
  
quoted
Thanks John! I agree. The phrase that is often used is intention
revealing names. The kernel style for naming is to be brief:

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help