From: Andrew Morton <akpm@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
Mike Travis <travis@sgi.com>
Subject: Re: [PATCH] trivial - convert "for(foo=0;foo<NR_CPUS;foo++)" to "for_each_possible_cpu(foo)"
Date: Mon, 27 Aug 2007 17:12:27 -0700 [thread overview]
Message-ID: <20070827171227.285b7383.akpm@linux-foundation.org> (raw)
In-Reply-To: <1188258887.18004.173.camel@localhost>
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.
next prev parent reply other threads:[~2007-08-28 0:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-27 23:54 [PATCH] trivial - convert "for(foo=0;foo<NR_CPUS;foo++)" to "for_each_possible_cpu(foo)" Joe Perches
2007-08-28 0:12 ` Andrew Morton [this message]
2007-08-28 0:31 ` Joe Perches
2007-08-28 0:14 ` Michal Piotrowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070827171227.285b7383.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=travis@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox