[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a6a88962951a9bfdb69facaadf45a6b6cf5aa625.camel@mellanox.com>
Date: Tue, 10 Mar 2020 23:34:16 +0000
From: Saeed Mahameed <saeedm@...lanox.com>
To: "jonathan.lemon@...il.com" <jonathan.lemon@...il.com>
CC: "kernel-team@...com" <kernel-team@...com>,
"davem@...emloft.net" <davem@...emloft.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"brouer@...hat.com" <brouer@...hat.com>,
"ilias.apalodimas@...aro.org" <ilias.apalodimas@...aro.org>
Subject: Re: [PATCH] page_pool: use irqsave/irqrestore to protect ring access.
On Tue, 2020-03-10 at 10:07 -0700, Jonathan Lemon wrote:
>
> 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@...il.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@...il.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.
I think that if you use another variant this it intorduce a possiblerace bestrewn sofitq and hardirq ..
Powered by blists - more mailing lists