Skip to contentSkip to conversation

x86, ptrace: support pebs in ds.c

PATCH In review Markus Metzger 4 participants 7 messages Feb 13, 2008 – Feb 26, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 x86, ptrace: support pebs in ds.c

Polish the ds.h interface and add support for PEBS.

Ds.c is meant to be the resource allocator for per-thread and per-cpu BTS and PEBS recording.
It is used by ptrace to provide execution tracing of debugged tasks. It will be used by profilers (e.g. perfmon2).

Changes in detail:
- separate DS and BTS more clearly
- simplify field accesses
- add functions to manage PEBS buffers
- add simple protection/allocation mechanism

I further did two tiny changes to the ptrace user API:
- remove support for cutting the requested buffer size down to the maximal available size. Users should check their resource limits.
- request (re)allocation of BTS buffers explicitly.
This used to be implicit on a change of the requested buffer size.

The user API (ptrace extensions) is not public, yet.

Opens:
- buffer overflow handling
Currently, only circular buffers are supported. This is all we need for debugging. Profilers would want an overflow notification. This is planned to be added when perfmon2 is made to use the ds.h interface.

---

include/asm-x86/ds.h +206 -47
Index: linux-2.6-x86/include/asm-x86/ds.h
===================================================================
@@ -2,19 +2,22 @@
  * Debug Store (DS) support
  *
  * This provides a low-level interface to the hardware's Debug Store
- * feature that is used for last branch recording (LBR) and
+ * feature that is used for branch trace store (BTS) and
  * precise-event based sampling (PEBS).
  *
- * Different architectures use a different DS layout/pointer size.
- * The below functions therefore work on a void*.
+ * It manages:
+ * - per-thread and per-cpu allocation of BTS and PEBS
+ * - buffer memory allocation (optional)
+ * - buffer overflow handling
+ * - buffer access
+ *
+ * It assumes:
+ * - get_task_struct on all parameter tasks
+ * - current is allowed to trace parameter tasks
  *
  *
- * Since there is no user for PEBS, yet, only LBR (or branch
- * trace store, BTS) is supported.
- *
- *
- * Copyright (C) 2007 Intel Corporation.
- * Markus Metzger <[email protected]>, Dec 2007
+ * Copyright (C) 2007-2008 Intel Corporation.
+ * Markus Metzger <[email protected]>, 2007-2008
  */
 
 #ifndef _ASM_X86_DS_H
@@ -23,50 +26,206 @@
 #include <linux/types.h>
 #include <linux/init.h>
 
-struct cpuinfo_x86;
 
+struct task_struct;
 
-/* a branch trace record entry
+/*
+ * Request BTS or PEBS
  *
- * In order to unify the interface between various processor versions,
- * we use the below data structure for all processors.
+ * Due to alignement constraints, the actual buffer may be slightly
+ * smaller than the requested or provided buffer.
+ *
+ * Returns 0 on success; -Eerrno otherwise
+ *
+ * task: the task to request recording for;
+ *       NULL for per-cpu recording on the current cpu
+ * base: the base pointer for the (non-pageable) buffer;
+ *       NULL if buffer allocation requested
+ * size: the size of the requested or provided buffer
+ * ovfl: pointer to a function to be called on buffer overflow;
+ *       NULL if cyclic buffer requested
  */
-enum bts_qualifier {
-	BTS_INVALID = 0,
-	BTS_BRANCH,
-	BTS_TASK_ARRIVES,
-	BTS_TASK_DEPARTS
-};
+typedef void (*ds_ovfl_callback_t)(struct task_struct *);
+extern int ds_request_bts(struct task_struct *task, void *base, size_t size,
+			  ds_ovfl_callback_t ovfl);
+extern int ds_request_pebs(struct task_struct *task, void *base, size_t size,
+			   ds_ovfl_callback_t ovfl);
+
+/*
+ * Release BTS or PEBS resources
+ *
+ * Frees buffers allocated on ds_request.
+ *
+ * Returns 0 on success; -Eerrno otherwise
+ *
+ * task: the task to release resources for;
+ *       NULL to release resources for the current cpu
+ */
+extern int ds_release_bts(struct task_struct *task);
+extern int ds_release_pebs(struct task_struct *task);
+
+/*
+ * Return the (array) index of the write pointer.
+ * (assuming an array of BTS/PEBS records)
+ *
+ * Returns -Eerrno on error
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ * pos (out): if not NULL, will hold the result
+ */
+extern int ds_get_bts_index(struct task_struct *task, size_t *pos);
+extern int ds_get_pebs_index(struct task_struct *task, size_t *pos);
 
