From: Ratheesh Kannoth <rkannoth@marvell.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: <andrew+netdev@lunn.ch>, <davem@davemloft.net>,
<donald.hunter@gmail.com>, <edumazet@google.com>,
<horms@kernel.org>, <jiri@resnulli.us>, <kuba@kernel.org>,
<pabeni@redhat.com>, <sgoutham@marvell.com>
Subject: Re: [PATCH v18 net-next 8/8] octeontx2-af: npc: cn20k: Allocate npc_priv and dstats dynamically.
Date: Thu, 4 Jun 2026 08:51:02 +0530 [thread overview]
Message-ID: <aiDvHu_f0nPpXC81@rkannoth-OptiPlex-7090> (raw)
In-Reply-To: <20260602060359.1894952-9-rkannoth@marvell.com>
On 2026-06-02 at 11:33:59, Ratheesh Kannoth (rkannoth@marvell.com) wrote:
> Replace the file-scope static npc_priv with a kcalloc'd struct filled
> from hardware bank/subbank geometry at init (num_banks is no longer a
> const compile-time constant; drop init_done and use a non-NULL
> npc_priv pointer for liveness). Thread npc_priv_get() / pointer access
> through the CN20K NPC code paths, extend teardown to kfree the root
> struct on failure and in npc_cn20k_deinit, and adjust MCAM section
> setup to use the discovered subbank count.
>
> Allocate MCAM debugfs dstats via devm_kzalloc instead of a static matrix,
> and use the allocated backing store consistently when computing deltas
> (including the counter rollover compare).
>
> Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260602060359.1894952-1-rkannoth%40marvell.com says
>> +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c
>[ ... ]
>> @@ -397,6 +398,10 @@ int npc_cn20k_debugfs_init(struct rvu *rvu)
>> debugfs_create_file("vidx2idx", 0444, rvu->rvu_dbg.npc,
>> npc_priv, &npc_vidx2idx_map_fops);
>>
>> + dstats = devm_kzalloc(rvu->dev, sizeof(*dstats), GFP_KERNEL);
>> + if (!dstats)
>> + return -ENOMEM;
>> +
>> debugfs_create_file("dstats", 0444, rvu->rvu_dbg.npc, rvu,
>> &npc_mcam_dstats_fops);
>Should the dstats allocation move to the top of npc_cn20k_debugfs_init()?
>By the time the kzalloc fails, three debugfs files (mcam_layout,
>mcam_default, vidx2idx) have already been created, and on -ENOMEM the
>function returns without unwinding them. The sole caller in
>rvu_dbg_npc_init() is:
> if (is_cn20k(rvu->pdev))
> npc_cn20k_debugfs_init(rvu);
>rvu_dbg_npc_init() is static void and discards the return value, so under
>memory pressure during probe the device completes probe with a partially
>populated debugfs hierarchy and no error is logged. Pre-patch the function
>unconditionally returned 0, so this is a new failure mode introduced by
>this change.
I dont see any problem with this.
>> - xa_destroy(&npc_priv.xa_sb_used);
>[ ... ]
>> + if (!npc_priv)
>> + return;
>[ ... ]
>> + kfree(npc_priv->sb);
>> kfree(subbank_srch_order);
>> - bitmap_clear(npc_priv.en_map, 0, MAX_NUM_BANKS * MAX_NUM_SUB_BANKS *
>> + bitmap_clear(npc_priv->en_map, 0, MAX_NUM_BANKS * MAX_NUM_SUB_BANKS *
>> MAX_SUBBANK_DEPTH);
>> + npc_defrag_list_clear();
>> + kfree(npc_priv);
>> + npc_priv = NULL;
>> }
>Should npc_cn20k_deinit() also NULL out subbank_srch_order after
>kfree()ing it, to match the cleanup symmetry of the fail3 path in
>npc_priv_init()?
I dont see a need as there is only one AF device per system
>> - const int num_banks;
>> + int num_banks;
>> int num_subbanks;
>> int subbank_depth;
>> DECLARE_BITMAP(en_map, MAX_NUM_BANKS *
>> @@ -214,7 +214,6 @@ struct npc_priv_t {
>> struct list_head defrag_lh;
>> struct mutex lock; /* protect defrag nodes */
>> int pf_cnt;
>> - bool init_done;
>> };
>The init_done field is removed from struct npc_priv_t, but the
>kernel-doc block above the struct still carries the corresponding
>description:
> * @init_done: Indicates MCAM initialization is done.
>Should this @init_done line in the kernel-doc be removed alongside the
>field? scripts/kernel-doc and make htmldocs will warn with "Excess
>struct member init_done description in npc_priv_t".
ACK. Should i post v19 to address this ?
prev parent reply other threads:[~2026-06-04 3:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 6:03 [PATCH v18 net-next 0/8] octeontx2-af: npc: Enhancements Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 1/8] octeontx2-af: npc: cn20k: debugfs enhancements Ratheesh Kannoth
2026-06-03 6:19 ` Ratheesh Kannoth
2026-06-04 2:19 ` Ratheesh Kannoth
2026-06-04 14:45 ` Jakub Kicinski
2026-06-05 2:07 ` Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 2/8] devlink: heap-allocate param fill buffers in devlink_nl_param_fill Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 3/8] devlink: Implement devlink param multi attribute nested data values Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 4/8] octeontx2-af: npc: cn20k: add subbank search order control Ratheesh Kannoth
2026-06-04 2:34 ` Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 5/8] octeontx2: cn20k: Coordinate default rules with NIX LF lifecycle Ratheesh Kannoth
2026-06-03 6:37 ` Ratheesh Kannoth
2026-06-04 2:41 ` Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 6/8] octeontx2-af: npc: Support for custom KPU profile from filesystem Ratheesh Kannoth
2026-06-03 6:46 ` Ratheesh Kannoth
2026-06-04 3:07 ` Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 7/8] octeontx2: cn20k: Respect NPC MCAM X2/X4 profile in flows and DFT alloc Ratheesh Kannoth
2026-06-03 6:54 ` Ratheesh Kannoth
2026-06-04 3:16 ` Ratheesh Kannoth
2026-06-02 6:03 ` [PATCH v18 net-next 8/8] octeontx2-af: npc: cn20k: Allocate npc_priv and dstats dynamically Ratheesh Kannoth
2026-06-03 7:03 ` Ratheesh Kannoth
2026-06-04 3:21 ` Ratheesh Kannoth [this message]
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=aiDvHu_f0nPpXC81@rkannoth-OptiPlex-7090 \
--to=rkannoth@marvell.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgoutham@marvell.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