lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 27 Aug 2007 17:12:27 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Joe Perches <joe@...ches.com>
Cc:	linux-kernel@...r.kernel.org, torvalds@...ux-foundation.org,
	Mike Travis <travis@....com>
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@...ches.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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