workflows.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] docs: netdev: Document guidance on inline functions
@ 2025-02-03 13:59 Simon Horman
  2025-02-03 15:00 ` Jonathan Corbet
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-03 13:59 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Corbet
  Cc: Alexandre Ferrieux, netdev, workflows, linux-doc

Document preference for non inline functions in .c files.
This has been the preference for as long as I can recall
and I was recently surprised to discover that it is undocumented.

Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
Signed-off-by: Simon Horman <horms@kernel.org>
---
 Documentation/process/maintainer-netdev.rst | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
index e497729525d5..1fbb8178b8cd 100644
--- a/Documentation/process/maintainer-netdev.rst
+++ b/Documentation/process/maintainer-netdev.rst
@@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
 
 Conversely, spelling and grammar fixes are not discouraged.
 
+Inline functions
+----------------
+
+The use of static inline functions in .c file is strongly discouraged
+unless there is a demonstrable reason for them, usually performance
+related. Rather, it is preferred to omit the inline keyword and allow the
+compiler to inline them as it sees fit.
+
+This is a stricter requirement than that of the general Linux Kernel
+:ref:`Coding Style<codingstyle>`
+
 Resending after review
 ~~~~~~~~~~~~~~~~~~~~~~
 


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 13:59 [PATCH net] docs: netdev: Document guidance on inline functions Simon Horman
@ 2025-02-03 15:00 ` Jonathan Corbet
  2025-02-03 19:50   ` Mauro Carvalho Chehab
  2025-02-04 22:46   ` David Laight
  2025-02-03 15:10 ` Andrew Lunn
  2025-02-03 18:51 ` Randy Dunlap
  2 siblings, 2 replies; 13+ messages in thread
From: Jonathan Corbet @ 2025-02-03 15:00 UTC (permalink / raw)
  To: Simon Horman, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: Alexandre Ferrieux, netdev, workflows, linux-doc

Simon Horman <horms@kernel.org> writes:

> Document preference for non inline functions in .c files.
> This has been the preference for as long as I can recall
> and I was recently surprised to discover that it is undocumented.
>
> Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
> Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>  Documentation/process/maintainer-netdev.rst | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
> index e497729525d5..1fbb8178b8cd 100644
> --- a/Documentation/process/maintainer-netdev.rst
> +++ b/Documentation/process/maintainer-netdev.rst
> @@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
>  
>  Conversely, spelling and grammar fixes are not discouraged.
>  
> +Inline functions
> +----------------
> +
> +The use of static inline functions in .c file is strongly discouraged
> +unless there is a demonstrable reason for them, usually performance
> +related. Rather, it is preferred to omit the inline keyword and allow the
> +compiler to inline them as it sees fit.
> +
> +This is a stricter requirement than that of the general Linux Kernel
> +:ref:`Coding Style<codingstyle>`

I have no objection to this change, but I do wonder if it does indeed
belong in the central coding-style document.  I don't think anybody
encourages use of "inline" these days...?

jon

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 13:59 [PATCH net] docs: netdev: Document guidance on inline functions Simon Horman
  2025-02-03 15:00 ` Jonathan Corbet
@ 2025-02-03 15:10 ` Andrew Lunn
  2025-02-04  9:35   ` Simon Horman
  2025-02-03 18:51 ` Randy Dunlap
  2 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2025-02-03 15:10 UTC (permalink / raw)
  To: Simon Horman
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Corbet, Alexandre Ferrieux, netdev, workflows, linux-doc

>  Conversely, spelling and grammar fixes are not discouraged.
>  
> +Inline functions
> +----------------
> +
> +The use of static inline functions in .c file is strongly discouraged

I don't think 'static' is relevant here. They probably are static, if
they are inline, and to avoid warnings about missing declarations. But
we just prefer not to have any sort of inline functions without good
justifications within a .c file.

A nit pick, so:

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 13:59 [PATCH net] docs: netdev: Document guidance on inline functions Simon Horman
  2025-02-03 15:00 ` Jonathan Corbet
  2025-02-03 15:10 ` Andrew Lunn
@ 2025-02-03 18:51 ` Randy Dunlap
  2025-02-04 11:56   ` Simon Horman
  2 siblings, 1 reply; 13+ messages in thread
From: Randy Dunlap @ 2025-02-03 18:51 UTC (permalink / raw)
  To: Simon Horman, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Jonathan Corbet
  Cc: Alexandre Ferrieux, netdev, workflows, linux-doc

Hi Simon,

