mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Alexander Potapenko <glider@google.com>
Cc: catalin.marinas@arm.com, will@kernel.org, pcc@google.com,
	andreyknvl@gmail.com, aleksander.lobakin@intel.com,
	linux@rasmusvillemoes.dk, yury.norov@gmail.com,
	alexandru.elisei@arm.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, eugenis@google.com,
	syednwaris@gmail.com, william.gray@linaro.org
Subject: Re: [PATCH v8 2/2] lib/test_bitmap: add tests for bitmap_{read,write}()
Date: Mon, 23 Oct 2023 22:49:36 +0300	[thread overview]
Message-ID: <ZTbOUIAxuOGgLH+y@smile.fi.intel.com> (raw)
In-Reply-To: <CAG_fn=VOJM5Ok+rvTMB08TKW=1xkU+LmMDWEPugxBaE0XgbL_w@mail.gmail.com>

On Mon, Oct 23, 2023 at 03:50:42PM +0200, Alexander Potapenko wrote:
> On Mon, Oct 23, 2023 at 1:32 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Mon, Oct 23, 2023 at 12:23:27PM +0200, Alexander Potapenko wrote:

...

> > > +                             val = bitmap_read(bitmap, i, nbits);
> > > +                             (void)val;
> >
> > Is it marked with __must_check? Otherwise why do we need this?
> 
> That was a weak attempt to prevent the compiler from completely
> optimizing away the bitmap_read() calls, but I haven't really looked
> at the result.
> The reality is that even with this check the calls are deleted, and
> the size of the function is only 68 bytes.
> Replacing the val assignment with a WRITE_ONCE() actually ensures the
> bitmap_read() calls are not deleted:
> 
> diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
> index ba567f53feff1..ae57ae48ef3ad 100644
> --- a/lib/test_bitmap.c
> +++ b/lib/test_bitmap.c
> @@ -1360,8 +1360,7 @@ static void __init test_bitmap_read_perf(void)
>                         for (i = 0; i < TEST_BIT_LEN; i++) {
>                                 if (i + nbits > TEST_BIT_LEN)
>                                         break;
> -                               val = bitmap_read(bitmap, i, nbits);
> -                               (void)val;
> +                               WRITE_ONCE(val, bitmap_read(bitmap, i, nbits));
>                         }
>                 }
>         }

Okay, whatever you choose, please add a comment explaining this.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-10-23 19:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 10:23 [PATCH v8 1/2] lib/bitmap: add bitmap_{read,write}() Alexander Potapenko
2023-10-23 10:23 ` [PATCH v8 2/2] lib/test_bitmap: add tests for bitmap_{read,write}() Alexander Potapenko
2023-10-23 11:32   ` Andy Shevchenko
2023-10-23 13:50     ` Alexander Potapenko
2023-10-23 19:49       ` Andy Shevchenko [this message]
2023-10-23 20:49   ` Yury Norov
2023-10-24 11:56     ` Alexander Potapenko

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=ZTbOUIAxuOGgLH+y@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=alexandru.elisei@arm.com \
    --cc=andreyknvl@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=eugenis@google.com \
    --cc=glider@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=pcc@google.com \
    --cc=syednwaris@gmail.com \
    --cc=will@kernel.org \
    --cc=william.gray@linaro.org \
    --cc=yury.norov@gmail.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

all inboxes | Powered by JetHome®