lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFULd4atoeGkCTc+itU_ACBAcBxXPbPNOhockqCnd4Xsc75R9w@mail.gmail.com>
Date: Mon, 7 Oct 2024 17:02:30 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>
Subject: Re: [PATCH] namespace: Use atomic64_inc_return() in alloc_mnt_ns()

On Mon, Oct 7, 2024 at 4:50 PM Al Viro <viro@...iv.linux.org.uk> wrote:
>
> On Mon, Oct 07, 2024 at 10:52:37AM +0200, Uros Bizjak wrote:
> > Use atomic64_inc_return(&ref) instead of atomic64_add_return(1, &ref)
> > to use optimized implementation and ease register pressure around
> > the primitive for targets that implement optimized variant.
> >
> > Signed-off-by: Uros Bizjak <ubizjak@...il.com>
> > Cc: Alexander Viro <viro@...iv.linux.org.uk>
> > Cc: Christian Brauner <brauner@...nel.org>
> > Cc: Jan Kara <jack@...e.cz>
> > ---
> >  fs/namespace.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/namespace.c b/fs/namespace.c
> > index 93c377816d75..9a3c251d033d 100644
> > --- a/fs/namespace.c
> > +++ b/fs/namespace.c
> > @@ -3901,7 +3901,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a
> >       }
> >       new_ns->ns.ops = &mntns_operations;
> >       if (!anon)
> > -             new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
> > +             new_ns->seq = atomic64_inc_return(&mnt_ns_seq);
>
> On which load do you see that path hot enough for the change to
> make any difference???

It is not performance, but code size improvement, as stated in the
commit message.

The difference on x86_32 (that implements atomic64_inc_return()) is:

     eeb:    b8 01 00 00 00           mov    $0x1,%eax
     ef0:    31 d2                    xor    %edx,%edx
     ef2:    b9 20 00 00 00           mov    $0x20,%ecx
            ef3: R_386_32    .data
     ef7:    e8 fc ff ff ff           call   ef8 <alloc_mnt_ns+0xd0>
            ef8: R_386_PC32    atomic64_add_return_cx8
     efc:    89 46 20                 mov    %eax,0x20(%esi)
     eff:    89 56 24                 mov    %edx,0x24(%esi)

vs:

     eeb:    be 20 00 00 00           mov    $0x20,%esi
            eec: R_386_32    .data
     ef0:    e8 fc ff ff ff           call   ef1 <alloc_mnt_ns+0xc9>
            ef1: R_386_PC32    atomic64_inc_return_cx8
     ef5:    89 43 20                 mov    %eax,0x20(%ebx)
     ef8:    89 53 24                 mov    %edx,0x24(%ebx)

Uros.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