Skip to contentSkip to conversation

perfmon2 context: thread_struct vs. task_struct?

DISCUSSION Stephane Eranian 2 participants 3 messages Mar 22, 2006 – Mar 23, 2006

lore
Share & tools
lore
#0 lore raw

Hello,

The perfmon2 subsystem maintains a structure per-thread that contains the save-area for the performance counters and related software state. The save area is used on context-switch. There can only be one context per thread. The context is dynamically allocated as such it does not consume memory in each thread. It is dyanmically attached to the thread to monitor.

In the current implementation, the context (pfm_context) pointer is implemented in the thread_struct on the basis that this is somewhat related to machine state.

Historically, the perfmon subsystem only existed on IA-64 which made the thread_struct (an arch-specific structure) the obvious place to put this.

Nowadays, perfmon2 supports most major architectures. It may make sense to move the void *pfm_context pointer from the thread_struct into the task_struct. This would save some indirections, make it readily available to other archiectures when it is ported.

I admit I am not quite clear as to what goes where between thread_struct and task_struct.

Would it make sense to move the pointer to the perfmon2 context into the task_struct?

Thanks.

Signature · 1 line
-Stephane
#1 lore raw
Quoted 25 lines · Stephane Eranian

Hello,

The perfmon2 subsystem maintains a structure per-thread that contains the save-area for the performance counters and related software state. The save area is used on context-switch. There can only be one context per thread. The context is dynamically allocated as such it does not consume memory in each thread. It is dyanmically attached to the thread to monitor.

In the current implementation, the context (pfm_context) pointer is implemented in the thread_struct on the basis that this is somewhat related to machine state.

Historically, the perfmon subsystem only existed on IA-64 which made the thread_struct (an arch-specific structure) the obvious place to put this.

Nowadays, perfmon2 supports most major architectures. It may make sense to move the void *pfm_context pointer from the thread_struct into the task_struct. This would save some indirections, make it readily available to other archiectures when it is ported.

Quoted 5 lines

I admit I am not quite clear as to what goes where between thread_struct and task_struct.

Would it make sense to move the pointer to the perfmon2 context into the task_struct?

I'd say so, yes. Especialy if the struct is the same on all architectures, is referred to from non-arch-specific code and is absent if CONFIG_PERFMON=n.

#2 lore raw

Andrew,

Quoted 7 lines · Andrew Morton
Quoted 2 lines

Would it make sense to move the pointer to the perfmon2 context into the task_struct?

I'd say so, yes. Especialy if the struct is the same on all architectures, is referred to from non-arch-specific code and is absent if CONFIG_PERFMON=n.

Yes the structure is the same for all architectures. It looks like task_struct already has #ifdefs in it. So I could do:

struct task_struct {
	....
#ifdef CONFIG_PERFMON
	struct pfm_context *pfm_context;
#endif
	...
};
Signature · 1 line
-Stephane