[4/5] perf/hw_breakpoint: Enable breakpoint in modify_user_hw_breakpoint
diff mbox series

Message ID 20180810104730.3293-5-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
Currently we enable the breakpoint back only if the breakpoint
modification was successful. If it fails we can leave the
breakpoint in disabled state with attr->disabled == 0.

We can safely enable the breakpoint back for both the fail
and success paths by checking 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-79p9ttocwy2ju2s6qh25dvre@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 kernel/events/hw_breakpoint.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Oleg Nesterov Aug. 14, 2018, 10:32 a.m. UTC | #1
On 08/10, Jiri Olsa wrote:
>
> --- a/kernel/events/hw_breakpoint.c
> +++ b/kernel/events/hw_breakpoint.c
> @@ -523,13 +523,11 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
>  		perf_event_disable(bp);
>  
>  	err = modify_user_hw_breakpoint_check(bp, attr, false);
> -	if (err)
> -		return err;
>  
> -	if (!attr->disabled)
> +	if (!bp->attr.disabled)
>  		perf_event_enable(bp);
>  
> -	return 0;
> +	return err;
>  }

Acked-by: Oleg Nesterov <oleg@redhat.com>
Frederic Weisbecker Aug. 17, 2018, 2:50 p.m. UTC | #2
On Fri, Aug 10, 2018 at 12:47:29PM +0200, Jiri Olsa wrote:
> Currently we enable the breakpoint back only if the breakpoint
> modification was successful. If it fails we can leave the
> breakpoint in disabled state with attr->disabled == 0.
> 
> We can safely enable the breakpoint back for both the fail
> and success paths by checking 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-79p9ttocwy2ju2s6qh25dvre@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Frederic Weisbecker <frederic@kernel.org>

Thanks a lot!

Patch
diff mbox series

diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c
index 3e560d7609fd..d6b56180827c 100644
--- a/kernel/events/hw_breakpoint.c
+++ b/kernel/events/hw_breakpoint.c
@@ -523,13 +523,11 @@  int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att
 		perf_event_disable(bp);
 
 	err = modify_user_hw_breakpoint_check(bp, attr, false);
-	if (err)
-		return err;
 
-	if (!attr->disabled)
+	if (!bp->attr.disabled)
 		perf_event_enable(bp);
 
-	return 0;
+	return err;
 }
 EXPORT_SYMBOL_GPL(modify_user_hw_breakpoint);