-struct bts_struct {
-	u64 qualifier;
-	union {
-		/* BTS_BRANCH */
-		struct {
-			u64 from_ip;
-			u64 to_ip;
-		} lbr;
-		/* BTS_TASK_ARRIVES or
-		   BTS_TASK_DEPARTS */
-		u64 jiffies;
-	} variant;
+/*
+ * Return the (array) index one record beyond the end of the array.
+ * (assuming an array of BTS/PEBS records)
+ *
+ * Returns -Eerrno on error
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ * pos (out): if not NULL, will hold the result
+ */
+extern int ds_get_bts_end(struct task_struct *task, size_t *pos);
+extern int ds_get_pebs_end(struct task_struct *task, size_t *pos);
+
+/*
+ * Provide a pointer to the BTS/PEBS record at parameter index.
+ * (assuming an array of BTS/PEBS records)
+ *
+ * The pointer points directly into the buffer. The user is
+ * responsible for copying the record.
+ *
+ * Returns the size of a single record on success; -Eerrno on error
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ * index: the index of the requested record
+ * record (out): pointer to the requested record
+ */
+extern int ds_access_bts(struct task_struct *task,
+			 size_t index, const void **record);
+extern int ds_access_pebs(struct task_struct *task,
+			  size_t index, const void **record);
+
+/*
+ * Write one or more BTS/PEBS records at the write pointer index and
+ * advance the write pointer.
+ *
+ * If size is not a multiple of the record size, trailing bytes are
+ * zeroed out.
+ *
+ * May result in one or more overflow notifications.
+ *
+ * If called during overflow handling, that is, with index >=
+ * interrupt threshold, the write will wrap around.
+ *
+ * An overflow notification is given if and when the interrupt
+ * threshold is reached during or after the write.
+ *
+ * Returns the number of bytes written or -Eerrno.
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ * buffer: the buffer to write
+ * size: the size of the buffer
+ */
+extern int ds_write_bts(struct task_struct *task,
+			const void *buffer, size_t size);
+extern int ds_write_pebs(struct task_struct *task,
+			 const void *buffer, size_t size);
+
+/*
+ * Same as ds_write_bts/pebs, but omit ownership checks.
+ *
+ * This is needed to have some other task than the owner of the
+ * BTS/PEBS buffer or the parameter task itself write into the
+ * respective buffer.
+ */
+extern int ds_unchecked_write_bts(struct task_struct *task,
+				  const void *buffer, size_t size);
+extern int ds_unchecked_write_pebs(struct task_struct *task,
+				   const void *buffer, size_t size);
+
+/*
+ * Reset the write pointer of the BTS/PEBS buffer.
+ *
+ * Returns 0 on success; -Eerrno on error
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ */
+extern int ds_reset_bts(struct task_struct *task);
+extern int ds_reset_pebs(struct task_struct *task);
+
+/*
+ * Clear the BTS/PEBS buffer and reset the write pointer.
+ * The entire buffer will be zeroed out.
+ *
+ * Returns 0 on success; -Eerrno on error
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ */
+extern int ds_clear_bts(struct task_struct *task);
+extern int ds_clear_pebs(struct task_struct *task);
+
+/*
+ * Provide the PEBS counter reset value.
+ *
+ * Returns 0 on success; -Eerrno on error
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ * value (out): the counter reset value
+ */
+extern int ds_get_pebs_reset(struct task_struct *task, u64 *value);
+
+/*
+ * Set the PEBS counter reset value.
+ *
+ * Returns 0 on success; -Eerrno on error
+ *
+ * task: the task to access;
+ *       NULL to access the current cpu
+ * value: the new counter reset value
+ */
+extern int ds_set_pebs_reset(struct task_struct *task, u64 value);
+
+/*
+ * Initialization
+ */
+struct cpuinfo_x86;
+extern void __cpuinit ds_init_intel(struct cpuinfo_x86 *);
+
+
+
+/*
+ * The DS context - part of struct thread_struct.
+ */
+struct ds_context {
+	/* pointer to the DS configuration; goes into MSR_IA32_DS_AREA */
+	unsigned char *ds;
+	/* the owner of the BTS and PEBS configuration, respectively */
+	struct task_struct *owner[2];
+	/* buffer overflow notification function for BTS and PEBS */
+	ds_ovfl_callback_t callback[2];
+	/* the original buffer address */
+	void *buffer[2];
+	/* the number of allocated pages for on-request allocated buffers */
+	unsigned int pages[2];
+	/* use count */
+	unsigned long count;
+	/* a pointer to the context location inside the thread_struct
+	 * or the per_cpu context array */
+	struct ds_context **this;
+	/* a pointer to the task owning this context, or NULL, if the
+	 * context is owned by a cpu */
+	struct task_struct *task;
 };
 
-/* Overflow handling mechanisms */
-#define DS_O_SIGNAL	1 /* send overflow signal */
-#define DS_O_WRAP	2 /* wrap around */
-
-extern int ds_allocate(void **, size_t);
-extern int ds_free(void **);
-extern int ds_get_bts_size(void *);
-extern int ds_get_bts_end(void *);
-extern int ds_get_bts_index(void *);
-extern int ds_set_overflow(void *, int);
-extern int ds_get_overflow(void *);
-extern int ds_clear(void *);
-extern int ds_read_bts(void *, int, struct bts_struct *);
-extern int ds_write_bts(void *, const struct bts_struct *);
-extern unsigned long ds_debugctl_mask(void);
-extern void __cpuinit ds_init_intel(struct cpuinfo_x86 *c);
+/* called by exit_thread() to free leftover contexts */
+extern void ds_free(struct ds_context *context);
 
 #endif /* _ASM_X86_DS_H */
include/asm-x86/ptrace.h +30 -2
Index: linux-2.6-x86/include/asm-x86/ptrace.h
===================================================================
@@ -125,13 +125,41 @@
 #endif /* __KERNEL__ */
 #endif /* !__i386__ */
 
+
+/* a branch trace record entry
+ *
+ * In order to unify the interface between various processor versions,
+ * we use the below data structure for all processors.
+ */
+enum bts_qualifier {
+	BTS_INVALID = 0,
+	BTS_BRANCH,
+	BTS_TASK_ARRIVES,
+	BTS_TASK_DEPARTS
+};
+
+struct bts_struct {
+	u64 qualifier;
+	union {
+		/* BTS_BRANCH */
+		struct {
+			u64 from_ip;
+			u64 to_ip;
+		} lbr;
+		/* BTS_TASK_ARRIVES or
+		   BTS_TASK_DEPARTS */
+		u64 jiffies;
+	} variant;
+};
+
 #ifdef __KERNEL__
 
-/* the DS BTS struct is used for ptrace as well */
-#include <asm/ds.h>
+#include <linux/init.h>
 
+struct cpuinfo_x86;
 struct task_struct;
 
+extern void __cpuinit ptrace_bts_init_intel(struct cpuinfo_x86 *);
 extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier);
 
 extern unsigned long profile_pc(struct pt_regs *regs);
