All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jonathan Lemon" <jonathan.lemon@gmail.com>
To: "Saeed Mahameed" <saeedm@mellanox.com>
Cc: davem@davemloft.net, kernel-team@fb.com, netdev@vger.kernel.org,
	ilias.apalodimas@linaro.org, brouer@redhat.com
Subject: Re: [PATCH] page_pool: use irqsave/irqrestore to protect ring access.
Date: Tue, 10 Mar 2020 10:07:06 -0700	[thread overview]
Message-ID: <D6B9A0EF-61FA-40A9-AED3-4B4927FD9115@gmail.com> (raw)
In-Reply-To: <9b09170da05fb59bde7b003be282dfa63edd969e.camel@mellanox.com>



On 9 Mar 2020, at 19:30, Saeed Mahameed wrote:

> On Mon, 2020-03-09 at 17:55 -0700, David Miller wrote:
>> From: Jonathan Lemon <jonathan.lemon@gmail.com>
>> Date: Mon, 9 Mar 2020 12:49:29 -0700
>>
>>> netpoll may be called from IRQ context, which may access the
>>> page pool ring.  The current _bh variants do not provide sufficient
>>> protection, so use irqsave/restore instead.
>>>
>>> Error observed on a modified mlx4 driver, but the code path exists
>>> for any driver which calls page_pool_recycle from napi poll.
>>>
>>> WARNING: CPU: 34 PID: 550248 at /ro/source/kernel/softirq.c:161
>> __local_bh_enable_ip+0x35/0x50
>>  ...
>>> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
>>
>> The netpoll stuff always makes the locking more complicated than it
>> needs
>> to be.  I wonder if there is another way around this issue?
>>
>> Because IRQ save/restore is a high cost to pay in this critical path.
>
> a printk inside irq context lead to this, so maybe it can be avoided ..

This was caused by a printk in hpet_rtc_timer_reinit() complaining about
RTC interrupts being lost.  I'm not sure it's practical trying to locate
all the printk cases like this.


> or instead of checking in_serving_softirq()  change page_pool to
> check in_interrupt() which is more powerful, to avoid ptr_ring locking
> and the complication with netpoll altogether.

That's another approach:

    ret = 1;
    if (!in_irq()) {
        if (in_serving_softirq())
            ret = ptr_ring_produce(....
        else
            ret = ptr_ring_produce_bh(....
    }

which would return failure and release the page from the page pool.
This doesn't address the allocation or the bulk release path.


>
> I wonder why Jesper picked in_serving_softirq() in first place, was
> there a specific reason ? or he just wanted it to be as less strict as
> possible ?

From the code, it looks like he was optimizing to avoid the _bh variant
if possible.
-- 
Jonathan

  parent reply	other threads:[~2020-03-10 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 19:49 [PATCH] page_pool: use irqsave/irqrestore to protect ring access Jonathan Lemon
2020-03-10  0:55 ` David Miller
2020-03-10  2:30   ` Saeed Mahameed
2020-03-10 10:04     ` Jesper Dangaard Brouer
2020-03-10 17:52       ` Jonathan Lemon
2020-03-10 21:09       ` Jakub Kicinski
2020-03-10 23:53         ` Saeed Mahameed
2020-03-10 17:07     ` Jonathan Lemon [this message]
2020-03-10 23:34       ` Saeed Mahameed
2020-03-10 16:52   ` Jonathan Lemon

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=D6B9A0EF-61FA-40A9-AED3-4B4927FD9115@gmail.com \
    --to=jonathan.lemon@gmail.com \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.