This is the mail archive of the mailing list for the systemtap project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Enabling irqs in begin/end probes

Last week I was asked to explain why enabling irqs in begin/end probes might be desired. I haven't run into a specific need to enable irqs in end probes, but my recent argtap post shows an example for begin probes.

That script grabs a snapshot of the task list in the begin probe (see code below). The main point of the script is to filter and aggregate processes based on their arguments. I'd like to access the arguments while walking through the list, but I can't do that because the arguments are stored in the processes' address space. The functions to access process address space must be called with irqs enabled because they can potentially sleep. The workaround I came up with is to grab the arguments when the process is "current" in the scheduler.cpu_off probe. I'd prefer not to do this, though, because it adds undesirable overhead to the scheduler.

There may be a better way to get the arguments of running processes. I'm open to suggestions. This is just an example of how having irqs disabled in begin probes, and having no control over that, made writing the script more difficult.


Example code:

// Grab the existing pids
itask = inittask()
for (task = next_task(itask); task != itask; task = next_task(task)) {
// Ignore kernel threads
if (is_kthread(task)) continue
p = task_pid(task)
if (p > 0) {
// NOTE: process arguments are kept in user address space.
// All probes, including begin, run with irqs disabled and // cannot sleep, so we cannot access user space for non-current
// processes at this point. Thus, we wait until a process is
// "current" in scheduler.cpu_off before grabbing the arguments.
initial_pids[p] = 1
user[p] = task_uid(task)
cputime[p, old] = task_cputime(task)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]