public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-s390@vger.kernel.org, Stable <stable@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Yury Norov <yury.norov@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Amritha Nambiar <amritha.nambiar@intel.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Kees Cook <keescook@chromium.org>,
	Matthew Wilcox <willy@infradead.org>,
	Miklos Szeredi <mszeredi@redhat.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	"Tobin C . Harding" <tobin@kernel.org>,
	Vineet Gupta <vineet.gupta1@synopsys.com>,
	Will Deacon <will.deacon@arm.com>,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH RESEND2] lib: fix bitmap_parse() on 64-bit big endian archs
Date: Mon, 8 Jun 2020 14:44:34 +0200	[thread overview]
Message-ID: <20200608124433.GA28369@oc3871087118.ibm.com> (raw)
In-Reply-To: <CAHp75VcFdrvNMj0TL8ZHxShqqGDM31Hy8vitmn9HOPjZ6f9uYw@mail.gmail.com>

On Mon, Jun 08, 2020 at 03:03:05PM +0300, Andy Shevchenko wrote:
> On Mon, Jun 8, 2020 at 1:26 PM Alexander Gordeev <agordeev@linux.ibm.com> wrote:
> >
> > Commit 2d6261583be0 ("lib: rework bitmap_parse()") does not
> > take into account order of halfwords on 64-bit big endian
> > architectures. As result (at least) Receive Packet Steering,
> > IRQ affinity masks and runtime kernel test "test_bitmap" get
> > broken on s390.
> 
> ...
> 
> > +#if defined(__BIG_ENDIAN) && defined(CONFIG_64BIT)
> 
> I think it's better to re-use existing patterns.
> 
> ipc/sem.c:1682:#if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN)
> 
> > +static void save_x32_chunk(unsigned long *maskp, u32 chunk, int chunk_idx)
> > +{
> > +       maskp += (chunk_idx / 2);
> > +       ((u32 *)maskp)[(chunk_idx & 1) ^ 1] = chunk;
> > +}
> > +#else
> > +static void save_x32_chunk(unsigned long *maskp, u32 chunk, int chunk_idx)
> > +{
> > +       ((u32 *)maskp)[chunk_idx] = chunk;
> > +}
> > +#endif
> 
> See below.
> 
> ...
> 
> > -               end = bitmap_get_x32_reverse(start, end, bitmap++);
> > +               end = bitmap_get_x32_reverse(start, end, &chunk);
> >                 if (IS_ERR(end))
> >                         return PTR_ERR(end);
> > +
> > +               save_x32_chunk(maskp, chunk, chunk_idx++);
> 
> Can't we simple do
> 
>         int chunk_index = 0;
>         ...
>         do {
> #if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN)
>                end = bitmap_get_x32_reverse(start, end,
> bitmap[chunk_index ^ 1]);
> #else
>                end = bitmap_get_x32_reverse(start, end, bitmap[chunk_index]);
> #endif
>         ...
>         } while (++chunk_index);
> 
> ?

Well, unless we ignore coding style 21) Conditional Compilation
we could. Do you still insist it would be better?

Thanks for the review!

> -- 
> With Best Regards,
> Andy Shevchenko

  parent reply	other threads:[~2020-06-08 12:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-08 10:23 [PATCH RESEND2] lib: fix bitmap_parse() on 64-bit big endian archs Alexander Gordeev
2020-06-08 12:03 ` Andy Shevchenko
2020-06-08 12:08   ` Andy Shevchenko
2020-06-08 12:44   ` Alexander Gordeev [this message]
2020-06-08 13:00     ` 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=20200608124433.GA28369@oc3871087118.ibm.com \
    --to=agordeev@linux.ibm.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=amritha.nambiar@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mszeredi@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=tobin@kernel.org \
    --cc=vineet.gupta1@synopsys.com \
    --cc=will.deacon@arm.com \
    --cc=willemb@google.com \
    --cc=willy@infradead.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