cpusets: randomize node rotor used in cpuset_mem_spread_node()

[ This patch has already been accepted as commit 0ac0c0d0f8 but later
  reverted (commit 35926ff5fb) because it itroduced arch specific
  __node_random which was defined only for x86 code so it broke other
  archs.  This is a followup without any arch specific code.  Other than
  that there are no functional changes.]

Some workloads that create a large number of small files tend to assign
too many pages to node 0 (multi-node systems).  Part of the reason is
that the rotor (in cpuset_mem_spread_node()) used to assign nodes starts
at node 0 for newly created tasks.

This patch changes the rotor to be initialized to a random node number
of the cpuset.

[[email protected]: fix layout]
[[email protected]: Define stub numa_random() for !NUMA configuration]
[[email protected]: Make it arch independent]
[[email protected]: fix CONFIG_NUMA=y, MAX_NUMNODES>1 build]
Signed-off-by: Jack Steiner <[email protected]>
Signed-off-by: Lee Schermerhorn <[email protected]>
Signed-off-by: Michal Hocko <[email protected]>
Reviewed-by: KOSAKI Motohiro <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Paul Menage <[email protected]>
Cc: Jack Steiner <[email protected]>
Cc: Robin Holt <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Jack Steiner <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: Lee Schermerhorn <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Paul Menage <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Robin Holt <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Michal Hocko 2011-07-26 16:08:30 -07:00 • committed by Linus Torvalds
commit 778d3b0ff0
6 changed files with 43 additions and 1 deletions

View file

@ -756,7 +756,7 @@ static int bitmap_pos_to_ord(const unsigned long *buf, int pos, int bits)
*
* The bit positions 0 through @bits are valid positions in @buf.
*/
static int bitmap_ord_to_pos(const unsigned long *buf, int ord, int bits)
int bitmap_ord_to_pos(const unsigned long *buf, int ord, int bits)
{
int pos = 0;