arch/x86/kernel/ptrace.c +266 -174

562 lines not on this page · raw message

arch/x86/kernel/ds.c +667 -279

1,103 lines not on this page · raw message

include/asm-x86/processor.h +5 -3
Index: linux-2.6-x86/include/asm-x86/processor.h
===================================================================
@@ -24,6 +24,7 @@
 #include <asm/msr.h>
 #include <asm/desc_defs.h>
 #include <asm/nops.h>
+#include <asm/ds.h>
 #include <linux/personality.h>
 #include <linux/cpumask.h>
 #include <linux/cache.h>
@@ -355,9 +356,10 @@
 	unsigned io_bitmap_max;
 /* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set.  */
 	unsigned long	debugctlmsr;
-/* Debug Store - if not 0 points to a DS Save Area configuration;
- *               goes into MSR_IA32_DS_AREA */
-	unsigned long	ds_area_msr;
+/* Debug Store context; see include/asm-x86/ds.h; goes into MSR_IA32_DS_AREA */
+	struct ds_context	*ds_ctx;
+/* the signal to send on a bts buffer overflow */
+	unsigned int	bts_ovfl_signal;
 };
 
 static inline unsigned long native_get_debugreg(int regno)
arch/x86/kernel/process_32.c +14 -2
Index: linux-2.6-x86/arch/x86/kernel/process_32.c
===================================================================
@@ -455,6 +455,12 @@
 		tss->x86_tss.io_bitmap_base = INVALID_IO_BITMAP_OFFSET;
 		put_cpu();
 	}
