[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 4 Apr 2023 15:34:51 +0800
From: Jason Xing <kerneljasonxing@...il.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Kuniyuki Iwashima <kuniyu@...zon.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Kuniyuki Iwashima <kuni1840@...il.com>, netdev@...r.kernel.org,
syzbot <syzkaller@...glegroups.com>,
"Dae R . Jeong" <threeearcat@...il.com>
Subject: Re: [PATCH v1 net 1/2] raw: Fix NULL deref in raw_get_next().
On Tue, Apr 4, 2023 at 3:23 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
> On Tue, Apr 4, 2023 at 8:56 AM Jason Xing <kerneljasonxing@...il.com> wrote:
> >
> > On Tue, Apr 4, 2023 at 12:07 PM Eric Dumazet <edumazet@...gle.com> wrote:
> > >
> > > On Tue, Apr 4, 2023 at 4:46 AM Jason Xing <kerneljasonxing@...il.com> wrote:
> > > >
> > > > I would like to ask two questions which make me confused:
> > > > 1) Why would we use spin_lock to protect the socket in a raw hashtable
> > > > for reader's safety under the rcu protection? Normally, if we use the
> > > > RCU protection, we only make sure that we need to destroy the socket
> > > > by calling call_rcu() which would prevent the READER of the socket
> > > > from getting a NULL pointer.
> > >
> > > Yes, but then we can not sleep or yield the cpu.
> >
> > Indeed. We also cannot sleep/yield under the protection of the spin
> > lock. And I checked the caller in fs/seq_file.c and noticed that we
> > have no chance to sleep/yield between ->start and ->stop.
> >
>
> You missed my point.
> The spinlock can trivially be replaced by a mutex, now the fast path
> has been RCU converted.
> This would allow raw_get_idx()/raw_get_first() to use cond_resched(),
> if some hosts try to use 10,000 raw sockets :/
Thanks for the clarification. I agreed. The patch for now itself is good :)
> Is it a real problem to solve right now ? I do not think so.
>
> > So I wonder why we couldn't use RCU directly like the patch[1] you
> > proposed before and choose deliberately to switch to spin lock? Spin
> > lock for the whole hashinfo to protect the reader side is heavy, and
> > RCU outperforms spin lock in this case, I think.
>
> spinlock is just fine enough, most hosts have less than 10 raw sockets,
> because raw sockets make things _much_ slower.
Sure.
Thanks,
Jason
>
> RCU 'just because' does not make sense, it would suggest that RAW sockets
> scale, while they do not.
Powered by blists - more mailing lists