* [PATCH] locking: Detect includes rwlock.h outside of spinlock.h
@ 2022-08-25 16:08 Sebastian Andrzej Siewior
2022-09-08 6:37 ` Sebastian Andrzej Siewior
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-08-25 16:08 UTC (permalink / raw)
To: linux-kernel
Cc: Boqun Feng, Ingo Molnar, Michael S. Tsirkin, Peter Zijlstra,
Thomas Gleixner, Waiman Long, Will Deacon
From: Michael S. Tsirkin <mst@redhat.com>
The check for __LINUX_SPINLOCK_H within rwlock.h (and other files)
detects the direct include of the header file if it is at the very
beginning of the include section.
If it is listed later then chances are high that spinlock.h was already
included (including rwlock.h) and the additional listing of rwlock.h
will not cause any failure.
On PREEMPT_RT this additional rwlock.h will lead to compile failures
since it uses a different rwlock implementation.
Add __LINUX_INSIDE_SPINLOCK_H to spinlock.h and check for this instead
of __LINUX_SPINLOCK_H to detect wrong includes. This will help detect
direct includes of rwlock.h with without PREEMPT_RT enabled.
[ bigeasy: add remaining __LINUX_SPINLOCK_H user and rewrite
commit description. ]
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
This is to avoid patches like
https://lkml.kernel.org/r/20220816074816.173227-1-bigeasy@linutronix.de
in the future which is not the first I sent…
include/linux/rwlock.h | 2 +-
include/linux/spinlock.h | 2 ++
include/linux/spinlock_api_smp.h | 2 +-
include/linux/spinlock_api_up.h | 2 +-
include/linux/spinlock_rt.h | 2 +-
include/linux/spinlock_up.h | 2 +-
6 files changed, 7 insertions(+), 5 deletions(-)
--- a/include/linux/rwlock.h
+++ b/include/linux/rwlock.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_RWLOCK_H
#define __LINUX_RWLOCK_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_SPINLOCK_H
#define __LINUX_SPINLOCK_H
+#define __LINUX_INSIDE_SPINLOCK_H
/*
* include/linux/spinlock.h - generic spinlock/rwlock declarations
@@ -492,4 +493,5 @@ int __alloc_bucket_spinlocks(spinlock_t
void free_bucket_spinlocks(spinlock_t *locks);
+#undef __LINUX_INSIDE_SPINLOCK_H
#endif /* __LINUX_SPINLOCK_H */
--- a/include/linux/spinlock_api_smp.h
+++ b/include/linux/spinlock_api_smp.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_SPINLOCK_API_SMP_H
#define __LINUX_SPINLOCK_API_SMP_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
--- a/include/linux/spinlock_api_up.h
+++ b/include/linux/spinlock_api_up.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_SPINLOCK_API_UP_H
#define __LINUX_SPINLOCK_API_UP_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
--- a/include/linux/spinlock_rt.h
+++ b/include/linux/spinlock_rt.h
@@ -2,7 +2,7 @@
#ifndef __LINUX_SPINLOCK_RT_H
#define __LINUX_SPINLOCK_RT_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
#error Do not include directly. Use spinlock.h
#endif
--- a/include/linux/spinlock_up.h
+++ b/include/linux/spinlock_up.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_SPINLOCK_UP_H
#define __LINUX_SPINLOCK_UP_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking: Detect includes rwlock.h outside of spinlock.h
2022-08-25 16:08 [PATCH] locking: Detect includes rwlock.h outside of spinlock.h Sebastian Andrzej Siewior
@ 2022-09-08 6:37 ` Sebastian Andrzej Siewior
2022-09-08 6:54 ` Michael S. Tsirkin
2022-09-08 8:47 ` Peter Zijlstra
2022-09-15 14:23 ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2 siblings, 1 reply; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-09-08 6:37 UTC (permalink / raw)
To: Boqun Feng, Ingo Molnar, Michael S. Tsirkin, Peter Zijlstra,
Thomas Gleixner, Waiman Long, Will Deacon
Cc: linux-kernel
On 2022-08-25 18:08:59 [+0200], To linux-kernel@vger.kernel.org wrote:
> From: Michael S. Tsirkin <mst@redhat.com>
>
> The check for __LINUX_SPINLOCK_H within rwlock.h (and other files)
> detects the direct include of the header file if it is at the very
> beginning of the include section.
> If it is listed later then chances are high that spinlock.h was already
> included (including rwlock.h) and the additional listing of rwlock.h
> will not cause any failure.
>
> On PREEMPT_RT this additional rwlock.h will lead to compile failures
> since it uses a different rwlock implementation.
>
> Add __LINUX_INSIDE_SPINLOCK_H to spinlock.h and check for this instead
> of __LINUX_SPINLOCK_H to detect wrong includes. This will help detect
> direct includes of rwlock.h with without PREEMPT_RT enabled.
>
> [ bigeasy: add remaining __LINUX_SPINLOCK_H user and rewrite
> commit description. ]
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>
> This is to avoid patches like
> https://lkml.kernel.org/r/20220816074816.173227-1-bigeasy@linutronix.de
>
> in the future which is not the first I sent…
polite *ping*
Sebastian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking: Detect includes rwlock.h outside of spinlock.h
2022-09-08 6:37 ` Sebastian Andrzej Siewior
@ 2022-09-08 6:54 ` Michael S. Tsirkin
2022-09-08 6:57 ` Sebastian Andrzej Siewior
0 siblings, 1 reply; 6+ messages in thread
From: Michael S. Tsirkin @ 2022-09-08 6:54 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: Boqun Feng, Ingo Molnar, Peter Zijlstra, Thomas Gleixner,
Waiman Long, Will Deacon, linux-kernel
On Thu, Sep 08, 2022 at 08:37:38AM +0200, Sebastian Andrzej Siewior wrote:
> On 2022-08-25 18:08:59 [+0200], To linux-kernel@vger.kernel.org wrote:
> > From: Michael S. Tsirkin <mst@redhat.com>
> >
> > The check for __LINUX_SPINLOCK_H within rwlock.h (and other files)
> > detects the direct include of the header file if it is at the very
> > beginning of the include section.
> > If it is listed later then chances are high that spinlock.h was already
> > included (including rwlock.h) and the additional listing of rwlock.h
> > will not cause any failure.
> >
> > On PREEMPT_RT this additional rwlock.h will lead to compile failures
> > since it uses a different rwlock implementation.
> >
> > Add __LINUX_INSIDE_SPINLOCK_H to spinlock.h and check for this instead
> > of __LINUX_SPINLOCK_H to detect wrong includes. This will help detect
> > direct includes of rwlock.h with without PREEMPT_RT enabled.
> >
> > [ bigeasy: add remaining __LINUX_SPINLOCK_H user and rewrite
> > commit description. ]
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > ---
> >
> > This is to avoid patches like
> > https://lkml.kernel.org/r/20220816074816.173227-1-bigeasy@linutronix.de
> >
> > in the future which is not the first I sent…
>
> polite *ping*
>
> Sebastian
This needs to be merged by locking maintainers IMHO, not by me.
--
MST
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking: Detect includes rwlock.h outside of spinlock.h
2022-09-08 6:54 ` Michael S. Tsirkin
@ 2022-09-08 6:57 ` Sebastian Andrzej Siewior
0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2022-09-08 6:57 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Boqun Feng, Ingo Molnar, Peter Zijlstra, Thomas Gleixner,
Waiman Long, Will Deacon, linux-kernel
On 2022-09-08 02:54:33 [-0400], Michael S. Tsirkin wrote:
>
> This needs to be merged by locking maintainers IMHO, not by me.
I'm aware. This was directed towards will/peterz :)
Sebastian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking: Detect includes rwlock.h outside of spinlock.h
2022-08-25 16:08 [PATCH] locking: Detect includes rwlock.h outside of spinlock.h Sebastian Andrzej Siewior
2022-09-08 6:37 ` Sebastian Andrzej Siewior
@ 2022-09-08 8:47 ` Peter Zijlstra
2022-09-15 14:23 ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
2 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2022-09-08 8:47 UTC (permalink / raw)
To: Sebastian Andrzej Siewior
Cc: linux-kernel, Boqun Feng, Ingo Molnar, Michael S. Tsirkin,
Thomas Gleixner, Waiman Long, Will Deacon
On Thu, Aug 25, 2022 at 06:08:56PM +0200, Sebastian Andrzej Siewior wrote:
> From: Michael S. Tsirkin <mst@redhat.com>
>
> The check for __LINUX_SPINLOCK_H within rwlock.h (and other files)
> detects the direct include of the header file if it is at the very
> beginning of the include section.
> If it is listed later then chances are high that spinlock.h was already
> included (including rwlock.h) and the additional listing of rwlock.h
> will not cause any failure.
>
> On PREEMPT_RT this additional rwlock.h will lead to compile failures
> since it uses a different rwlock implementation.
>
> Add __LINUX_INSIDE_SPINLOCK_H to spinlock.h and check for this instead
> of __LINUX_SPINLOCK_H to detect wrong includes. This will help detect
> direct includes of rwlock.h with without PREEMPT_RT enabled.
>
> [ bigeasy: add remaining __LINUX_SPINLOCK_H user and rewrite
> commit description. ]
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tip: locking/core] locking: Detect includes rwlock.h outside of spinlock.h
2022-08-25 16:08 [PATCH] locking: Detect includes rwlock.h outside of spinlock.h Sebastian Andrzej Siewior
2022-09-08 6:37 ` Sebastian Andrzej Siewior
2022-09-08 8:47 ` Peter Zijlstra
@ 2022-09-15 14:23 ` tip-bot2 for Sebastian Andrzej Siewior
2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Sebastian Andrzej Siewior @ 2022-09-15 14:23 UTC (permalink / raw)
To: linux-tip-commits
Cc: Michael S. Tsirkin, Sebastian Andrzej Siewior,
Peter Zijlstra (Intel),
x86, linux-kernel
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 2747b93ebbede2af2d7bb088b9ddae3193ceede8
Gitweb: https://git.kernel.org/tip/2747b93ebbede2af2d7bb088b9ddae3193ceede8
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate: Thu, 25 Aug 2022 18:08:56 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 15 Sep 2022 16:14:02 +02:00
locking: Detect includes rwlock.h outside of spinlock.h
From: Michael S. Tsirkin <mst@redhat.com>
The check for __LINUX_SPINLOCK_H within rwlock.h (and other files)
detects the direct include of the header file if it is at the very
beginning of the include section.
If it is listed later then chances are high that spinlock.h was already
included (including rwlock.h) and the additional listing of rwlock.h
will not cause any failure.
On PREEMPT_RT this additional rwlock.h will lead to compile failures
since it uses a different rwlock implementation.
Add __LINUX_INSIDE_SPINLOCK_H to spinlock.h and check for this instead
of __LINUX_SPINLOCK_H to detect wrong includes. This will help detect
direct includes of rwlock.h with without PREEMPT_RT enabled.
[ bigeasy: add remaining __LINUX_SPINLOCK_H user and rewrite
commit description. ]
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/YweemHxJx7O8rjBx@linutronix.de
---
include/linux/rwlock.h | 2 +-
include/linux/spinlock.h | 2 ++
include/linux/spinlock_api_smp.h | 2 +-
include/linux/spinlock_api_up.h | 2 +-
include/linux/spinlock_rt.h | 2 +-
include/linux/spinlock_up.h | 2 +-
6 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/include/linux/rwlock.h b/include/linux/rwlock.h
index 8f416c5..c0ef596 100644
--- a/include/linux/rwlock.h
+++ b/include/linux/rwlock.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_RWLOCK_H
#define __LINUX_RWLOCK_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 5c0c517..1341f7d 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_SPINLOCK_H
#define __LINUX_SPINLOCK_H
+#define __LINUX_INSIDE_SPINLOCK_H
/*
* include/linux/spinlock.h - generic spinlock/rwlock declarations
@@ -492,4 +493,5 @@ int __alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask,
void free_bucket_spinlocks(spinlock_t *locks);
+#undef __LINUX_INSIDE_SPINLOCK_H
#endif /* __LINUX_SPINLOCK_H */
diff --git a/include/linux/spinlock_api_smp.h b/include/linux/spinlock_api_smp.h
index 51fa0da..89eb6f4 100644
--- a/include/linux/spinlock_api_smp.h
+++ b/include/linux/spinlock_api_smp.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_SPINLOCK_API_SMP_H
#define __LINUX_SPINLOCK_API_SMP_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
diff --git a/include/linux/spinlock_api_up.h b/include/linux/spinlock_api_up.h
index b8ba00c..819aeba 100644
--- a/include/linux/spinlock_api_up.h
+++ b/include/linux/spinlock_api_up.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_SPINLOCK_API_UP_H
#define __LINUX_SPINLOCK_API_UP_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h
index 835aeda..61c49b1 100644
--- a/include/linux/spinlock_rt.h
+++ b/include/linux/spinlock_rt.h
@@ -2,7 +2,7 @@
#ifndef __LINUX_SPINLOCK_RT_H
#define __LINUX_SPINLOCK_RT_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
#error Do not include directly. Use spinlock.h
#endif
diff --git a/include/linux/spinlock_up.h b/include/linux/spinlock_up.h
index 1652107..c872042 100644
--- a/include/linux/spinlock_up.h
+++ b/include/linux/spinlock_up.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_SPINLOCK_UP_H
#define __LINUX_SPINLOCK_UP_H
-#ifndef __LINUX_SPINLOCK_H
+#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-15 14:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25 16:08 [PATCH] locking: Detect includes rwlock.h outside of spinlock.h Sebastian Andrzej Siewior
2022-09-08 6:37 ` Sebastian Andrzej Siewior
2022-09-08 6:54 ` Michael S. Tsirkin
2022-09-08 6:57 ` Sebastian Andrzej Siewior
2022-09-08 8:47 ` Peter Zijlstra
2022-09-15 14:23 ` [tip: locking/core] " tip-bot2 for Sebastian Andrzej Siewior
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.