+	/* Free any DS contexts that have not been properly released. */
+	if (unlikely(current->thread.ds_ctx)) {
+		/* we clear debugctl to make sure DS is not used. */
+		wrmsrl(MSR_IA32_DEBUGCTLMSR, 0);
+		ds_free(current->thread.ds_ctx);
+	}
 }
 
 void flush_thread(void)
@@ -566,17 +572,23 @@
 {
 	struct thread_struct *prev, *next;
 	unsigned long debugctl;
+	unsigned long ds_prev = 0, ds_next = 0;
 
 	prev = &prev_p->thread;
 	next = &next_p->thread;
 
+	if (prev->ds_ctx)
+		ds_prev = (unsigned long)prev->ds_ctx->ds;
+	if (next->ds_ctx)
+		ds_next = (unsigned long)next->ds_ctx->ds;
+
 	debugctl = prev->debugctlmsr;
-	if (next->ds_area_msr != prev->ds_area_msr) {
+	if (ds_next != ds_prev) {
 		/* we clear debugctl to make sure DS
 		 * is not in use when we change it */
 		debugctl = 0;
 		wrmsrl(MSR_IA32_DEBUGCTLMSR, 0);
-		wrmsr(MSR_IA32_DS_AREA, next->ds_area_msr, 0);
+		wrmsr(MSR_IA32_DS_AREA, ds_next, 0);
 	}
 
 	if (next->debugctlmsr != debugctl)
arch/x86/kernel/process_64.c +14 -2
Index: linux-2.6-x86/arch/x86/kernel/process_64.c
===================================================================
@@ -416,6 +416,12 @@
 		t->io_bitmap_max = 0;
 		put_cpu();
 	}
+	/* Free any DS contexts that have not been properly released. */
+	if (unlikely(t->ds_ctx)) {
+		/* we clear debugctl to make sure DS is not used. */
+		wrmsrl(MSR_IA32_DEBUGCTLMSR, 0);
+		ds_free(t->ds_ctx);
+	}
 }
 
 void flush_thread(void)
