netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <hawk@kernel.org>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: hawk@kernel.org,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	netdev@vger.kernel.org, Ratheesh Kannoth <rkannoth@marvell.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Geetha sowjanya <gakula@marvell.com>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Subbaraya Sundeep <sbhatta@marvell.com>,
	Sunil Goutham <sgoutham@marvell.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	hariprasad <hkelam@marvell.com>,
	Qingfang DENG <qingfang.deng@siflower.com.cn>
Subject: Re: [BUG] Possible unsafe page_pool usage in octeontx2
Date: Fri, 25 Aug 2023 15:22:05 +0200	[thread overview]
Message-ID: <044c90b6-4e38-9ae9-a462-def21649183d@kernel.org> (raw)
In-Reply-To: <923d74d4-3d43-8cac-9732-c55103f6dafb@intel.com>



On 24/08/2023 17.26, Alexander Lobakin wrote:
> From: Jesper Dangaard Brouer<hawk@kernel.org>
> Date: Wed, 23 Aug 2023 21:45:04 +0200
> 
>> (Cc Olek as he have changes in this code path)
> Thanks! I was reading the thread a bit on LKML, but being in the CC list
> is more convenient :D
> 

:D

>> On 23/08/2023 11.47, Sebastian Andrzej Siewior wrote:
>>> Hi,
>>>
>>> I've been looking at the page_pool locking.
>>>
>>> page_pool_alloc_frag() -> page_pool_alloc_pages() ->
>>> __page_pool_get_cached():
>>>
>>> There core of the allocation is:
>>> |         /* Caller MUST guarantee safe non-concurrent access, e.g.
>>> softirq */
>>> |         if (likely(pool->alloc.count)) {
>>> |                 /* Fast-path */
>>> |                 page = pool->alloc.cache[--pool->alloc.count];
>>>
>>> The access to the `cache' array and the `count' variable is not locked.
>>> This is fine as long as there only one consumer per pool. In my
>>> understanding the intention is to have one page_pool per NAPI callback
>>> to ensure this.
>>>
>> Yes, the intention is a single PP instance is "bound" to one RX-NAPI.
>
> Isn't that also a misuse of page_pool->p.napi? I thought it can be set
> only when page allocation and cache refill happen both inside the same
> NAPI polling function. Otx2 uses workqueues to refill the queues,
> meaning that consumer and producer can happen in different contexts or
> even threads and it shouldn't set p.napi.
> 

As Jakub wrote this otx2 driver doesn't set p.napi (so that part of the
problem cannot happen).

That said using workqueues to refill the queues is not compatible with
using page_pool_alloc APIs.  This need to be fixed in driver!

--Jesper

  reply	other threads:[~2023-08-25 13:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-23  9:47 [BUG] Possible unsafe page_pool usage in octeontx2 Sebastian Andrzej Siewior
2023-08-23 11:36 ` Ilias Apalodimas
2023-08-23 13:31   ` Sebastian Andrzej Siewior
2023-08-23 12:28 ` [EXT] " Ratheesh Kannoth
2023-08-23 12:54   ` Sebastian Andrzej Siewior
2023-08-24  2:49     ` Ratheesh Kannoth
2023-08-23 14:49 ` Jakub Kicinski
2023-08-23 19:45 ` Jesper Dangaard Brouer
2023-08-24  7:21   ` Ilias Apalodimas
2023-08-24  7:42     ` Ilias Apalodimas
2023-08-24 15:26   ` Alexander Lobakin
2023-08-25 13:22     ` Jesper Dangaard Brouer [this message]
2023-08-25 13:38       ` Alexander Lobakin
2023-08-25 17:25         ` Jesper Dangaard Brouer
2023-08-26  0:42           ` Jakub Kicinski
2023-08-28 10:59             ` Alexander Lobakin
2023-08-28 12:25             ` Jesper Dangaard Brouer
2023-08-28 11:07           ` Alexander Lobakin
2023-08-28 12:34             ` Jesper Dangaard Brouer
2023-08-28 16:40             ` Sebastian Andrzej Siewior
2023-08-25 13:16   ` Jesper Dangaard Brouer
2023-08-30  7:14     ` [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=044c90b6-4e38-9ae9-a462-def21649183d@kernel.org \
    --to=hawk@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=qingfang.deng@siflower.com.cn \
    --cc=rkannoth@marvell.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=tglx@linutronix.de \
    /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).