[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<CH3PR02MB102474F1D633D03102B5F2855B8872@CH3PR02MB10247.namprd02.prod.outlook.com>
Date: Wed, 14 Aug 2024 03:27:20 +0000
From: Brian Cain <bcain@...cinc.com>
To: Brian Cain <bcain@...cinc.com>, Nathan Chancellor <nathan@...nel.org>,
"Gustavo A. R. Silva" <gustavo@...eddedor.com>,
"Steven Walk (QUIC)"
<quic_walk@...cinc.com>
CC: kernel test robot <lkp@...el.com>,
"Gustavo A. R. Silva"
<gustavoars@...nel.org>,
"llvm@...ts.linux.dev" <llvm@...ts.linux.dev>,
"oe-kbuild-all@...ts.linux.dev" <oe-kbuild-all@...ts.linux.dev>,
LKML
<linux-kernel@...r.kernel.org>,
"linux-hexagon@...r.kernel.org"
<linux-hexagon@...r.kernel.org>,
Sid Manning <sidneym@...cinc.com>,
Sundeep
Kushwaha <sundeepk@...cinc.com>
Subject: RE: [gustavoars:testing/wfamnae-next20240729-cbc-2 11/18]
include/rdma/uverbs_ioctl.h:643:15: error: static assertion failed due to
requirement '__builtin_offsetof(struct uverbs_attr_bundle, attrs) ==
sizeof(struct uverbs_attr_bundle_hdr)': struct memb...
> -----Original Message-----
> From: Brian Cain <bcain@...cinc.com>
> Sent: Tuesday, August 6, 2024 10:36 AM
> To: Nathan Chancellor <nathan@...nel.org>; Gustavo A. R. Silva
> <gustavo@...eddedor.com>
> Cc: kernel test robot <lkp@...el.com>; Gustavo A. R. Silva
> <gustavoars@...nel.org>; llvm@...ts.linux.dev; oe-kbuild-all@...ts.linux.dev;
> LKML <linux-kernel@...r.kernel.org>; linux-hexagon@...r.kernel.org; Sid
> Manning <sidneym@...cinc.com>; Sundeep Kushwaha
> <sundeepk@...cinc.com>
> Subject: RE: [gustavoars:testing/wfamnae-next20240729-cbc-2 11/18]
> include/rdma/uverbs_ioctl.h:643:15: error: static assertion failed due to
> requirement '__builtin_offsetof(struct uverbs_attr_bundle, attrs) ==
> sizeof(struct uverbs_attr_bundle_hdr)': struct memb...
>
> WARNING: This email originated from outside of Qualcomm. Please be wary of
> any links or attachments, and do not enable macros.
>
> > -----Original Message-----
> > From: Nathan Chancellor <nathan@...nel.org>
> > Sent: Friday, August 2, 2024 5:20 PM
> > To: Gustavo A. R. Silva <gustavo@...eddedor.com>
> > Cc: kernel test robot <lkp@...el.com>; Gustavo A. R. Silva
> > <gustavoars@...nel.org>; llvm@...ts.linux.dev; oe-kbuild-all@...ts.linux.dev;
> > LKML <linux-kernel@...r.kernel.org>; Brian Cain <bcain@...cinc.com>; linux-
> > hexagon@...r.kernel.org
> > Subject: Re: [gustavoars:testing/wfamnae-next20240729-cbc-2 11/18]
> > include/rdma/uverbs_ioctl.h:643:15: error: static assertion failed due to
> > requirement '__builtin_offsetof(struct uverbs_attr_bundle, attrs) ==
> > sizeof(struct uverbs_attr_bundle_hdr)': struct memb...
> >
> > WARNING: This email originated from outside of Qualcomm. Please be wary
> of
> > any links or attachments, and do not enable macros.
> >
> > On Thu, Aug 01, 2024 at 04:35:59PM -0600, Gustavo A. R. Silva wrote:
> > >
> > >
> > > On 01/08/24 16:14, Nathan Chancellor wrote:
> > > > On Thu, Aug 01, 2024 at 02:17:50PM -0600, Gustavo A. R. Silva wrote:
> > > > >
> > > > >
> > > > > On 01/08/24 13:08, Nathan Chancellor wrote:
> > > > > > On Thu, Aug 01, 2024 at 06:47:58AM -0600, Gustavo A. R. Silva wrote:
> > > > > > >
> > > > > > >
> > > > > > > On 01/08/24 05:35, kernel test robot wrote:
> > > > > > > > tree:
> > https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git
> > testing/wfamnae-next20240729-cbc-2
> > > > > > > > head: df15c862c1b93b6e1f6c90b0d7971f7a6ad66751
> > > > > > > > commit: e7cd9f429a852fb7e37a706c7d08fc36e7863e06 [11/18]
> > RDMA/uverbs: Use static_assert() to check struct sizes
> > > > > > > > config: hexagon-randconfig-001-20240801
> > (https://download.01.org/0day-
> ci/archive/20240801/202408011956.wscyBwq6-
> > lkp@...el.com/config)
> > > > > > > > compiler: clang version 20.0.0git (https://github.com/llvm/llvm-
> > project 430b90f04533b099d788db2668176038be38c53b)
> > > > > > >
> > > > > > >
> > > > > > > Clang 20.0.0?? (thinkingface)
> > > > > >
> > > > > > Indeed, Clang 19 branched and main is now 20 :)
> > > > > >
> > > > > > https://github.com/llvm/llvm-
> > project/commit/8f701b5df0adb3a2960d78ca2ad9cf53f39ba2fe
> > > > >
> > > > > Yeah, but is that a stable release?
> > > >
> > > > No, but the Intel folks have tested tip of tree LLVM against the kernel
> > > > for us for a few years now to try and catch issues such as this.
> > >
> > > Oh, I see, fine. :)
> > >
> > > >
> > > > > BTW, I don't see GCC reporting the same problem below:
> > > >
> > > > Hexagon does not have a GCC backend anymore so it is not going to be
> > > > possible to do an exact A/B comparison with this configuration but...
> > > >
> > > > > > > > > > include/rdma/uverbs_ioctl.h:643:15: error: static assertion
> failed
> > due to requirement '__builtin_offsetof(struct uverbs_attr_bundle, attrs) ==
> > sizeof(struct uverbs_attr_bundle_hdr)': struct member likely outside of
> > struct_group_tagged()
> > > > > > > > 643 | static_assert(offsetof(struct uverbs_attr_bundle, attrs)
> ==
> > sizeof(struct uverbs_attr_bundle_hdr),
> > > > > > > > |
> >
> ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > > > > 644 | "struct member likely outside of
> > struct_group_tagged()");
> > > > > > > > |
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > > > > include/linux/stddef.h:16:32: note: expanded from macro
> > 'offsetof'
> > > > > > > > 16 | #define offsetof(TYPE, MEMBER)
> __builtin_offsetof(TYPE,
> > MEMBER)
> > > > > > > > | ^
> > > > > > > > include/linux/build_bug.h:77:50: note: expanded from macro
> > 'static_assert'
> > > > > > > > 77 | #define static_assert(expr, ...) __static_assert(expr,
> > ##__VA_ARGS__, #expr)
> > > > > > > > |
> > ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > > > > include/linux/build_bug.h:78:56: note: expanded from macro
> > '__static_assert'
> > > > > > > > 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr,
> > msg)
> > > > > > > > | ^~~~
> > > > > > > > include/rdma/uverbs_ioctl.h:643:58: note: expression evaluates
> > to '56 == 52'
> > > >
> > > > This seems to give some indication that perhaps there may be some
> > > > architecture specific here with padding maybe? I seem to recall ARM OABI
> > > > having something similar. Adding the Hexagon folks/list to get some more
> > > > clarification. Full warning and context:
> > > >
> > > > https://lore.kernel.org/202408011956.wscyBwq6-lkp@intel.com/
> > > >
>
> There might be hexagon-specific padding requirements, but not ones that I've
> stumbled across before. I've added Sundeep from the compiler team who may
> be able to help.
Steve suggested I try dumping the record layouts using clang's "-fdump-record-layouts". I did so using the clang 18.1.8 binary from https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8 -- I thought it was reasonable to use this older release because it still generates the static assertion. But I can repeat it with clang-20 built from the bot's cited commit if preferred.
Steve - can you give any advice about the compiler's behavior wrt this struct layout and the assertion?
I've attached the unabridged output from clang with "-fdump-record-layouts". Here's an excerpt:
*** Dumping AST Record Layout
0 | struct uverbs_attr_bundle_hdr
0 | struct ib_udata driver_udata
0 | const void * inbuf
4 | void * outbuf
8 | size_t inlen
12 | size_t outlen
16 | struct ib_udata ucore
16 | const void * inbuf
20 | void * outbuf
24 | size_t inlen
28 | size_t outlen
32 | struct ib_uverbs_file * ufile
36 | struct ib_ucontext * context
40 | struct ib_uobject * uobject
44 | unsigned long[2] attr_present
| [sizeof=52, align=4]
*** Dumping AST Record Layout
0 | union uverbs_attr_bundle::(anonymous at ../include/rdma/uverbs_ioctl.h:633:2)
0 | struct uverbs_attr_bundle::(anonymous at ../include/rdma/uverbs_ioctl.h:633:2)
0 | struct ib_udata driver_udata
0 | const void * inbuf
4 | void * outbuf
8 | size_t inlen
12 | size_t outlen
16 | struct ib_udata ucore
16 | const void * inbuf
20 | void * outbuf
24 | size_t inlen
28 | size_t outlen
32 | struct ib_uverbs_file * ufile
36 | struct ib_ucontext * context
40 | struct ib_uobject * uobject
44 | unsigned long[2] attr_present
0 | struct uverbs_attr_bundle_hdr hdr
0 | struct ib_udata driver_udata
0 | const void * inbuf
4 | void * outbuf
8 | size_t inlen
12 | size_t outlen
16 | struct ib_udata ucore
16 | const void * inbuf
20 | void * outbuf
24 | size_t inlen
In file included from ../drivers/infiniband/core/ib_core_uverbs.c:8:
In file included from ../drivers/infiniband/core/uverbs.h:49:
In file included from ../include/rdma/uverbs_std_types.h:10:
../include/rdma/uverbs_ioctl.h:643:15: error: static assertion failed due to requirement '__builtin_offsetof(struct uverbs_attr_bundle, attrs) == sizeof(struct uverbs_attr_bundle_hdr)': struct member likely outside of struct_group_tagged()
643 | static_assert(offsetof(struct uverbs_attr_bundle, attrs) == sizeof(struct uverbs_attr_bundle_hdr),
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
644 | "struct member likely outside of struct_group_tagged()");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/stddef.h:16:32: note: expanded from macro 'offsetof'
16 | #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
| ^
../include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
../include/rdma/uverbs_ioctl.h:643:58: note: expression evaluates to '56 == 52'
643 | static_assert(offsetof(struct uverbs_attr_bundle, attrs) == sizeof(struct uverbs_attr_bundle_hdr),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
644 | "struct member likely outside of struct_group_tagged()");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
28 | size_t outlen
32 | struct ib_uverbs_file * ufile
36 | struct ib_ucontext * context
40 | struct ib_uobject * uobject
44 | unsigned long[2] attr_present
| [sizeof=52, align=4]
I've also attached the "clang -cc1" invocation and preprocessed C output for reference.
> > > > The problematic section preprocessed since sometimes the macros
> > > > obfuscate things:
> > > >
> > > > struct uverbs_attr_bundle {
> > > > union {
> > > > struct {
> > > > struct ib_udata driver_udata;
> > > > struct ib_udata ucore;
> > > > struct ib_uverbs_file *ufile;
> > > > struct ib_ucontext *context;
> > > > struct ib_uobject *uobject;
> > > > unsigned long
> attr_present[(((UVERBS_API_ATTR_BKEY_LEN)
> > +
> > > > ((sizeof(long) * 8)) - 1) /
> > > > ((sizeof(long) * 8)))];
> > > > };
> > > > struct uverbs_attr_bundle_hdr {
> > > > struct ib_udata driver_udata;
> > > > struct ib_udata ucore;
> > > > struct ib_uverbs_file *ufile;
> > > > struct ib_ucontext *context;
> > > > struct ib_uobject *uobject;
> > > > unsigned long
> attr_present[(((UVERBS_API_ATTR_BKEY_LEN)
> > +
> > > > ((sizeof(long) * 8)) - 1) /
> > > > ((sizeof(long) * 8)))];
> > > > } hdr;
> > > > };
> > > >
> > > > struct uverbs_attr attrs[];
> > > > };
> > > > _Static_assert(__builtin_offsetof(struct uverbs_attr_bundle, attrs) ==
> > > > sizeof(struct uverbs_attr_bundle_hdr),
> > > > "struct member likely outside of struct_group_tagged()");
> > > >
> > > > FWIW, I see this with all versions of Clang that the kernel supports
> > > > with this configuration.
> > >
> > > I don't have access to a Clang compiler right now; I wonder if you could
> > > help me get the output of this command:
> > >
> > > pahole -C uverbs_attr_bundle drivers/infiniband/core/rdma_core.o
> >
> > We disabled CONFIG_DEBUG_INFO_BTF for Hexagon because elfutils does
> not
> > support Hexagon relocations but this is built-in for this configuration
> > so I removed that limitation and ended up with:
> >
> > $ pahole -C uverbs_attr_bundle vmlinux
> > struct uverbs_attr_bundle {
> > union {
> > struct {
> > struct ib_udata driver_udata; /* 0 16 */
> > struct ib_udata ucore; /* 16 16 */
> > struct ib_uverbs_file * ufile; /* 32 4 */
> > struct ib_ucontext * context; /* 36 4 */
> > struct ib_uobject * uobject; /* 40 4 */
> > unsigned long attr_present[2]; /* 44 8 */
> > }; /* 0 52 */
> > struct uverbs_attr_bundle_hdr hdr; /* 0 52 */
> > }; /* 0 52 */
> >
> > /* XXX 4 bytes hole, try to pack */
> > union {
> > struct {
> > struct ib_udata driver_udata; /* 0 16 */
> > struct ib_udata ucore; /* 16 16 */
> > struct ib_uverbs_file * ufile; /* 32 4 */
> > struct ib_ucontext * context; /* 36 4 */
> > struct ib_uobject * uobject; /* 40 4 */
> > unsigned long attr_present[2]; /* 44 8 */
> > }; /* 0 52 */
> > struct uverbs_attr_bundle_hdr hdr; /* 0 52 */
> > };
> >
> >
> > struct uverbs_attr attrs[]; /* 56 0 */
> >
> > /* size: 56, cachelines: 1, members: 2 */
> > /* sum members: 52, holes: 1, sum holes: 4 */
> > /* last cacheline: 56 bytes */
> > };
> >
> > If you want any other information or want me to test anything, I am more
> > than happy to do so.
> >
> > Cheers,
> > Nathan
> >
> > > > > > > > 643 | static_assert(offsetof(struct uverbs_attr_bundle, attrs)
> ==
> > sizeof(struct uverbs_attr_bundle_hdr),
> > > > > > > > |
> >
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > > > > 644 | "struct member likely outside of
> > struct_group_tagged()");
> > > > > > > > |
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > > > > include/linux/build_bug.h:77:50: note: expanded from macro
> > 'static_assert'
> > > > > > > > 77 | #define static_assert(expr, ...) __static_assert(expr,
> > ##__VA_ARGS__, #expr)
> > > > > > > > |
> > ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > > > > > > include/linux/build_bug.h:78:56: note: expanded from macro
> > '__static_assert'
> > > > > > > > 78 | #define __static_assert(expr, msg, ...) _Static_assert(expr,
> > msg)
> > > > > > > > | ^~~~
> > > > > > > > 7 warnings and 1 error generated.
> > > > > > > >
> > > > > > > >
> > > > > > > > vim +643 include/rdma/uverbs_ioctl.h
> > > > > > > >
> > > > > > > > 630
> > > > > > > > 631 struct uverbs_attr_bundle {
> > > > > > > > 632 /* New members MUST be added within the
> > struct_group() macro below. */
> > > > > > > > 633 struct_group_tagged(uverbs_attr_bundle_hdr, hdr,
> > > > > > > > 634 struct ib_udata driver_udata;
> > > > > > > > 635 struct ib_udata ucore;
> > > > > > > > 636 struct ib_uverbs_file *ufile;
> > > > > > > > 637 struct ib_ucontext *context;
> > > > > > > > 638 struct ib_uobject *uobject;
> > > > > > > > 639 DECLARE_BITMAP(attr_present,
> > UVERBS_API_ATTR_BKEY_LEN);
> > > > > > > > 640 );
> > > > > > > > 641 struct uverbs_attr attrs[];
> > > > > > > > 642 };
> > > > > > > > > 643 static_assert(offsetof(struct uverbs_attr_bundle, attrs) ==
> > sizeof(struct uverbs_attr_bundle_hdr),
> > > > > > > > 644 "struct member likely outside of
> > struct_group_tagged()");
> > > > > > > > 645
> > > > > > > >
> > > > > > >
> > > > >
> > > > > Thanks
> > > > > --
> > > > > Gustavo
Download attachment "ib_core_uverbs.ii" of type "application/octet-stream" (4035986 bytes)
View attachment "uverbs_compile.txt" of type "text/plain" (3480 bytes)
View attachment "rec_layouts_ib_core_uverbs.txt" of type "text/plain" (1250186 bytes)
Powered by blists - more mailing lists