@@ -564,17 +570,23 @@
 {
 	struct thread_struct *prev, *next;
 	unsigned long debugctl;
+	unsigned long ds_prev = 0, ds_next = 0;
 
 	prev = &prev_p->thread,
 	next = &next_p->thread;
 
+	if (prev->ds_ctx)
+		ds_prev = (unsigned long)prev->ds_ctx->ds;
+	if (next->ds_ctx)
+		ds_next = (unsigned long)next->ds_ctx->ds;
+
 	debugctl = prev->debugctlmsr;
-	if (next->ds_area_msr != prev->ds_area_msr) {
+	if (ds_next != ds_prev) {
 		/* we clear debugctl to make sure DS
 		 * is not in use when we change it */
 		debugctl = 0;
 		wrmsrl(MSR_IA32_DEBUGCTLMSR, 0);
-		wrmsrl(MSR_IA32_DS_AREA, next->ds_area_msr);
+		wrmsrl(MSR_IA32_DS_AREA, ds_next);
 	}
 
 	if (next->debugctlmsr != debugctl)
arch/x86/kernel/cpu/intel.c +2 -1
Index: linux-2.6-x86/arch/x86/kernel/cpu/intel.c
===================================================================
@@ -220,10 +220,11 @@
 			set_bit(X86_FEATURE_BTS, c->x86_capability);
 		if (!(l1 & (1<<12)))
 			set_bit(X86_FEATURE_PEBS, c->x86_capability);
+		ds_init_intel(c);
 	}
 
 	if (cpu_has_bts)
-		ds_init_intel(c);
+		ptrace_bts_init_intel(c);
 }
 
 static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
arch/x86/kernel/setup_64.c +2 -1
Index: linux-2.6-x86/arch/x86/kernel/setup_64.c
===================================================================
@@ -836,11 +836,12 @@
 			set_cpu_cap(c, X86_FEATURE_BTS);
 		if (!(l1 & (1<<12)))
 			set_cpu_cap(c, X86_FEATURE_PEBS);
+		ds_init_intel(c);
 	}
 
 
 	if (cpu_has_bts)
