Skip to content

x86, ptrace, bts, hw-branch-tracer: fixes and cleanups

Markus Metzger lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 of 21 patches 18 repliesIn review

15 of 21 patches are in this archive. The cover letter announces 21.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21x86, bts: fix race when bts tracer is removedarch/x86/kernel/ds.c+17 -73 replies
2/21sched: add task_is_running() fucntion to sched.hinclude/linux/sched.h kernel/sched.c+17 -00 replies
3/21x86, bts: wait until traced task has been scheduled outarch/x86/kernel/ds.c+42 -09 replies
4/21mm: refund memory for a locked bufferinclude/linux/mm.h mm/mlock.c+8 -81 reply
5/21x86, ptrace, bts: defer branch trace stoppingarch/x86/kernel/ptrace.c include/linux/sched.h+165 -880 replies
6/21x86, bts: fix race between per-task and per-cpu branch tracingarch/x86/kernel/ds.c+46 -320 replies
7/21x86, bts: add _noirq variants to the debug store interfacearch/x86/include/asm/ds.h arch/x86/kernel/ds.c+384 -960 replies
8/21x86, debugctlmsr: add _on_cpu variants to debugctlmsr functionsarch/x86/include/asm/processor.h+27 -00 replies
9/21x86, hw-branch-tracer: use new debug store interfacekernel/trace/trace_hw_branches.c+64 -1200 replies
10/21x86, ptrace: use new debug store interfacearch/x86/kernel/ptrace.c+3 -20 replies
11/21x86, ds: make ds selftests use new debug store interfacearch/x86/kernel/ds_selftest.c+138 -490 replies
12/21x86, ds: defer ds selftestsarch/x86/kernel/ds.c+26 -200 replies
13/21x86, ds: fix compiler warningarch/x86/kernel/ds_selftest.c+1 -10 replies
14/21x86, ds: fix bounds check in ds selftestarch/x86/kernel/ds_selftest.c+6 -10 replies
15/21x86, ds: add task tracing selftestarch/x86/kernel/ds_selftest.c+71 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [patch 0/21] x86, ptrace, bts, hw-branch-tracer: fixes and cleanups

Patches 1-6 fix a number of races when the traced task is currently running.

In the worst case, the kernel may crash since the cpu may continue tracing after the trace buffer has already been freed. This may happen when the tracing or traced task are killed.

The first 5 patches apply to .29 with the small preparation patch below.

Patches 7-11 fix problems with the hw-branch-tracer. It performs DS operations in an on_each_cpu() context, which has interrupts disabled. Patch 7 adds a _noirq version for most ds_ functions and separates cpu and task tracing. It allows cpu tracing to be configured from any cpu. This allows the hw-branch-tracer in patch 8 to remove the bad spinlock and use simple for_each_online_cpu loops.
The remaining patches change the other DS users to use the new interface.

Patches 12-15 add more selftests, defer selftesting, and fix a bad check.

Patches 16-19 do some cleanups that have been requested from reviewers.

Patch 20 fixes a bug where the wrong qualifier was passed to a shared function resulting in the bts configuration to be reset when a reset of the pebs configuration had been requested.

Patch 21 adds support for Core i7.

Thanks to Oleg Nesterov for reviewing the first round of patches and for pointing out several races!

---

arch/x86/kernel/ds.c +2 -2
Index: linux-2.6.29/arch/x86/kernel/ds.c
===================================================================
@@ -78,8 +78,8 @@ struct bts_tracer {
 	struct ds_tracer ds;
 	/* the trace including the DS configuration */
 	struct bts_trace trace;
-	/* buffer overflow notification function */
-	bts_ovfl_callback_t ovfl;
+	/* Buffer overflow notification function: */
+	bts_ovfl_callback_t	ovfl;
 };
 
 struct pebs_tracer {
arch/x86/kernel/ptrace.c +1 -0
Index: linux-2.6.29/arch/x86/kernel/ptrace.c
===================================================================
@@ -21,6 +21,7 @@
 #include <linux/audit.h>
 #include <linux/seccomp.h>
 #include <linux/signal.h>
+#include <linux/ftrace.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>

---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.