From: Michal Hocko <mhocko@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Mel Gorman <mgorman@suse.de>,
Frederic Weisbecker <fweisbecker@suse.de>,
Ingo Molnar <mingo@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
Michal Hocko <mhocko@suse.com>
Subject: [RFC PATCH v2 1/5] jump_label: split out declaration parts into its own headers
Date: Fri, 9 Oct 2020 14:29:22 +0200 [thread overview]
Message-ID: <20201009122926.29962-2-mhocko@kernel.org> (raw)
In-Reply-To: <20201009122926.29962-1-mhocko@kernel.org>
From: Michal Hocko <mhocko@suse.com>
Follow up patch would like to add a static key into kernel.h and that
requires a declaration of the key in the same file. Including
jump_label.h into kernel.h is not possible due to headers dependencies.
Separate parts needed for declaration into its own header which doesn't
depend on any other header file. kernel.h can include jump_abel_type.h.
Signed-off-by: Michal Hocko <mhocko@suse.com>
---
include/linux/jump_label.h | 44 +----------------------------
include/linux/jump_label_type.h | 49 +++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 43 deletions(-)
create mode 100644 include/linux/jump_label_type.h
diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 32809624d422..bd0d846d0bde 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -75,6 +75,7 @@
#include <linux/types.h>
#include <linux/compiler.h>
+#include <linux/jump_label_type.h>
extern bool static_key_initialized;
@@ -82,35 +83,6 @@ extern bool static_key_initialized;
"%s(): static key '%pS' used before call to jump_label_init()", \
__func__, (key))
-#ifdef CONFIG_JUMP_LABEL
-
-struct static_key {
- atomic_t enabled;
-/*
- * Note:
- * To make anonymous unions work with old compilers, the static
- * initialization of them requires brackets. This creates a dependency
- * on the order of the struct with the initializers. If any fields
- * are added, STATIC_KEY_INIT_TRUE and STATIC_KEY_INIT_FALSE may need
- * to be modified.
- *
- * bit 0 => 1 if key is initially true
- * 0 if initially false
- * bit 1 => 1 if points to struct static_key_mod
- * 0 if points to struct jump_entry
- */
- union {
- unsigned long type;
- struct jump_entry *entries;
- struct static_key_mod *next;
- };
-};
-
-#else
-struct static_key {
- atomic_t enabled;
-};
-#endif /* CONFIG_JUMP_LABEL */
#endif /* __ASSEMBLY__ */
#ifdef CONFIG_JUMP_LABEL
@@ -343,14 +315,6 @@ static inline void static_key_disable(struct static_key *key)
* All the below code is macros in order to play type games.
*/
-struct static_key_true {
- struct static_key key;
-};
-
-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, }
@@ -360,18 +324,12 @@ struct static_key_false {
#define DEFINE_STATIC_KEY_TRUE_RO(name) \
struct static_key_true name __ro_after_init = STATIC_KEY_TRUE_INIT
-#define DECLARE_STATIC_KEY_TRUE(name) \
- extern struct static_key_true name
-
#define DEFINE_STATIC_KEY_FALSE(name) \
struct static_key_false name = STATIC_KEY_FALSE_INIT
#define DEFINE_STATIC_KEY_FALSE_RO(name) \
struct static_key_false name __ro_after_init = STATIC_KEY_FALSE_INIT
-#define DECLARE_STATIC_KEY_FALSE(name) \
- extern struct static_key_false name
-
#define DEFINE_STATIC_KEY_ARRAY_TRUE(name, count) \
struct static_key_true name[count] = { \
[0 ... (count) - 1] = STATIC_KEY_TRUE_INIT, \
diff --git a/include/linux/jump_label_type.h b/include/linux/jump_label_type.h
new file mode 100644
index 000000000000..37cb02c12f35
--- /dev/null
+++ b/include/linux/jump_label_type.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_JUMP_LABEL_TYPE_H
+#define _LINUX_JUMP_LABEL_TYPE_H
+
+#ifdef CONFIG_JUMP_LABEL
+
+struct static_key {
+ atomic_t enabled;
+/*
+ * Note:
+ * To make anonymous unions work with old compilers, the static
+ * initialization of them requires brackets. This creates a dependency
+ * on the order of the struct with the initializers. If any fields
+ * are added, STATIC_KEY_INIT_TRUE and STATIC_KEY_INIT_FALSE may need
+ * to be modified.
+ *
+ * bit 0 => 1 if key is initially true
+ * 0 if initially false
+ * bit 1 => 1 if points to struct static_key_mod
+ * 0 if points to struct jump_entry
+ */
+ union {
+ unsigned long type;
+ struct jump_entry *entries;
+ struct static_key_mod *next;
+ };
+};
+
+#else
+struct static_key {
+ atomic_t enabled;
+};
+#endif /* CONFIG_JUMP_LABEL */
+
+struct static_key_true {
+ struct static_key key;
+};
+
+struct static_key_false {
+ struct static_key key;
+};
+
+#define DECLARE_STATIC_KEY_TRUE(name) \
+ extern struct static_key_true name
+
+#define DECLARE_STATIC_KEY_FALSE(name) \
+ extern struct static_key_false name
+
+#endif /* _LINUX_JUMP_LABEL_TYPE_H */
--
2.28.0
next prev parent reply other threads:[~2020-10-09 12:30 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-07 12:04 [RFC PATCH] kernel: allow to configure PREEMPT_NONE, PREEMPT_VOLUNTARY on kernel command line Michal Hocko
2020-10-07 12:19 ` Peter Zijlstra
2020-10-07 12:29 ` Michal Hocko
2020-10-07 13:01 ` Mel Gorman
2020-10-07 12:21 ` Peter Zijlstra
2020-10-07 12:35 ` Michal Hocko
2020-10-09 9:47 ` Peter Zijlstra
2020-10-09 10:14 ` Michal Hocko
2020-10-09 10:20 ` Peter Zijlstra
2020-10-09 10:48 ` Michal Hocko
2020-10-09 11:17 ` Michal Hocko
2020-10-09 11:26 ` Michal Hocko
2020-10-09 11:39 ` Peter Zijlstra
2020-10-09 9:12 ` Michal Hocko
2020-10-09 9:42 ` Peter Zijlstra
2020-10-09 10:10 ` Michal Hocko
2020-10-09 10:14 ` Peter Zijlstra
2020-10-09 10:37 ` Michal Hocko
2020-10-09 11:42 ` Peter Zijlstra
2020-10-09 12:29 ` [RFC PATCH v2 0/5] allow overriding default preempt mode from " Michal Hocko
2020-10-09 12:29 ` Michal Hocko [this message]
2020-10-09 12:29 ` [RFC PATCH v2 2/5] kernel: allow to configure PREEMPT_NONE, PREEMPT_VOLUNTARY on kernel " Michal Hocko
2020-10-09 12:29 ` [RFC PATCH v2 3/5] kernel: ARCH_NO_PREEMPT shouldn't exclude PREEMPT_VOLUNTARY Michal Hocko
2020-10-09 12:29 ` [RFC PATCH v2 4/5] kernel: introduce CONFIG_PREEMPT_DYNAMIC Michal Hocko
2020-10-09 12:29 ` [RFC PATCH v2 5/5] kernel: drop PREEMPT_NONE compile time option Michal Hocko
2020-10-09 12:50 ` [RFC PATCH v2 0/5] allow overriding default preempt mode from command line Peter Zijlstra
2020-10-09 13:03 ` Michal Hocko
2020-10-09 13:22 ` Peter Zijlstra
2020-10-09 17:45 ` Peter Zijlstra
2020-10-27 12:22 ` Frederic Weisbecker
2020-10-27 12:28 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201009122926.29962-2-mhocko@kernel.org \
--to=mhocko@kernel.org \
--cc=fweisbecker@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox