2022-03-16 19:23:34

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH v2 0/2] linux/types.h: Tidy __bitwise, add __CHECKER__ hints

From: Bjorn Helgaas <[email protected]>

- Tidy up __bitwise__, which is unused except in the __bitwise definition

- Add hints about what __CHECKER__ means


Changes since v1:
- Also remove unnecessary __bitwise__ in tools/include/linux/types.h
(thanks to Andrew for pointing this out)

v1: https://lore.kernel.org/all/[email protected]/

Bjorn Helgaas (2):
linux/types.h: Remove unnecessary __bitwise__
Documentation/sparse: Add hints about __CHECKER__

Documentation/dev-tools/sparse.rst | 2 ++
include/linux/compiler_types.h | 1 +
include/uapi/linux/types.h | 6 +++---
tools/include/linux/types.h | 5 ++---
4 files changed, 8 insertions(+), 6 deletions(-)

--
2.25.1


2022-03-17 03:32:16

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH v2 2/2] Documentation/sparse: Add hints about __CHECKER__

From: Bjorn Helgaas <[email protected]>

Several attributes depend on __CHECKER__, but previously there was no clue
in the tree about when __CHECKER__ might be defined. Add hints at the most
common places (__kernel, __user, __iomem, __bitwise) and in the sparse
documentation.

Signed-off-by: Bjorn Helgaas <[email protected]>
---
Documentation/dev-tools/sparse.rst | 2 ++
include/linux/compiler_types.h | 1 +
include/uapi/linux/types.h | 1 +
3 files changed, 4 insertions(+)

diff --git a/Documentation/dev-tools/sparse.rst b/Documentation/dev-tools/sparse.rst
index 02102be7ff49..dc791c8d84d1 100644
--- a/Documentation/dev-tools/sparse.rst
+++ b/Documentation/dev-tools/sparse.rst
@@ -100,3 +100,5 @@ have already built it.

The optional make variable CF can be used to pass arguments to sparse. The
build system passes -Wbitwise to sparse automatically.
+
+Note that sparse defines the __CHECKER__ preprocessor symbol.
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index 3c1795fdb568..4b3915ce38a4 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -4,6 +4,7 @@

#ifndef __ASSEMBLY__

+/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
#ifdef __CHECKER__
/* address spaces */
# define __kernel __attribute__((address_space(0)))
diff --git a/include/uapi/linux/types.h b/include/uapi/linux/types.h
index 71696f424ac8..c4dc597f3dcf 100644
--- a/include/uapi/linux/types.h
+++ b/include/uapi/linux/types.h
@@ -19,6 +19,7 @@
* any application/library that wants linux/types.h.
*/

+/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
#ifdef __CHECKER__
#define __bitwise __attribute__((bitwise))
#else
--
2.25.1

2022-03-17 05:38:29

by Bjorn Helgaas

[permalink] [raw]
Subject: [PATCH v2 1/2] linux/types.h: Remove unnecessary __bitwise__

From: Bjorn Helgaas <[email protected]>

There are no users of "__bitwise__" except the definition of "__bitwise".
Remove __bitwise__ and define __bitwise directly.

This is a follow-up to 05de97003c77 ("linux/types.h: enable endian checks
for all sparse builds").

Signed-off-by: Bjorn Helgaas <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>
---
include/uapi/linux/types.h | 5 ++---
tools/include/linux/types.h | 5 ++---
2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/include/uapi/linux/types.h b/include/uapi/linux/types.h
index f6d2f83cbe29..71696f424ac8 100644
--- a/include/uapi/linux/types.h
+++ b/include/uapi/linux/types.h
@@ -20,11 +20,10 @@
*/

#ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
+#define __bitwise __attribute__((bitwise))
#else
-#define __bitwise__
+#define __bitwise
#endif
-#define __bitwise __bitwise__

typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
index 6e14a533ab4e..6c18c54e7d7f 100644
--- a/tools/include/linux/types.h
+++ b/tools/include/linux/types.h
@@ -43,11 +43,10 @@ typedef __u8 u8;
typedef __s8 s8;

#ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
+#define __bitwise __attribute__((bitwise))
#else
-#define __bitwise__
+#define __bitwise
#endif
-#define __bitwise __bitwise__

#define __force
#define __user
--
2.25.1

2022-05-25 16:00:15

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] linux/types.h: Remove unnecessary __bitwise__

