All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 014/102] llist: introduce llist_entry_safe()
@ 2016-10-11 20:51 akpm
       [not found] ` <CA+55aFxr2uZADh--vtLYXjcLjNGO5t4jmTWEVZWbRuaJwiocug@mail.gmail.com>
  0 siblings, 1 reply; 19+ messages in thread
From: akpm @ 2016-10-11 20:51 UTC (permalink / raw)
  To: torvalds, mm-commits, akpm, glider, dvyukov, edumazet, kcc, mingo

From: Alexander Potapenko <glider@google.com>
Subject: llist: introduce llist_entry_safe()

Currently llist_for_each_entry() and llist_for_each_entry_safe() iterate
until &pos->member != NULL.  But when building the kernel with Clang, the
compiler assumes &pos->member cannot be NULL if the member's offset is
greater than 0.  Therefore the loop condition is always true, and the
loops become infinite.

To work around this, introduce llist_entry_safe(), which returns NULL for
NULL pointers, and additionally check that pos is not NULL in the list
iterators before dereferencing it.

Link: http://lkml.kernel.org/r/1474636978-41435-3-git-send-email-glider@google.com
Signed-off-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Kostya Serebryany <kcc@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/llist.h |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff -puN include/linux/llist.h~llist-introduce-llist_entry_safe include/linux/llist.h
--- a/include/linux/llist.h~llist-introduce-llist_entry_safe
+++ a/include/linux/llist.h
@@ -88,6 +88,16 @@ static inline void init_llist_head(struc
 	container_of(ptr, type, member)
 
 /**
+ * llist_entry_safe - get the struct of this entry without overflowing
+ * @ptr:	the &struct llist_node pointer.
+ * @type:	the type of the struct this is embedded in.
+ * @member:	the name of the llist_node within the struct.
+ */
+#define llist_entry_safe(ptr, type, member)		\
+	container_of_safe(ptr, type, member)
+
+
+/**
  * llist_for_each - iterate over some deleted entries of a lock-less list
  * @pos:	the &struct llist_node to use as a loop cursor
  * @node:	the first entry of deleted list entries
@@ -120,9 +130,10 @@ static inline void init_llist_head(struc
  * reverse the order by yourself before traversing.
  */
 #define llist_for_each_entry(pos, node, member)				\
-	for ((pos) = llist_entry((node), typeof(*(pos)), member);	\
-	     &(pos)->member != NULL;					\
-	     (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
+	for ((pos) = llist_entry_safe((node), typeof(*(pos)), member);	\
+	     pos != NULL && &(pos)->member != NULL;			\
+	     (pos) = llist_entry_safe((pos)->member.next, \
+					typeof(*(pos)), member))
 
 /**
  * llist_for_each_entry_safe - iterate over some deleted entries of lock-less list of given type
@@ -141,10 +152,11 @@ static inline void init_llist_head(struc
  * you want to traverse from the oldest to the newest, you must
  * reverse the order by yourself before traversing.
  */
-#define llist_for_each_entry_safe(pos, n, node, member)			       \
-	for (pos = llist_entry((node), typeof(*pos), member);		       \
-	     &pos->member != NULL &&					       \
-	        (n = llist_entry(pos->member.next, typeof(*n), member), true); \
+#define llist_for_each_entry_safe(pos, n, node, member)			     \
+	for (pos = llist_entry_safe((node), typeof(*pos), member);	     \
+	     pos != NULL && &pos->member != NULL &&			     \
+		(n = llist_entry_safe(pos->member.next, typeof(*n), member), \
+		 true); \
 	     pos = n)
 
 /**
_

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
       [not found]   ` <CA+55aFxQRf+U0z6mrAd5QQLWgB2A_mRjY7g9vpZHCSuyjrdhxQ@mail.gmail.com>
