* [PATCH 7/6 v3] ipc/sem.c: add a printk_once for semctl(GETNCNT/GETZCNT)
@ 2014-05-26 17:12 Manfred Spraul
0 siblings, 0 replies; only message in thread
From: Manfred Spraul @ 2014-05-26 17:12 UTC (permalink / raw)
To: Andrew Morton
Cc: LKML, Davidlohr Bueso, Michael Kerrisk, 1vier1, Manfred Spraul,
Joe Perches
The actual Linux implementation for semctl(GETNCNT) and semctl(GETZCNT)
always (since 0.99.10) reported a thread as sleeping on all semaphores
that are listed in the semop() call.
The documented behavior (both in the Linux man page and in the Single Unix
Specification) is that a task should be reported on exactly one semaphore:
The semaphore that caused the thread to got to sleep.
This patch adds a pr_info_once() that is triggered if a thread hits
the relevant case.
The code triggers slightly too often, otherwise it would be necessary to
replicate the old code. As there are no known users of GETNCNT or GETZCNT,
this is done to prevent unnecessary bloat.
The task that triggered is reported with name (tsk->comm) and pid.
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Acked-by: Davidlohr Bueso <davidlohr@hp.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Joe Perches <joe@perches.com>
---
ipc/sem.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/ipc/sem.c b/ipc/sem.c
index 71a3caf..a6c292d 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1000,6 +1000,17 @@ static int check_qop(struct sem_array *sma, int semnum, struct sem_queue *q,
{
struct sembuf *sop = q->blocking;
+ /*
+ * Linux always (since 0.99.10) reported a task as sleeping on all
+ * semaphores. This violates SUS, therefore it was changed to the
+ * standard compliant behavior.
+ * Give the administrators a chance to notice that an application
+ * might misbehave because it relies on the Linux behavior.
+ */
+ pr_info_once("semctl(GETNCNT/GETZCNT) is since 3.16 Single Unix Specification compliant.\n"
+ "The task %s (%d) triggered the difference, watch for misbehavior.\n",
+ current->comm, task_pid_nr(current));
+
if (sop->sem_num != semnum)
return 0;
--
1.9.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-05-26 17:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 17:12 [PATCH 7/6 v3] ipc/sem.c: add a printk_once for semctl(GETNCNT/GETZCNT) Manfred Spraul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®