Commit 5f0b6c94 authored by Jakub Kicinski's avatar Jakub Kicinski

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.cnSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents ad6afdfc d33fe171
...@@ -2896,11 +2896,14 @@ static int dpaa2_eth_xdp_xmit(struct net_device *net_dev, int n, ...@@ -2896,11 +2896,14 @@ static int dpaa2_eth_xdp_xmit(struct net_device *net_dev, int n,
static int update_xps(struct dpaa2_eth_priv *priv) static int update_xps(struct dpaa2_eth_priv *priv)
{ {
struct net_device *net_dev = priv->net_dev; struct net_device *net_dev = priv->net_dev;
struct cpumask xps_mask;
struct dpaa2_eth_fq *fq;
int i, num_queues, netdev_queues; int i, num_queues, netdev_queues;
struct dpaa2_eth_fq *fq;
cpumask_var_t xps_mask;
int err = 0; int err = 0;
if (!alloc_cpumask_var(&xps_mask, GFP_KERNEL))
return -ENOMEM;
num_queues = dpaa2_eth_queue_count(priv); num_queues = dpaa2_eth_queue_count(priv);
netdev_queues = (net_dev->num_tc ? : 1) * num_queues; netdev_queues = (net_dev->num_tc ? : 1) * num_queues;
...@@ -2910,16 +2913,17 @@ static int update_xps(struct dpaa2_eth_priv *priv) ...@@ -2910,16 +2913,17 @@ static int update_xps(struct dpaa2_eth_priv *priv)
for (i = 0; i < netdev_queues; i++) { for (i = 0; i < netdev_queues; i++) {
fq = &priv->fq[i % num_queues]; fq = &priv->fq[i % num_queues];
cpumask_clear(&xps_mask); cpumask_clear(xps_mask);
cpumask_set_cpu(fq->target_cpu, &xps_mask); cpumask_set_cpu(fq->target_cpu, xps_mask);
err = netif_set_xps_queue(net_dev, &xps_mask, i); err = netif_set_xps_queue(net_dev, xps_mask, i);
if (err) { if (err) {
netdev_warn_once(net_dev, "Error setting XPS queue\n"); netdev_warn_once(net_dev, "Error setting XPS queue\n");
break; break;
} }
} }
free_cpumask_var(xps_mask);
return err; return err;
} }
......
...@@ -520,7 +520,7 @@ static void iucv_setmask_mp(void) ...@@ -520,7 +520,7 @@ static void iucv_setmask_mp(void)
*/ */
static void iucv_setmask_up(void) static void iucv_setmask_up(void)
{ {
cpumask_t cpumask; static cpumask_t cpumask;
int cpu; int cpu;
/* Disable all cpu but the first in cpu_irq_cpumask. */ /* Disable all cpu but the first in cpu_irq_cpumask. */
...@@ -628,23 +628,33 @@ static int iucv_cpu_online(unsigned int cpu) ...@@ -628,23 +628,33 @@ static int iucv_cpu_online(unsigned int cpu)
static int iucv_cpu_down_prep(unsigned int cpu) static int iucv_cpu_down_prep(unsigned int cpu)
{ {
cpumask_t cpumask; cpumask_var_t cpumask;
int ret = 0;
if (!iucv_path_table) if (!iucv_path_table)
return 0; return 0;
cpumask_copy(&cpumask, &iucv_buffer_cpumask); if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
cpumask_clear_cpu(cpu, &cpumask); return -ENOMEM;
if (cpumask_empty(&cpumask))
cpumask_copy(cpumask, &iucv_buffer_cpumask);
cpumask_clear_cpu(cpu, cpumask);
if (cpumask_empty(cpumask)) {
/* Can't offline last IUCV enabled cpu. */ /* Can't offline last IUCV enabled cpu. */
return -EINVAL; ret = -EINVAL;
goto __free_cpumask;
}
iucv_retrieve_cpu(NULL); iucv_retrieve_cpu(NULL);
if (!cpumask_empty(&iucv_irq_cpumask)) if (!cpumask_empty(&iucv_irq_cpumask))
return 0; goto __free_cpumask;
smp_call_function_single(cpumask_first(&iucv_buffer_cpumask), smp_call_function_single(cpumask_first(&iucv_buffer_cpumask),
iucv_allow_cpu, NULL, 1); iucv_allow_cpu, NULL, 1);
return 0;
__free_cpumask:
free_cpumask_var(cpumask);
return ret;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment