Hi,
This is v2 of previous series[1] about cpumask var on stack for net
subsystem.
Change since v1:
- For iucv_setmask_up() which returns void to caller, just make cpumask
var static which is protected by global lock iucv_register_mutex. [Eric]
[1] v1:
https://lore.kernel.org/lkml/[email protected]/
Dawei Li (2):
net/iucv: Avoid explicit cpumask var allocation on stack
net/dpaa2: Avoid explicit cpumask var allocation on stack
.../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 14 ++++++----
net/iucv/iucv.c | 26 +++++++++++++------
2 files changed, 27 insertions(+), 13 deletions(-)
Thanks,
Dawei
--
2.27.0
For CONFIG_CPUMASK_OFFSTACK=y kernel, explicit allocation of cpumask
variable on stack is not recommended since it can cause potential stack
overflow.
Instead, kernel code should always use *cpumask_var API(s) to allocate
cpumask var in config-neutral way, leaving allocation strategy to
CONFIG_CPUMASK_OFFSTACK.
Use *cpumask_var API(s) to address it.
Signed-off-by: Dawei Li <[email protected]>
---
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 888509cf1f21..40e881829595 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -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)
{
struct net_device *net_dev = priv->net_dev;
- struct cpumask xps_mask;
- struct dpaa2_eth_fq *fq;
int i, num_queues, netdev_queues;
+ struct dpaa2_eth_fq *fq;
+ cpumask_var_t xps_mask;
int err = 0;
+ if (!alloc_cpumask_var(&xps_mask, GFP_KERNEL))
+ return -ENOMEM;
+
num_queues = dpaa2_eth_queue_count(priv);
netdev_queues = (net_dev->num_tc ? : 1) * num_queues;
@@ -2910,16 +2913,17 @@ static int update_xps(struct dpaa2_eth_priv *priv)
for (i = 0; i < netdev_queues; i++) {
fq = &priv->fq[i % num_queues];
- cpumask_clear(&xps_mask);
- cpumask_set_cpu(fq->target_cpu, &xps_mask);
+ cpumask_clear(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) {
netdev_warn_once(net_dev, "Error setting XPS queue\n");
break;
}
}
+ free_cpumask_var(xps_mask);
return err;
}
--
2.27.0
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <[email protected]>:
On Sun, 31 Mar 2024 13:34:39 +0800 you wrote:
> Hi,
>
> This is v2 of previous series[1] about cpumask var on stack for net
> subsystem.
>
> Change since v1:
> - For iucv_setmask_up() which returns void to caller, just make cpumask
> var static which is protected by global lock iucv_register_mutex. [Eric]
>
> [...]
Here is the summary with links:
- [net-next,v2,1/2] net/iucv: Avoid explicit cpumask var allocation on stack
https://git.kernel.org/netdev/net-next/c/be4e1304419c
- [net-next,v2,2/2] net/dpaa2: Avoid explicit cpumask var allocation on stack
https://git.kernel.org/netdev/net-next/c/d33fe1714a44
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html