Skip to contentSkip to conversation

ARM: hw_breakpoint: Do not directly check the event's overflow_handler hook

PATCH In review Zhen Lei 2 participants 6 messages Feb 7, 2021 – Feb 18, 2021

Subsystems (2)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 ARM: hw_breakpoint: Do not directly check the event's overflow_handler hook

The commit 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()") set a default event->overflow_handler in perf_event_alloc(), and replace the check event->overflow_handler with is_default_overflow_handler(), but one is missing.

Currently, the bp->overflow_handler can not be NULL. As a result, enable_single_step() is always not invoked.

Fixes 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()")
Cc Wang Nan <[email protected]>
---
 arch/arm/kernel/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/hw_breakpoint.c +1 -1
index 08660ae9dcbce1c..b1423fb130ea4a0 100644
@@ -886,7 +886,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
 			info->trigger = addr;
 			pr_debug("breakpoint fired: address = 0x%x\n", addr);
 			perf_bp_event(bp, regs);
-			if (!bp->overflow_handler)
+			if (is_default_overflow_handler(bp))
 				enable_single_step(bp, addr);
 			goto unlock;
 		}
Signature · 8 lines
1.8.3



_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 7 lines · Zhen Lei

The commit 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()") set a default event->overflow_handler in perf_event_alloc(), and replace the check event->overflow_handler with is_default_overflow_handler(), but one is missing.

Currently, the bp->overflow_handler can not be NULL. As a result, enable_single_step() is always not invoked.

Our test case use "perf record -e mem:$TEST_LOC_ADDR:x -p $TEST_PID sleep 10" to track the invocation of a test function, the entry address of the function is $TEST_LOC_ADDR. This function was called only once. Therefore, the sampling result of perf should be one, as follow:
[ perf record: Captured and wrote 0.001 MB perf.data (1 samples) ]

But it's actually infinite.
[ perf record: Captured and wrote 135.426 MB perf.data (2068004 samples) ]

If sleep 10 is not specified, OOM will be reported.

Quoted 14 lines
Fixes 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()")
Cc Wang Nan <[email protected]>
---
 arch/arm/kernel/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/hw_breakpoint.c +0 -0
index 08660ae9dcbce1c..b1423fb130ea4a0 100644

arch/arm/kernel/hw_breakpoint.c static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs) · line 892

Quoted 8 lines
arch/arm/kernel/hw_breakpoint.c +1 -1
@@ -886,7 +886,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
 			info->trigger = addr;
 			pr_debug("breakpoint fired: address = 0x%x\n", addr);
 			perf_bp_event(bp, regs);
-			if (!bp->overflow_handler)
+			if (is_default_overflow_handler(bp))
 				enable_single_step(bp, addr);
 			goto unlock;
 		}

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Zhen Lei
Quoted 20 lines · Zhen Lei

The commit 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()") set a default event->overflow_handler in perf_event_alloc(), and replace the check event->overflow_handler with is_default_overflow_handler(), but one is missing.

Currently, the bp->overflow_handler can not be NULL. As a result, enable_single_step() is always not invoked.

Fixes 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()")
Cc Wang Nan <[email protected]>
---
 arch/arm/kernel/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/hw_breakpoint.c +0 -0
index 08660ae9dcbce1c..b1423fb130ea4a0 100644

arch/arm/kernel/hw_breakpoint.c static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs) · line 892

Quoted 8 lines
arch/arm/kernel/hw_breakpoint.c +1 -1
@@ -886,7 +886,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
 			info->trigger = addr;
 			pr_debug("breakpoint fired: address = 0x%x\n", addr);
 			perf_bp_event(bp, regs);
-			if (!bp->overflow_handler)
+			if (is_default_overflow_handler(bp))
 				enable_single_step(bp, addr);
 			goto unlock;
 		}

Please can you put this into the patch tracker?

https://www.arm.linux.org.uk/developer/patches/

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
Quoted 32 lines · Will Deacon
Quoted 20 lines · Zhen Lei

The commit 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()") set a default event->overflow_handler in perf_event_alloc(), and replace the check event->overflow_handler with is_default_overflow_handler(), but one is missing.

