All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm: Disable the strict alignment of data on armv7
Date: Fri, 09 Mar 2018 12:26:01 +0100	[thread overview]
Message-ID: <20180309112601.14CEE247241@gemini.denx.de> (raw)
In-Reply-To: <f144e491-5ce5-2ad0-70a8-d36397752863@xilinx.com>

Dear Michal,

In message <f144e491-5ce5-2ad0-70a8-d36397752863@xilinx.com> you wrote:
> 
> > Can you please add some comments what the consequences of this
> > change are?  I guess there are advantages, but I also guess these
> > come at a price?
> 
> That's something what I am expecting from this discussion if there are
> any corner cases which we are not aware of.
> 
> We found this setting based on randomized testing where simply non
> aligned access for memory read was causing exception.

Hm... One possible position one can take is that unaligned accesses
are likely an indication for incorrect or sloppy programming.
usually we design data structures, buffers etc. such that no
unaligned accesses take place.  Most code is explicitly written in
such a way that it also runs on architectures where unaligned access
simply don't work.

I feel that providing such an option just opens the door for lousy
programmers who don't think throroughly about the code they write.

Yes, in some cases this may be conveniendt.  But there are also
cases where the problem is just papered over, and hits all the
harder later like when you also enable caching.

Thi is why I'm asking for the advantages.  If it's just is that
broken code starts working, then I'd rather see a clear error
message that forces the code to be fixed.

> The same tests were running fine on arm64 where non aligned accesses are
> permitted.

But I guess they still come under a (severe?) performance penalty?

> It is hard to compare performance impact on u-boot but from
> functionality point of view we are not able to see difference.
> If there is any performance impact that it is quite low.

Hm.... I have to admit that I don't know ARM/ARM64 that well, but I
am pretty sure that even on ARM an aligned 32 bit access on a 32 bit
bus will result in a single read cycle on that bus - while I would
expect that an unaligned 32 bit access might get broken down into 4
byte accesses?

Also, I wonder if ARM still maintains atomicity for unaligned reads/
writes ? [IIRC, x86 doesn't, while it's guaranteed for aligned
accesses.]

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
What is mind?  No matter.  What is matter?  Never mind.
                                      -- Thomas Hewitt Key, 1799-1875

  reply	other threads:[~2018-03-09 11:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 14:39 [U-Boot] [PATCH] arm: Disable the strict alignment of data on armv7 Michal Simek
2018-03-08 22:52 ` Wolfgang Denk
2018-03-09  6:59   ` Michal Simek
2018-03-09 11:26     ` Wolfgang Denk [this message]
2018-03-09 11:41       ` Michal Simek
2018-03-09 12:02         ` Wolfgang Denk
2018-03-09 12:25           ` Michal Simek
2018-03-09 12:23       ` Mark Kettenis
2018-03-09 12:29         ` Michal Simek

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=20180309112601.14CEE247241@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.