@ 2019-10-16 22:23     ` Linus Torvalds
  2019-10-16 22:40       ` Linus Torvalds
  2019-10-16 23:11       ` Kirill A. Shutemov
  0 siblings, 2 replies; 19+ messages in thread
From: Linus Torvalds @ 2019-10-16 22:23 UTC (permalink / raw)
  To: Andrew Morton, Kirill A. Shutemov, Sasha Levin, Andrew Pinski,
	Arnd Bergmann, Masahiro Yamada, Michal Marek
  Cc: mm-commits, Alexander Potapenko, Dmitry Vyukov, Eric Dumazet,
	Kostya Serebryany, Ingo Molnar, linux-arch,
	Linux Kbuild mailing list

[-- Attachment #1: Type: text/plain, Size: 2978 bytes --]

[ Coming back to this, because it was annoying me ]

On Tue, Oct 11, 2016 at 4:06 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> HOWEVER - and this is really annoying - we'd need to use "-std=gnu99/gnu11"

Hmm.

I just tried it again after a long time, and "-std=gnu99" seems to
work fine for me on the kernel these days. The old "compound literal"
issues we had at some point seem gone.

Maybe we've cleaned everything up that used to cause problems. Or
maybe I just mis-remembered and we should have done this long ago?

If we switched the kernel over from gnu89 to gnu99, we could use a
couple of modern C features that are really nice. The main one is
variable declarations in loops, which isn't just syntactic sugar: it
makes it much easier to reduce the scope of variables naturally, but
it also makes it easier to do legible macros for for-loops when you
can declare your helper variables inside the for-statement.

The one thing I noticed while doing this was that switching to
std=gnu99 results in some funky new warnings. In particular, drm has a
number of warnings like this:

  drivers/gpu/drm/i915/gt/intel_sseu.c: In function ‘intel_sseu_make_rpcs’:
  drivers/gpu/drm/i915/gt/intel_sseu.c:64:10: warning: left shift of
negative value [-Wshift-negative-value]
     64 |     ~(~0 << (hweight8(ctx_sseu.subslice_mask) / 2));
        |          ^~

and that seems to be because c99 allows ones-complement machines to do
odd things with left shifts.

It doesn't make any sensible difference on a two's-complement machine,
and it's insane that c99 changed the semantics to be worse for
something that will never matter, but there you have it.

Language standards people seemingly still not realizing that undefined
behavior is a *bad* thing, not a good thing, and adding it for no good
reason? Welcome to the mad-house.

Anyway, that warning is easy enough to shut up. Would people mind
testing this patch? Does it cause problems on other architectures?
Maybe the drm code could even be made to use unsigned values for their
shifts?

Because I'd love to finally be able to do things like that

  #define llist_for_each_entry(pos, node, member) \
        for (struct llist_node *_lptr = (node); \
        (pos) = llist_entry(_lptr, typeof(*(pos)), member), !!_lptr; \
        _lptr = (pos)->member.next)

and not have that odd "member_address_is_nonnull()" because of how we
convert back and forth.

It would also allow us to force the caller to pointlessly have to
declare a temporary variable for the loop for the safe versions.

I only tested gnu99 - which is sufficient for the above - and didn't
see if gnu11 ends up causing more issues.. And I didn't actually test
any of the code modifications that this would allow us to do.

Adding Arnd (because he seems to like compiler updates, and works with
compiler warnings ;) and the kbuild people and arch list.

             Linus

[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 1398 bytes --]

 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index ffd7a912fc46..cb9ab8a70b8e 100644
--- a/Makefile
+++ b/Makefile
@@ -397,7 +397,7 @@ HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
 HOSTCC       = gcc
 HOSTCXX      = g++
 KBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
-		-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
+		-fomit-frame-pointer -std=gnu99 $(HOST_LFS_CFLAGS) \
 		$(HOSTCFLAGS)
 KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
 KBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
@@ -459,7 +459,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
 		   -Werror=implicit-function-declaration -Werror=implicit-int \
 		   -Wno-format-security \
-		   -std=gnu89
+		   -std=gnu99
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
@@ -699,6 +699,7 @@ KBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
 KBUILD_CFLAGS	+= $(call cc-disable-warning, format-truncation)
 KBUILD_CFLAGS	+= $(call cc-disable-warning, format-overflow)
 KBUILD_CFLAGS	+= $(call cc-disable-warning, address-of-packed-member)
+KBUILD_CFLAGS	+= $(call cc-disable-warning, shift-negative-value)
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
 KBUILD_CFLAGS += -O2

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-16 22:23     ` Linus Torvalds
@ 2019-10-16 22:40       ` Linus Torvalds
  2019-10-16 23:13         ` Kirill A. Shutemov
  2019-10-16 23:11       ` Kirill A. Shutemov
  1 sibling, 1 reply; 19+ messages in thread
From: Linus Torvalds @ 2019-10-16 22:40 UTC (permalink / raw)
  To: Andrew Morton, Kirill A. Shutemov, Andrew Pinski, Arnd Bergmann,
	Masahiro Yamada, Michal Marek
  Cc: mm-commits, Alexander Potapenko, Dmitry Vyukov, Eric Dumazet,
	Kostya Serebryany, Ingo Molnar, linux-arch,
	Linux Kbuild mailing list

On Wed, Oct 16, 2019 at 3:23 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> I only tested gnu99 - which is sufficient for the above - and didn't
> see if gnu11 ends up causing more issues..

I see at least no obvious issues with gnu11, so if this works for
other architectures too, we should just switch over.

              Linus

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-16 22:23     ` Linus Torvalds
  2019-10-16 22:40       ` Linus Torvalds
@ 2019-10-16 23:11       ` Kirill A. Shutemov
  2019-10-16 23:29         ` Linus Torvalds
  1 sibling, 1 reply; 19+ messages in thread
From: Kirill A. Shutemov @ 2019-10-16 23:11 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Sasha Levin, Andrew Pinski, Arnd Bergmann,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Wed, Oct 16, 2019 at 03:23:42PM -0700, Linus Torvalds wrote:
> [ Coming back to this, because it was annoying me ]
> 
> On Tue, Oct 11, 2016 at 4:06 PM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > HOWEVER - and this is really annoying - we'd need to use "-std=gnu99/gnu11"
> 
> Hmm.
> 
> I just tried it again after a long time, and "-std=gnu99" seems to
> work fine for me on the kernel these days. The old "compound literal"
> issues we had at some point seem gone.
> 
> Maybe we've cleaned everything up that used to cause problems. Or
> maybe I just mis-remembered and we should have done this long ago?

Looks like it was fixed soon after the complain:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-16 22:40       ` Linus Torvalds
@ 2019-10-16 23:13         ` Kirill A. Shutemov
  0 siblings, 0 replies; 19+ messages in thread
From: Kirill A. Shutemov @ 2019-10-16 23:13 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Andrew Pinski, Arnd Bergmann, Masahiro Yamada,
	Michal Marek, mm-commits, Alexander Potapenko, Dmitry Vyukov,
	Eric Dumazet, Kostya Serebryany, Ingo Molnar, linux-arch,
	Linux Kbuild mailing list

On Wed, Oct 16, 2019 at 03:40:03PM -0700, Linus Torvalds wrote:
> On Wed, Oct 16, 2019 at 3:23 PM Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > I only tested gnu99 - which is sufficient for the above - and didn't
> > see if gnu11 ends up causing more issues..
> 
> I see at least no obvious issues with gnu11, so if this works for
> other architectures too, we should just switch over.

It would mean bumping GCC version requirements to 4.7. But no objections
on my side.

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-16 23:11       ` Kirill A. Shutemov
@ 2019-10-16 23:29         ` Linus Torvalds
  2019-10-17  0:16           ` Kirill A. Shutemov
  2019-10-17 12:53           ` Arnd Bergmann
  0 siblings, 2 replies; 19+ messages in thread
From: Linus Torvalds @ 2019-10-16 23:29 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Andrew Morton, Sasha Levin, Andrew Pinski, Arnd Bergmann,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Wed, Oct 16, 2019 at 4:11 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> Looks like it was fixed soon after the complain:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567

Ahh, so there are gcc versions which essentially do this wrong, and
I'm not seeing it because it was fixed.

Ho humm. Considering that this was fixed in gcc five years ago, and we
already require gc-4.6, and did that two years ago, maybe we can just
raise the requirement a bit further.

BUT.

It's not clear which versions are ok with this. In your next email you said:

> It would mean bumping GCC version requirements to 4.7.

which I think would be reasonable, but is it actually ok in 4.7?

The bugzilla entry says "Target Milestone: 5.0", and I'm not sure how
to check what that "revision=216440" ends up actually meaning.

I have a git tree of gcc, and in that one 216440 is commit
d303aeafa9b, but that seems to imply it only made it into 5.1:

  [torvalds@i7 gcc]$ git name-rev --tags
d303aeafa9b46e06cd853696acb6345dff51a6b9
  d303aeafa9b46e06cd853696acb6345dff51a6b9 tags/gcc-5_1_0-release~3943

so we'd have to jump forward a _lot_.

That's a bit sad and annoying. I'd be ok with jumping to 4.7, but I'm
not sure we can jump to 5.1.

Although maybe we should be a _lot_ more aggressive about gcc
versions, I'm on gcc-9.2.1 right now, and gcc-5.1 is from April 22,
2015.

              Linus

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-16 23:29         ` Linus Torvalds
@ 2019-10-17  0:16           ` Kirill A. Shutemov
  2019-10-17  5:20             ` Masahiro Yamada
  2019-10-17 12:53           ` Arnd Bergmann
  1 sibling, 1 reply; 19+ messages in thread
From: Kirill A. Shutemov @ 2019-10-17  0:16 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Sasha Levin, Andrew Pinski, Arnd Bergmann,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Wed, Oct 16, 2019 at 04:29:54PM -0700, Linus Torvalds wrote:
> On Wed, Oct 16, 2019 at 4:11 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
> >
> > Looks like it was fixed soon after the complain:
> >
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
> 
> Ahh, so there are gcc versions which essentially do this wrong, and
> I'm not seeing it because it was fixed.
> 
> Ho humm. Considering that this was fixed in gcc five years ago, and we
> already require gc-4.6, and did that two years ago, maybe we can just
> raise the requirement a bit further.
> 
> BUT.
> 
> It's not clear which versions are ok with this. In your next email you said:
> 
> > It would mean bumping GCC version requirements to 4.7.
> 
> which I think would be reasonable, but is it actually ok in 4.7?

I think, not. I don't have 4.7 around, but 4.9.3 has the issue if
-std=gnu99 is used.

> The bugzilla entry says "Target Milestone: 5.0", and I'm not sure how
> to check what that "revision=216440" ends up actually meaning.
> 
> I have a git tree of gcc, and in that one 216440 is commit
> d303aeafa9b, but that seems to imply it only made it into 5.1:
> 
>   [torvalds@i7 gcc]$ git name-rev --tags
> d303aeafa9b46e06cd853696acb6345dff51a6b9
>   d303aeafa9b46e06cd853696acb6345dff51a6b9 tags/gcc-5_1_0-release~3943
> 
> so we'd have to jump forward a _lot_.
> 
> That's a bit sad and annoying. I'd be ok with jumping to 4.7, but I'm
> not sure we can jump to 5.1.
>
> Although maybe we should be a _lot_ more aggressive about gcc
> versions, I'm on gcc-9.2.1 right now, and gcc-5.1 is from April 22,
> 2015.

5.4.1 builds kernel fine for me with allmodconfig (minus retpoline which
requires compiler support). Both -std=gnu99 and -std=gnu11.

Note that GCC has changed their version scheme. 5.4.1 is bug-fix release
of GCC-5.

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-17  0:16           ` Kirill A. Shutemov
@ 2019-10-17  5:20             ` Masahiro Yamada
  2019-10-17  8:50               ` Arnd Bergmann
  2019-10-17 15:17               ` Linus Torvalds
  0 siblings, 2 replies; 19+ messages in thread
From: Masahiro Yamada @ 2019-10-17  5:20 UTC (permalink / raw)
  To: Kirill A. Shutemov, Linus Torvalds, Arnd Bergmann
  Cc: Andrew Morton, Sasha Levin, Andrew Pinski, Michal Marek,
	mm-commits, Alexander Potapenko, Dmitry Vyukov, Eric Dumazet,
	Kostya Serebryany, Ingo Molnar, linux-arch,
	Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 9:16 AM Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> On Wed, Oct 16, 2019 at 04:29:54PM -0700, Linus Torvalds wrote:
> > On Wed, Oct 16, 2019 at 4:11 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
> > >
> > > Looks like it was fixed soon after the complain:
> > >
> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
> >
> > Ahh, so there are gcc versions which essentially do this wrong, and
> > I'm not seeing it because it was fixed.
> >
> > Ho humm. Considering that this was fixed in gcc five years ago, and we
> > already require gc-4.6, and did that two years ago, maybe we can just
> > raise the requirement a bit further.
> >
> > BUT.
> >
> > It's not clear which versions are ok with this. In your next email you said:
> >
> > > It would mean bumping GCC version requirements to 4.7.
> >
> > which I think would be reasonable, but is it actually ok in 4.7?
>
> I think, not. I don't have 4.7 around, but 4.9.3 has the issue if
> -std=gnu99 is used.
>
> > The bugzilla entry says "Target Milestone: 5.0", and I'm not sure how
> > to check what that "revision=216440" ends up actually meaning.
> >
> > I have a git tree of gcc, and in that one 216440 is commit
> > d303aeafa9b, but that seems to imply it only made it into 5.1:
> >
> >   [torvalds@i7 gcc]$ git name-rev --tags
> > d303aeafa9b46e06cd853696acb6345dff51a6b9
> >   d303aeafa9b46e06cd853696acb6345dff51a6b9 tags/gcc-5_1_0-release~3943
> >
> > so we'd have to jump forward a _lot_.
> >
> > That's a bit sad and annoying. I'd be ok with jumping to 4.7, but I'm
> > not sure we can jump to 5.1.
> >
> > Although maybe we should be a _lot_ more aggressive about gcc
> > versions, I'm on gcc-9.2.1 right now, and gcc-5.1 is from April 22,
> > 2015.
>
> 5.4.1 builds kernel fine for me with allmodconfig (minus retpoline which
> requires compiler support). Both -std=gnu99 and -std=gnu11.
>
> Note that GCC has changed their version scheme. 5.4.1 is bug-fix release
> of GCC-5.


I tested -std=gnu99 for ARM
with pre-built Linaro toolchains.


GCC 4.9.4 was NG,
GCC 5.3.1 was OK.



If we increase the minimal GCC version,
we might end up with dropping more architecture.

I can no longer get the toolchains for hexagon, unicore32.


https://mirrors.edge.kernel.org/pub/tools/crosstool/
provides hexagon compilers, but only for GCC 4.6.1



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-17  5:20             ` Masahiro Yamada
@ 2019-10-17  8:50               ` Arnd Bergmann
  2019-10-17 15:17               ` Linus Torvalds
  1 sibling, 0 replies; 19+ messages in thread
From: Arnd Bergmann @ 2019-10-17  8:50 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Kirill A. Shutemov, Linus Torvalds, Andrew Morton, Sasha Levin,
	Andrew Pinski, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 7:21 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> On Thu, Oct 17, 2019 at 9:16 AM Kirill A. Shutemov <kirill@shutemov.name> wrote:
> > On Wed, Oct 16, 2019 at 04:29:54PM -0700, Linus Torvalds wrote:
> I can no longer get the toolchains for hexagon, unicore32.

Guan Xuetao said in 2018 that he'd try to make a new gcc available, but
I don't think anything ever came out of that.

> https://mirrors.edge.kernel.org/pub/tools/crosstool/
> provides hexagon compilers, but only for GCC 4.6.1

For all I know, Qualcomm use clang internally to build hexagon kernels,
it may be a good idea to try again with clang-9. The last I know about it,
clang itself should have all the required patches, but there were still
issues with using llvm as a binutils replacement (as and/or ld). Not sure
if that has been resolved by now.

      Arnd

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-16 23:29         ` Linus Torvalds
  2019-10-17  0:16           ` Kirill A. Shutemov
