Messages in this thread | | | Date | Mon, 27 Aug 2007 17:12:27 -0700 | From | Andrew Morton <> | Subject | Re: [PATCH] trivial - convert "for(foo=0;foo<NR_CPUS;foo++)" to "for_each_possible_cpu(foo)" |
| |
On Mon, 27 Aug 2007 16:54:47 -0700 Joe Perches <joe@perches.com> 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |