All of lore.kernel.org
 help / color / mirror / Atom feed
* Tasks blocking on POSIX message queue using wrong priority?
@ 2017-11-10 21:12 Jonathan Haws
  0 siblings, 0 replies; only message in thread
From: Jonathan Haws @ 2017-11-10 21:12 UTC (permalink / raw)
  To: linux-kernel

Hello all,

I'm looking at the file ipc/mqueue.c and I found what I believe to be a
bug, but I would love it if someone corrected me or confirmed this.

In the wq_add() function, it appears that the task is added to the wait
queue using the static priority, which I believe equates to the
processes' niceness value.  However, this means that real-time threads
(which share a processes niceness value I believe) get added to the
queue in FIFO order (unless of course the user adjusts the niceness
value, but that gets tricky for a multithreaded process :) ).

static void wq_add(struct mqueue_inode_info *info, int sr,
                        struct ext_wait_queue *ewp)
{
        struct ext_wait_queue *walk;

        ewp->task = current;

        list_for_each_entry(walk, &info->e_wait_q[sr].list, list) {
                if (walk->task->static_prio <= current->static_prio) {
                        list_add_tail(&ewp->list, &walk->list);
                        return;
                }
        }
        list_add_tail(&ewp->list, &info->e_wait_q[sr].list);
}

It seems that to have this work properly for RT threads as well all
that would be required is to have access to a function similar to the
effective_prio() call in kernel/sched/core.c.  Am I missing something,
or would that add things to the wait queue in task priority order?

Of course I could be missing some detail about how task priorities get
set.  I do have test code I can send along that fills a POSIX message
queue, spawns a few threads of varying priorities - each posting to the
queue with a message priority equal to the thread priority, and then
the reader thread pulls messages out and prints the message priority.
 I'm seeing that the order in which threads are waking is always FIFO
order, supporting my earlier argument about niceness values.

What am I missing or is this a very subtle bug in message queue
handling?

Thanks!
Jon

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

only message in thread, other threads:[~2017-11-10 21:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-10 21:12 Tasks blocking on POSIX message queue using wrong priority? Jonathan Haws

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.