lkml.org 
[lkml]   [2018]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 1/6] jump_label: Add for_each_label_entry helper
Date
This patch adds the helper:
for_each_label_entry(key, entry, stop)

For the "for each jump label entry" for defined as:
for (; (entry < stop) && (jump_entry_key(entry) == key); entry++)

Simplifying the reading and usage.

Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Pavel Tatashin <pasha.tatashin@oracle.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Zhou Chengming <zhouchengming1@huawei.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Chris von Recklinghausen <crecklin@redhat.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Scott Wood <swood@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Clark Williams <williams@redhat.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
---
include/linux/jump_label.h | 3 +++
kernel/jump_label.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h
index 1a0b6f17a5d6..cd3bed880ca0 100644
--- a/include/linux/jump_label.h
+++ b/include/linux/jump_label.h
@@ -170,6 +170,9 @@ extern void static_key_disable(struct static_key *key);
extern void static_key_enable_cpuslocked(struct static_key *key);
extern void static_key_disable_cpuslocked(struct static_key *key);

+#define for_each_label_entry(key, entry, stop) \
+ for (; (entry < stop) && (jump_entry_key(entry) == key); entry++)
+
/*
* We should be using ATOMIC_INIT() for initializing .enabled, but
* the inclusion of atomic.h is problematic for inclusion of jump_label.h
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 2e62503bea0d..e853916a3b46 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -365,7 +365,7 @@ static void __jump_label_update(struct static_key *key,
struct jump_entry *entry,
struct jump_entry *stop)
{
- for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) {
+ for_each_label_entry(key, entry, stop) {
/*
* An entry->code of 0 indicates an entry which has been
* disabled because it was in an init text area.
--
2.17.1
\
 
 \ /
  Last update: 2018-10-08 14:54    [W:0.097 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site