Subject: Re: [RFC net-next 1/3] net: provide macros for commonly copied lockless queue stop/wake code

From: Stephen Hemminger <[email-masked]>
Date: Sun, 12 Mar 2023 18:45:15 -0700

On Sun, 12 Mar 2023 21:37:39 -0400
Willem de Bruijn <[email-masked]> wrote:

> Stephen Hemminger wrote:
> > On Fri, 10 Mar 2023 21:01:28 -0800
> > Jakub Kicinski <[email-masked]> wrote:
> >   
> > > A lot of drivers follow the same scheme to stop / start queues
> > > without introducing locks between xmit and NAPI tx completions.
> > > I'm guessing they all copy'n'paste each other's code.
> > > 
> > > Smaller drivers shy away from the scheme and introduce a lock
> > > which may cause deadlocks in netpoll.
> > > 
> > > Provide macros which encapsulate the necessary logic.  
> > 
> > Could any of these be inline functions instead for type safety?  
> 
> I suppose not because of the condition that is evaluated.

It is more that the condition needs to evaluated after some other
pre-conditions.