Re: [PATCH] trivial - convert "for(foo=0;foo<NR_CPUS;foo++)" to "for_each_possible_cpu(foo)"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 27 Aug 2007 16:54:47 -0700
Joe Perches <[email protected]> wrote:

> Done via grep/sed and compile tested i386 with xen
> 
> Changed the foo++ and ++foo forms
> 
> $ egrep -r -l "for[[:space:]]*\([[:space:]]*([A-Za-z0-9_]+)[[:space:]]*=[[:space:]]*0[[:space:]]*;[[:space:]]*\1[[:space:]]*<[[:space:]]*NR_CPUS[[:space:]]*;[[:space:]]*\1\+\+[[:space:]]*[[:space:]]*\)" * | xargs sed -i -r -e "s/for[[:space:]]*\([[:space:]]*([A-Za-z0-9_]+)[[:space:]]*=[[:space:]]*0[[:space:]]*;[[:space:]]*\1[[:space:]]*<[[:space:]]*NR_CPUS[[:space:]]*;[[:space:]]*\1[[:space:]]*\+\+[[:space:]]*\)/for_each_possible_cpu\(\1\)/g"
> $ egrep -r -l "for[[:space:]]*\([[:space:]]*([A-Za-z0-9_]+)[[:space:]]*=[[:space:]]*0[[:space:]]*;[[:space:]]*\1[[:space:]]*<[[:space:]]*NR_CPUS[[:space:]]*;[[:space:]]*\+\+[[:space:]]*\1[[:space:]]*\)" * | xargs sed -i -r -e "s/for[[:space:]]*\([[:space:]]*([A-Za-z0-9_]+)[[:space:]]*=[[:space:]]*0[[:space:]]*;[[:space:]]*\1[[:space:]]*<[[:space:]]*NR_CPUS[[:space:]]*;[[:space:]]*\+\+[[:space:]]*\1[[:space:]]*\)/for_each_possible_cpu\(\1\)/g"

No, each of these sites needs careful attention.

- Can we reduce the amount of memory which is being used?  Because
  hweight(num_possible_cpus) <= hweight(NR_CPUS)

- Do we _really_ need to be iterating across all possible CPUS?  Or
  should we really have been using for_each_online_cpu() or
  for_each_present_cpu()?

See, many of these sites will be old code which predates cpu hotplug and
the more advanced cpu masks.  We shouldn't just blindly go and pretend that
these sites have been modernised when they haven't.

Right now, pretty much every instance of NR_CPUS in the tree is a flag
which says "old, krufty, fixme".   Let's not hide that please. 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux