kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Walking a wait_queue_t list of tasks blocked on pipe
@ 2016-01-13  3:13 W. Michael Petullo
  0 siblings, 0 replies; only message in thread
From: W. Michael Petullo @ 2016-01-13  3:13 UTC (permalink / raw)
  To: kernelnewbies

I am trying to walk a wait_queue_t list as part of a LSM file_permission
function. The purpose is to act on each task which has blocked while
trying to read from a pipe.

I have modeled my code on __wake_up_common() in kernel/sched/core.c,
and it looks something like this:

	if (i_pipe->reader <= 0) {
		return;
	}

	list_for_each_entry_safe(curr, next, &i_pipe->wait.task, task_list) {
		[...]
		struct task_struct *blocked = curr->private;
		[...]
	}

I have tried to wrap this with:

	spin_lock_irqsave(&i_pipe->wait.lock, flags)
	spin_unlock_irqrestore[...]

and also:

	write_lock_irq(&tasklist_lock).
	write_unlock_irq[...]

Despite this, I sometimes find that blocked (AKA curr->private) == NULL
during an iteration of the list_for_each_entry_safe loop, and this
surprises me. Why would there be en entry in the wait_queue_t list which
does not have a process associated with it? Is the data structure moving
out from under me? Is there something else I should lock?

Thank you,

-- 
Mike

:wq

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-13  3:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-13  3:13 Walking a wait_queue_t list of tasks blocked on pipe W. Michael Petullo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).