From: Breno Leitao <leitao@debian.org>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: kernel test robot <lkp@intel.com>,
netdev@vger.kernel.org, Roy.Pledge@nxp.com, llvm@lists.linux.dev,
open list <linux-kernel@vger.kernel.org>,
horms@kernel.org, oe-kbuild-all@lists.linux.dev, kuba@kernel.org,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/4] soc: fsl: qbman: FSL_DPAA depends on COMPILE_TEST
Date: Mon, 8 Jul 2024 12:08:05 -0700 [thread overview]
Message-ID: <Zow5FUmOADrqUpM9@gmail.com> (raw)
In-Reply-To: <20240708133746.ea62kkeq2inzcos5@skbuf>
Hello Vladimir,
On Mon, Jul 08, 2024 at 04:37:46PM +0300, Vladimir Oltean wrote:
> On Thu, Jun 27, 2024 at 11:40:24AM -0700, Breno Leitao wrote:
> > > > 454 | static int dpaa_set_coalesce(struct net_device *dev,
> > > > | ^
> > > > 1 warning generated.
> > >
> > > Arrays of NR_CPUS elements are what it probably doesn't like?
> > Can it use the number of online CPUs instead of NR_CPUS?
> I don't see how, given that variable length arrays are something which
> should be avoided in the kernel?
I thought about a patch like the following (compile tested only). What
do you think?
Author: Breno Leitao <leitao@debian.org>
Date: Mon Jul 8 11:57:33 2024 -0700
net: dpaa: Allocate only for online CPUs in dpaa_set_coalesce
Currently, dpaa_set_coalesce allocates a boolean for every possible CPU
(NR_CPUS). This approach is suboptimal and causes failures in COMPILE_TEST.
For reference, see:
https://lore.kernel.org/all/202406261920.l5pzM1rj-lkp@intel.com/
Modify the allocation to consider only online CPUs instead of
NR_CPUs. This change reduces the function's memory footprint and resolves
the COMPILE_TEST issues.
Signed-off-by: Breno Leitao <leitao@debian.org>
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
index 5bd0b36d1feb..7202a5310045 100644
--- a/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
+++ b/drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
@@ -457,7 +457,7 @@ static int dpaa_set_coalesce(struct net_device *dev,
struct netlink_ext_ack *extack)
{
const cpumask_t *cpus = qman_affine_cpus();
- bool needs_revert[NR_CPUS] = {false};
+ bool *needs_revert;
struct qman_portal *portal;
u32 period, prev_period;
u8 thresh, prev_thresh;
@@ -466,6 +466,11 @@ static int dpaa_set_coalesce(struct net_device *dev,
period = c->rx_coalesce_usecs;
thresh = c->rx_max_coalesced_frames;
+ needs_revert = kmalloc_array(num_possible_cpus(), sizeof(bool), GFP_KERNEL);
+ if (!needs_revert)
+ return -ENOMEM;
+ memset(needs_revert, 0, num_online_cpus() * sizeof(bool));
+
/* save previous values */
portal = qman_get_affine_portal(smp_processor_id());
qman_portal_get_iperiod(portal, &prev_period);
@@ -498,6 +503,7 @@ static int dpaa_set_coalesce(struct net_device *dev,
qman_dqrr_set_ithresh(portal, prev_thresh);
}
+ kfree(needs_revert);
return res;
}
next prev parent reply other threads:[~2024-07-08 19:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 16:21 [PATCH 1/4] soc: fsl: qbman: FSL_DPAA depends on COMPILE_TEST Breno Leitao
2024-06-24 16:21 ` [PATCH 2/4] crypto: caam: Depend on COMPILE_TEST also Breno Leitao
2024-06-29 11:29 ` kernel test robot
2024-06-24 16:21 ` [PATCH 3/4] crypto: caam: Unembed net_dev structure from qi Breno Leitao
2024-06-28 16:32 ` Simon Horman
2024-07-02 13:32 ` Breno Leitao
2024-06-24 16:21 ` [PATCH 4/4] crypto: caam: Unembed net_dev structure in dpaa2 Breno Leitao
2024-06-25 14:39 ` [PATCH 1/4] soc: fsl: qbman: FSL_DPAA depends on COMPILE_TEST Jakub Kicinski
2024-06-25 22:06 ` Herbert Xu
2024-06-26 12:09 ` kernel test robot
2024-06-26 14:06 ` Vladimir Oltean
2024-06-27 18:40 ` Breno Leitao
2024-07-08 13:37 ` Vladimir Oltean
2024-07-08 19:08 ` Breno Leitao [this message]
2024-07-09 13:58 ` Vladimir Oltean
2024-07-09 15:15 ` Breno Leitao
2024-07-09 15:25 ` Vladimir Oltean
2024-06-29 13:55 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zow5FUmOADrqUpM9@gmail.com \
--to=leitao@debian.org \
--cc=Roy.Pledge@nxp.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=olteanv@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).