From: Arnd Bergmann <arnd@arndb.de>
To: Julia Lawall <Julia.Lawall@inria.fr>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
"Jani Nikula" <jani.nikula@intel.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Sudip Mukherjee" <sudipm.mukherjee@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"Viresh Kumar" <vireshk@kernel.org>,
"Shiraz Hashim" <shiraz.linux.kernel@gmail.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@linux.ie>,
"Daniel Vetter" <daniel@ffwll.ch>,
dri-devel <dri-devel@lists.freedesktop.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Linux ARM" <linux-arm-kernel@lists.infradead.org>,
"SoC Team" <soc@kernel.org>
Subject: Re: mainline build failure due to f1e4c916f97f ("drm/edid: add EDID block count and size helpers")
Date: Tue, 31 May 2022 10:04:19 +0200 [thread overview]
Message-ID: <CAK8P3a2iAsemAQdbTZ_E7GGGCXAOeWbjSjLgXEsd5sg_buZWhw@mail.gmail.com> (raw)
In-Reply-To: <91E67F46-A3C7-4159-9E0C-C6C6306F3669@inria.fr>
On Tue, May 31, 2022 at 8:26 AM Julia Lawall <Julia.Lawall@inria.fr> wrote:
> > On 30 May 2022, at 15:27, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Mon, May 30, 2022 at 4:08 PM Jani Nikula <jani.nikula@intel.com> wrote:
> >>> On Mon, 30 May 2022, Arnd Bergmann <arnd@arndb.de> wrote:
> >>> struct my_driver_priv {
> >>> struct device dev;
> >>> u8 causes_misalignment;
> >>> spinlock_t lock;
> >>> atomic_t counter;
> >>> } __packed; /* this annotation is harmful because it breaks the atomics */
> >>
> >> I wonder if this is something that could be caught with coccinelle. Or
> >> sparse. Are there any cases where this combo is necessary? (I can't
> >> think of any, but it's a low bar. ;)
> >>
...
> >>> or if the annotation does not change the layout like
> >>>
> >>> struct my_dma_descriptor {
> >>> __le64 address;
> >>> __le64 length;
> >>> } __packed; /* does not change layout but makes access slow on some
> >>> architectures */
> >>
> >> Why is this the case, though? I'd imagine the compiler could figure this
> >> out.
> >
> > When you annotate the entire structure as __packed without an
> > extra __aligned() annotation, the compiler has to assume that the
> > structure itself is unaligned as well. On many of the older architectures,
> > this will result in accessing the values one byte at a time. Marking
> > the structure as "__packed __aligned(8)" instead would be harmless.
> >
> > When I have a structure with a few misaligned members, I generally
> > prefer to only annotate the members that are not naturally aligned,
> > but this approach is not very common.
>
> Searching for specific types in a packed structure would be easy.
As an experiment: what kind of results would we get when looking
for packed structures and unions that contain any of these:
- spinlock_t
- atomic_t
- dma_addr_t
- phys_addr_t
- size_t
- any pointer
- any enum
- struct mutex
- struct device
This is just a list of common data types that are used in a lot of
structures but that one should never find in hardware specific
types. If the output from coccinelle is 90% actual bugs, this would
be really helpful. OTOH if there is no output at all, or all
false-positives, we don't need to look for additional types.
> Coccinelle could duplicate the structure without the packed and see if
> any offsets change, using build bug on, but that would be architecture
> specific so maybe not useful.
I would consider this a separate issue. The first one above is for identifying
structures that are marked as packed but should not be packed at
all, regardless of whether that changes the layout.
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-05-31 8:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <YpCUzStDnSgQLNFN@debian>
[not found] ` <CAHk-=wg0uGAX5DYZq+tY2KeUAR8DtR91YE1y9CkPMKkKOyE4jg@mail.gmail.com>
[not found] ` <CADVatmNGPbSdRNQuwJEWAaPtqb3vBYRjvsuBpoRUnhEHj=X5GQ@mail.gmail.com>
[not found] ` <CAHk-=wisQd8yiPX=SsK3eFiakKo713hq4SyqPWsJ-oyAmLFefQ@mail.gmail.com>
[not found] ` <YpIR67FMtTGCwARZ@debian>
[not found] ` <CAHk-=wjuyHE=1wLgHncub8FfgeyYqfWYsy4-YrhAvq9991h_Aw@mail.gmail.com>
2022-05-28 18:08 ` mainline build failure due to f1e4c916f97f ("drm/edid: add EDID block count and size helpers") Linus Torvalds
2022-05-28 18:58 ` Arnd Bergmann
2022-05-28 20:31 ` Linus Torvalds
2022-05-28 21:08 ` Arnd Bergmann
2022-05-30 9:31 ` Jani Nikula
2022-05-30 9:33 ` Jani Nikula
2022-05-30 12:43 ` Arnd Bergmann
2022-05-30 13:10 ` Jani Nikula
2022-05-30 13:35 ` Arnd Bergmann
2022-05-30 14:08 ` Jani Nikula
2022-05-30 14:26 ` Arnd Bergmann
2022-05-31 6:26 ` Julia Lawall
2022-05-31 8:04 ` Arnd Bergmann [this message]
2022-05-31 16:41 ` Linus Torvalds
2022-06-01 22:28 ` Keisuke Nishimura
2022-06-02 1:08 ` Linus Torvalds
2022-06-02 7:38 ` Arnd Bergmann
2022-06-02 11:21 ` Tetsuo Handa
2022-06-02 12:11 ` Arnd Bergmann
2022-06-02 13:18 ` Ard Biesheuvel
2022-06-02 12:19 ` Christoph Hellwig
2022-06-06 10:51 ` Keisuke Nishimura
2022-05-30 16:56 ` Russell King (Oracle)
2022-05-30 16:54 ` Russell King (Oracle)
2022-05-30 16:53 ` Russell King (Oracle)
2022-05-28 20:32 ` Russell King (Oracle)
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=CAK8P3a2iAsemAQdbTZ_E7GGGCXAOeWbjSjLgXEsd5sg_buZWhw@mail.gmail.com \
--to=arnd@arndb.de \
--cc=Julia.Lawall@inria.fr \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=shiraz.linux.kernel@gmail.com \
--cc=soc@kernel.org \
--cc=sudipm.mukherjee@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=tzimmermann@suse.de \
--cc=ville.syrjala@linux.intel.com \
--cc=vireshk@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 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).