• Ming Lei's avatar
    genirq/affinity: Spread vectors on node according to nr_cpu ratio · b1a5a73e
    Ming Lei authored
    Now __irq_build_affinity_masks() spreads vectors evenly per node, but there
    is a case that not all vectors have been spread when each numa node has a
    different number of CPUs which triggers the warning in the spreading code.
    
    Improve the spreading algorithm by
    
     - assigning vectors according to the ratio of the number of CPUs on a node
       to the number of remaining CPUs.
    
     - running the assignment from smaller nodes to bigger nodes to guarantee
       that every active node gets allocated at least one vector.
    
    This ensures that all vectors are spread out. Asided of that the spread
    becomes more fair if the nodes have different number of CPUs.
    
    For example, on the following machine:
    	CPU(s):              16
    	On-line CPU(s) list: 0-15
    	Thread(s) per core:  1
    	Core(s) per socket:  8
    	Socket(s):           2
    	NUMA node(s):        2
    	...
    	NUMA node0 CPU(s):   0,1,3,5-9,11,13-15
    	NUMA node1 CPU(s):   2,4,10,12
    
    When a driver requests to allocate 8 vectors, the following spread results:
    
    	irq 31, cpu list 2,4
    	irq 32, cpu list 10,12
    	irq 33, cpu list 0-1
    	irq 34, cpu list 3,5
    	irq 35, cpu list 6-7
    	irq 36, cpu list 8-9
    	irq 37, cpu list 11,13
    	irq 38, cpu list 14-15
    
    So Node 0 has now 6 and Node 1 has 2 vectors assigned. The original
    algorithm assigned 4 vectors on each node which was unfair versus Node 0.
    
    [ tglx: Massaged changelog ]
    Reported-by: default avatarJon Derrick <jonathan.derrick@intel.com>
    Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
    Reviewed-by: default avatarJon Derrick <jonathan.derrick@intel.com>
    Link: https://lkml.kernel.org/r/20190816022849.14075-3-ming.lei@redhat.com
    b1a5a73e
affinity.c 12.9 KB