All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	"Joel Fernandes (Google)" <joel@joelfernandes.org>,
	Robert Richter <rric@kernel.org>,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
	x86 <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [tip: core/static_call] module: Fix up module_notifier return values
Date: Tue, 01 Sep 2020 11:48:08 -0000	[thread overview]
Message-ID: <159896088863.20229.11644142375792343382.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200818135804.385360407@infradead.org>

The following commit has been merged into the core/static_call branch of tip:

Commit-ID:     0340a6b7fb767f7f296b9bacc9a215920519a644
Gitweb:        https://git.kernel.org/tip/0340a6b7fb767f7f296b9bacc9a215920519a644
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Tue, 18 Aug 2020 15:57:37 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 01 Sep 2020 09:58:03 +02:00

module: Fix up module_notifier return values

While auditing all module notifiers I noticed a whole bunch of fail
wrt the return value. Notifiers have a 'special' return semantics.

As is; NOTIFY_DONE vs NOTIFY_OK is a bit vague; but
notifier_from_errno(0) results in NOTIFY_OK and NOTIFY_DONE has a
comment that says "Don't care".

>From this I've used NOTIFY_DONE when the function completely ignores
the callback and notifier_to_error() isn't used.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: Robert Richter <rric@kernel.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lore.kernel.org/r/20200818135804.385360407@infradead.org
---
 drivers/oprofile/buffer_sync.c | 4 ++--
 kernel/trace/bpf_trace.c       | 8 ++++++--
 kernel/trace/trace.c           | 2 +-
 kernel/trace/trace_events.c    | 2 +-
 kernel/trace/trace_printk.c    | 4 ++--
 kernel/tracepoint.c            | 2 +-
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 4d76952..cc91786 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -116,7 +116,7 @@ module_load_notify(struct notifier_block *self, unsigned long val, void *data)
 {
 #ifdef CONFIG_MODULES
 	if (val != MODULE_STATE_COMING)
-		return 0;
+		return NOTIFY_DONE;
 
 	/* FIXME: should we process all CPU buffers ? */
 	mutex_lock(&buffer_mutex);
@@ -124,7 +124,7 @@ module_load_notify(struct notifier_block *self, unsigned long val, void *data)
 	add_event_entry(MODULE_LOADED_CODE);
 	mutex_unlock(&buffer_mutex);
 #endif
-	return 0;
+	return NOTIFY_OK;
 }
 
 
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index a8d4f25..2ecf789 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -2027,10 +2027,11 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
 {
 	struct bpf_trace_module *btm, *tmp;
 	struct module *mod = module;
+	int ret = 0;
 
 	if (mod->num_bpf_raw_events == 0 ||
 	    (op != MODULE_STATE_COMING && op != MODULE_STATE_GOING))
-		return 0;
+		goto out;
 
 	mutex_lock(&bpf_module_mutex);
 
@@ -2040,6 +2041,8 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
 		if (btm) {
 			btm->module = module;
 			list_add(&btm->list, &bpf_trace_modules);
+		} else {
+			ret = -ENOMEM;
 		}
 		break;
 	case MODULE_STATE_GOING:
@@ -2055,7 +2058,8 @@ static int bpf_event_notify(struct notifier_block *nb, unsigned long op,
 
 	mutex_unlock(&bpf_module_mutex);
 
-	return 0;
+out:
+	return notifier_from_errno(ret);
 }
 
 static struct notifier_block bpf_module_nb = {
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index f40d850..df49992 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -9072,7 +9072,7 @@ static int trace_module_notify(struct notifier_block *self,
 		break;
 	}
 
-	return 0;
+	return NOTIFY_OK;
 }
 
 static struct notifier_block trace_module_nb = {
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index a85effb..beebf2c 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2646,7 +2646,7 @@ static int trace_module_notify(struct notifier_block *self,
 	mutex_unlock(&trace_types_lock);
 	mutex_unlock(&event_mutex);
 
-	return 0;
+	return NOTIFY_OK;
 }
 
 static struct notifier_block trace_module_nb = {
diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
index d4e31e9..bb7783b 100644
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -96,7 +96,7 @@ static int module_trace_bprintk_format_notify(struct notifier_block *self,
 		if (val == MODULE_STATE_COMING)
 			hold_module_trace_bprintk_format(start, end);
 	}
-	return 0;
+	return NOTIFY_OK;
 }
 
 /*
@@ -174,7 +174,7 @@ __init static int
 module_trace_bprintk_format_notify(struct notifier_block *self,
 		unsigned long val, void *data)
 {
-	return 0;
+	return NOTIFY_OK;
 }
 static inline const char **
 find_next_mod_format(int start_index, void *v, const char **fmt, loff_t *pos)
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 73956ea..8e05ed2 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -521,7 +521,7 @@ static int tracepoint_module_notify(struct notifier_block *self,
 	case MODULE_STATE_UNFORMED:
 		break;
 	}
-	return ret;
+	return notifier_from_errno(ret);
 }
 
 static struct notifier_block tracepoint_module_nb = {

  reply	other threads:[~2020-09-01 12:01 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 13:57 [PATCH v7 00/18] Add static_call Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 01/18] notifier: Fix broken error handling pattern Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 02/18] module: Fix up module_notifier return values Peter Zijlstra
2020-09-01 11:48   ` tip-bot2 for Peter Zijlstra [this message]
2020-08-18 13:57 ` [PATCH v7 03/18] module: Properly propagate MODULE_STATE_COMING failure Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 04/18] jump_label,module: Fix module lifetime for __jump_label_mod_text_reserved Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] jump_label,module: Fix module lifetime for __jump_label_mod_text_reserved() tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 05/18] compiler.h: Make __ADDRESSABLE() symbol truly unique Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Josh Poimboeuf
2020-08-18 13:57 ` [PATCH v7 06/18] static_call: Add basic static call infrastructure Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Josh Poimboeuf
2020-08-18 13:57 ` [PATCH v7 07/18] static_call: Add inline " Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Josh Poimboeuf
2020-08-18 13:57 ` [PATCH v7 08/18] static_call: Avoid kprobes on inline static_call()s Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-09-02  1:35   ` [PATCH v7 08/18] " Masami Hiramatsu
2020-09-02  9:48     ` peterz
2020-09-02 10:16       ` Masami Hiramatsu
2020-09-02 12:01         ` peterz
2020-08-18 13:57 ` [PATCH v7 09/18] x86/static_call: Add out-of-line static call implementation Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Josh Poimboeuf
2020-08-18 13:57 ` [PATCH v7 10/18] x86/static_call: Add inline static call implementation for x86-64 Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Josh Poimboeuf
2020-08-18 13:57 ` [PATCH v7 11/18] static_call: Simple self-test Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] static_call: Add simple self-test for static calls tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 12/18] x86/alternatives: Teach text_poke_bp() to emulate RET Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 13/18] static_call: Add static_call_cond() Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 14/18] static_call: Handle tail-calls Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 15/18] static_call: Add some validation Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 16/18] static_call: Allow early init Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Peter Zijlstra
2020-08-18 13:57 ` [PATCH v7 17/18] tracepoint: Optimize using static_call() Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for Steven Rostedt (VMware)
2020-08-18 13:57 ` [PATCH v7 18/18] x86/perf, static_call: Optimize x86_pmu methods Peter Zijlstra
2020-09-01 11:48   ` [tip: core/static_call] " tip-bot2 for 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=159896088863.20229.11644142375792343382.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rric@kernel.org \
    --cc=x86@kernel.org \
    /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 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.