On 15. 03. 22, 16:30, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <[email protected]>
>
> There are no users of "__bitwise__" except the definition of "__bitwise".
> Remove __bitwise__ and define __bitwise directly.
>
> This is a follow-up to 05de97003c77 ("linux/types.h: enable endian checks
> for all sparse builds").
>
> Signed-off-by: Bjorn Helgaas <[email protected]>
> Cc: Michael S. Tsirkin <[email protected]>
> ---
> include/uapi/linux/types.h | 5 ++---
> tools/include/linux/types.h | 5 ++---
> 2 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/include/uapi/linux/types.h b/include/uapi/linux/types.h
> index f6d2f83cbe29..71696f424ac8 100644
> --- a/include/uapi/linux/types.h
> +++ b/include/uapi/linux/types.h
> @@ -20,11 +20,10 @@
> */
>
> #ifdef __CHECKER__
> -#define __bitwise__ __attribute__((bitwise))
> +#define __bitwise __attribute__((bitwise))
> #else
> -#define __bitwise__
> +#define __bitwise
> #endif
> -#define __bitwise __bitwise__

Hi,

this broke userspace, like open-iscsi:
> [ 34s] In file included from session_info.h:9,
> [ 34s] from iscsi_util.c:38:
> [ 34s] ../include/iscsi_proto.h:66:30: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'itt_t'
> [ 34s] 66 | typedef uint32_t __bitwise__ itt_t;
> [ 34s] | ^~~~~

It looks like we need __bitwise__ back.

thanks,
--
js
suse labs

2022-05-26 00:18:23

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] linux/types.h: Remove unnecessary __bitwise__

On Wed, May 25, 2022 at 08:51:29AM +0200, Jiri Slaby wrote:
> On 15. 03. 22, 16:30, Bjorn Helgaas wrote:
> > From: Bjorn Helgaas <[email protected]>
> >
> > There are no users of "__bitwise__" except the definition of "__bitwise".
> > Remove __bitwise__ and define __bitwise directly.
> >
> > This is a follow-up to 05de97003c77 ("linux/types.h: enable endian checks
> > for all sparse builds").
> >
> > Signed-off-by: Bjorn Helgaas <[email protected]>
> > Cc: Michael S. Tsirkin <[email protected]>
> > ---
> > include/uapi/linux/types.h | 5 ++---
> > tools/include/linux/types.h | 5 ++---
> > 2 files changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/uapi/linux/types.h b/include/uapi/linux/types.h
> > index f6d2f83cbe29..71696f424ac8 100644
> > --- a/include/uapi/linux/types.h
> > +++ b/include/uapi/linux/types.h
> > @@ -20,11 +20,10 @@
> > */
> > #ifdef __CHECKER__
> > -#define __bitwise__ __attribute__((bitwise))
> > +#define __bitwise __attribute__((bitwise))
> > #else
> > -#define __bitwise__
> > +#define __bitwise
> > #endif
> > -#define __bitwise __bitwise__
>
> Hi,
>
> this broke userspace, like open-iscsi:
> > [ 34s] In file included from session_info.h:9,
> > [ 34s] from iscsi_util.c:38:
> > [ 34s] ../include/iscsi_proto.h:66:30: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'itt_t'
> > [ 34s] 66 | typedef uint32_t __bitwise__ itt_t;
> > [ 34s] | ^~~~~
>
> It looks like we need __bitwise__ back.

Crap, sorry. I don't know why I thought it would be safe to remove
something from uapi. I'll send a revert.

Bjorn