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] [thread-next>] [day] [month] [year] [list]
Message-ID: <YuajMOuaGYBihRaK@yury-laptop>
Date:   Sun, 31 Jul 2022 08:43:44 -0700
From:   Yury Norov <yury.norov@...il.com>
To:     Sander Vanheule <sander@...nheule.net>
Cc:     linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        David Howells <dhowells@...hat.com>,
        Ingo Molnar <mingo@...nel.org>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        Jonathan Corbet <corbet@....net>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
        Matthew Wilcox <willy@...radead.org>,
        NeilBrown <neilb@...e.de>,
        Rasmus Villemoes <linux@...musvillemoes.dk>,
        Russell King <linux@...linux.org.uk>,
        Vlastimil Babka <vbabka@...e.cz>,
        William Kucharski <william.kucharski@...cle.com>,
        linux-doc@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-mm@...ck.org
Subject: Re: [PATCH 06/10] lib/cpumask: move trivial wrappers around find_bit
 to the header

On Sun, Jul 31, 2022 at 11:42:52AM +0200, Sander Vanheule wrote:
> Hi Yury,
> 
> On Wed, 2022-07-06 at 10:42 -0700, Yury Norov wrote:
> > To avoid circular dependencies, cpumask keeps simple (almost) one-line
> > wrappers around find_bit() in a c-file.
> > 
> > Commit 47d8c15615c0a2 ("include: move find.h from asm_generic to linux")
> > moved find.h header out of asm_generic include path, and it helped to fix
> > many circular dependencies, including some in cpumask.h.
> > 
> > This patch moves those one-liners to header files.
> > 
> > Signed-off-by: Yury Norov <yury.norov@...il.com>
> > ---
> >  include/linux/cpumask.h | 57 ++++++++++++++++++++++++++++++++++++++---
> >  lib/cpumask.c           | 55 ---------------------------------------
> >  2 files changed, 54 insertions(+), 58 deletions(-)
> > 
> > diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> > index 760022bcb925..ea3de2c2c180 100644
> > --- a/include/linux/cpumask.h
> > +++ b/include/linux/cpumask.h
> > @@ -241,7 +241,21 @@ static inline unsigned int cpumask_last(const struct
> > cpumask *srcp)
> >         return find_last_bit(cpumask_bits(srcp), nr_cpumask_bits);
> >  }
> >  
> > -unsigned int __pure cpumask_next(int n, const struct cpumask *srcp);
> > +/**
> > + * cpumask_next - get the next cpu in a cpumask
> > + * @n: the cpu prior to the place to search (ie. return will be > @n)
> > + * @srcp: the cpumask pointer
> > + *
> > + * Returns >= nr_cpu_ids if no further cpus set.
> > + */
> > +static inline
> > +unsigned int cpumask_next(int n, const struct cpumask *srcp)
> 
> This also drops the __pure speficier for these functions. Since I have a patch
> that does the opposite for cpumask_next_wrap() [1], I was wondering what your
> reasoning behind this is.
> 
> Since a cpumask like cpu_online_mask may change between subsequent calls, I'm
> considering to drop my patch adding __pure, and to follow the changes you've
> made here.
> 
> [1]
> https://lore.kernel.org/all/06eebdc46cfb21eb437755a2a5a56d55c41400f5.1659077534.git.sander@svanheule.net/
 
__pure is a promise to the compiler that the function will not modify
system state (i.e. will not write into the memory). Now that the
cpumask_next etc. became static inline, there's no reason for the hint
because the compiler inlines the code, and there's no a real function.

Maybe then it's worth to propagate the __pure to find_bit() helpers...

Would be great to get comments form compiler people. Rasmus?

Thanks,
Yury

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