Currently, the bp->overflow_handler can not be NULL. As a result, enable_single_step() is always not invoked.

Fixes 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()")
Cc Wang Nan <[email protected]>
---
 arch/arm/kernel/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/hw_breakpoint.c +0 -0
index 08660ae9dcbce1c..b1423fb130ea4a0 100644

arch/arm/kernel/hw_breakpoint.c static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs) · line 892

Quoted 8 lines
arch/arm/kernel/hw_breakpoint.c +1 -1
@@ -886,7 +886,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
 			info->trigger = addr;
 			pr_debug("breakpoint fired: address = 0x%x\n", addr);
 			perf_bp_event(bp, regs);
-			if (!bp->overflow_handler)
+			if (is_default_overflow_handler(bp))
 				enable_single_step(bp, addr);
 			goto unlock;
 		}
Quoted 3 lines

Please can you put this into the patch tracker?

https://www.arm.linux.org.uk/developer/patches/

I've added it.

https://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=9064/1

Quoted 5 lines

Will

.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#4 lore raw
Quoted 35 lines · Leizhen (ThunderTown)
Quoted 32 lines · Will Deacon
Quoted 20 lines · Zhen Lei

The commit 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()") set a default event->overflow_handler in perf_event_alloc(), and replace the check event->overflow_handler with is_default_overflow_handler(), but one is missing.

Currently, the bp->overflow_handler can not be NULL. As a result, enable_single_step() is always not invoked.

Fixes 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()")
Cc Wang Nan <[email protected]>
---
 arch/arm/kernel/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/hw_breakpoint.c +0 -0
index 08660ae9dcbce1c..b1423fb130ea4a0 100644

arch/arm/kernel/hw_breakpoint.c static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs) · line 892

Quoted 8 lines
arch/arm/kernel/hw_breakpoint.c +1 -1
@@ -886,7 +886,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
 			info->trigger = addr;
 			pr_debug("breakpoint fired: address = 0x%x\n", addr);
 			perf_bp_event(bp, regs);
-			if (!bp->overflow_handler)
+			if (is_default_overflow_handler(bp))
 				enable_single_step(bp, addr);
 			goto unlock;
 		}
Quoted 7 lines
Quoted 3 lines

Please can you put this into the patch tracker?

https://www.arm.linux.org.uk/developer/patches/

I've added it.

https://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=9064/1

Thanks, although you forgot to add my Ack!

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw
Quoted 38 lines · Will Deacon
Quoted 37 lines · Leizhen (ThunderTown)
Quoted 34 lines · Will Deacon
Quoted 20 lines · Zhen Lei

The commit 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()") set a default event->overflow_handler in perf_event_alloc(), and replace the check event->overflow_handler with is_default_overflow_handler(), but one is missing.

Currently, the bp->overflow_handler can not be NULL. As a result, enable_single_step() is always not invoked.

Fixes 1879445dfa7b ("perf/core: Set event's default ::overflow_handler()")
Cc Wang Nan <[email protected]>
---
 arch/arm/kernel/hw_breakpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/hw_breakpoint.c +0 -0
index 08660ae9dcbce1c..b1423fb130ea4a0 100644

arch/arm/kernel/hw_breakpoint.c static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs) · line 892

Quoted 8 lines
arch/arm/kernel/hw_breakpoint.c +1 -1
@@ -886,7 +886,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
 			info->trigger = addr;
 			pr_debug("breakpoint fired: address = 0x%x\n", addr);
 			perf_bp_event(bp, regs);
-			if (!bp->overflow_handler)
+			if (is_default_overflow_handler(bp))
 				enable_single_step(bp, addr);
 			goto unlock;
 		}

Please can you put this into the patch tracker?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

https://www.arm.linux.org.uk/developer/patches/

I've added it.

https://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=9064/1

Thanks, although you forgot to add my Ack!

Sorry, the first time I operated this web, the patch in the attachment can no longer be updated. I just mentioned it in the new "Node".

Quoted 5 lines

Will

.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel