From: mike@flyn.org (W. Michael Petullo)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Walking a wait_queue_t list of tasks blocked on pipe
Date: Tue, 12 Jan 2016 22:13:35 -0500 [thread overview]
Message-ID: <20160113031335.GA17121@imp.flyn.org> (raw)
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
next reply other threads:[~2016-01-13 3:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 3:13 W. Michael Petullo [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-01-14 3:30 Walking a wait_queue_t list of tasks blocked on pipe W. Michael Petullo
2016-01-14 8:33 ` Christoph Hellwig
2016-01-14 21:45 ` W. Michael Petullo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160113031335.GA17121@imp.flyn.org \
--to=mike@flyn.org \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.