LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch <linux-arch@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	Wedson Almeida Filho <wedsonaf@google.com>,
	Gary Guo <gary@garyguo.net>, Hector Martin <marcan@marcan.st>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [Question] Alignment requirement for readX() and writeX()
Date: Sat, 31 Jul 2021 09:51:05 +0800	[thread overview]
Message-ID: <YQSsiacvJHFKk3Cj@boqun-archlinux> (raw)
In-Reply-To: <CAK8P3a3_pgtUWrg-MpaVyVqhffeuvQECHCmSCLyudfSwuEcP_g@mail.gmail.com>

On Fri, Jul 30, 2021 at 10:24:53PM +0200, Arnd Bergmann wrote:
> On Fri, Jul 30, 2021 at 7:31 PM Boqun Feng <boqun.feng@gmail.com> wrote:
> > On Fri, Jul 30, 2021 at 06:58:30PM +0200, Arnd Bergmann wrote:
> >
> > If we want to check, I'd expect we do the checks inside
> > readX()/writeX(), for example, readl() could be implemented as:
> >
> >         #define readl(c)                                        \
> >         ({                                                      \
> >                 u32 __v;                                        \
> >                                                                 \
> >                 /* alignment checking */                        \
> >                 BUG_ON(c & (sizeof(__v) - 1));                  \
> >                 __v = readl_relaxed(c);                         \
> >                 __iormb(__v);                                   \
> >                 __v;                                            \
> >         })
> >
> > It's a runtime check, so if anyone hates it I can understand ;-)
> 
> Right, I really don't think that adds any value, this just replaces one
> oops message with a more different oops message, while adding
> some overhead.
> 

Agreed. I wasn't planning to propose this kind of checks for C code.
Just want to understand better on the alignment requirement of these
APIs. Thanks  ;-)

Regards,
Boqun

>         Arnd

  reply	other threads:[~2021-07-31  1:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-30 16:42 Boqun Feng
2021-07-30 16:58 ` Arnd Bergmann
2021-07-30 17:30   ` Boqun Feng
2021-07-30 20:24     ` Arnd Bergmann
2021-07-31  1:51       ` Boqun Feng [this message]
2021-08-02  8:37   ` David Laight

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=YQSsiacvJHFKk3Cj@boqun-archlinux \
    --to=boqun.feng@gmail.com \
    --cc=arnd@arndb.de \
    --cc=gary@garyguo.net \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcan@marcan.st \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=wedsonaf@google.com \
    --subject='Re: [Question] Alignment requirement for readX() and writeX()' \
    /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

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).