Skip to content

Commit 5f0b6c9

Browse files
committed
Merge branch 'avoid-explicit-cpumask-var-allocation-on-stack'
Dawei Li says: ==================== Avoid explicit cpumask var allocation on stack v1: https://lore.kernel.org/lkml/20240329105610.922675-1-dawei.li@shingroup.cn/ ==================== Link: https://lore.kernel.org/r/20240331053441.1276826-1-dawei.li@shingroup.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents ad6afdf + d33fe17 commit 5f0b6c9

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,11 +2896,14 @@ static int dpaa2_eth_xdp_xmit(struct net_device *net_dev, int n,
28962896
static int update_xps(struct dpaa2_eth_priv *priv)
28972897
{
28982898
struct net_device *net_dev = priv->net_dev;
2899-
struct cpumask xps_mask;
2900-
struct dpaa2_eth_fq *fq;
29012899
int i, num_queues, netdev_queues;
2900+
struct dpaa2_eth_fq *fq;
2901+
cpumask_var_t xps_mask;
29022902
int err = 0;
29032903

2904+
if (!alloc_cpumask_var(&xps_mask, GFP_KERNEL))
2905+
return -ENOMEM;
2906+
29042907
num_queues = dpaa2_eth_queue_count(priv);
29052908
netdev_queues = (net_dev->num_tc ? : 1) * num_queues;
29062909

@@ -2910,16 +2913,17 @@ static int update_xps(struct dpaa2_eth_priv *priv)
29102913
for (i = 0; i < netdev_queues; i++) {
29112914
fq = &priv->fq[i % num_queues];
29122915

2913-
cpumask_clear(&xps_mask);
2914-
cpumask_set_cpu(fq->target_cpu, &xps_mask);
2916+
cpumask_clear(xps_mask);
2917+
cpumask_set_cpu(fq->target_cpu, xps_mask);
29152918

2916-
err = netif_set_xps_queue(net_dev, &xps_mask, i);
2919+
err = netif_set_xps_queue(net_dev, xps_mask, i);
29172920
if (err) {
29182921
netdev_warn_once(net_dev, "Error setting XPS queue\n");
29192922
break;
29202923
}
29212924
}
29222925

2926+
free_cpumask_var(xps_mask);
29232927
return err;
29242928
}
29252929

net/iucv/iucv.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static void iucv_setmask_mp(void)
520520
*/
521521
static void iucv_setmask_up(void)
522522
{
523-
cpumask_t cpumask;
523+
static cpumask_t cpumask;
524524
int cpu;
525525

526526
/* Disable all cpu but the first in cpu_irq_cpumask. */
@@ -628,23 +628,33 @@ static int iucv_cpu_online(unsigned int cpu)
628628

629629
static int iucv_cpu_down_prep(unsigned int cpu)
630630
{
631-
cpumask_t cpumask;
631+
cpumask_var_t cpumask;
632+
int ret = 0;
632633

633634
if (!iucv_path_table)
634635
return 0;
635636

636-
cpumask_copy(&cpumask, &iucv_buffer_cpumask);
637-
cpumask_clear_cpu(cpu, &cpumask);
638-
if (cpumask_empty(&cpumask))
637+
if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
638+
return -ENOMEM;
639+
640+
cpumask_copy(cpumask, &iucv_buffer_cpumask);
641+
cpumask_clear_cpu(cpu, cpumask);
642+
if (cpumask_empty(cpumask)) {
639643
/* Can't offline last IUCV enabled cpu. */
640-
return -EINVAL;
644+
ret = -EINVAL;
645+
goto __free_cpumask;
646+
}
641647

642648
iucv_retrieve_cpu(NULL);
643649
if (!cpumask_empty(&iucv_irq_cpumask))
644-
return 0;
650+
goto __free_cpumask;
651+
645652
smp_call_function_single(cpumask_first(&iucv_buffer_cpumask),
646653
iucv_allow_cpu, NULL, 1);
647-
return 0;
654+
655+
__free_cpumask:
656+
free_cpumask_var(cpumask);
657+
return ret;
648658
}
649659

650660
/**

0 commit comments

Comments
 (0)