From: "Theodore Ts'o" <tytso@mit.edu>
To: Eric Biggers <ebiggers@kernel.org>
Cc: harshad shirwadkar <harshadshirwadkar@gmail.com>,
Andreas Dilger <adilger@dilger.ca>,
Ext4 Developers List <linux-ext4@vger.kernel.org>,
Harshad Shirwadkar <harshads@google.com>
Subject: Re: [PATCH] e2fsck: fix portability problems caused by unaligned accesses
Date: Fri, 7 May 2021 11:56:22 -0400 [thread overview]
Message-ID: <YJVjJoI8sX531AL2@mit.edu> (raw)
In-Reply-To: <YJTh9T3sgdFFE7fM@sol.localdomain>
On Thu, May 06, 2021 at 11:45:09PM -0700, Eric Biggers wrote:
> Just to be clear (looking at the latest patches on the list which are copying
> whole structs), by "the memcpy() approach does get optimized properly", I meant
> that it gets optimized properly in implementations of get_unaligned_le16(),
> get_unaligned_le32(), put_unaligned_le32(), etc., where a single word (or less
> than a word) is loaded or stored. I don't know how reliably the compilers will
> optimize out the copy if you memcpy() a whole struct instead of a single word.
>
> Even if they don't optimize it out, I don't expect that it would be a
> performance problem in this context, so it's probably still fine to solve the
> problem. But I just wanted to clarify what I meant here.
For the most recent patch that sent out, we really needed to copy out
the whole structure since we're then passing it to ext2fs library
functions. I agree that it's not likely going to be a performance
problem, and at this point, I'm more concerned about code clarity and
correctness.
Especially since apparently the problems which Harshad's change and my
most recent commit addressed were not picked up by UBSAN (either using
gcc or clang), --- and IMHO they really should have. So we can't
count on UBSAN to find all possible alignment problems.
Lesson learned, before I do future releases, I should do a build and
"make check" on a armhf chroot running on a arm-64 machine, as well as
on a sparc64 machine, since these seem to be the most sensitive to
alignment issues. And if I miss anything, fortunately Debian's
autobuilders on a large cross-section of architectures will catch them
since we run the regression test suite as part of the package build.
- Ted
P.S. Harshad, could you prepare patches to kernel files in ext4 and
jbd2 to make similar alignment portability fixes? Thanks!!
next prev parent reply other threads:[~2021-05-07 15:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 3:10 [PATCH] e2fsck: fix portability problems caused by unaligned accesses Theodore Ts'o
2021-05-04 6:29 ` Andreas Dilger
2021-05-04 9:40 ` harshad shirwadkar
2021-05-04 13:49 ` Theodore Ts'o
2021-05-04 16:46 ` Eric Biggers
2021-05-04 17:55 ` harshad shirwadkar
2021-05-04 19:14 ` Eric Biggers
2021-05-04 19:53 ` Theodore Ts'o
2021-05-04 20:14 ` harshad shirwadkar
2021-05-04 20:45 ` Eric Biggers
2021-05-04 21:10 ` Theodore Ts'o
2021-05-04 21:30 ` Eric Biggers
2021-05-07 6:45 ` Eric Biggers
2021-05-07 15:56 ` Theodore Ts'o [this message]
2021-05-07 16:22 ` harshad shirwadkar
2021-05-04 20:35 ` Eric Biggers
2021-05-04 15:18 ` Theodore Ts'o
2021-05-06 18:30 ` [PATCH -v2] " Theodore Ts'o
2021-05-06 23:30 ` harshad shirwadkar
2021-05-07 1:50 ` Theodore Ts'o
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=YJVjJoI8sX531AL2@mit.edu \
--to=tytso@mit.edu \
--cc=adilger@dilger.ca \
--cc=ebiggers@kernel.org \
--cc=harshads@google.com \
--cc=harshadshirwadkar@gmail.com \
--cc=linux-ext4@vger.kernel.org \
/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.