[5/5] perf/hw_breakpoint: Simplify breakpoint enable in perf_event_modify_breakpoint
diff mbox series

Message ID 20180810104730.3293-6-jolsa@kernel.org
State New
Headers show
Series
  • perf/hw_breakpoint: Fix breakpoint modify
Related show

Commit Message

Jiri Olsa Aug. 10, 2018, 10:47 a.m. UTC
We can safely enable the breakpoint back for both the fail
and success paths by checking only the bp->attr.disabled,
which either holds the new 'requested' disabled state or
the original breakpoint state.

Suggested-by: Oleg Nesterov <oleg@redhat.com>
Link: http://lkml.kernel.org/n/tip-vo1jm1u2nar6lj6hnd9g73ug@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 kernel/events/core.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Oleg Nesterov Aug. 14, 2018, 10:32 a.m. UTC | #1
On 08/10, Jiri Olsa wrote:
>
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -2867,16 +2867,11 @@ static int perf_event_modify_breakpoint(struct perf_event *bp,
>  	_perf_event_disable(bp);
>  
>  	err = modify_user_hw_breakpoint_check(bp, attr, true);
> -	if (err) {
> -		if (!bp->attr.disabled)
> -			_perf_event_enable(bp);
>  
> -		return err;
> -	}
> -
> -	if (!attr->disabled)
> +	if (!bp->attr.disabled)
>  		_perf_event_enable(bp);
> -	return 0;
> +
> +	return err;
>  }

Acked-by: Oleg Nesterov <oleg@redhat.com>

Patch
diff mbox series

diff --git a/kernel/events/core.c b/kernel/events/core.c
index f6ea33a9f904..22ede28ec07d 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -2867,16 +2867,11 @@  static int perf_event_modify_breakpoint(struct perf_event *bp,
 	_perf_event_disable(bp);
 
 	err = modify_user_hw_breakpoint_check(bp, attr, true);
-	if (err) {
-		if (!bp->attr.disabled)
-			_perf_event_enable(bp);
 
-		return err;
-	}
-
-	if (!attr->disabled)
+	if (!bp->attr.disabled)
 		_perf_event_enable(bp);
-	return 0;
+
+	return err;
 }
 
 static int perf_event_modify_attr(struct perf_event *event,