Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux

Pull fixes for cpumask and modules from Rusty Russell:
"** NOW WITH TESTING! **

Two fixes which got lost in my recent distraction. One is a weird
cpumask function which needed to be rewritten, the other is a module
bug which is cc:stable"

* tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
cpumask_set_cpu_local_first => cpumask_local_spread, lament
module: Call module notifier on failure after complete_formation()

+38 -63
+3 -3
drivers/net/ethernet/emulex/benet/be_main.c
··· 2358 2358 adapter->cfg_num_qs); 2359 2359 2360 2360 for_all_evt_queues(adapter, eqo, i) { 2361 + int numa_node = dev_to_node(&adapter->pdev->dev); 2361 2362 if (!zalloc_cpumask_var(&eqo->affinity_mask, GFP_KERNEL)) 2362 2363 return -ENOMEM; 2363 - cpumask_set_cpu_local_first(i, dev_to_node(&adapter->pdev->dev), 2364 - eqo->affinity_mask); 2365 - 2364 + cpumask_set_cpu(cpumask_local_spread(i, numa_node), 2365 + eqo->affinity_mask); 2366 2366 netif_napi_add(adapter->netdev, &eqo->napi, be_poll, 2367 2367 BE_NAPI_WEIGHT); 2368 2368 napi_hash_add(&eqo->napi);
+3 -7
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
··· 1501 1501 { 1502 1502 struct mlx4_en_rx_ring *ring = priv->rx_ring[ring_idx]; 1503 1503 int numa_node = priv->mdev->dev->numa_node; 1504 - int ret = 0; 1505 1504 1506 1505 if (!zalloc_cpumask_var(&ring->affinity_mask, GFP_KERNEL)) 1507 1506 return -ENOMEM; 1508 1507 1509 - ret = cpumask_set_cpu_local_first(ring_idx, numa_node, 1510 - ring->affinity_mask); 1511 - if (ret) 1512 - free_cpumask_var(ring->affinity_mask); 1513 - 1514 - return ret; 1508 + cpumask_set_cpu(cpumask_local_spread(ring_idx, numa_node), 1509 + ring->affinity_mask); 1510 + return 0; 1515 1511 } 1516 1512 1517 1513 static void mlx4_en_free_affinity_hint(struct mlx4_en_priv *priv, int ring_idx)
+3 -3
drivers/net/ethernet/mellanox/mlx4/en_tx.c
··· 144 144 ring->queue_index = queue_index; 145 145 146 146 if (queue_index < priv->num_tx_rings_p_up) 147 - cpumask_set_cpu_local_first(queue_index, 148 - priv->mdev->dev->numa_node, 149 - &ring->affinity_mask); 147 + cpumask_set_cpu(cpumask_local_spread(queue_index, 148 + priv->mdev->dev->numa_node), 149 + &ring->affinity_mask); 150 150 151 151 *pring = ring; 152 152 return 0;
+2 -4
include/linux/cpumask.h
··· 151 151 return 1; 152 152 } 153 153 154 - static inline int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp) 154 + static inline unsigned int cpumask_local_spread(unsigned int i, int node) 155 155 { 156 - set_bit(0, cpumask_bits(dstp)); 157 - 158 156 return 0; 159 157 } 160 158 ··· 206 208 207 209 int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *); 208 210 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu); 209 - int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp); 211 + unsigned int cpumask_local_spread(unsigned int i, int node); 210 212 211 213 /** 212 214 * for_each_cpu - iterate over every cpu in a mask
+3
kernel/module.c
··· 3370 3370 module_bug_cleanup(mod); 3371 3371 mutex_unlock(&module_mutex); 3372 3372 3373 + blocking_notifier_call_chain(&module_notify_list, 3374 + MODULE_STATE_GOING, mod); 3375 + 3373 3376 /* we can't deallocate the module until we clear memory protection */ 3374 3377 unset_module_init_ro_nx(mod); 3375 3378 unset_module_core_ro_nx(mod);
+24 -46
lib/cpumask.c
··· 139 139 #endif 140 140 141 141 /** 142 - * cpumask_set_cpu_local_first - set i'th cpu with local numa cpu's first 143 - * 142 + * cpumask_local_spread - select the i'th cpu with local numa cpu's first 144 143 * @i: index number 145 - * @numa_node: local numa_node 146 - * @dstp: cpumask with the relevant cpu bit set according to the policy 144 + * @node: local numa_node 147 145 * 148 - * This function sets the cpumask according to a numa aware policy. 149 - * cpumask could be used as an affinity hint for the IRQ related to a 150 - * queue. When the policy is to spread queues across cores - local cores 151 - * first. 146 + * This function selects an online CPU according to a numa aware policy; 147 + * local cpus are returned first, followed by non-local ones, then it 148 + * wraps around. 152 149 * 153 - * Returns 0 on success, -ENOMEM for no memory, and -EAGAIN when failed to set 154 - * the cpu bit and need to re-call the function. 150 + * It's not very efficient, but useful for setup. 155 151 */ 156 - int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp) 152 + unsigned int cpumask_local_spread(unsigned int i, int node) 157 153 { 158 - cpumask_var_t mask; 159 154 int cpu; 160 - int ret = 0; 161 155 162 - if (!zalloc_cpumask_var(&mask, GFP_KERNEL)) 163 - return -ENOMEM; 164 - 156 + /* Wrap: we always want a cpu. */ 165 157 i %= num_online_cpus(); 166 158 167 - if (numa_node == -1 || !cpumask_of_node(numa_node)) { 168 - /* Use all online cpu's for non numa aware system */ 169 - cpumask_copy(mask, cpu_online_mask); 159 + if (node == -1) { 160 + for_each_cpu(cpu, cpu_online_mask) 161 + if (i-- == 0) 162 + return cpu; 170 163 } else { 171 - int n; 164 + /* NUMA first. */ 165 + for_each_cpu_and(cpu, cpumask_of_node(node), cpu_online_mask) 166 + if (i-- == 0) 167 + return cpu; 172 168 173 - cpumask_and(mask, 174 - cpumask_of_node(numa_node), cpu_online_mask); 169 + for_each_cpu(cpu, cpu_online_mask) { 170 + /* Skip NUMA nodes, done above. */ 171 + if (cpumask_test_cpu(cpu, cpumask_of_node(node))) 172 + continue; 175 173 176 - n = cpumask_weight(mask); 177 - if (i >= n) { 178 - i -= n; 179 - 180 - /* If index > number of local cpu's, mask out local 181 - * cpu's 182 - */ 183 - cpumask_andnot(mask, cpu_online_mask, mask); 174 + if (i-- == 0) 175 + return cpu; 184 176 } 185 177 } 186 - 187 - for_each_cpu(cpu, mask) { 188 - if (--i < 0) 189 - goto out; 190 - } 191 - 192 - ret = -EAGAIN; 193 - 194 - out: 195 - free_cpumask_var(mask); 196 - 197 - if (!ret) 198 - cpumask_set_cpu(cpu, dstp); 199 - 200 - return ret; 178 + BUG(); 201 179 } 202 - EXPORT_SYMBOL(cpumask_set_cpu_local_first); 180 + EXPORT_SYMBOL(cpumask_local_spread);