-		ds_init_intel(c);
+		ptrace_bts_init_intel(c);
 
 	n = c->extended_cpuid_level;
 	if (n >= 0x80000008) {
include/asm-x86/ptrace-abi.h +4 -4
Index: linux-2.6-x86/include/asm-x86/ptrace-abi.h
===================================================================
@@ -103,14 +103,14 @@
 #define PTRACE_BTS_O_SCHED	0x2 /* scheduling events w/ jiffies */
 #define PTRACE_BTS_O_SIGNAL     0x4 /* send SIG<signal> on buffer overflow
 				       instead of wrapping around */
-#define PTRACE_BTS_O_CUT_SIZE	0x8 /* cut requested size to max available
-				       instead of failing */
+#define PTRACE_BTS_O_ALLOC	0x8 /* (re)allocate buffer */
 
 #define PTRACE_BTS_CONFIG	40
 /* Configure branch trace recording.
    ADDR points to a struct ptrace_bts_config.
    DATA gives the size of that buffer.
-   A new buffer is allocated, iff the size changes.
+   A new buffer is allocated, if requested in the flags.
+   An overflow signal may only be requested for new buffers.
    Returns the number of bytes read.
 */
 #define PTRACE_BTS_STATUS	41
@@ -119,7 +119,7 @@
    Returns the number of bytes written.
 */
 #define PTRACE_BTS_SIZE		42
-/* Return the number of available BTS records.
+/* Return the number of available BTS records for draining.
    DATA and ADDR are ignored.
 */
 #define PTRACE_BTS_GET		43

---------------------------------------------------------------------
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.

#1 lore raw

Sorry I haven't replied in this thread sooner.

I would like to see all the BTS and DS work wait until after 2.6.25. We have a lot of x86 churn in 2.6.25 already, and I think we'd do better without adding this wrinkle at the same time.

The low-level implementation pieces should gel a bit more in -mm or whereever. They should both get more testing and also get more concrete use from the perfmon2 integration effort to iron out their internal interface kinks.

For the user-level interface, we should not be hasty with cooking up hairy ptrace extensions. Personally, I'd prefer that we never add a ptrace-based interface for this (ptrace must die). I think it will fit much better either merged into the interfaces that come from perfmon2 integration, or into what replaces ptrace when that comes. There is not yet any different userland interface framework in the tree to base it on, so ptrace extensions may be better than nothing if they are well-gelled in 2.6.26 and nothing else is close to ready. But I also don't know of anyone desperate and about to burst from lack of BTS functionality.

Thanks,
Roland

#2 lore raw

Roland,

I think you bring up some very good points and I agree with you. Hopefully, I should be able to modify perfmon to use this new internal interface in the coming weeks. That should be a good test.

Quoted 26 lines · Roland McGrath

Sorry I haven't replied in this thread sooner.

I would like to see all the BTS and DS work wait until after 2.6.25. We have a lot of x86 churn in 2.6.25 already, and I think we'd do better without adding this wrinkle at the same time.

The low-level implementation pieces should gel a bit more in -mm or whereever. They should both get more testing and also get more concrete use from the perfmon2 integration effort to iron out their internal interface kinks.

For the user-level interface, we should not be hasty with cooking up hairy ptrace extensions. Personally, I'd prefer that we never add a ptrace-based interface for this (ptrace must die). I think it will fit much better either merged into the interfaces that come from perfmon2 integration, or into what replaces ptrace when that comes. There is not yet any different userland interface framework in the tree to base it on, so ptrace extensions may be better than nothing if they are well-gelled in 2.6.26 and nothing else is close to ready. But I also don't know of anyone desperate and about to burst from lack of BTS functionality.

Thanks,
Roland

#3 lore raw
In reply to Roland McGrath
Quoted 5 lines

-----Original Message-----
From: Roland McGrath [mailto:[email protected]]
Sent: Donnerstag, 21. Februar 2008 22:00

Sorry I haven't replied in this thread sooner.

Thanks for your comments. I hope we get this resolved quickly.

Quoted 5 lines

For the user-level interface, we should not be hasty with cooking up hairy ptrace extensions. Personally, I'd prefer that we never add a ptrace-based interface for this (ptrace must die). I think it will fit much better either merged into the interfaces that come from perfmon2 integration, or into what replaces ptrace when that comes.

Ptrace seems the natural choice for a debug feature.

When ptrace goes away, I will be happy to integrate this feature into its successor. But as long as ptrace lives, I think it should support this.

Quoted 2 lines

But I also don't know of anyone desperate and about to burst from lack of BTS functionality.

Intel is waiting for this interface - desperate and about to burst from lack of it.

For one, Intel's debugger is ready to support this. Second, Intel would like to see all linux debuggers use this hardware debugging feature.

Quoted 4 lines

The low-level implementation pieces should gel a bit more in -mm or whereever. They should both get more testing and also get more concrete use from the perfmon2 integration effort to iron out their internal interface kinks.

I see the two parts (ptrace API and ds.c interface) independent from each other.

The ptrace API is the user interface for the debugging/BTS aspect of it. As such, it will remain stable.

The ds.c interface is the kernel interface to DS (which covers both BTS and PEBS). It is currently used by ptrace (the per-thread BTS part) and it will be used by perfmon2 (the PEBS part) and by kernel debuggers (the per-cpu BTS part).

If we need to change the ds.c interface to better fit perfmon2's needs, we can easily adapt the ptrace layer without affecting the ptrace API.

Quoted 3 lines

I would like to see all the BTS and DS work wait until after 2.6.25. We have a lot of x86 churn in 2.6.25 already, and I think we'd do better without adding this wrinkle at the same time.

The ptrace BTS extension has been out for review since 2.6.24 (that is, 2.6.23 was the stable kernel at that time). The ptrace API has been extensively discussed by mostly Ingo and myself until we agreed on its usefulness. I have not heard any complaints about the API, since then.

I would suggest that we iron out the ptrace API for 2.6.25. This would introduce ds.c and a first user. It would allow application debuggers to use that feature.

For 2.6.26 we would make perfmon2 use the ds.c interface. This would add a second user to ds.c. It would allow profilers to use that feature.

As soon as a ptrace successor becomes available, we will integrate BTS support into it. We might want to introduce another layer between ptrace and ds to share some code. This would leave the ptrace layer almost empty.

What do you think?

thanks and regards,
markus.

---------------------------------------------------------------------
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.

#4 lore raw
Quoted 2 lines · Metzger, Markus T

The ptrace API is the user interface for the debugging/BTS aspect of it. As such, it will remain stable.

your last patch does this to arch/x86/kernel/ptrace.c:

266 insertions(+), 174 deletions(-)

doesnt that change the ptrace bits and the ptrace API semantics?

Ingo

#5 lore raw
Quoted 5 lines

-----Original Message-----
From: Ingo Molnar [mailto:[email protected]]
Sent: Freitag, 22. Februar 2008 10:53
To: Metzger, Markus T

Quoted 8 lines
Quoted 2 lines

The ptrace API is the user interface for the debugging/BTS aspect of it. As such, it will remain stable.

your last patch does this to arch/x86/kernel/ptrace.c:

266 insertions(+), 174 deletions(-)

doesnt that change the ptrace bits and the ptrace API semantics?

The last patch does change the ptrace API - before it becomes public.

After it becomes public, ds.c can be changed without affecting the ptrace API.

The last changes are not strictly necessary - I could as well implement the old interface. If there are objections to or concerns regarding those API changes, I will do just that. The changes are:
- add PTRACE_BTS_O_ALLOC to explicitly request reallocation of the BTS buffer.
This used to be implicit when the size changes.
- remove PTRACE_BTS_O_CUT_SIZE
This used to reduce the size requested for the BTS buffer to the
maximal available size, if necessary.
I do not think this is necessary. Users should check their ulimits.

This is what I meant with ironing out the ptrace API.

thanks and regards,
markus.
---------------------------------------------------------------------
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.

#6 lore raw
In reply to Roland McGrath
Quoted 11 lines · Roland McGrath

Sorry I haven't replied in this thread sooner.

I would like to see all the BTS and DS work wait until after 2.6.25. We have a lot of x86 churn in 2.6.25 already, and I think we'd do better without adding this wrinkle at the same time.

The low-level implementation pieces should gel a bit more in -mm or whereever. They should both get more testing and also get more concrete use from the perfmon2 integration effort to iron out their internal interface kinks.

Quoted 10 lines

For the user-level interface, we should not be hasty with cooking up hairy ptrace extensions. Personally, I'd prefer that we never add a ptrace-based interface for this (ptrace must die). I think it will fit much better either merged into the interfaces that come from perfmon2 integration, or into what replaces ptrace when that comes. There is not yet any different userland interface framework in the tree to base it on, so ptrace extensions may be better than nothing if they are well-gelled in 2.6.26 and nothing else is close to ready. But I also don't know of anyone desperate and about to burst from lack of BTS functionality.

i'd you'd like to have something like the patch below to happen?

what API should BTS/DS functionality use towards user-space if not ptrace? Should it be utrace?

Ingo

--------------------->
Subject: x86: disable BTS ptrace extensions for now
From: Ingo Molnar <[email protected]>
Date: Tue Feb 26 09:40:27 CET 2008

based on general objections from Roland McGrath:

    http://lkml.org/lkml/2008/2/21/323

we'll let the BTS functionality cook some more and enable it in v2.6.26.

(X86_BTS is not defined at the moment)

---
 arch/x86/kernel/ptrace.c |    5 +++++
 1 file changed, 5 insertions(+)
arch/x86/kernel/ptrace.c +5 -0
Index: linux-x86.q/arch/x86/kernel/ptrace.c
===================================================================
@@ -961,6 +961,10 @@ long arch_ptrace(struct task_struct *chi
 		break;
 #endif
 
+	/*
+	 * These bits need more cooking - not enabled yet:
+	 */
+#ifdef X86_BTS
 	case PTRACE_BTS_CONFIG:
 		ret = ptrace_bts_config
 			(child, data, (struct ptrace_bts_config __user *)addr);
@@ -988,6 +992,7 @@ long arch_ptrace(struct task_struct *chi
 		ret = ptrace_bts_drain
 			(child, data, (struct bts_struct __user *) addr);
 		break;
+#endif
 
 	default:
 		ret = ptrace_request(child, request, addr, data);