@ 2019-10-17 12:53           ` Arnd Bergmann
  2019-10-17 12:56             ` [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99 Arnd Bergmann
  1 sibling, 1 reply; 19+ messages in thread
From: Arnd Bergmann @ 2019-10-17 12:53 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Kirill A. Shutemov, Andrew Morton, Sasha Levin, Andrew Pinski,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 1:30 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Wed, Oct 16, 2019 at 4:11 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
> >
> > Looks like it was fixed soon after the complain:
> >
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63567
>
> Ahh, so there are gcc versions which essentially do this wrong, and
> I'm not seeing it because it was fixed.
>
> Ho humm. Considering that this was fixed in gcc five years ago, and we
> already require gc-4.6, and did that two years ago, maybe we can just
> raise the requirement a bit further.

If the compound literal extension is now all that's keeping us from
moving to gnu99, the alternative would be to change the kernel not
to use compound literals.

I think some other gnu99 incompatibilities were fixed by the clang patches,
such as marking inline as __gnu_inline, and other problems were avoiding by
making gcc-4.5 the minimum.

I've tried it out now, and found that we do use compound literals in
some important code, but the number of instances is small enough
that we can actually rewrite them all.

Just getting the defconfig (x86-64 and arm32) building with "gcc-4.9
--std=gnu89" takes changes to around 50 files, though at least one
driver (i915 gpu) needs significant additional changes beyond this:

 Makefile                                           |  2 +-
 arch/x86/boot/compressed/acpi.c                    |  4 +-
 arch/x86/entry/vsyscall/vsyscall_64.c              |  2 +-
 arch/x86/include/asm/pgtable_types.h               | 59 ++++++++++++----------
 arch/x86/include/asm/processor.h                   |  4 +-
 arch/x86/include/asm/uaccess.h                     |  3 +-
 arch/x86/mm/pat_rbtree.c                           |  2 +-
 arch/x86/platform/efi/quirks.c                     |  9 ++--
 block/partitions/efi.c                             |  4 +-
 drivers/acpi/numa.c                                |  2 +-
 drivers/firmware/efi/efi.c                         |  4 +-
 drivers/firmware/efi/libstub/fdt.c                 |  2 +-
 drivers/firmware/efi/libstub/tpm.c                 |  2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h            |  2 +-
 drivers/input/mouse/elantech.c                     | 22 ++++----
 .../broadcom/brcm80211/brcmfmac/firmware.c         |  2 +-
 drivers/soc/tegra/pmc.c                            |  8 +--
 fs/proc/root.c                                     |  2 +-
 include/linux/capability.h                         | 17 ++++---
 include/linux/cpumask.h                            |  8 +--
 include/linux/efi.h                                |  2 +-
 include/linux/futex.h                              |  2 +-
 include/linux/jump_label.h                         |  4 +-
 include/linux/nodemask.h                           | 20 ++++----
 include/linux/property.h                           | 10 ++--
 include/linux/rbtree.h                             |  7 ++-
 include/linux/rwlock.h                             |  2 +-
 include/linux/rwlock_types.h                       |  4 +-
 include/linux/sched/signal.h                       |  2 +-
 include/linux/spinlock.h                           |  2 +-
 include/linux/spinlock_types.h                     |  4 +-
 include/linux/uidgid.h                             | 13 ++++-
 include/uapi/linux/uuid.h                          |  8 +--
 init/init_task.c                                   |  4 +-
 kernel/audit.c                                     |  2 +-
 kernel/capability.c                                |  2 +-
 kernel/cred.c                                      | 24 ++++-----
 kernel/events/uprobes.c                            |  2 +-
 kernel/futex.c                                     |  2 +-
 kernel/power/swap.c                                |  2 +-
 kernel/trace/trace_clock.c                         |  2 +-
 kernel/umh.c                                       |  4 +-
 kernel/user.c                                      |  6 +--
 mm/backing-dev.c                                   |  2 +-
 mm/init-mm.c                                       |  2 +-
 mm/page_alloc.c                                    |  2 +-
 mm/vmalloc.c                                       |  4 +-
 net/core/fib_rules.c                               |  4 +-
 net/rds/cong.c                                     |  2 +-
 security/integrity/iint.c                          |  2 +-
 security/keys/process_keys.c                       |  2 +-
 51 files changed, 169 insertions(+), 141 deletions(-)

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-17 12:53           ` Arnd Bergmann
@ 2019-10-17 12:56             ` Arnd Bergmann
  2019-10-17 15:05               ` Linus Torvalds
  0 siblings, 1 reply; 19+ messages in thread
From: Arnd Bergmann @ 2019-10-17 12:56 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Kirill A . Shutemov, Andrew Morton, Sasha Levin, Andrew Pinski,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list, Arnd Bergmann

Any variable intialized statically to a gnu89 compound literal
like

static struct foo x = (struct foo){};

causes a build failure in --std=gnu99 with gcc-4.9 or earlier.
Later gcc versions and clang accept it as an extension the
same was with --std=gnu89.

Change enough of the kernel to allow building a 'defconfig'
kernel on x86 and arm, by turning the compound literals into
struct initializers. As many compound literals are defined
in macros, that means we now need two versions of them --
one with the cast for use in assignments, and one without
the cast as a struct initializer.

A lot of this does make the code uglier, and more changes
are needed to fix the rest of the kernel, but this should
give an overview of what is still needed.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 Makefile                                      |  2 +-
 arch/x86/boot/compressed/acpi.c               |  4 +-
 arch/x86/entry/vsyscall/vsyscall_64.c         |  2 +-
 arch/x86/include/asm/pgtable_types.h          | 59 +++++++++++--------
 arch/x86/include/asm/processor.h              |  4 +-
 arch/x86/include/asm/uaccess.h                |  3 +-
 arch/x86/mm/pat_rbtree.c                      |  2 +-
 arch/x86/platform/efi/quirks.c                |  9 ++-
 block/partitions/efi.c                        |  4 +-
 drivers/acpi/numa.c                           |  2 +-
 drivers/firmware/efi/efi.c                    |  4 +-
 drivers/firmware/efi/libstub/fdt.c            |  2 +-
 drivers/firmware/efi/libstub/tpm.c            |  2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h       |  2 +-
 drivers/input/mouse/elantech.c                | 22 +++----
 .../broadcom/brcm80211/brcmfmac/firmware.c    |  2 +-
 drivers/soc/tegra/pmc.c                       |  8 +--
 fs/proc/root.c                                |  2 +-
 include/linux/capability.h                    | 17 ++++--
 include/linux/cpumask.h                       |  8 +--
 include/linux/efi.h                           |  2 +-
 include/linux/futex.h                         |  2 +-
 include/linux/jump_label.h                    |  4 +-
 include/linux/nodemask.h                      | 20 ++++---
 include/linux/property.h                      | 10 ++--
 include/linux/rbtree.h                        |  7 ++-
 include/linux/rwlock.h                        |  2 +-
 include/linux/rwlock_types.h                  |  4 +-
 include/linux/sched/signal.h                  |  2 +-
 include/linux/spinlock.h                      |  2 +-
 include/linux/spinlock_types.h                |  4 +-
 include/linux/uidgid.h                        | 13 +++-
 include/uapi/linux/uuid.h                     |  8 ++-
 init/init_task.c                              |  4 +-
 kernel/audit.c                                |  2 +-
 kernel/capability.c                           |  2 +-
 kernel/cred.c                                 | 24 ++++----
 kernel/events/uprobes.c                       |  2 +-
 kernel/futex.c                                |  2 +-
 kernel/power/swap.c                           |  2 +-
 kernel/trace/trace_clock.c                    |  2 +-
 kernel/umh.c                                  |  4 +-
 kernel/user.c                                 |  6 +-
 mm/backing-dev.c                              |  2 +-
 mm/init-mm.c                                  |  2 +-
 mm/page_alloc.c                               |  2 +-
 mm/vmalloc.c                                  |  4 +-
 net/core/fib_rules.c                          |  4 +-
 net/rds/cong.c                                |  2 +-
 security/integrity/iint.c                     |  2 +-
 security/keys/process_keys.c                  |  2 +-
 51 files changed, 169 insertions(+), 141 deletions(-)

diff --git a/Makefile b/Makefile
index e7b2b44e0666..ec2d9e911ec6 100644
--- a/Makefile
+++ b/Makefile
@@ -459,7 +459,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
 		   -Werror=implicit-function-declaration -Werror=implicit-int \
 		   -Wno-format-security \
-		   -std=gnu89
+		   -std=gnu99
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
diff --git a/arch/x86/boot/compressed/acpi.c b/arch/x86/boot/compressed/acpi.c
index 149795c369f2..dc57644f2aaa 100644
--- a/arch/x86/boot/compressed/acpi.c
+++ b/arch/x86/boot/compressed/acpi.c
@@ -79,9 +79,9 @@ __efi_get_rsdp_addr(unsigned long config_tables, unsigned int nr_tables,
 			table = tbl->table;
 		}
 
-		if (!(efi_guidcmp(guid, ACPI_TABLE_GUID)))
+		if (!(efi_guidcmp(guid, (guid_t)ACPI_TABLE_GUID)))
 			rsdp_addr = table;
-		else if (!(efi_guidcmp(guid, ACPI_20_TABLE_GUID)))
+		else if (!(efi_guidcmp(guid, (guid_t)ACPI_20_TABLE_GUID)))
 			return table;
 	}
 #endif
diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
index 76e62bcb8d87..eecd6f066b17 100644
--- a/arch/x86/entry/vsyscall/vsyscall_64.c
+++ b/arch/x86/entry/vsyscall/vsyscall_64.c
@@ -308,7 +308,7 @@ static const struct vm_operations_struct gate_vma_ops = {
 static struct vm_area_struct gate_vma __ro_after_init = {
 	.vm_start	= VSYSCALL_ADDR,
 	.vm_end		= VSYSCALL_ADDR + PAGE_SIZE,
-	.vm_page_prot	= PAGE_READONLY_EXEC,
+	.vm_page_prot	= { __PAGE_READONLY_EXEC },
 	.vm_flags	= VM_READ | VM_EXEC,
 	.vm_ops		= &gate_vma_ops,
 };
diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
index b5e49e6bac63..2544a73605cc 100644
--- a/arch/x86/include/asm/pgtable_types.h
+++ b/arch/x86/include/asm/pgtable_types.h
@@ -150,21 +150,28 @@ enum page_cache_mode {
 #define _PAGE_NOCACHE		(cachemode2protval(_PAGE_CACHE_MODE_UC))
 #define _PAGE_CACHE_WP		(cachemode2protval(_PAGE_CACHE_MODE_WP))
 
-#define PAGE_NONE	__pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
-#define PAGE_SHARED	__pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
+#define __PAGE_NONE		(_PAGE_PROTNONE | _PAGE_ACCESSED)
+#define PAGE_NONE		__pgprot(__PAGE_NONE)
+#define __PAGE_SHARED		(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
 				 _PAGE_ACCESSED | _PAGE_NX)
+#define PAGE_SHARED		__pgprot(__PAGE_SHARED)
 
-#define PAGE_SHARED_EXEC	__pgprot(_PAGE_PRESENT | _PAGE_RW |	\
+#define __PAGE_SHARED_EXEC	(_PAGE_PRESENT | _PAGE_RW |	\
 					 _PAGE_USER | _PAGE_ACCESSED)
-#define PAGE_COPY_NOEXEC	__pgprot(_PAGE_PRESENT | _PAGE_USER |	\
+#define PAGE_SHARED_EXEC	__pgprot(__PAGE_SHARED_EXEC)
+#define __PAGE_COPY_NOEXEC	(_PAGE_PRESENT | _PAGE_USER |	\
 					 _PAGE_ACCESSED | _PAGE_NX)
-#define PAGE_COPY_EXEC		__pgprot(_PAGE_PRESENT | _PAGE_USER |	\
+#define __PAGE_COPY_EXEC	(_PAGE_PRESENT | _PAGE_USER |	\
 					 _PAGE_ACCESSED)
-#define PAGE_COPY		PAGE_COPY_NOEXEC
-#define PAGE_READONLY		__pgprot(_PAGE_PRESENT | _PAGE_USER |	\
+#define PAGE_COPY_EXEC		__pgprot(__PAGE_COPY_EXEC)
+
+#define __PAGE_COPY		__PAGE_COPY_NOEXEC
+#define PAGE_COPY		__pgprot(__PAGE_COPY)
+#define __PAGE_READONLY		(_PAGE_PRESENT | _PAGE_USER |	\
 					 _PAGE_ACCESSED | _PAGE_NX)
-#define PAGE_READONLY_EXEC	__pgprot(_PAGE_PRESENT | _PAGE_USER |	\
-					 _PAGE_ACCESSED)
+#define PAGE_READONLY		__pgprot(__PAGE_READONLY)
+#define __PAGE_READONLY_EXEC	(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
+#define PAGE_READONLY_EXEC	__pgprot(__PAGE_READONLY_EXEC)
 
 #define __PAGE_KERNEL_EXEC						\
 	(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
@@ -214,23 +221,23 @@ enum page_cache_mode {
 #endif	/* __ASSEMBLY__ */
 
 /*         xwr */
-#define __P000	PAGE_NONE
-#define __P001	PAGE_READONLY
-#define __P010	PAGE_COPY
-#define __P011	PAGE_COPY
-#define __P100	PAGE_READONLY_EXEC
-#define __P101	PAGE_READONLY_EXEC
-#define __P110	PAGE_COPY_EXEC
-#define __P111	PAGE_COPY_EXEC
-
-#define __S000	PAGE_NONE
-#define __S001	PAGE_READONLY
-#define __S010	PAGE_SHARED
-#define __S011	PAGE_SHARED
-#define __S100	PAGE_READONLY_EXEC
-#define __S101	PAGE_READONLY_EXEC
-#define __S110	PAGE_SHARED_EXEC
-#define __S111	PAGE_SHARED_EXEC
+#define __P000	{__PAGE_NONE}
+#define __P001	{__PAGE_READONLY}
+#define __P010	{__PAGE_COPY}
+#define __P011	{__PAGE_COPY}
+#define __P100	{__PAGE_READONLY_EXEC}
+#define __P101	{__PAGE_READONLY_EXEC}
+#define __P110	{__PAGE_COPY_EXEC}
+#define __P111	{__PAGE_COPY_EXEC}
+
+#define __S000	{__PAGE_NONE}
+#define __S001	{__PAGE_READONLY}
+#define __S010	{__PAGE_SHARED}
+#define __S011	{__PAGE_SHARED}
+#define __S100	{__PAGE_READONLY_EXEC}
+#define __S101	{__PAGE_READONLY_EXEC}
+#define __S110	{__PAGE_SHARED_EXEC}
+#define __S111	{__PAGE_SHARED_EXEC}
 
 /*
  * early identity mapping  pte attrib macros.
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 6e0a3b43d027..0be68f3dbdf1 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -842,7 +842,7 @@ static inline void spin_lock_prefetch(const void *x)
 	.sp0			= TOP_OF_INIT_STACK,			  \
 	.sysenter_cs		= __KERNEL_CS,				  \
 	.io_bitmap_ptr		= NULL,					  \
-	.addr_limit		= KERNEL_DS,				  \
+	.addr_limit		= {__KERNEL_ADDR_LIMIT},		  \
 }
 
 #define KSTK_ESP(task)		(task_pt_regs(task)->sp)
@@ -887,7 +887,7 @@ static inline void spin_lock_prefetch(const void *x)
 #define STACK_TOP_MAX		TASK_SIZE_MAX
 
 #define INIT_THREAD  {						\
-	.addr_limit		= KERNEL_DS,			\
+	.addr_limit		= {__KERNEL_ADDR_LIMIT},	\
 }
 
 extern unsigned long KSTK_ESP(struct task_struct *task);
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 61d93f062a36..30b0cc30847d 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -22,7 +22,8 @@
 
 #define MAKE_MM_SEG(s)	((mm_segment_t) { (s) })
 
-#define KERNEL_DS	MAKE_MM_SEG(-1UL)
+#define __KERNEL_ADDR_LIMIT (-1UL)
+#define KERNEL_DS	MAKE_MM_SEG(__KERNEL_ADDR_LIMIT)
 #define USER_DS 	MAKE_MM_SEG(TASK_SIZE_MAX)
 
 #define get_fs()	(current->thread.addr_limit)
diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
index 65ebe4b88f7c..70bcb2239728 100644
--- a/arch/x86/mm/pat_rbtree.c
+++ b/arch/x86/mm/pat_rbtree.c
@@ -34,7 +34,7 @@
  * memtype_lock protects the rbtree.
  */
 
-static struct rb_root memtype_rbroot = RB_ROOT;
+static struct rb_root memtype_rbroot = __RB_ROOT;
 
 static int is_node_overlap(struct memtype *node, u64 start, u64 end)
 {
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 3b9fd679cea9..5c98747f7ef3 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -20,8 +20,7 @@
 
 #define EFI_MIN_RESERVE 5120
 
-#define EFI_DUMMY_GUID \
-	EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e, 0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92, 0xa9)
+static guid_t efi_dummy_guid = EFI_GUID(0x4424ac57, 0xbe4b, 0x47dd, 0x9e, 0x97, 0xed, 0x50, 0xf0, 0x9f, 0x92, 0xa9);
 
 #define QUARK_CSH_SIGNATURE		0x5f435348	/* _CSH */
 #define QUARK_SECURITY_HEADER_SIZE	0x400
@@ -107,7 +106,7 @@ early_param("efi_no_storage_paranoia", setup_storage_paranoia);
 void efi_delete_dummy_variable(void)
 {
 	efi.set_variable_nonblocking((efi_char16_t *)efi_dummy_name,
-				     &EFI_DUMMY_GUID,
+				     &efi_dummy_guid,
 				     EFI_VARIABLE_NON_VOLATILE |
 				     EFI_VARIABLE_BOOTSERVICE_ACCESS |
 				     EFI_VARIABLE_RUNTIME_ACCESS, 0, NULL);
@@ -184,7 +183,7 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,
 			return EFI_OUT_OF_RESOURCES;
 
 		status = efi.set_variable((efi_char16_t *)efi_dummy_name,
-					  &EFI_DUMMY_GUID,
+					  &efi_dummy_guid,
 					  EFI_VARIABLE_NON_VOLATILE |
 					  EFI_VARIABLE_BOOTSERVICE_ACCESS |
 					  EFI_VARIABLE_RUNTIME_ACCESS,
@@ -545,7 +544,7 @@ int __init efi_reuse_config(u64 tables, int nr_tables)
 
 		guid = ((efi_config_table_64_t *)p)->guid;
 
-		if (!efi_guidcmp(guid, SMBIOS_TABLE_GUID))
+		if (!efi_guidcmp(guid, (guid_t)SMBIOS_TABLE_GUID))
 			((efi_config_table_64_t *)p)->table = data->smbios;
 		p += sz;
 	}
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index db2fef7dfc47..8d9ab8403749 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -462,7 +462,7 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
 static inline int
 is_pte_valid(const gpt_entry *pte, const u64 lastlba)
 {
-	if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) ||
+	if ((!efi_guidcmp(pte->partition_type_guid, (guid_t)NULL_GUID)) ||
 	    le64_to_cpu(pte->starting_lba) > lastlba         ||
 	    le64_to_cpu(pte->ending_lba)   > lastlba)
 		return 0;
@@ -704,7 +704,7 @@ int efi_partition(struct parsed_partitions *state)
 		put_partition(state, i+1, start * ssz, size * ssz);
 
 		/* If this is a RAID volume, tell md */
-		if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID))
+		if (!efi_guidcmp(ptes[i].partition_type_guid, (guid_t)PARTITION_LINUX_RAID_GUID))
 			state->parts[i + 1].flags = ADDPART_FLAG_RAID;
 
 		info = &state->parts[i + 1].info;
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index eadbf90e65d1..80272352ebea 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -18,7 +18,7 @@
 #include <linux/nodemask.h>
 #include <linux/topology.h>
 
-static nodemask_t nodes_found_map = NODE_MASK_NONE;
+static nodemask_t nodes_found_map = __NODE_MASK_NONE;
 
 /* maps to convert between proximity domain and logical node ID */
 static int pxm_to_node_map[MAX_PXM_DOMAINS]
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 8d3e778e988b..47cb499054d7 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -57,7 +57,7 @@ struct efi __read_mostly efi = {
 EXPORT_SYMBOL(efi);
 
 struct mm_struct efi_mm = {
-	.mm_rb			= RB_ROOT,
+	.mm_rb			= __RB_ROOT,
 	.mm_users		= ATOMIC_INIT(2),
 	.mm_count		= ATOMIC_INIT(1),
 	.mmap_sem		= __RWSEM_INITIALIZER(efi_mm.mmap_sem),
@@ -484,7 +484,7 @@ static __init int match_config_table(efi_guid_t *guid,
 	int i;
 
 	if (table_types) {
-		for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) {
+		for (i = 0; efi_guidcmp(table_types[i].guid, (guid_t)NULL_GUID); i++) {
 			if (!efi_guidcmp(*guid, table_types[i].guid)) {
 				*(table_types[i].ptr) = table;
 				if (table_types[i].name)
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 0bf0190917e0..adcf3c40240b 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -365,7 +365,7 @@ void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size)
 {
 	void *fdt;
 
-	fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID);
+	fdt = get_efi_config_table(sys_table, (guid_t)DEVICE_TREE_GUID);
 
 	if (!fdt)
 		return NULL;
diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index eb9af83e4d59..6bfe812c2ef8 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -141,7 +141,7 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg)
 	 * final events structure, and if so how much space they take up
 	 */
 	final_events_table = get_efi_config_table(sys_table_arg,
-						LINUX_EFI_TPM_FINAL_LOG_GUID);
+						(guid_t)LINUX_EFI_TPM_FINAL_LOG_GUID);
 	if (final_events_table && final_events_table->nr_events) {
 		struct tcg_pcr_event2_head *header;
 		int offset;
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index c7441fb8313e..d120202bd405 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -61,7 +61,7 @@ struct adreno_rev {
 };
 
 #define ADRENO_REV(core, major, minor, patchid) \
-	((struct adreno_rev){ core, major, minor, patchid })
+	{ core, major, minor, patchid }
 
 struct adreno_gpu_funcs {
 	struct msm_gpu_funcs base;
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 04fe43440a3c..9625f9e0a4d1 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1792,36 +1792,36 @@ static int elantech_create_smbus(struct psmouse *psmouse,
 
 	smbus_board.properties = i2c_props;
 
-	i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-x",
+	i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("touchscreen-size-x",
 						   info->x_max + 1);
-	i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-y",
+	i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("touchscreen-size-y",
 						   info->y_max + 1);
-	i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-x",
+	i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("touchscreen-min-x",
 						   info->x_min);
-	i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-y",
+	i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("touchscreen-min-y",
 						   info->y_min);
 	if (info->x_res)
-		i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-x-mm",
+		i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("touchscreen-x-mm",
 						      (info->x_max + 1) / info->x_res);
 	if (info->y_res)
-		i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-y-mm",
+		i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("touchscreen-y-mm",
 						      (info->y_max + 1) / info->y_res);
 
 	if (info->has_trackpoint)
-		i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,trackpoint");
+		i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_BOOL("elan,trackpoint");
 
 	if (info->has_middle_button)
-		i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,middle-button");
+		i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_BOOL("elan,middle-button");
 
 	if (info->x_traces)
-		i2c_props[idx++] = PROPERTY_ENTRY_U32("elan,x_traces",
+		i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("elan,x_traces",
 						      info->x_traces);
 	if (info->y_traces)
-		i2c_props[idx++] = PROPERTY_ENTRY_U32("elan,y_traces",
+		i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_U32("elan,y_traces",
 						      info->y_traces);
 
 	if (elantech_is_buttonpad(info))
-		i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,clickpad");
+		i2c_props[idx++] = (struct property_entry)PROPERTY_ENTRY_BOOL("elan,clickpad");
 
 	return psmouse_smbus_init(psmouse, &smbus_board, NULL, 0, false,
 				  leave_breadcrumbs);
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
index 3aed4c4b887a..97fef627c2fb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
@@ -472,7 +472,7 @@ static u8 *brcmf_fw_nvram_from_efi(size_t *data_len_ret)
 		return NULL;
 
 	memcpy(&nvram_efivar->var.VariableName, name, sizeof(name));
-	nvram_efivar->var.VendorGuid = EFI_GUID(0x74b00bd9, 0x805a, 0x4d61,
+	nvram_efivar->var.VendorGuid = (guid_t)EFI_GUID(0x74b00bd9, 0x805a, 0x4d61,
 						0xb5, 0x1f, 0x43, 0x26,
 						0x81, 0x23, 0xd1, 0x13);
 
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 9f9c1c677cf4..6f98a13c361b 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -2378,18 +2378,18 @@ static const u8 tegra124_cpu_powergates[] = {
 };
 
 #define TEGRA_IO_PAD(_id, _dpd, _voltage, _name)	\
-	((struct tegra_io_pad_soc) {			\
+	{						\
 		.id	= (_id),			\
 		.dpd	= (_dpd),			\
 		.voltage = (_voltage),			\
 		.name	= (_name),			\
-	})
+	}
 
 #define TEGRA_IO_PIN_DESC(_id, _dpd, _voltage, _name)	\
-	((struct pinctrl_pin_desc) {			\
+	{						\
 		.number = (_id),			\
 		.name	= (_name)			\
-	})
+	}
 
 #define TEGRA124_IO_PAD_TABLE(_pad)					\
 	/* .id                          .dpd    .voltage  .name	*/	\
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 0b7c8dffc9ae..8824414d8f7b 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -294,7 +294,7 @@ struct proc_dir_entry proc_root = {
 	.proc_iops	= &proc_root_inode_operations, 
 	.proc_fops	= &proc_root_operations,
 	.parent		= &proc_root,
-	.subdir		= RB_ROOT,
+	.subdir		= __RB_ROOT,
 	.name		= "/proc",
 };
 
diff --git a/include/linux/capability.h b/include/linux/capability.h
index ecce0f43c73a..7e405382f0ee 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -82,14 +82,19 @@ extern const kernel_cap_t __cap_init_eff_set;
 #define CAP_LAST_U32			((_KERNEL_CAPABILITY_U32S) - 1)
 #define CAP_LAST_U32_VALID_MASK		(CAP_TO_MASK(CAP_LAST_CAP + 1) -1)
 
-# define CAP_EMPTY_SET    ((kernel_cap_t){{ 0, 0 }})
-# define CAP_FULL_SET     ((kernel_cap_t){{ ~0, CAP_LAST_U32_VALID_MASK }})
-# define CAP_FS_SET       ((kernel_cap_t){{ CAP_FS_MASK_B0 \
+# define __CAP_EMPTY_SET    {{ 0, 0 }}
+# define __CAP_FULL_SET     {{ ~0, CAP_LAST_U32_VALID_MASK }}
+# define __CAP_FS_SET       {{ CAP_FS_MASK_B0 \
 				    | CAP_TO_MASK(CAP_LINUX_IMMUTABLE), \
-				    CAP_FS_MASK_B1 } })
-# define CAP_NFSD_SET     ((kernel_cap_t){{ CAP_FS_MASK_B0 \
+				    CAP_FS_MASK_B1 } }
+# define __CAP_NFSD_SET     {{ CAP_FS_MASK_B0 \
 				    | CAP_TO_MASK(CAP_SYS_RESOURCE), \
-				    CAP_FS_MASK_B1 } })
+				    CAP_FS_MASK_B1 } }
+
+# define CAP_EMPTY_SET    ((kernel_cap_t)__CAP_EMPTY_SET)
+# define CAP_FULL_SET     ((kernel_cap_t)__CAP_FULL_SET)
+# define CAP_FS_SET       ((kernel_cap_t)__CAP_FS_SET)
+# define CAP_NFSD_SET     ((kernel_cap_t)__CAP_NFSD_SET)
 
 #endif /* _KERNEL_CAPABILITY_U32S != 2 */
 
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 78a73eba64dd..c843d273f2ac 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -919,24 +919,24 @@ cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask)
 
 #if NR_CPUS <= BITS_PER_LONG
 #define CPU_MASK_ALL							\
-(cpumask_t) { {								\
+{ {								\
 	[BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS)	\
 } }
 #else
 #define CPU_MASK_ALL							\
-(cpumask_t) { {								\
+{ {								\
 	[0 ... BITS_TO_LONGS(NR_CPUS)-2] = ~0UL,			\
 	[BITS_TO_LONGS(NR_CPUS)-1] = BITMAP_LAST_WORD_MASK(NR_CPUS)	\
 } }
 #endif /* NR_CPUS > BITS_PER_LONG */
 
 #define CPU_MASK_NONE							\
-(cpumask_t) { {								\
+{ {								\
 	[0 ... BITS_TO_LONGS(NR_CPUS)-1] =  0UL				\
 } }
 
 #define CPU_MASK_CPU0							\
-(cpumask_t) { {								\
+{ {								\
 	[0] =  1UL							\
 } }
 
diff --git a/include/linux/efi.h b/include/linux/efi.h
index bd3837022307..a0f42c62d283 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -64,7 +64,7 @@ typedef void *efi_handle_t;
 typedef guid_t efi_guid_t __aligned(__alignof__(u32));
 
 #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
-	GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
+	__GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
 
 /*
  * Generic EFI table header
diff --git a/include/linux/futex.h b/include/linux/futex.h
index ccaef0097785..f60697001f62 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -45,7 +45,7 @@ union futex_key {
 	} both;
 };
 
-#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
+#define FUTEX_KEY_INIT { .both = { .ptr = NULL } }
 
 #ifdef CONFIG_FUTEX
 extern void exit_robust_list(struct task_struct *curr);
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 3526c0aee954..7787b2650916 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -351,8 +351,8 @@ struct static_key_false {
 	struct static_key key;
 };
 
-#define STATIC_KEY_TRUE_INIT  (struct static_key_true) { .key = STATIC_KEY_INIT_TRUE,  }
-#define STATIC_KEY_FALSE_INIT (struct static_key_false){ .key = STATIC_KEY_INIT_FALSE, }
+#define STATIC_KEY_TRUE_INIT  { .key = STATIC_KEY_INIT_TRUE,  }
+#define STATIC_KEY_FALSE_INIT { .key = STATIC_KEY_INIT_FALSE, }
 
 #define DEFINE_STATIC_KEY_TRUE(name)	\
 	struct static_key_true name = STATIC_KEY_TRUE_INIT
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 27e7fa36f707..4eb6e645458d 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -306,25 +306,27 @@ static inline int __first_unset_node(const nodemask_t *maskp)
 
 #if MAX_NUMNODES <= BITS_PER_LONG
 
-#define NODE_MASK_ALL							\
-((nodemask_t) { {							\
+#define __NODE_MASK_ALL							\
+{ {							\
 	[BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD		\
-} })
+} }
 
 #else
 
-#define NODE_MASK_ALL							\
-((nodemask_t) { {							\
+#define __NODE_MASK_ALL							\
+{ {							\
 	[0 ... BITS_TO_LONGS(MAX_NUMNODES)-2] = ~0UL,			\
 	[BITS_TO_LONGS(MAX_NUMNODES)-1] = NODE_MASK_LAST_WORD		\
-} })
+} }
 
 #endif
+#define NODE_MASK_ALL (((nodemask_t)__MODE_MASK_ALL)
 
-#define NODE_MASK_NONE							\
-((nodemask_t) { {							\
+#define __NODE_MASK_NONE						\
+{ {							\
 	[0 ... BITS_TO_LONGS(MAX_NUMNODES)-1] =  0UL			\
-} })
+} }
+#define NODE_MASK_NONE ((nodemask_t)__NODE_MASK_NONE)
 
 #define nodes_addr(src) ((src).bits)
 
diff --git a/include/linux/property.h b/include/linux/property.h
index 9b3d4ca3a73a..7c615b8061fc 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -258,7 +258,7 @@ struct property_entry {
  */
 
 #define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _Type_, _val_)	\
-(struct property_entry) {						\
+{						\
 	.name = _name_,							\
 	.length = ARRAY_SIZE(_val_) * sizeof(_type_),			\
 	.is_array = true,						\
@@ -276,7 +276,7 @@ struct property_entry {
 	PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, U64, _val_)
 
 #define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_)		\
-(struct property_entry) {					\
+{								\
 	.name = _name_,						\
 	.length = ARRAY_SIZE(_val_) * sizeof(const char *),	\
 	.is_array = true,					\
@@ -285,7 +285,7 @@ struct property_entry {
 }
 
 #define PROPERTY_ENTRY_INTEGER(_name_, _type_, _Type_, _val_)	\
-(struct property_entry) {					\
+{								\
 	.name = _name_,						\
 	.length = sizeof(_type_),				\
 	.type = DEV_PROP_##_Type_,				\
@@ -302,7 +302,7 @@ struct property_entry {
 	PROPERTY_ENTRY_INTEGER(_name_, u64, U64, _val_)
 
 #define PROPERTY_ENTRY_STRING(_name_, _val_)		\
-(struct property_entry) {				\
+{							\
 	.name = _name_,					\
 	.length = sizeof(const char *),			\
 	.type = DEV_PROP_STRING,			\
@@ -310,7 +310,7 @@ struct property_entry {
 }
 
 #define PROPERTY_ENTRY_BOOL(_name_)		\
-(struct property_entry) {			\
+{						\
 	.name = _name_,				\
 }
 
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 1fd61a9af45c..203019a9d7e7 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -34,7 +34,9 @@ struct rb_root {
 
 #define rb_parent(r)   ((struct rb_node *)((r)->__rb_parent_color & ~3))
 
-#define RB_ROOT	(struct rb_root) { NULL, }
+#define __RB_ROOT { NULL, }
+#define RB_ROOT	(struct rb_root) __RB_ROOT
+#define DEFINE_RB_ROOT(name) struct rb_root name = __RB_ROOT
 #define	rb_entry(ptr, type, member) container_of(ptr, type, member)
 
 #define RB_EMPTY_ROOT(root)  (READ_ONCE((root)->rb_node) == NULL)
@@ -127,7 +129,8 @@ struct rb_root_cached {
 	struct rb_node *rb_leftmost;
 };
 
-#define RB_ROOT_CACHED (struct rb_root_cached) { {NULL, }, NULL }
+#define __RB_ROOT_CACHED { {NULL, }, NULL }
+#define RB_ROOT_CACHED (struct rb_root_cached)__RB_ROOT_CACHED
 
 /* Same as rb_first(), but O(1) */
 #define rb_first_cached(root) (root)->rb_leftmost
diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h
index 3dcd617e65ae..665bbe362eaf 100644
--- a/include/linux/rwlock.h
+++ b/include/linux/rwlock.h
@@ -25,7 +25,7 @@ do {								\
 } while (0)
 #else
 # define rwlock_init(lock)					\
-	do { *(lock) = __RW_LOCK_UNLOCKED(lock); } while (0)
+	do { *(lock) = (rwlock_t)__RW_LOCK_UNLOCKED(lock); } while (0)
 #endif
 
 #ifdef CONFIG_DEBUG_SPINLOCK
diff --git a/include/linux/rwlock_types.h b/include/linux/rwlock_types.h
index 857a72ceb794..a2873d685061 100644
--- a/include/linux/rwlock_types.h
+++ b/include/linux/rwlock_types.h
@@ -29,14 +29,14 @@ typedef struct {
 
 #ifdef CONFIG_DEBUG_SPINLOCK
 #define __RW_LOCK_UNLOCKED(lockname)					\
-	(rwlock_t)	{	.raw_lock = __ARCH_RW_LOCK_UNLOCKED,	\
+			{	.raw_lock = __ARCH_RW_LOCK_UNLOCKED,	\
 				.magic = RWLOCK_MAGIC,			\
 				.owner = SPINLOCK_OWNER_INIT,		\
 				.owner_cpu = -1,			\
 				RW_DEP_MAP_INIT(lockname) }
 #else
 #define __RW_LOCK_UNLOCKED(lockname) \
-	(rwlock_t)	{	.raw_lock = __ARCH_RW_LOCK_UNLOCKED,	\
+			{	.raw_lock = __ARCH_RW_LOCK_UNLOCKED,	\
 				RW_DEP_MAP_INIT(lockname) }
 #endif
 
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 88050259c466..4067f176c4fd 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -49,7 +49,7 @@ struct task_cputime_atomic {
 };
 
 #define INIT_CPUTIME_ATOMIC \
-	(struct task_cputime_atomic) {				\
+	{				\
 		.utime = ATOMIC64_INIT(0),			\
 		.stime = ATOMIC64_INIT(0),			\
 		.sum_exec_runtime = ATOMIC64_INIT(0),		\
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 031ce8617df8..c869279b0deb 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -103,7 +103,7 @@ do {								\
 
 #else
 # define raw_spin_lock_init(lock)				\
-	do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)
+	do { *(lock) = (raw_spinlock_t) __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)
 #endif
 
 #define raw_spin_is_locked(lock)	arch_spin_is_locked(&(lock)->raw_lock)
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h
index 24b4e6f2c1a2..71822cdaf829 100644
--- a/include/linux/spinlock_types.h
+++ b/include/linux/spinlock_types.h
@@ -54,7 +54,7 @@ typedef struct raw_spinlock {
 	SPIN_DEP_MAP_INIT(lockname) }
 
 #define __RAW_SPIN_LOCK_UNLOCKED(lockname)	\
-	(raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname)
+	__RAW_SPIN_LOCK_INITIALIZER(lockname)
 
 #define DEFINE_RAW_SPINLOCK(x)	raw_spinlock_t x = __RAW_SPIN_LOCK_UNLOCKED(x)
 
@@ -76,7 +76,7 @@ typedef struct spinlock {
 	{ { .rlock = __RAW_SPIN_LOCK_INITIALIZER(lockname) } }
 
 #define __SPIN_LOCK_UNLOCKED(lockname) \
-	(spinlock_t ) __SPIN_LOCK_INITIALIZER(lockname)
+	__SPIN_LOCK_INITIALIZER(lockname)
 
 #define DEFINE_SPINLOCK(x)	spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
 
diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
index b0542cd11aeb..1c89f44e8eb2 100644
--- a/include/linux/uidgid.h
+++ b/include/linux/uidgid.h
@@ -27,8 +27,11 @@ typedef struct {
 	gid_t val;
 } kgid_t;
 
-#define KUIDT_INIT(value) (kuid_t){ value }
-#define KGIDT_INIT(value) (kgid_t){ value }
+#define __KUIDT_INIT(value) { value }
+#define __KGIDT_INIT(value) { value }
+
+#define KUIDT_INIT(value) (kuid_t)__KUIDT_INIT(value)
+#define KGIDT_INIT(value) (kgid_t)__KGIDT_INIT(value)
 
 #ifdef CONFIG_MULTIUSER
 static inline uid_t __kuid_val(kuid_t uid)
@@ -52,6 +55,12 @@ static inline gid_t __kgid_val(kgid_t gid)
 }
 #endif
 
+#define __GLOBAL_ROOT_UID __KUIDT_INIT(0)
+#define __GLOBAL_ROOT_GID __KGIDT_INIT(0)
+
+#define __INVALID_UID __KUIDT_INIT(-1)
+#define __INVALID_GID __KGIDT_INIT(-1)
+
 #define GLOBAL_ROOT_UID KUIDT_INIT(0)
 #define GLOBAL_ROOT_GID KGIDT_INIT(0)
 
diff --git a/include/uapi/linux/uuid.h b/include/uapi/linux/uuid.h
index e5a7eecef7c3..d141ceef3dcb 100644
--- a/include/uapi/linux/uuid.h
+++ b/include/uapi/linux/uuid.h
@@ -24,12 +24,14 @@ typedef struct {
 	__u8 b[16];
 } guid_t;
 
-#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)			\
-((guid_t)								\
+#define __GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)			\
 {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
    (b) & 0xff, ((b) >> 8) & 0xff,					\
    (c) & 0xff, ((c) >> 8) & 0xff,					\
-   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
+   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}
+
+#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)			\
+	__GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
 
 /* backwards compatibility, don't use in new code */
 typedef guid_t uuid_le;
diff --git a/init/init_task.c b/init/init_task.c
index 9e5cbe5eab7b..d02ec9aedb31 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -122,7 +122,7 @@ struct task_struct init_task
 	.thread_group	= LIST_HEAD_INIT(init_task.thread_group),
 	.thread_node	= LIST_HEAD_INIT(init_signals.thread_head),
 #ifdef CONFIG_AUDIT
-	.loginuid	= INVALID_UID,
+	.loginuid	= __INVALID_UID,
 	.sessionid	= AUDIT_SID_UNSET,
 #endif
 #ifdef CONFIG_PERF_EVENTS
@@ -144,7 +144,7 @@ struct task_struct init_task
 	.mems_allowed_seq = SEQCNT_ZERO(init_task.mems_allowed_seq),
 #endif
 #ifdef CONFIG_RT_MUTEXES
-	.pi_waiters	= RB_ROOT_CACHED,
+	.pi_waiters	= __RB_ROOT_CACHED,
 	.pi_top_task	= NULL,
 #endif
 	INIT_PREV_CPUTIME(init_task)
diff --git a/kernel/audit.c b/kernel/audit.c
index da8dc0db5bd3..dae3da7961db 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -122,7 +122,7 @@ static u32	audit_backlog_limit = 64;
 static u32	audit_backlog_wait_time = AUDIT_BACKLOG_WAIT_TIME;
 
 /* The identity of the user shutting down the audit system. */
-kuid_t		audit_sig_uid = INVALID_UID;
+kuid_t		audit_sig_uid = __INVALID_UID;
 pid_t		audit_sig_pid = -1;
 u32		audit_sig_sid = 0;
 
diff --git a/kernel/capability.c b/kernel/capability.c
index 1444f3954d75..862cd27578b2 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -24,7 +24,7 @@
  * Leveraged for setting/resetting capabilities
  */
 
-const kernel_cap_t __cap_empty_set = CAP_EMPTY_SET;
+const kernel_cap_t __cap_empty_set = __CAP_EMPTY_SET;
 EXPORT_SYMBOL(__cap_empty_set);
 
 int file_caps_enabled = 1;
diff --git a/kernel/cred.c b/kernel/cred.c
index c0a4c12d38b2..67fd8a3d5600 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -44,19 +44,19 @@ struct cred init_cred = {
 	.subscribers		= ATOMIC_INIT(2),
 	.magic			= CRED_MAGIC,
 #endif
-	.uid			= GLOBAL_ROOT_UID,
-	.gid			= GLOBAL_ROOT_GID,
-	.suid			= GLOBAL_ROOT_UID,
-	.sgid			= GLOBAL_ROOT_GID,
-	.euid			= GLOBAL_ROOT_UID,
-	.egid			= GLOBAL_ROOT_GID,
-	.fsuid			= GLOBAL_ROOT_UID,
-	.fsgid			= GLOBAL_ROOT_GID,
+	.uid			= __GLOBAL_ROOT_UID,
+	.gid			= __GLOBAL_ROOT_GID,
+	.suid			= __GLOBAL_ROOT_UID,
+	.sgid			= __GLOBAL_ROOT_GID,
+	.euid			= __GLOBAL_ROOT_UID,
+	.egid			= __GLOBAL_ROOT_GID,
+	.fsuid			= __GLOBAL_ROOT_UID,
+	.fsgid			= __GLOBAL_ROOT_GID,
 	.securebits		= SECUREBITS_DEFAULT,
-	.cap_inheritable	= CAP_EMPTY_SET,
-	.cap_permitted		= CAP_FULL_SET,
-	.cap_effective		= CAP_FULL_SET,
-	.cap_bset		= CAP_FULL_SET,
+	.cap_inheritable	= __CAP_EMPTY_SET,
+	.cap_permitted		= __CAP_FULL_SET,
+	.cap_effective		= __CAP_FULL_SET,
+	.cap_bset		= __CAP_FULL_SET,
 	.user			= INIT_USER,
 	.user_ns		= &init_user_ns,
 	.group_info		= &init_groups,
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 94d38a39d72e..39dec5776d26 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -33,7 +33,7 @@
 #define UINSNS_PER_PAGE			(PAGE_SIZE/UPROBE_XOL_SLOT_BYTES)
 #define MAX_UPROBE_XOL_SLOTS		UINSNS_PER_PAGE
 
-static struct rb_root uprobes_tree = RB_ROOT;
+static DEFINE_RB_ROOT(uprobes_tree);
 /*
  * allows us to skip the uprobe_mmap if there are no uprobe events active
  * at this time.  Probably a fine grained per inode count is better?
diff --git a/kernel/futex.c b/kernel/futex.c
index b11c6562941d..17b5d6895e75 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -817,7 +817,7 @@ static int refill_pi_state_cache(void)
 	/* pi_mutex gets initialized later */
 	pi_state->owner = NULL;
 	refcount_set(&pi_state->refcount, 1);
-	pi_state->key = FUTEX_KEY_INIT;
+	pi_state->key = (union futex_key)FUTEX_KEY_INIT;
 
 	current->pi_state_cache = pi_state;
 
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index ca0fcb5ced71..dcb6b5a572d1 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -125,7 +125,7 @@ struct swsusp_extent {
 	unsigned long end;
 };
 
-static struct rb_root swsusp_extents = RB_ROOT;
+static DEFINE_RB_ROOT(swsusp_extents);
 
 static int swsusp_extents_insert(unsigned long swap_offset)
 {
diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
index aaf6793ededa..5e05ee2190d4 100644
--- a/kernel/trace/trace_clock.c
+++ b/kernel/trace/trace_clock.c
@@ -88,7 +88,7 @@ static struct {
 	arch_spinlock_t lock;
 } trace_clock_struct ____cacheline_aligned_in_smp =
 	{
-		.lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED,
+		.lock = __ARCH_SPIN_LOCK_UNLOCKED,
 	};
 
 u64 notrace trace_clock_global(void)
diff --git a/kernel/umh.c b/kernel/umh.c
index 7f255b5a8845..80a9103dba23 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -34,8 +34,8 @@
 #define CAP_BSET	(void *)1
 #define CAP_PI		(void *)2
 
-static kernel_cap_t usermodehelper_bset = CAP_FULL_SET;
-static kernel_cap_t usermodehelper_inheritable = CAP_FULL_SET;
+static kernel_cap_t usermodehelper_bset = __CAP_FULL_SET;
+static kernel_cap_t usermodehelper_inheritable = __CAP_FULL_SET;
 static DEFINE_SPINLOCK(umh_sysctl_lock);
 static DECLARE_RWSEM(umhelper_sem);
 static LIST_HEAD(umh_list);
diff --git a/kernel/user.c b/kernel/user.c
index 5235d7f49982..55dbedc46932 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -56,8 +56,8 @@ struct user_namespace init_user_ns = {
 		},
 	},
 	.count = ATOMIC_INIT(3),
-	.owner = GLOBAL_ROOT_UID,
-	.group = GLOBAL_ROOT_GID,
+	.owner = __GLOBAL_ROOT_UID,
+	.group = __GLOBAL_ROOT_GID,
 	.ns.inum = PROC_USER_INIT_INO,
 #ifdef CONFIG_USER_NS
 	.ns.ops = &userns_operations,
@@ -101,7 +101,7 @@ struct user_struct root_user = {
 	.processes	= ATOMIC_INIT(1),
 	.sigpending	= ATOMIC_INIT(0),
 	.locked_shm     = 0,
-	.uid		= GLOBAL_ROOT_UID,
+	.uid		= __GLOBAL_ROOT_UID,
 	.ratelimit	= RATELIMIT_STATE_INIT(root_user.ratelimit, 0, 0),
 };
 
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index d9daa3e422d0..c09799876add 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -28,7 +28,7 @@ static struct class *bdi_class;
  */
 DEFINE_SPINLOCK(bdi_lock);
 static u64 bdi_id_cursor;
-static struct rb_root bdi_tree = RB_ROOT;
+static DEFINE_RB_ROOT(bdi_tree);
 LIST_HEAD(bdi_list);
 
 /* bdi_wq serves all asynchronous writeback tasks */
diff --git a/mm/init-mm.c b/mm/init-mm.c
index fb1e15028ef0..944a5c0eb3ec 100644
--- a/mm/init-mm.c
+++ b/mm/init-mm.c
@@ -26,7 +26,7 @@
  * and size this cpu_bitmask to NR_CPUS.
  */
 struct mm_struct init_mm = {
-	.mm_rb		= RB_ROOT,
+	.mm_rb		= __RB_ROOT,
 	.pgd		= swapper_pg_dir,
 	.mm_users	= ATOMIC_INIT(2),
 	.mm_count	= ATOMIC_INIT(1),
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c0b2e0306720..ccbd0daed88f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -115,7 +115,7 @@ EXPORT_SYMBOL(latent_entropy);
  * Array of node states.
  */
 nodemask_t node_states[NR_NODE_STATES] __read_mostly = {
-	[N_POSSIBLE] = NODE_MASK_ALL,
+	[N_POSSIBLE] = __NODE_MASK_ALL,
 	[N_ONLINE] = { { [0] = 1UL } },
 #ifndef CONFIG_NUMA
 	[N_NORMAL_MEMORY] = { { [0] = 1UL } },
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index a3c70e275f4e..f19b508a5af3 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -334,7 +334,7 @@ static DEFINE_SPINLOCK(vmap_area_lock);
 /* Export for kexec only */
 LIST_HEAD(vmap_area_list);
 static LLIST_HEAD(vmap_purge_list);
-static struct rb_root vmap_area_root = RB_ROOT;
+static DEFINE_RB_ROOT(vmap_area_root);
 static bool vmap_initialized __read_mostly;
 
 /*
@@ -361,7 +361,7 @@ static LIST_HEAD(free_vmap_area_list);
  * of its sub-tree, right or left. Therefore it is possible to
  * find a lowest match of free area.
  */
-static struct rb_root free_vmap_area_root = RB_ROOT;
+static DEFINE_RB_ROOT(free_vmap_area_root);
 
 /*
  * Preload a CPU with one object for "no edge" split case. The
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c
index dd220ce7ca7a..1d9788f74e9d 100644
--- a/net/core/fib_rules.c
+++ b/net/core/fib_rules.c
@@ -16,8 +16,8 @@
 #include <net/ip_tunnels.h>
 
 static const struct fib_kuid_range fib_kuid_range_unset = {
-	KUIDT_INIT(0),
-	KUIDT_INIT(~0),
+	__KUIDT_INIT(0),
+	__KUIDT_INIT(~0),
 };
 
 bool fib_rule_matchall(const struct fib_rule *rule)
diff --git a/net/rds/cong.c b/net/rds/cong.c
index ccdff09a79c8..7769a667842e 100644
--- a/net/rds/cong.c
+++ b/net/rds/cong.c
@@ -99,7 +99,7 @@ static DEFINE_RWLOCK(rds_cong_monitor_lock);
  *  lock masks interrupts.
  */
 static DEFINE_SPINLOCK(rds_cong_lock);
-static struct rb_root rds_cong_tree = RB_ROOT;
+static DEFINE_RB_ROOT(rds_cong_tree);
 
 static struct rds_cong_map *rds_cong_tree_walk(const struct in6_addr *addr,
 					       struct rds_cong_map *insert)
diff --git a/security/integrity/iint.c b/security/integrity/iint.c
index e12c4900510f..115d89f0adcc 100644
--- a/security/integrity/iint.c
+++ b/security/integrity/iint.c
@@ -21,7 +21,7 @@
 #include <linux/lsm_hooks.h>
 #include "integrity.h"
 
-static struct rb_root integrity_iint_tree = RB_ROOT;
+static DEFINE_RB_ROOT(integrity_iint_tree);
 static DEFINE_RWLOCK(integrity_iint_lock);
 static struct kmem_cache *iint_cache __read_mostly;
 
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 09541de31f2f..4979c104926f 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -29,7 +29,7 @@ struct key_user root_key_user = {
 	.lock		= __SPIN_LOCK_UNLOCKED(root_key_user.lock),
 	.nkeys		= ATOMIC_INIT(2),
 	.nikeys		= ATOMIC_INIT(2),
-	.uid		= GLOBAL_ROOT_UID,
+	.uid		= __GLOBAL_ROOT_UID,
 };
 
 /*
-- 
2.20.0

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-17 12:56             ` [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99 Arnd Bergmann
@ 2019-10-17 15:05               ` Linus Torvalds
  2019-10-17 15:37                 ` Kirill A. Shutemov
  0 siblings, 1 reply; 19+ messages in thread
From: Linus Torvalds @ 2019-10-17 15:05 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Kirill A . Shutemov, Andrew Morton, Sasha Levin, Andrew Pinski,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 6:02 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> Change enough of the kernel to allow building a 'defconfig'
> kernel on x86 and arm, by turning the compound literals into
> struct initializers.

Ugh. I detest this patch.

Not only is the patch itself fairly ugly, the end result is
unmaintainable, since any regular kernel developer will

 (a) not use ancient compilers

 (b) look at code like this

   static struct rb_root memtype_rbroot = __RB_ROOT;

and go "that double underscore is pointless" and fix it. And it will
build fine for the developer.

So some of the patch looks like fine cleanups and not bad at all, but
some of it really looks like it's going to be long-term annoyance,
with duplicate names and unnecessary underscores.

In general the double underscores in contexts where they don't exist
from before just look wrong.

Some of the "just remove the cast from the macro define" look good,
though. And making users do DEFINE_RB_ROOT() looks fine. It's more the
"make users have to use the internal double-underscore versions" where
I go "that's wrong".

What distros are still stuck on gcc-4?

              Linus

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [patch 014/102] llist: introduce llist_entry_safe()
  2019-10-17  5:20             ` Masahiro Yamada
  2019-10-17  8:50               ` Arnd Bergmann
@ 2019-10-17 15:17               ` Linus Torvalds
  1 sibling, 0 replies; 19+ messages in thread
From: Linus Torvalds @ 2019-10-17 15:17 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Kirill A. Shutemov, Arnd Bergmann, Andrew Morton, Sasha Levin,
	Andrew Pinski, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Wed, Oct 16, 2019 at 10:21 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> I tested -std=gnu99 for ARM with pre-built Linaro toolchains.
>
> GCC 4.9.4 was NG,
> GCC 5.3.1 was OK.

Ok, so the gcc-5.1 cut-off from my gcc git tree conversion looks to be
the right one. I wasn't sure how official/complete the git conversion
was.

> If we increase the minimal GCC version, we might end up with dropping
> more architecture.

That I wouldn't worry about. If some architecture can't get a gcc
version from the last five years, I think we _should_ drop it.

Historically, the problem has more been distro gcc versions. An
unmaintained architecture that has a compiler that is ancient I don't
much care about, but if we lose testers that use ancient distros, that
loses real coverage.

That's true even if it's just one or two actual users that upgrade
kernels - we found a real bug not that long ago because rmk used some
ancient Debian install with a new kernel. That's the kind of odd use
we want to encourage, and that matters. Hexagon? Not so much.

Although I think rmk actually had a new compiler and cross-built the
new kernel, so that likely wasn't the issue in _that_ particular case,
but in other cases it might have been.

              Linus

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-17 15:05               ` Linus Torvalds
@ 2019-10-17 15:37                 ` Kirill A. Shutemov
  2019-10-17 15:47                   ` Arnd Bergmann
  0 siblings, 1 reply; 19+ messages in thread
From: Kirill A. Shutemov @ 2019-10-17 15:37 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Arnd Bergmann, Andrew Morton, Sasha Levin, Andrew Pinski,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 08:05:28AM -0700, Linus Torvalds wrote:
> What distros are still stuck on gcc-4?

According to Distowatch:

- Debian 8.0 Jessie has 4.9.2, EOL 2020-05

- Ubuntu 14.04 LTS Trusty has 4.8.2, EOL 2019-04;

- Fedora 21 has 4.9.2, EOL 2015-12;

- OpenSUSE 42.3 has 4.8.5, EOL 2019-06;

- RHEL 7.7 has 4.8.5, EOL 2024-06;

- RHEL 6.9 has 4.4.7, EOL 2020-11;

- SUSE 12-SP4 has 4.8.6, EOL ?;

- Oracle 7.6 has 4.8.5, EOL ?;

Missed somebody?

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-17 15:37                 ` Kirill A. Shutemov
@ 2019-10-17 15:47                   ` Arnd Bergmann
  2019-10-17 15:56                     ` Linus Torvalds
  0 siblings, 1 reply; 19+ messages in thread
From: Arnd Bergmann @ 2019-10-17 15:47 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Linus Torvalds, Andrew Morton, Sasha Levin, Andrew Pinski,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 5:37 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
>
> On Thu, Oct 17, 2019 at 08:05:28AM -0700, Linus Torvalds wrote:
> > What distros are still stuck on gcc-4?
>
> According to Distowatch:
>
> - Debian 8.0 Jessie has 4.9.2, EOL 2020-05
>
> - Ubuntu 14.04 LTS Trusty has 4.8.2, EOL 2019-04;
>
> - Fedora 21 has 4.9.2, EOL 2015-12;
>
> - OpenSUSE 42.3 has 4.8.5, EOL 2019-06;
>
> - RHEL 7.7 has 4.8.5, EOL 2024-06;
>
> - RHEL 6.9 has 4.4.7, EOL 2020-11;
>
> - SUSE 12-SP4 has 4.8.6, EOL ?;

EOL 2024 as well, extended support 2027

> - Oracle 7.6 has 4.8.5, EOL ?;
>
> Missed somebody?

I started a similar list, the only other one I found was

Slackware 14.1 (no EOL announced): gcc-4.8

For the record, that seems to mean that moving to gcc-4.8
would likely not cause a lot of problems and would let us do
some other cleanups, but unfortunately would not help with
the compound literals.

     Arnd

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-17 15:47                   ` Arnd Bergmann
@ 2019-10-17 15:56                     ` Linus Torvalds
  2019-10-17 16:16                       ` Kirill A. Shutemov
  0 siblings, 1 reply; 19+ messages in thread
From: Linus Torvalds @ 2019-10-17 15:56 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Kirill A. Shutemov, Andrew Morton, Andrew Pinski,
	Masahiro Yamada, Michal Marek, mm-commits, Alexander Potapenko,
	Dmitry Vyukov, Eric Dumazet, Kostya Serebryany, Ingo Molnar,
	linux-arch, Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 8:47 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> For the record, that seems to mean that moving to gcc-4.8
> would likely not cause a lot of problems and would let us do
> some other cleanups, but unfortunately would not help with
> the compound literals.

Yeah, that's certainly less than wonderful.

That said, there's no way in hell we'll support gcc-4 for another 7
years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even
relevant any more.

But it does look like we can't just say "gcc-5.1 is ok". Darn.

           Linus

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-17 15:56                     ` Linus Torvalds
@ 2019-10-17 16:16                       ` Kirill A. Shutemov
  2019-10-18  7:56                         ` Arnd Bergmann
  0 siblings, 1 reply; 19+ messages in thread
From: Kirill A. Shutemov @ 2019-10-17 16:16 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Arnd Bergmann, Andrew Morton, Andrew Pinski, Masahiro Yamada,
	Michal Marek, mm-commits, Alexander Potapenko, Dmitry Vyukov,
	Eric Dumazet, Kostya Serebryany, Ingo Molnar, linux-arch,
	Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 08:56:50AM -0700, Linus Torvalds wrote:
> On Thu, Oct 17, 2019 at 8:47 AM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > For the record, that seems to mean that moving to gcc-4.8
> > would likely not cause a lot of problems and would let us do
> > some other cleanups, but unfortunately would not help with
> > the compound literals.
> 
> Yeah, that's certainly less than wonderful.
> 
> That said, there's no way in hell we'll support gcc-4 for another 7
> years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even
> relevant any more.
> 
> But it does look like we can't just say "gcc-5.1 is ok". Darn.

I don't read the picture the same way. All distributions have at least one
major release with GCC >= 5.

The first release with gcc >= 5:

- Debian 9 stretch has 6.3.0, released 2017-06-18;

- Ubuntu 15.10 wily has 5.2.1, released 2015-10-22;

- Fedora 24 has 6.1.1, released 2016-06-21;

- OpenSUSE 15 has 7.4.1, released 2018-05-25;

- RHEL 8.0 has 8.2.1, released 2019-05-06;

- SUSE 15 has 7.3.1, released 2018-06-25;

- Oracle 7.6.4 has 7.6.4, release 2019-07-18;

- Slackware 14.2 has 5.3.0, released 2016-07-01;

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-17 16:16                       ` Kirill A. Shutemov
@ 2019-10-18  7:56                         ` Arnd Bergmann
  2019-10-18 10:10                           ` Kirill A. Shutemov
  0 siblings, 1 reply; 19+ messages in thread
From: Arnd Bergmann @ 2019-10-18  7:56 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Linus Torvalds, Andrew Morton, Andrew Pinski, Masahiro Yamada,
	Michal Marek, mm-commits, Alexander Potapenko, Dmitry Vyukov,
	Eric Dumazet, Kostya Serebryany, Ingo Molnar, linux-arch,
	Linux Kbuild mailing list

On Thu, Oct 17, 2019 at 6:16 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
> On Thu, Oct 17, 2019 at 08:56:50AM -0700, Linus Torvalds wrote:
> > Yeah, that's certainly less than wonderful.
> >
> > That said, there's no way in hell we'll support gcc-4 for another 7
> > years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even
> > relevant any more.
> >
> > But it does look like we can't just say "gcc-5.1 is ok". Darn.
>
> I don't read the picture the same way. All distributions have at least one
> major release with GCC >= 5.
>
> The first release with gcc >= 5:
>
> - Debian 9 stretch has 6.3.0, released 2017-06-18;
>
> - Ubuntu 15.10 wily has 5.2.1, released 2015-10-22;
>
> - Fedora 24 has 6.1.1, released 2016-06-21;
>
> - OpenSUSE 15 has 7.4.1, released 2018-05-25;
>
> - RHEL 8.0 has 8.2.1, released 2019-05-06;
>
> - SUSE 15 has 7.3.1, released 2018-06-25;
>
> - Oracle 7.6.4 has 7.6.4, release 2019-07-18;
               ^^^ Oracle 8
>
> - Slackware 14.2 has 5.3.0, released 2016-07-01;

For /most/ of these I see no problem, but RHEL 7 / Centos 7 /
Oracle 7 and (to a lesser degree) SUSE 12 must have users
that want to build new kernels for some reason without a trivial
way to install new compilers.

OTOH, I agree that requiring a much more recent compiler has
some advantages that may outweigh these troubles. glibc has
moved to requiring a 3 (!) year old compiler or newer, which gives
them a reasonable time frame to make changes to gcc and then
build on requiring these changes.

      Arnd

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99
  2019-10-18  7:56                         ` Arnd Bergmann
@ 2019-10-18 10:10                           ` Kirill A. Shutemov
  0 siblings, 0 replies; 19+ messages in thread
From: Kirill A. Shutemov @ 2019-10-18 10:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linus Torvalds, Andrew Morton, Andrew Pinski, Masahiro Yamada,
	Michal Marek, mm-commits, Alexander Potapenko, Dmitry Vyukov,
	Eric Dumazet, Kostya Serebryany, Ingo Molnar, linux-arch,
	Linux Kbuild mailing list

On Fri, Oct 18, 2019 at 09:56:01AM +0200, Arnd Bergmann wrote:
> On Thu, Oct 17, 2019 at 6:16 PM Kirill A. Shutemov <kirill@shutemov.name> wrote:
> > On Thu, Oct 17, 2019 at 08:56:50AM -0700, Linus Torvalds wrote:
> > > Yeah, that's certainly less than wonderful.
> > >
> > > That said, there's no way in hell we'll support gcc-4 for another 7
> > > years (eg Suse 12-sp4), so at _some_ point the EOL dates aren't even
> > > relevant any more.
> > >
> > > But it does look like we can't just say "gcc-5.1 is ok". Darn.
> >
> > I don't read the picture the same way. All distributions have at least one
> > major release with GCC >= 5.
> >
> > The first release with gcc >= 5:
> >
> > - Debian 9 stretch has 6.3.0, released 2017-06-18;
> >
> > - Ubuntu 15.10 wily has 5.2.1, released 2015-10-22;
> >
> > - Fedora 24 has 6.1.1, released 2016-06-21;
> >
> > - OpenSUSE 15 has 7.4.1, released 2018-05-25;
> >
> > - RHEL 8.0 has 8.2.1, released 2019-05-06;
> >
> > - SUSE 15 has 7.3.1, released 2018-06-25;
> >
> > - Oracle 7.6.4 has 7.6.4, release 2019-07-18;
>                ^^^ Oracle 8
> >
> > - Slackware 14.2 has 5.3.0, released 2016-07-01;
> 
> For /most/ of these I see no problem, but RHEL 7 / Centos 7 /
> Oracle 7 and (to a lesser degree) SUSE 12 must have users
> that want to build new kernels for some reason without a trivial
> way to install new compilers.

Isn't crosstool the trivial enough? We can directly suggest using it if
compiler is too old.

BTW, we already require much newer compiler for some features. See
retpoline.

-- 
 Kirill A. Shutemov

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-10-18 10:10 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-11 20:51 [patch 014/102] llist: introduce llist_entry_safe() akpm
     [not found] ` <CA+55aFxr2uZADh--vtLYXjcLjNGO5t4jmTWEVZWbRuaJwiocug@mail.gmail.com>
     [not found]   ` <CA+55aFxQRf+U0z6mrAd5QQLWgB2A_mRjY7g9vpZHCSuyjrdhxQ@mail.gmail.com>
2019-10-16 22:23     ` Linus Torvalds
2019-10-16 22:40       ` Linus Torvalds
2019-10-16 23:13         ` Kirill A. Shutemov
2019-10-16 23:11       ` Kirill A. Shutemov
2019-10-16 23:29         ` Linus Torvalds
2019-10-17  0:16           ` Kirill A. Shutemov
2019-10-17  5:20             ` Masahiro Yamada
2019-10-17  8:50               ` Arnd Bergmann
2019-10-17 15:17               ` Linus Torvalds
2019-10-17 12:53           ` Arnd Bergmann
2019-10-17 12:56             ` [PATCH] [RFC, EXPERIMENTAL] allow building with --std=gnu99 Arnd Bergmann
2019-10-17 15:05               ` Linus Torvalds
2019-10-17 15:37                 ` Kirill A. Shutemov
2019-10-17 15:47                   ` Arnd Bergmann
2019-10-17 15:56                     ` Linus Torvalds
2019-10-17 16:16                       ` Kirill A. Shutemov
2019-10-18  7:56                         ` Arnd Bergmann
2019-10-18 10:10                           ` Kirill A. Shutemov

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.