cpusets: randomize node rotor used in cpuset_mem_spread_node()

[ This patch has already been accepted as commit 0ac0c0d0f837 but later
  reverted (commit 35926ff5fba8) 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]>
6 files changed