From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Ratheesh Kannoth <rkannoth@marvell.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
sgoutham@marvell.com, gakula@marvell.com, sbhatta@marvell.com,
hkelam@marvell.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, hawk@kernel.org,
alexander.duyck@gmail.com, ilias.apalodimas@linaro.org,
linyunsheng@huawei.com
Subject: Re: [PATCH net v2] octeontx2-pf: Fix page pool cache index corruption.
Date: Thu, 7 Sep 2023 09:09:55 +0200 [thread overview]
Message-ID: <20230907070955.0kdmjXbB@linutronix.de> (raw)
In-Reply-To: <20230907014711.3869840-1-rkannoth@marvell.com>
On 2023-09-07 07:17:11 [+0530], Ratheesh Kannoth wrote:
> The access to page pool `cache' array and the `count' variable
> is not locked. Page pool cache access is fine as long as there
> is only one consumer per pool.
>
> octeontx2 driver fills in rx buffers from page pool in NAPI context.
> If system is stressed and could not allocate buffers, refiiling work
> will be delegated to a delayed workqueue. This means that there are
> two cosumers to the page pool cache.
>
> Either workqueue or IRQ/NAPI can be run on other CPU. This will lead
> to lock less access, hence corruption of cache pool indexes.
>
> To fix this issue, NAPI is rescheduled from workqueue context to refill
> rx buffers.
>
> Fixes: b2e3406a38f0 ("octeontx2-pf: Add support for page pool")
> Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> index 8511906cb4e2..997fedac3a98 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
> static void otx2_pool_refill_task(struct work_struct *work)
> {
> struct otx2_cq_queue *cq;
> - struct otx2_pool *rbpool;
> struct refill_work *wrk;
> - int qidx, free_ptrs = 0;
> struct otx2_nic *pfvf;
> - dma_addr_t bufptr;
> + int qidx;
>
> wrk = container_of(work, struct refill_work, pool_refill_work.work);
> pfvf = wrk->pf;
> qidx = wrk - pfvf->refill_wrk;
> cq = &pfvf->qset.cq[qidx];
…
> cq->refill_task_sched = false;
> +
> + local_bh_disable();
> + napi_schedule(wrk->napi);
> + local_bh_enable();
This is a nitpick since I haven't look how it works exactly: Is it
possible that the wrk->napi pointer gets overwritten by
otx2_napi_handler() since you cleared cq->refill_task_sched() earlier?
> }
>
> int otx2_config_nix_queues(struct otx2_nic *pfvf)
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> index e369baf11530..b778ed366f81 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
> @@ -561,9 +565,24 @@ int otx2_napi_handler(struct napi_struct *napi, int budget)
> otx2_config_irq_coalescing(pfvf, i);
> }
>
> - /* Re-enable interrupts */
> - otx2_write64(pfvf, NIX_LF_CINTX_ENA_W1S(cq_poll->cint_idx),
> - BIT_ULL(0));
> + if (unlikely(!filled_cnt)) {
> + struct refill_work *work;
> + struct delayed_work *dwork;
> +
> + work = &pfvf->refill_wrk[cq->cq_idx];
> + dwork = &work->pool_refill_work;
> + /* Schedule a task if no other task is running */
> + if (!cq->refill_task_sched) {
> + work->napi = napi;
> + cq->refill_task_sched = true;
> + schedule_delayed_work(dwork,
> + msecs_to_jiffies(100));
> + }
> + } else {
> + /* Re-enable interrupts */
> + otx2_write64(pfvf, NIX_LF_CINTX_ENA_W1S(cq_poll->cint_idx),
> + BIT_ULL(0));
> + }
> }
> return workdone;
> }
Sebastian
next prev parent reply other threads:[~2023-09-07 17:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 1:47 [PATCH net v2] octeontx2-pf: Fix page pool cache index corruption Ratheesh Kannoth
2023-09-07 7:09 ` Sebastian Andrzej Siewior [this message]
2023-09-07 8:15 ` [EXT] " Ratheesh Kannoth
2023-09-07 10:15 ` Sebastian Andrzej Siewior
2023-09-07 15:08 ` Simon Horman
2023-09-08 2:51 ` [EXT] " Ratheesh Kannoth
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=20230907070955.0kdmjXbB@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=hawk@kernel.org \
--cc=hkelam@marvell.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linyunsheng@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rkannoth@marvell.com \
--cc=sbhatta@marvell.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;
as well as URLs for NNTP newsgroup(s).