linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yury Norov <yury.norov@gmail.com>
To: Sander Vanheule <sander@svanheule.net>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	David Howells <dhowells@redhat.com>,
	Ingo Molnar <mingo@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Jonathan Corbet <corbet@lwn.net>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Matthew Wilcox <willy@infradead.org>, NeilBrown <neilb@suse.de>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Russell King <linux@armlinux.org.uk>,
	Vlastimil Babka <vbabka@suse.cz>,
	William Kucharski <william.kucharski@oracle.com>,
	linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-mm@kvack.org
Subject: Re: [PATCH 06/10] lib/cpumask: move trivial wrappers around find_bit to the header
Date: Sun, 31 Jul 2022 08:43:44 -0700	[thread overview]
Message-ID: <YuajMOuaGYBihRaK@yury-laptop> (raw)
In-Reply-To: <9383b9b62a15ba6f91af5adb0b0b1dd90ac1a3df.camel@svanheule.net>

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@gmail.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


  reply	other threads:[~2022-07-31 15:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 17:42 [PATCH v2 00/10] lib: cleanup bitmap-related headers Yury Norov
2022-07-06 17:42 ` [PATCH 01/10] arm: align find_bit declarations with generic kernel Yury Norov
2022-07-06 17:42 ` [PATCH 02/10] lib/bitmap: change return types to bool where appropriate Yury Norov
2022-07-06 17:42 ` [PATCH 03/10] lib/bitmap: change type of bitmap_weight to unsigned long Yury Norov
2022-07-06 17:42 ` [PATCH 04/10] cpumask: change return types to bool where appropriate Yury Norov
2022-07-06 17:42 ` [PATCH 05/10] lib/cpumask: change return types to unsigned " Yury Norov
2022-07-06 17:42 ` [PATCH 06/10] lib/cpumask: move trivial wrappers around find_bit to the header Yury Norov
2022-07-31  9:42   ` Sander Vanheule
2022-07-31 15:43     ` Yury Norov [this message]
2022-07-06 17:42 ` [PATCH 07/10] headers/deps: mm: Optimize <linux/gfp.h> header dependencies Yury Norov
2022-07-06 17:42 ` [PATCH 08/10] headers/deps: mm: Split <linux/gfp_types.h> out of <linux/gfp.h> Yury Norov
2022-09-01 20:43   ` Matthew Wilcox
2022-09-02  2:10     ` Yury Norov
2022-09-02 15:12       ` Matthew Wilcox
2022-07-06 17:42 ` [PATCH 09/10] headers/deps: mm: align MANITAINERS and Docs with new gfp.h structure Yury Norov
2022-07-06 17:42 ` [PATCH 10/10] lib/cpumask: move some one-line wrappers to header file Yury Norov
2022-07-12 16:28 ` [PATCH v2 00/10] lib: cleanup bitmap-related headers Yury Norov
2022-07-14 22:15   ` Yury Norov

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=YuajMOuaGYBihRaK@yury-laptop \
    --to=yury.norov@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@armlinux.org.uk \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mingo@kernel.org \
    --cc=neilb@suse.de \
    --cc=sander@svanheule.net \
    --cc=vbabka@suse.cz \
    --cc=william.kucharski@oracle.com \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).