]> git.baikalelectronics.ru Git - kernel.git/commit
cpumask_set_cpu_local_first => cpumask_local_spread, lament
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 8 May 2015 17:44:13 +0000 (03:14 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 28 May 2015 01:35:20 +0000 (11:05 +0930)
commitbeaf1dbfaf2c6a5aa07f98deaaaf6b5cb2d7ab4d
tree1a7bdf324a50bc75efe6c57c2525ccffd9c385f4
parent032d68ab8f9211cc3072997e17a9b2027d351977
cpumask_set_cpu_local_first => cpumask_local_spread, lament

92fe29c3a0d6 (cpumask: Utility function to set n'th cpu...) created a
genuinely weird function.  I never saw it before, it went through DaveM.
(He only does this to make us other maintainers feel better about our own
mistakes.)

cpumask_set_cpu_local_first's purpose is say "I need to spread things
across N online cpus, choose the ones on this numa node first"; you call
it in a loop.

It can fail.  One of the two callers ignores this, the other aborts and
fails the device open.

It can fail in two ways: allocating the off-stack cpumask, or through a
convoluted codepath which AFAICT can only occur if cpu_online_mask
changes.  Which shouldn't happen, because if cpu_online_mask can change
while you call this, it could return a now-offline cpu anyway.

It contains a nonsensical test "!cpumask_of_node(numa_node)".  This was
drawn to my attention by Geert, who said this causes a warning on Sparc.
It sets a single bit in a cpumask instead of returning a cpu number,
because that's what the callers want.

It could be made more efficient by passing the previous cpu rather than
an index, but that would be more invasive to the callers.

Fixes: 92fe29c3a0d63497d90e0bd6c24a9960da51e531
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (then rebased)
Tested-by: Amir Vadai <amirv@mellanox.com>
Acked-by: Amir Vadai <amirv@mellanox.com>
Acked-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/emulex/benet/be_main.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/en_tx.c
include/linux/cpumask.h
lib/cpumask.c