Another nit:

On 2/3/25 5:59 AM, Simon Horman wrote:
> Document preference for non inline functions in .c files.
> This has been the preference for as long as I can recall
> and I was recently surprised to discover that it is undocumented.
> 
> Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
> Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
>  Documentation/process/maintainer-netdev.rst | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
> index e497729525d5..1fbb8178b8cd 100644
> --- a/Documentation/process/maintainer-netdev.rst
> +++ b/Documentation/process/maintainer-netdev.rst
> @@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
>  
>  Conversely, spelling and grammar fixes are not discouraged.
>  
> +Inline functions
> +----------------
> +
> +The use of static inline functions in .c file is strongly discouraged
> +unless there is a demonstrable reason for them, usually performance
> +related. Rather, it is preferred to omit the inline keyword and allow the
> +compiler to inline them as it sees fit.
> +
> +This is a stricter requirement than that of the general Linux Kernel
> +:ref:`Coding Style<codingstyle>`

Is there an ending period (full stop) after that sentence?
Could/should there be?

Thanks.

> +
>  Resending after review
>  ~~~~~~~~~~~~~~~~~~~~~~
>  
> 
> 

-- 
~Randy


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 15:00 ` Jonathan Corbet
@ 2025-02-03 19:50   ` Mauro Carvalho Chehab
  2025-02-03 19:53     ` Mauro Carvalho Chehab
  2025-02-04 11:54     ` Simon Horman
  2025-02-04 22:46   ` David Laight
  1 sibling, 2 replies; 13+ messages in thread
From: Mauro Carvalho Chehab @ 2025-02-03 19:50 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Simon Horman, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexandre Ferrieux, netdev, workflows, linux-doc

Em Mon, 03 Feb 2025 08:00:56 -0700
Jonathan Corbet <corbet@lwn.net> escreveu:

> Simon Horman <horms@kernel.org> writes:
> 
> > Document preference for non inline functions in .c files.
> > This has been the preference for as long as I can recall
> > and I was recently surprised to discover that it is undocumented.
> >
> > Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
> > Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
> > Signed-off-by: Simon Horman <horms@kernel.org>
> > ---
> >  Documentation/process/maintainer-netdev.rst | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
> > index e497729525d5..1fbb8178b8cd 100644
> > --- a/Documentation/process/maintainer-netdev.rst
> > +++ b/Documentation/process/maintainer-netdev.rst
> > @@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
> >  
> >  Conversely, spelling and grammar fixes are not discouraged.
> >  
> > +Inline functions
> > +----------------
> > +
> > +The use of static inline functions in .c file is strongly discouraged
> > +unless there is a demonstrable reason for them, usually performance
> > +related. Rather, it is preferred to omit the inline keyword and allow the
> > +compiler to inline them as it sees fit.

You should probably point to chapter (12) of Documentation/process/coding-style.rst
where it mentions that inline for function prototypes and as a way to
replace macros are OK.

> > +
> > +This is a stricter requirement than that of the general Linux Kernel
> > +:ref:`Coding Style<codingstyle>`  
> 
> I have no objection to this change, but I do wonder if it does indeed
> belong in the central coding-style document.  I don't think anybody
> encourages use of "inline" these days...?

Indeed IMO this belongs to the coding style. I would place it close
to chapter (12) at Documentation/process/coding-style.rst.

Regards,

Thanks,
Mauro

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 19:50   ` Mauro Carvalho Chehab
@ 2025-02-03 19:53     ` Mauro Carvalho Chehab
  2025-02-04 11:55       ` Simon Horman
  2025-02-04 11:54     ` Simon Horman
  1 sibling, 1 reply; 13+ messages in thread
From: Mauro Carvalho Chehab @ 2025-02-03 19:53 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Simon Horman, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexandre Ferrieux, netdev, workflows, linux-doc

Em Mon, 3 Feb 2025 20:50:39 +0100
Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:

> Em Mon, 03 Feb 2025 08:00:56 -0700
> Jonathan Corbet <corbet@lwn.net> escreveu:
> 
> > Simon Horman <horms@kernel.org> writes:
> > 
> > > Document preference for non inline functions in .c files.
> > > This has been the preference for as long as I can recall
> > > and I was recently surprised to discover that it is undocumented.
> > >
> > > Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
> > > Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
> > > Signed-off-by: Simon Horman <horms@kernel.org>
> > > ---
> > >  Documentation/process/maintainer-netdev.rst | 11 +++++++++++
> > >  1 file changed, 11 insertions(+)
> > >
> > > diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
> > > index e497729525d5..1fbb8178b8cd 100644
> > > --- a/Documentation/process/maintainer-netdev.rst
> > > +++ b/Documentation/process/maintainer-netdev.rst
> > > @@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
> > >  
> > >  Conversely, spelling and grammar fixes are not discouraged.
> > >  
> > > +Inline functions
> > > +----------------
> > > +
> > > +The use of static inline functions in .c file is strongly discouraged
> > > +unless there is a demonstrable reason for them, usually performance
> > > +related. Rather, it is preferred to omit the inline keyword and allow the
> > > +compiler to inline them as it sees fit.
> 
> You should probably point to chapter (12) of Documentation/process/coding-style.rst
> where it mentions that inline for function prototypes and as a way to
> replace macros are OK.

Heh, I hit enter too quickly...

I mean:
	"inline for function prototypes and as a way to replace macros on
	 header files (*.h) are OK."

> 
> > > +
> > > +This is a stricter requirement than that of the general Linux Kernel
> > > +:ref:`Coding Style<codingstyle>`  
> > 
> > I have no objection to this change, but I do wonder if it does indeed
> > belong in the central coding-style document.  I don't think anybody
> > encourages use of "inline" these days...?
> 
> Indeed IMO this belongs to the coding style. I would place it close
> to chapter (12) at Documentation/process/coding-style.rst.
> 
> Regards,
> 
> Thanks,
> Mauro



Thanks,
Mauro

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 15:10 ` Andrew Lunn
@ 2025-02-04  9:35   ` Simon Horman
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-04  9:35 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Corbet, Alexandre Ferrieux, netdev, workflows, linux-doc

On Mon, Feb 03, 2025 at 04:10:24PM +0100, Andrew Lunn wrote:
> >  Conversely, spelling and grammar fixes are not discouraged.
> >  
> > +Inline functions
> > +----------------
> > +
> > +The use of static inline functions in .c file is strongly discouraged
> 
> I don't think 'static' is relevant here. They probably are static, if
> they are inline, and to avoid warnings about missing declarations. But
> we just prefer not to have any sort of inline functions without good
> justifications within a .c file.
> 
> A nit pick, so:
> 
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

Thanks Andrew,

I agree that static is not helpful here, I'll drop that in a v2.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 19:50   ` Mauro Carvalho Chehab
  2025-02-03 19:53     ` Mauro Carvalho Chehab
@ 2025-02-04 11:54     ` Simon Horman
  2025-02-04 13:25       ` Andrew Lunn
  1 sibling, 1 reply; 13+ messages in thread
From: Simon Horman @ 2025-02-04 11:54 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Jonathan Corbet, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexandre Ferrieux, netdev, workflows, linux-doc

On Mon, Feb 03, 2025 at 08:50:39PM +0100, Mauro Carvalho Chehab wrote:
> Em Mon, 03 Feb 2025 08:00:56 -0700
> Jonathan Corbet <corbet@lwn.net> escreveu:
> 
> > Simon Horman <horms@kernel.org> writes:
> > 
> > > Document preference for non inline functions in .c files.
> > > This has been the preference for as long as I can recall
> > > and I was recently surprised to discover that it is undocumented.
> > >
> > > Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
> > > Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
> > > Signed-off-by: Simon Horman <horms@kernel.org>
> > > ---
> > >  Documentation/process/maintainer-netdev.rst | 11 +++++++++++
> > >  1 file changed, 11 insertions(+)
> > >
> > > diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
> > > index e497729525d5..1fbb8178b8cd 100644
> > > --- a/Documentation/process/maintainer-netdev.rst
> > > +++ b/Documentation/process/maintainer-netdev.rst
> > > @@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
> > >  
> > >  Conversely, spelling and grammar fixes are not discouraged.
> > >  
> > > +Inline functions
> > > +----------------
> > > +
> > > +The use of static inline functions in .c file is strongly discouraged

As suggested by Andrew Lunn elsewhere in this thread I will drop
"static" from the line above.

> > > +unless there is a demonstrable reason for them, usually performance
> > > +related. Rather, it is preferred to omit the inline keyword and allow the
> > > +compiler to inline them as it sees fit.
> 
> You should probably point to chapter (12) of Documentation/process/coding-style.rst
> where it mentions that inline for function prototypes and as a way to
>static  replace macros are OK.

Thanks, perhaps something like this would help:

  Using inline in .h files is fine and is encouraged in place of macros
  [reference section 12].

> 
> > > +
> > > +This is a stricter requirement than that of the general Linux Kernel
> > > +:ref:`Coding Style<codingstyle>`  
> > 
> > I have no objection to this change, but I do wonder if it does indeed
> > belong in the central coding-style document.  I don't think anybody
> > encourages use of "inline" these days...?
> 
> Indeed IMO this belongs to the coding style. I would place it close
> to chapter (12) at Documentation/process/coding-style.rst.

Sure, thanks to you and Jonathan for the positive feedback there.
I will prepare a revised patch that updates coding-style.rst instead.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 19:53     ` Mauro Carvalho Chehab
@ 2025-02-04 11:55       ` Simon Horman
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-04 11:55 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Jonathan Corbet, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexandre Ferrieux, netdev, workflows, linux-doc

On Mon, Feb 03, 2025 at 08:53:12PM +0100, Mauro Carvalho Chehab wrote:
> Em Mon, 3 Feb 2025 20:50:39 +0100
> Mauro Carvalho Chehab <mchehab+huawei@kernel.org> escreveu:
> 
> > Em Mon, 03 Feb 2025 08:00:56 -0700
> > Jonathan Corbet <corbet@lwn.net> escreveu:
> > 
> > > Simon Horman <horms@kernel.org> writes:
> > > 
> > > > Document preference for non inline functions in .c files.
> > > > This has been the preference for as long as I can recall
> > > > and I was recently surprised to discover that it is undocumented.
> > > >
> > > > Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
> > > > Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
> > > > Signed-off-by: Simon Horman <horms@kernel.org>
> > > > ---
> > > >  Documentation/process/maintainer-netdev.rst | 11 +++++++++++
> > > >  1 file changed, 11 insertions(+)
> > > >
> > > > diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
> > > > index e497729525d5..1fbb8178b8cd 100644
> > > > --- a/Documentation/process/maintainer-netdev.rst
> > > > +++ b/Documentation/process/maintainer-netdev.rst
> > > > @@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
> > > >  
> > > >  Conversely, spelling and grammar fixes are not discouraged.
> > > >  
> > > > +Inline functions
> > > > +----------------
> > > > +
> > > > +The use of static inline functions in .c file is strongly discouraged
> > > > +unless there is a demonstrable reason for them, usually performance
> > > > +related. Rather, it is preferred to omit the inline keyword and allow the
> > > > +compiler to inline them as it sees fit.
> > 
> > You should probably point to chapter (12) of Documentation/process/coding-style.rst
> > where it mentions that inline for function prototypes and as a way to
> > replace macros are OK.
> 
> Heh, I hit enter too quickly...
> 
> I mean:
> 	"inline for function prototypes and as a way to replace macros on
> 	 header files (*.h) are OK."

Likewise, I responded to your previous message too quickly.

Yes, I agree something like that would be good.

> 
> > 
> > > > +
> > > > +This is a stricter requirement than that of the general Linux Kernel
> > > > +:ref:`Coding Style<codingstyle>`  
> > > 
> > > I have no objection to this change, but I do wonder if it does indeed
> > > belong in the central coding-style document.  I don't think anybody
> > > encourages use of "inline" these days...?
> > 
> > Indeed IMO this belongs to the coding style. I would place it close
> > to chapter (12) at Documentation/process/coding-style.rst.
> > 
> > Regards,
> > 
> > Thanks,
> > Mauro
> 
> 
> 
> Thanks,
> Mauro
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 18:51 ` Randy Dunlap
@ 2025-02-04 11:56   ` Simon Horman
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-04 11:56 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Corbet, Alexandre Ferrieux, netdev, workflows, linux-doc

On Mon, Feb 03, 2025 at 10:51:49AM -0800, Randy Dunlap wrote:
> Hi Simon,
> 
> Another nit:
> 
> On 2/3/25 5:59 AM, Simon Horman wrote:
> > Document preference for non inline functions in .c files.
> > This has been the preference for as long as I can recall
> > and I was recently surprised to discover that it is undocumented.
> > 
> > Reported-by: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
> > Closes: https://lore.kernel.org/all/9662e6fe-cc91-4258-aba1-ab5b016a041a@orange.com/
> > Signed-off-by: Simon Horman <horms@kernel.org>
> > ---
> >  Documentation/process/maintainer-netdev.rst | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/Documentation/process/maintainer-netdev.rst b/Documentation/process/maintainer-netdev.rst
> > index e497729525d5..1fbb8178b8cd 100644
> > --- a/Documentation/process/maintainer-netdev.rst
> > +++ b/Documentation/process/maintainer-netdev.rst
> > @@ -408,6 +408,17 @@ at a greater cost than the value of such clean-ups.
> >  
> >  Conversely, spelling and grammar fixes are not discouraged.
> >  
> > +Inline functions
> > +----------------
> > +
> > +The use of static inline functions in .c file is strongly discouraged
> > +unless there is a demonstrable reason for them, usually performance
> > +related. Rather, it is preferred to omit the inline keyword and allow the
> > +compiler to inline them as it sees fit.
> > +
> > +This is a stricter requirement than that of the general Linux Kernel
> > +:ref:`Coding Style<codingstyle>`
> 
> Is there an ending period (full stop) after that sentence?
> Could/should there be?

Thanks,

I think so. I will add one.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-04 11:54     ` Simon Horman
@ 2025-02-04 13:25       ` Andrew Lunn
  2025-02-04 20:07         ` Simon Horman
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew Lunn @ 2025-02-04 13:25 UTC (permalink / raw)
  To: Simon Horman
  Cc: Mauro Carvalho Chehab, Jonathan Corbet, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Ferrieux,
	netdev, workflows, linux-doc

