Linux filesystem development
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Jori Koolstra <jkoolstra@xs4all.nl>
Cc: NeilBrown <neilb@ownmail.net>, NeilBrown <neil@brown.name>,
	Jeff Layton <jlayton@kernel.org>,
	Christian Brauner <brauner@kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Aleksa Sarai <aleksa@amutable.com>,
	Amir Goldstein <amir73il@gmail.com>, Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 01/14] fs/namei.c: use trailing_slashes()
Date: Tue, 7 Jul 2026 08:42:37 +0100	[thread overview]
Message-ID: <20260707084237.3d445b19@pumpkin> (raw)
In-Reply-To: <202595709.128794.1783371348230@kpc.webmail.kpnmail.nl>

On Mon, 6 Jul 2026 22:55:48 +0200 (CEST)
Jori Koolstra <jkoolstra@xs4all.nl> wrote:

> > Op 06-07-2026 09:29 CEST schreef David Laight <david.laight.linux@gmail.com>:
> > 
> >  
> > On Mon, 06 Jul 2026 13:56:00 +1000
> > NeilBrown <neilb@ownmail.net> wrote:
> >   
> > > On Sun, 05 Jul 2026, Jori Koolstra wrote:  
> > > > There are several places in fs/namei.c that can use the
> > > > trailing_slashes() function to improve intent.    
> > > 
> > > I think it would help to state here that trailing_slashes() is changed
> > > to take a qstr instead of a nameidata as that is useful in more places.  
> 
> Yes, thanks.
> 
> > 
> > It is also taking the struct 'by value' so should really be always_inline
> > before something makes a compiler decide it should be a real function.
> > 
> > (Or make it take a pointer)
> > 
> > 	David  
> 
> You know more about this compiler optimization stuff than I do, David. So:
> is there any chance this does not get inlined? I am fine with always_inline,
> but I don't see it often in these scenarios (just inline usually). Is there
> a reason for that?

There is a view that you should just let the compiler decide whether to
inline something unless there are technical reasons why it must be inlined.
But I've seen gcc fail to inline static functions that are only called once
even when they are marked 'inline' (that mattered in some embedded code where
any spills to stack would make it too slow).

It is normally the KASAN (etc) options that cause functions not to be inlined
(as well as causing massive stack use when there are lots of calls to functions
that get inlined).

It has been suggested that the kernel be built with inline implying
always_inline - but there are a few quite large functions that are marked
inline and they really don't want to be inlined. 

> 
> Pointer is also OK, but this is just two register copies (even if it does not get
> inlined) on 64-bit. Is that really less fast than one copy and a pointer deref?
> Genuine question, I am no expert on this.

It isn't obvious from the code that the structure is that short (I didn't look
further than the patch and it appears to contain an array).
But passing structures by value is usually either not intended or inefficient.
Any longer than (I think) two registers are passed by taking a copy on stack
and passing that by reference.
(In the pre-ANSI C days you could do that by mistake and spends days trying
to work out why one code path failed to update some members.)

On 32bit I'm pretty sure the three values will be copied and passed
by reference.

This function does have a strange name and implementation.
There is the hidden assumption that if the name isn't '\0' terminated
the extra characters must be '/', and the (bool) cast was probably
added to silence a compiler warning, but '!= 0' would read better.

	David


> 
> Thanks,
> Jori.


  reply	other threads:[~2026-07-07  7:42 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-04 16:41 [PATCH v3 00/14] vfs: add O_CREAT|O_DIRECTORY to open*(2) Jori Koolstra
2026-07-04 16:41 ` [PATCH v3 01/14] fs/namei.c: use trailing_slashes() Jori Koolstra
2026-07-06  3:56   ` NeilBrown
2026-07-06  7:29     ` David Laight
2026-07-06 20:55       ` Jori Koolstra
2026-07-07  7:42         ` David Laight [this message]
2026-07-04 16:41 ` [PATCH v3 02/14] vfs: move create error && negative dentry case in lookup_open() up Jori Koolstra
2026-07-04 16:41 ` [PATCH v3 03/14] vfs: prepare vfs_creat|mkdir_no_perm for reuse in lookup_open() Jori Koolstra
2026-07-04 16:41 ` [PATCH v3 04/14] vfs: call audit_inode_child() in lookup_open() on failure too Jori Koolstra
2026-07-06  5:33   ` NeilBrown
2026-07-06 21:20     ` Jori Koolstra
2026-07-06 23:02       ` NeilBrown
2026-07-04 16:41 ` [PATCH v3 05/14] fs/namei.c: update docstring of atomic_open() Jori Koolstra
2026-07-06  5:36   ` NeilBrown
2026-07-04 16:41 ` [PATCH v3 06/14] vfs: lookup_open(): move setting FMODE_CREATED down Jori Koolstra
2026-07-04 16:41 ` [PATCH v3 07/14] vfs: move ->create check in lookup_open() to before try_break_deleg() Jori Koolstra
2026-07-06  5:37   ` NeilBrown
2026-07-04 16:41 ` [PATCH v3 08/14] vfs: lookup_open(): use vfs_create_no_perm() Jori Koolstra
2026-07-06  5:38   ` NeilBrown
2026-07-04 16:41 ` [PATCH v3 09/14] vfs: add O_CREAT|O_DIRECTORY to open*(2) Jori Koolstra
2026-07-06  5:46   ` NeilBrown
2026-07-07  8:35   ` Pedro Falcato
2026-07-04 16:41 ` [PATCH v3 10/14] vfs: move O_IS_MKDIR check from lookup_open() into individual filesystems Jori Koolstra
2026-07-06  5:50   ` NeilBrown
2026-07-04 16:41 ` [PATCH v3 11/14] vfs: refuse O_CREAT for directories through a dangling symlink Jori Koolstra
2026-07-06  5:51   ` NeilBrown
2026-07-04 16:41 ` [PATCH v3 12/14] vfs: short-circuit MAY_WRITE access for O_DIRECTORY opens Jori Koolstra
2026-07-06  5:51   ` NeilBrown
2026-07-04 16:41 ` [PATCH v3 13/14] selftest: fix headers in fclog.c Jori Koolstra
2026-07-06  5:57   ` NeilBrown
2026-07-06 21:07     ` Jori Koolstra
2026-07-04 16:41 ` [PATCH v3 14/14] selftest: add tests for open*(O_CREAT|O_DIRECTORY) Jori Koolstra

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=20260707084237.3d445b19@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=aleksa@amutable.com \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jkoolstra@xs4all.nl \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=neilb@ownmail.net \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox