From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: linus.walleij@linaro.org, bgolaszewski@baylibre.com,
akpm@linux-foundation.org, linux-gpio@vger.kernel.org,
linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org,
linux@rasmusvillemoes.dk, yamada.masahiro@socionext.com,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
geert@linux-m68k.org, preid@electromag.com.au,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro
Date: Tue, 26 Mar 2019 13:42:52 +0200 [thread overview]
Message-ID: <20190326114252.GX9224@smile.fi.intel.com> (raw)
In-Reply-To: <20190326025459.GA3356@icarus>
On Tue, Mar 26, 2019 at 11:54:59AM +0900, William Breathitt Gray wrote:
> On Mon, Mar 25, 2019 at 03:12:36PM +0200, Andy Shevchenko wrote:
> > On Mon, Mar 25, 2019 at 03:22:23PM +0900, William Breathitt Gray wrote:
> > > This macro iterates for each 8-bit group of bits (clump) with set bits,
> > > within a bitmap memory region. For each iteration, "start" is set to the
> > > bit offset of the found clump, while the respective clump value is
> > > stored to the location pointed by "clump". Additionally, the
> > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to
> > > respectively get and set an 8-bit value in a bitmap memory region.
> >
> >
> > This seems to miss Randy's (IIRC) comment about too many const specifiers.
>
> I disagree with removing the const qualifiers; I believe they are useful
> and do not significantly impact the clarity of the code (in fact, I'd
> argue the opposite).
Had you checked the assembly? I'm talking about const for values on the stack.
I think if you put less const there compiler can keep something in the
registers instead of using direct constants or accessing stack.
I might be mistaken, so, I can't argue without evidence of either.
> The const qualifiers make it clear these values are
> constant, allowing readers at a glace to know these values never change
> within this function. Although I believe GCC is smart enough in this
> case to deduce implicitly that these are constant values, generally
> speaking const qualifiers do make it easier for compilers to optimize
> sections of code (OoO execution, algorithm simplification, etc.), so I
> believe it's useful in a technical sense as well.
Again, what the difference do you see in assembly if any?
> I added the const qualifier to these variables because they really are
> constant, and I believe there is merit in making it explicit in the
> code. If the primary reason for removing the const qualifiers is for
> aesthetics, then I must dissent with that decision.
The point is, if there is no difference, I would prefer one which will be
better to read, otherwise check the assembly.
> However, it is difficult to read the definitions that wrap around to a
> second line. These definitions are long enough that even removing the
> const qualifiers would not help prevent the wrapping, so perhaps it
> would make to let these stay on a single line. Do you think it would
> help to ignore the 80-character maximum line width coding style rule for
> these cases here?
80-characters rule can be slightly bended depending on the context. Here, I
think, we might continue discussing the matter after having an evidence how
const qualifiers affect the code.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2019-03-26 11:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-25 6:20 [PATCH v12 00/11] Introduce the for_each_set_clump8 macro William Breathitt Gray
2019-03-25 6:22 ` [PATCH v12 01/11] bitops: " William Breathitt Gray
2019-03-25 9:38 ` Lukas Wunner
2019-03-25 13:09 ` Andy Shevchenko
2019-03-26 3:14 ` William Breathitt Gray
2019-03-26 9:43 ` Lukas Wunner
2019-03-26 9:53 ` Andy Shevchenko
2019-03-26 10:08 ` William Breathitt Gray
2019-03-26 10:19 ` Andy Shevchenko
2019-03-26 10:28 ` William Breathitt Gray
2019-03-26 13:03 ` Lukas Wunner
2019-03-26 13:18 ` Andy Shevchenko
2019-03-25 13:12 ` Andy Shevchenko
2019-03-26 2:54 ` William Breathitt Gray
2019-03-26 11:42 ` Andy Shevchenko [this message]
2019-03-25 6:23 ` [PATCH v12 02/11] lib/test_bitmap.c: Add for_each_set_clump8 test cases William Breathitt Gray
2019-03-25 6:23 ` [PATCH v12 03/11] gpio: 104-dio-48e: Utilize for_each_set_clump8 macro William Breathitt Gray
2019-03-25 6:23 ` [PATCH v12 04/11] gpio: 104-idi-48: " William Breathitt Gray
2019-03-25 6:24 ` [PATCH v12 05/11] gpio: gpio-mm: " William Breathitt Gray
2019-03-25 6:24 ` [PATCH v12 06/11] gpio: ws16c48: " William Breathitt Gray
2019-03-25 6:24 ` [PATCH v12 07/11] gpio: pci-idio-16: " William Breathitt Gray
2019-03-25 6:25 ` [PATCH v12 08/11] gpio: pcie-idio-24: " William Breathitt Gray
2019-03-25 6:25 ` [PATCH v12 09/11] gpio: uniphier: " William Breathitt Gray
2019-03-25 6:26 ` [PATCH v12 10/11] thermal: intel: intel_soc_dts_iosf: " William Breathitt Gray
2019-03-25 6:26 ` [PATCH v12 11/11] gpio: 74x164: Utilize the " William Breathitt Gray
2019-03-25 13:11 ` Andy Shevchenko
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=20190326114252.GX9224@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bgolaszewski@baylibre.com \
--cc=geert@linux-m68k.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=preid@electromag.com.au \
--cc=vilhelm.gray@gmail.com \
--cc=yamada.masahiro@socionext.com \
/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