Skip to contentSkip to conversation

perf: Remove a redundant check

PATCH New Alexander Shishkin 2 participants 2 messages Jun 7, 2016 – Jun 8, 2016 perf events

lore
Share & tools
lore

Alexander Shishkin

author reviewer
#0 lore raw

PATCH 1/1 perf: Remove a redundant check

There is no way to end up in _free_event() with event::pmu being NULL. The latter is initialized in event allocation path and remains set forever. In case of allocation failure, the error path doesn't use _free_event().

Having the check, however, suggests that it is possible to have a event::pmu==NULL situation in _free_event() and confuses the robots.

This patch gets rid of the check.

---
 kernel/events/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/events/core.c +2 -4
index 050a290c72..87e945d6eb 100644
@@ -3862,10 +3862,8 @@ static void _free_event(struct perf_event *event)
 	if (event->ctx)
 		put_ctx(event->ctx);
 
-	if (event->pmu) {
-		exclusive_event_destroy(event);
-		module_put(event->pmu->module);
-	}
+	exclusive_event_destroy(event);
+	module_put(event->pmu->module);
 
 	call_rcu(&event->rcu_head, free_event_rcu);
 }
Signature · 1 line
2.8.1
#1 lore raw

[tip:perf/urgent] perf/core: Remove a redundant check

perf/core: Remove a redundant check
Commit-ID:  62a92c8f553e49270a0ee391b8733da71ab0aebc
Gitweb:     http://git.kernel.org/tip/62a92c8f553e49270a0ee391b8733da71ab0aebc
Author:     Alexander Shishkin <[email protected]>
AuthorDate: Tue, 7 Jun 2016 15:44:15 +0300
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 8 Jun 2016 14:30:01 +0200

perf/core: Remove a redundant check

There is no way to end up in _free_event() with event::pmu being NULL. The latter is initialized in event allocation path and remains set forever. In case of allocation failure, the error path doesn't use _free_event().

Having the check, however, suggests that it is possible to have a event::pmu==NULL situation in _free_event() and confuses the robots.

This patch gets rid of the check.

---
 kernel/events/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/events/core.c +2 -4
index 050a290..87e945d 100644
@@ -3862,10 +3862,8 @@ static void _free_event(struct perf_event *event)
 	if (event->ctx)
 		put_ctx(event->ctx);
 
-	if (event->pmu) {
-		exclusive_event_destroy(event);
-		module_put(event->pmu->module);
-	}
+	exclusive_event_destroy(event);
+	module_put(event->pmu->module);
 
 	call_rcu(&event->rcu_head, free_event_rcu);
 }