> Thanks, perhaps something like this would help:
> 
>   Using inline in .h files is fine and is encouraged in place of macros
>   [reference section 12].

The other major use of them in headers is for stub functions when an
API implementation has a Kconfig option. The question is, do we really
want to start creating such a list, and have people wanting to add to
it?

	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-04 13:25       ` Andrew Lunn
@ 2025-02-04 20:07         ` Simon Horman
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Horman @ 2025-02-04 20:07 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Mauro Carvalho Chehab, Jonathan Corbet, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alexandre Ferrieux,
	netdev, workflows, linux-doc

On Tue, Feb 04, 2025 at 02:25:07PM +0100, Andrew Lunn wrote:
> > Thanks, perhaps something like this would help:
> > 
> >   Using inline in .h files is fine and is encouraged in place of macros
> >   [reference section 12].
> 
> The other major use of them in headers is for stub functions when an
> API implementation has a Kconfig option. The question is, do we really
> want to start creating such a list, and have people wanting to add to
> it?

Good point. Maybe it is sufficient to just make the distinction
between .c and .h files.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net] docs: netdev: Document guidance on inline functions
  2025-02-03 15:00 ` Jonathan Corbet
  2025-02-03 19:50   ` Mauro Carvalho Chehab
@ 2025-02-04 22:46   ` David Laight
  1 sibling, 0 replies; 13+ messages in thread
From: David Laight @ 2025-02-04 22:46 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: Simon Horman, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexandre Ferrieux, netdev, workflows, linux-doc

... 
> > +Inline functions
> > +----------------
> > +
> > +The use of static inline functions in .c file is strongly discouraged
> > +unless there is a demonstrable reason for them, usually performance
> > +related. Rather, it is preferred to omit the inline keyword and allow the
> > +compiler to inline them as it sees fit.
> > +
> > +This is a stricter requirement than that of the general Linux Kernel
> > +:ref:`Coding Style<codingstyle>`  
> 
> I have no objection to this change, but I do wonder if it does indeed
> belong in the central coding-style document.  I don't think anybody
> encourages use of "inline" these days...?


Apart from the cases where the compiler really ought to inline something
but fails to do so because it doesn't notice just how much code collapses
out.
But in that case you need always_inline.

For instance get_sigset_argpack (fs/select.c) is marked inline but isn't
being inlined by gcc 12.2 (clang 18 is inlining it).

I've also seen places where #defines generate much better code than
inline functions because they get processed much earlier.

	David

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-02-04 22:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 13:59 [PATCH net] docs: netdev: Document guidance on inline functions Simon Horman
2025-02-03 15:00 ` Jonathan Corbet
2025-02-03 19:50   ` Mauro Carvalho Chehab
2025-02-03 19:53     ` Mauro Carvalho Chehab
2025-02-04 11:55       ` Simon Horman
2025-02-04 11:54     ` Simon Horman
2025-02-04 13:25       ` Andrew Lunn
2025-02-04 20:07         ` Simon Horman
2025-02-04 22:46   ` David Laight
2025-02-03 15:10 ` Andrew Lunn
2025-02-04  9:35   ` Simon Horman
2025-02-03 18:51 ` Randy Dunlap
2025-02-04 11:56   ` Simon Horman

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).