From f9b531fe14a539ec2ad802b73c9638f324e4a4ff Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 5 Mar 2015 10:49:16 +1030 Subject: drivers: fix up obsolete cpu function usage. Thanks to spatch, plus manual removal of "&*". Then a sweep for for_each_cpu_mask => for_each_cpu. Signed-off-by: Rusty Russell Acked-by: Rafael J. Wysocki Cc: Thomas Gleixner Cc: Herbert Xu Cc: Jason Cooper Cc: Chris Metcalf Cc: netdev@vger.kernel.org --- drivers/clocksource/dw_apb_timer.c | 3 ++- drivers/cpuidle/coupled.c | 6 +++--- drivers/crypto/n2_core.c | 4 ++-- drivers/irqchip/irq-gic-v3.c | 2 +- drivers/irqchip/irq-mips-gic.c | 6 +++--- drivers/net/ethernet/tile/tilegx.c | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/clocksource/dw_apb_timer.c b/drivers/clocksource/dw_apb_timer.c index f3656a6b0382..35a88097af3c 100644 --- a/drivers/clocksource/dw_apb_timer.c +++ b/drivers/clocksource/dw_apb_timer.c @@ -117,7 +117,8 @@ static void apbt_set_mode(enum clock_event_mode mode, unsigned long period; struct dw_apb_clock_event_device *dw_ced = ced_to_dw_apb_ced(evt); - pr_debug("%s CPU %d mode=%d\n", __func__, first_cpu(*evt->cpumask), + pr_debug("%s CPU %d mode=%d\n", __func__, + cpumask_first(evt->cpumask), mode); switch (mode) { diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c index 73fe2f8d7f96..7936dce4b878 100644 --- a/drivers/cpuidle/coupled.c +++ b/drivers/cpuidle/coupled.c @@ -292,7 +292,7 @@ static inline int cpuidle_coupled_get_state(struct cpuidle_device *dev, */ smp_rmb(); - for_each_cpu_mask(i, coupled->coupled_cpus) + for_each_cpu(i, &coupled->coupled_cpus) if (cpu_online(i) && coupled->requested_state[i] < state) state = coupled->requested_state[i]; @@ -338,7 +338,7 @@ static void cpuidle_coupled_poke_others(int this_cpu, { int cpu; - for_each_cpu_mask(cpu, coupled->coupled_cpus) + for_each_cpu(cpu, &coupled->coupled_cpus) if (cpu != this_cpu && cpu_online(cpu)) cpuidle_coupled_poke(cpu); } @@ -638,7 +638,7 @@ int cpuidle_coupled_register_device(struct cpuidle_device *dev) if (cpumask_empty(&dev->coupled_cpus)) return 0; - for_each_cpu_mask(cpu, dev->coupled_cpus) { + for_each_cpu(cpu, &dev->coupled_cpus) { other_dev = per_cpu(cpuidle_devices, cpu); if (other_dev && other_dev->coupled) { coupled = other_dev->coupled; diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index afd136b45f49..10a9aeff1666 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c @@ -1754,7 +1754,7 @@ static int spu_mdesc_walk_arcs(struct mdesc_handle *mdesc, dev->dev.of_node->full_name); return -EINVAL; } - cpu_set(*id, p->sharing); + cpumask_set_cpu(*id, &p->sharing); table[*id] = p; } return 0; @@ -1776,7 +1776,7 @@ static int handle_exec_unit(struct spu_mdesc_info *ip, struct list_head *list, return -ENOMEM; } - cpus_clear(p->sharing); + cpumask_clear(&p->sharing); spin_lock_init(&p->lock); p->q_type = q_type; INIT_LIST_HEAD(&p->jobs); diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 1c6dea2fbc34..04b6f0732c1a 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -512,7 +512,7 @@ static void gic_raise_softirq(const struct cpumask *mask, unsigned int irq) */ smp_wmb(); - for_each_cpu_mask(cpu, *mask) { + for_each_cpu(cpu, mask) { u64 cluster_id = cpu_logical_map(cpu) & ~0xffUL; u16 tlist; diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 9acdc080e7ec..f26307908a2a 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -345,19 +345,19 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, int i; cpumask_and(&tmp, cpumask, cpu_online_mask); - if (cpus_empty(tmp)) + if (cpumask_empty(&tmp)) return -EINVAL; /* Assumption : cpumask refers to a single CPU */ spin_lock_irqsave(&gic_lock, flags); /* Re-route this IRQ */ - gic_map_to_vpe(irq, first_cpu(tmp)); + gic_map_to_vpe(irq, cpumask_first(&tmp)); /* Update the pcpu_masks */ for (i = 0; i < NR_CPUS; i++) clear_bit(irq, pcpu_masks[i].pcpu_mask); - set_bit(irq, pcpu_masks[first_cpu(tmp)].pcpu_mask); + set_bit(irq, pcpu_masks[cpumask_first(&tmp)].pcpu_mask); cpumask_copy(d->affinity, cpumask); spin_unlock_irqrestore(&gic_lock, flags); diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c index bea8cd2bb56c..deac41498c6e 100644 --- a/drivers/net/ethernet/tile/tilegx.c +++ b/drivers/net/ethernet/tile/tilegx.c @@ -1122,7 +1122,7 @@ static int alloc_percpu_mpipe_resources(struct net_device *dev, addr + i * sizeof(struct tile_net_comps); /* If this is a network cpu, create an iqueue. */ - if (cpu_isset(cpu, network_cpus_map)) { + if (cpumask_test_cpu(cpu, &network_cpus_map)) { order = get_order(NOTIF_RING_SIZE); page = homecache_alloc_pages(GFP_KERNEL, order, cpu); if (page == NULL) { @@ -1298,7 +1298,7 @@ static int tile_net_init_mpipe(struct net_device *dev) int first_ring, ring; int instance = mpipe_instance(dev); struct mpipe_data *md = &mpipe_data[instance]; - int network_cpus_count = cpus_weight(network_cpus_map); + int network_cpus_count = cpumask_weight(&network_cpus_map); if (!hash_default) { netdev_err(dev, "Networking requires hash_default!\n"); -- cgit v1.2.3 From dc0d838a0527296730af6d3826bcda79d2918613 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Wed, 4 Mar 2015 01:07:51 -0500 Subject: staging/lustre/ptlrpc: Do not use deprecated cpus_* functions As per Rusty Russel, cpus_* functions are deprecated. When mixing cpumask_copy with cpus_weight, they operate on different sized masks if CPUMASK_OFFSTACK is enabled, causing an immediate assertion failure. Copying of cpumasks by assignment is also not allowed now. Additionally, in ptlrpc/service.c avoid the cpumask copies, since we only use it to check how many siblings are there for core #0 and nothing else. Reported-by: Tyson Whitehead Signed-off-by: Oleg Drokin Signed-off-by: Rusty Russell --- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 8 ++++---- drivers/staging/lustre/lustre/ptlrpc/service.c | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 4621b71fe0b6..7f13a2845e9f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -511,10 +511,10 @@ static int ptlrpcd_bind(int index, int max) #if defined(CONFIG_NUMA) { int i; - mask = *cpumask_of_node(cpu_to_node(index)); + cpumask_copy(&mask, cpumask_of_node(cpu_to_node(index))); for (i = max; i < num_online_cpus(); i++) - cpu_clear(i, mask); - pc->pc_npartners = cpus_weight(mask) - 1; + cpumask_clear_cpu(i, &mask); + pc->pc_npartners = cpumask_weight(&mask) - 1; set_bit(LIOD_BIND, &pc->pc_flags); } #else @@ -554,7 +554,7 @@ static int ptlrpcd_bind(int index, int max) * that are already initialized */ for (pidx = 0, i = 0; i < index; i++) { - if (cpu_isset(i, mask)) { + if (cpumask_test_cpu(i, &mask)) { ppc = &ptlrpcds->pd_threads[i]; pc->pc_partners[pidx++] = ppc; ppc->pc_partners[ppc-> diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 635b12b22cef..8e61421515cb 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -543,7 +543,6 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, if (tc->tc_thr_factor != 0) { int factor = tc->tc_thr_factor; const int fade = 4; - cpumask_t mask; /* * User wants to increase number of threads with for @@ -557,8 +556,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, * have too many threads no matter how many cores/HTs * there are. */ - cpumask_copy(&mask, topology_thread_cpumask(0)); - if (cpus_weight(mask) > 1) { /* weight is # of HTs */ + /* weight is # of HTs */ + if (cpumask_weight(topology_thread_cpumask(0)) > 1) { /* depress thread factor for hyper-thread */ factor = factor - (factor >> 1) + (factor >> 3); } @@ -2752,7 +2751,6 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) int ptlrpc_hr_init(void) { - cpumask_t mask; struct ptlrpc_hr_partition *hrp; struct ptlrpc_hr_thread *hrt; int rc; @@ -2770,8 +2768,7 @@ int ptlrpc_hr_init(void) init_waitqueue_head(&ptlrpc_hr.hr_waitq); - cpumask_copy(&mask, topology_thread_cpumask(0)); - weight = cpus_weight(mask); + weight = cpumask_weight(topology_thread_cpumask(0)); cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { hrp->hrp_cpt = i; -- cgit v1.2.3 From b25e74b56a34908c777c1e72ecd9c56c4c8e124d Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Wed, 4 Mar 2015 01:07:52 -0500 Subject: staging/lustre/libcfs: replace deprecated cpus_ calls with cpumask_ Rusty Russel advises that cpus_* functions are deprecated to work on cpumasks and cpumask_* functions should be called instead, otherwise problems with CPUMASK_OFFSTACK arise. Signed-off-by: Oleg Drokin Signed-off-by: Rusty Russell --- .../staging/lustre/lustre/libcfs/linux/linux-cpu.c | 102 +++++++++++---------- 1 file changed, 53 insertions(+), 49 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index 05f7595f18aa..cc3ab351943e 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -204,7 +204,7 @@ cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) } tmp += rc; - for_each_cpu_mask(j, *cptab->ctb_parts[i].cpt_cpumask) { + for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) { rc = snprintf(tmp, len, "%d ", j); len -= rc; if (len <= 0) { @@ -240,8 +240,8 @@ cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt) LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); return cpt == CFS_CPT_ANY ? - cpus_weight(*cptab->ctb_cpumask) : - cpus_weight(*cptab->ctb_parts[cpt].cpt_cpumask); + cpumask_weight(cptab->ctb_cpumask) : + cpumask_weight(cptab->ctb_parts[cpt].cpt_cpumask); } EXPORT_SYMBOL(cfs_cpt_weight); @@ -251,8 +251,10 @@ cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt) LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); return cpt == CFS_CPT_ANY ? - any_online_cpu(*cptab->ctb_cpumask) != NR_CPUS : - any_online_cpu(*cptab->ctb_parts[cpt].cpt_cpumask) != NR_CPUS; + cpumask_any_and(cptab->ctb_cpumask, + cpu_online_mask) < nr_cpu_ids : + cpumask_any_and(cptab->ctb_parts[cpt].cpt_cpumask, + cpu_online_mask) < nr_cpu_ids; } EXPORT_SYMBOL(cfs_cpt_online); @@ -283,7 +285,7 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) LASSERT(cpt >= 0 && cpt < cptab->ctb_nparts); - if (cpu < 0 || cpu >= NR_CPUS || !cpu_online(cpu)) { + if (cpu < 0 || cpu >= nr_cpu_ids || !cpu_online(cpu)) { CDEBUG(D_INFO, "CPU %d is invalid or it's offline\n", cpu); return 0; } @@ -296,11 +298,11 @@ cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) cptab->ctb_cpu2cpt[cpu] = cpt; - LASSERT(!cpu_isset(cpu, *cptab->ctb_cpumask)); - LASSERT(!cpu_isset(cpu, *cptab->ctb_parts[cpt].cpt_cpumask)); + LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask)); + LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask)); - cpu_set(cpu, *cptab->ctb_cpumask); - cpu_set(cpu, *cptab->ctb_parts[cpt].cpt_cpumask); + cpumask_set_cpu(cpu, cptab->ctb_cpumask); + cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask); node = cpu_to_node(cpu); @@ -324,7 +326,7 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts)); - if (cpu < 0 || cpu >= NR_CPUS) { + if (cpu < 0 || cpu >= nr_cpu_ids) { CDEBUG(D_INFO, "Invalid CPU id %d\n", cpu); return; } @@ -344,11 +346,11 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) return; } - LASSERT(cpu_isset(cpu, *cptab->ctb_parts[cpt].cpt_cpumask)); - LASSERT(cpu_isset(cpu, *cptab->ctb_cpumask)); + LASSERT(cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask)); + LASSERT(cpumask_test_cpu(cpu, cptab->ctb_cpumask)); - cpu_clear(cpu, *cptab->ctb_parts[cpt].cpt_cpumask); - cpu_clear(cpu, *cptab->ctb_cpumask); + cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask); + cpumask_clear_cpu(cpu, cptab->ctb_cpumask); cptab->ctb_cpu2cpt[cpu] = -1; node = cpu_to_node(cpu); @@ -356,22 +358,22 @@ cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu) LASSERT(node_isset(node, *cptab->ctb_parts[cpt].cpt_nodemask)); LASSERT(node_isset(node, *cptab->ctb_nodemask)); - for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask) { + for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) { /* this CPT has other CPU belonging to this node? */ if (cpu_to_node(i) == node) break; } - if (i == NR_CPUS) + if (i >= nr_cpu_ids) node_clear(node, *cptab->ctb_parts[cpt].cpt_nodemask); - for_each_cpu_mask(i, *cptab->ctb_cpumask) { + for_each_cpu(i, cptab->ctb_cpumask) { /* this CPT-table has other CPU belonging to this node? */ if (cpu_to_node(i) == node) break; } - if (i == NR_CPUS) + if (i >= nr_cpu_ids) node_clear(node, *cptab->ctb_nodemask); return; @@ -383,13 +385,14 @@ cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask) { int i; - if (cpus_weight(*mask) == 0 || any_online_cpu(*mask) == NR_CPUS) { + if (cpumask_weight(mask) == 0 || + cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) { CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU partition %d\n", cpt); return 0; } - for_each_cpu_mask(i, *mask) { + for_each_cpu(i, mask) { if (!cfs_cpt_set_cpu(cptab, cpt, i)) return 0; } @@ -403,7 +406,7 @@ cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask) { int i; - for_each_cpu_mask(i, *mask) + for_each_cpu(i, mask) cfs_cpt_unset_cpu(cptab, cpt, i); } EXPORT_SYMBOL(cfs_cpt_unset_cpumask); @@ -493,7 +496,7 @@ cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt) } for (; cpt <= last; cpt++) { - for_each_cpu_mask(i, *cptab->ctb_parts[cpt].cpt_cpumask) + for_each_cpu(i, cptab->ctb_parts[cpt].cpt_cpumask) cfs_cpt_unset_cpu(cptab, cpt, i); } } @@ -554,7 +557,7 @@ EXPORT_SYMBOL(cfs_cpt_current); int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu) { - LASSERT(cpu >= 0 && cpu < NR_CPUS); + LASSERT(cpu >= 0 && cpu < nr_cpu_ids); return cptab->ctb_cpu2cpt[cpu]; } @@ -578,14 +581,14 @@ cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt) nodemask = cptab->ctb_parts[cpt].cpt_nodemask; } - if (any_online_cpu(*cpumask) == NR_CPUS) { + if (cpumask_any_and(cpumask, cpu_online_mask) >= nr_cpu_ids) { CERROR("No online CPU found in CPU partition %d, did someone do CPU hotplug on system? You might need to reload Lustre modules to keep system working well.\n", cpt); return -EINVAL; } for_each_online_cpu(i) { - if (cpu_isset(i, *cpumask)) + if (cpumask_test_cpu(i, cpumask)) continue; rc = set_cpus_allowed_ptr(current, cpumask); @@ -616,14 +619,14 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, LASSERT(number > 0); - if (number >= cpus_weight(*node)) { - while (!cpus_empty(*node)) { - cpu = first_cpu(*node); + if (number >= cpumask_weight(node)) { + while (!cpumask_empty(node)) { + cpu = cpumask_first(node); rc = cfs_cpt_set_cpu(cptab, cpt, cpu); if (!rc) return -EINVAL; - cpu_clear(cpu, *node); + cpumask_clear_cpu(cpu, node); } return 0; } @@ -636,27 +639,27 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, goto out; } - while (!cpus_empty(*node)) { - cpu = first_cpu(*node); + while (!cpumask_empty(node)) { + cpu = cpumask_first(node); /* get cpumask for cores in the same socket */ cfs_cpu_core_siblings(cpu, socket); - cpus_and(*socket, *socket, *node); + cpumask_and(socket, socket, node); - LASSERT(!cpus_empty(*socket)); + LASSERT(!cpumask_empty(socket)); - while (!cpus_empty(*socket)) { + while (!cpumask_empty(socket)) { int i; /* get cpumask for hts in the same core */ cfs_cpu_ht_siblings(cpu, core); - cpus_and(*core, *core, *node); + cpumask_and(core, core, node); - LASSERT(!cpus_empty(*core)); + LASSERT(!cpumask_empty(core)); - for_each_cpu_mask(i, *core) { - cpu_clear(i, *socket); - cpu_clear(i, *node); + for_each_cpu(i, core) { + cpumask_clear_cpu(i, socket); + cpumask_clear_cpu(i, node); rc = cfs_cpt_set_cpu(cptab, cpt, i); if (!rc) { @@ -667,7 +670,7 @@ cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt, if (--number == 0) goto out; } - cpu = first_cpu(*socket); + cpu = cpumask_first(socket); } } @@ -767,7 +770,7 @@ cfs_cpt_table_create(int ncpt) for_each_online_node(i) { cfs_node_to_cpumask(i, mask); - while (!cpus_empty(*mask)) { + while (!cpumask_empty(mask)) { struct cfs_cpu_partition *part; int n; @@ -776,24 +779,24 @@ cfs_cpt_table_create(int ncpt) part = &cptab->ctb_parts[cpt]; - n = num - cpus_weight(*part->cpt_cpumask); + n = num - cpumask_weight(part->cpt_cpumask); LASSERT(n > 0); rc = cfs_cpt_choose_ncpus(cptab, cpt, mask, n); if (rc < 0) goto failed; - LASSERT(num >= cpus_weight(*part->cpt_cpumask)); - if (num == cpus_weight(*part->cpt_cpumask)) + LASSERT(num >= cpumask_weight(part->cpt_cpumask)); + if (num == cpumask_weight(part->cpt_cpumask)) cpt++; } } if (cpt != ncpt || - num != cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)) { + num != cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)) { CERROR("Expect %d(%d) CPU partitions but got %d(%d), CPU hotplug/unplug while setting?\n", cptab->ctb_nparts, num, cpt, - cpus_weight(*cptab->ctb_parts[ncpt - 1].cpt_cpumask)); + cpumask_weight(cptab->ctb_parts[ncpt - 1].cpt_cpumask)); goto failed; } @@ -845,7 +848,7 @@ cfs_cpt_table_create_pattern(char *pattern) return NULL; } - high = node ? MAX_NUMNODES - 1 : NR_CPUS - 1; + high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1; cptab = cfs_cpt_table_alloc(ncpt); if (cptab == NULL) { @@ -965,7 +968,8 @@ cfs_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu) mutex_lock(&cpt_data.cpt_mutex); /* if all HTs in a core are offline, it may break affinity */ cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask); - warn = any_online_cpu(*cpt_data.cpt_cpumask) >= nr_cpu_ids; + warn = cpumask_any_and(cpt_data.cpt_cpumask, + cpu_online_mask) >= nr_cpu_ids; mutex_unlock(&cpt_data.cpt_mutex); CDEBUG(warn ? D_WARNING : D_INFO, "Lustre: can't support CPU plug-out well now, performance and stability could be impacted [CPU %u action: %lx]\n", -- cgit v1.2.3 From e97636b487d0767500a1b898513577a5ce000ad9 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Wed, 4 Mar 2015 01:07:53 -0500 Subject: staging/lustre/o2iblnd: Don't use cpus_weight cpus_weight and for_each_cpu_mask are deprecated, so replace them with cpumask_weight and for_each_cpu respectively. Signed-off-by: Oleg Drokin Signed-off-by: Rusty Russell --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 651016919669..a25816ab9e53 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -638,8 +638,8 @@ kiblnd_get_completion_vector(kib_conn_t *conn, int cpt) return 0; /* hash NID to CPU id in this partition... */ - off = do_div(nid, cpus_weight(*mask)); - for_each_cpu_mask(i, *mask) { + off = do_div(nid, cpumask_weight(mask)); + for_each_cpu(i, mask) { if (off-- == 0) return i % vectors; } -- cgit v1.2.3 From c8ed00107b60b4a890798677d75e5c2910f393bb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 5 Mar 2015 10:49:19 +1030 Subject: Fix weird uses of num_online_cpus(). This may be OK in archs with contiguous CPU numbers and without hotplug CPUs, but it sets a terrible example. And open-coding it like drivers/scsi/hpsa.c is just weird. BTRFS has a weird comparison with num_online_cpus() too, but since BTRFS just screwed up my test machines' root partition, I'm not touching it :) Signed-off-by: Rusty Russell Reported-by: Oleg Drokin --- arch/m32r/kernel/smpboot.c | 2 +- arch/sh/include/asm/mmu_context.h | 2 +- arch/sh/kernel/smp.c | 6 +++--- arch/um/kernel/smp.c | 2 +- drivers/scsi/hpsa.c | 6 ++---- 5 files changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/arch/m32r/kernel/smpboot.c b/arch/m32r/kernel/smpboot.c index bb21f4f63170..a468467542f4 100644 --- a/arch/m32r/kernel/smpboot.c +++ b/arch/m32r/kernel/smpboot.c @@ -376,7 +376,7 @@ void __init smp_cpus_done(unsigned int max_cpus) if (!cpumask_equal(&cpu_callin_map, cpu_online_mask)) BUG(); - for (cpu_id = 0 ; cpu_id < num_online_cpus() ; cpu_id++) + for_each_online_cpu(cpu_id) show_cpu_info(cpu_id); /* diff --git a/arch/sh/include/asm/mmu_context.h b/arch/sh/include/asm/mmu_context.h index b9d9489a5012..9f417feaf6e8 100644 --- a/arch/sh/include/asm/mmu_context.h +++ b/arch/sh/include/asm/mmu_context.h @@ -99,7 +99,7 @@ static inline int init_new_context(struct task_struct *tsk, { int i; - for (i = 0; i < num_online_cpus(); i++) + for_each_online_cpu(i) cpu_context(i, mm) = NO_CONTEXT; return 0; diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c index fc5acfc93c92..de6be008fc01 100644 --- a/arch/sh/kernel/smp.c +++ b/arch/sh/kernel/smp.c @@ -363,7 +363,7 @@ void flush_tlb_mm(struct mm_struct *mm) smp_call_function(flush_tlb_mm_ipi, (void *)mm, 1); } else { int i; - for (i = 0; i < num_online_cpus(); i++) + for_each_online_cpu(i) if (smp_processor_id() != i) cpu_context(i, mm) = 0; } @@ -400,7 +400,7 @@ void flush_tlb_range(struct vm_area_struct *vma, smp_call_function(flush_tlb_range_ipi, (void *)&fd, 1); } else { int i; - for (i = 0; i < num_online_cpus(); i++) + for_each_online_cpu(i) if (smp_processor_id() != i) cpu_context(i, mm) = 0; } @@ -443,7 +443,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long page) smp_call_function(flush_tlb_page_ipi, (void *)&fd, 1); } else { int i; - for (i = 0; i < num_online_cpus(); i++) + for_each_online_cpu(i) if (smp_processor_id() != i) cpu_context(i, vma->vm_mm) = 0; } diff --git a/arch/um/kernel/smp.c b/arch/um/kernel/smp.c index 74077892b34a..525c3657a6af 100644 --- a/arch/um/kernel/smp.c +++ b/arch/um/kernel/smp.c @@ -45,7 +45,7 @@ void smp_send_stop(void) int i; printk(KERN_INFO "Stopping all CPUs..."); - for (i = 0; i < num_online_cpus(); i++) { + for_each_online_cpu(i) { if (i == current_thread->cpu) continue; os_write_file(cpu_data[i].ipi_pipe[1], "S", 1); diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index a1cfbd3dda47..8eab107b53fb 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -6632,14 +6632,12 @@ static void fail_all_outstanding_cmds(struct ctlr_info *h) static void set_lockup_detected_for_all_cpus(struct ctlr_info *h, u32 value) { - int i, cpu; + int cpu; - cpu = cpumask_first(cpu_online_mask); - for (i = 0; i < num_online_cpus(); i++) { + for_each_online_cpu(cpu) { u32 *lockup_detected; lockup_detected = per_cpu_ptr(h->lockup_detected, cpu); *lockup_detected = value; - cpu = cpumask_next(cpu, cpu_online_mask); } wmb(); /* be sure the per-cpu variables are out to memory */ } -- cgit v1.2.3