public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Bart Van Assche <Bart.VanAssche@wdc.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Neil Brown <neilb@suse.com>, Ingo Molnar <mingo@redhat.com>,
	"Theodore Ts'o" <tytso@mit.edu>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"agk@redhat.com" <agk@redhat.com>,
	"phil@raspberrypi.org" <phil@raspberrypi.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	"m.duckeck@kunbus.de" <m.duckeck@kunbus.de>,
	"snitzer@redhat.com" <snitzer@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] bitops: Introduce assign_bit()
Date: Tue, 22 Aug 2017 12:04:47 +0200	[thread overview]
Message-ID: <20170822100447.GC12241@wunner.de> (raw)
In-Reply-To: <20170822092731.k6zpoezpee5sal6w@hirez.programming.kicks-ass.net>

On Tue, Aug 22, 2017 at 11:27:31AM +0200, Peter Zijlstra wrote:
> On Tue, Aug 22, 2017 at 10:30:50AM +0200, Lukas Wunner wrote:
> > diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> > index a83c822c35c2..097af36887c0 100644
> > --- a/include/linux/bitops.h
> > +++ b/include/linux/bitops.h
> > @@ -226,6 +226,30 @@ static inline unsigned long __ffs64(u64 word)
> >  	return __ffs((unsigned long)word);
> >  }
> >  
> > +/**
> > + * assign_bit - Assign value to a bit in memory
> > + * @value: the value to assign
> > + * @nr: the bit to set
> > + * @addr: the address to start counting from
> > + */
> > +static __always_inline void assign_bit(bool value, long nr,
> > +				       volatile unsigned long *addr)
> > +{
> > +	if (value)
> > +		set_bit(nr, addr);
> > +	else
> > +		clear_bit(nr, addr);
> > +}
> > +
> > +static __always_inline void __assign_bit(bool value, long nr,
> > +					 volatile unsigned long *addr)
> > +{
> > +	if (value)
> > +		__set_bit(nr, addr);
> > +	else
> > +		__clear_bit(nr, addr);
> > +}
> > +
> 
> I dislike the argument order, in C you naturally write: dst = src. So I
> would have expected:
> 
> 	assign_bit(nr, addr, val);
> 
> but we have quite a few of these backwards functions in the kernel (like
> most of the atomic_t family) and I didn't check to see if the existing
> bitops are part of that 'tradition'.

The functions in include/linux/bitmap.h do follow the dst-then-src
pattern.  I carried over the argument order from Bart's function
to minimize the impact on the md subsystem, but will be happy to
respin with the order you're suggesting.  Will wait a bit though
to see if there are further comments.

Thanks,

Lukas

      reply	other threads:[~2017-08-22 10:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1503319573.git.lukas@wunner.de>
     [not found] ` <5487a5f7d1a4be1bb13e7d1f392281d18c0e935e.1503319573.git.lukas@wunner.de>
     [not found]   ` <1503332323.2571.5.camel@wdc.com>
2017-08-22  8:30     ` [PATCH 1/4] bitops: Introduce assign_bit() Lukas Wunner
2017-08-22  9:27       ` Peter Zijlstra
2017-08-22 10:04         ` Lukas Wunner [this message]

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=20170822100447.GC12241@wunner.de \
    --to=lukas@wunner.de \
    --cc=Bart.VanAssche@wdc.com \
    --cc=agk@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.duckeck@kunbus.de \
    --cc=mingo@redhat.com \
    --cc=neilb@suse.com \
    --cc=peterz@infradead.org \
    --cc=phil@raspberrypi.org \
    --cc=snitzer@redhat.com \
    --cc=tytso@mit.edu \
    /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