Re: [PATCH 0/6] ipc/sem.c: Fix semctl(,,{GETNCNT,GETZCNT})

From: Davidlohr Bueso
Date: Sun May 11 2014 - 23:01:29 EST


On Sat, 2014-05-10 at 12:03 +0200, Manfred Spraul wrote:
> Hi all,
>
> According to the man page of semop(), semzcnt or semncnt are increased
> exactly for the operation that couldn't proceed.
>
> The Linux implementation always tried to be clever and to increase the counters
> for all operations that might be the reason why a task sleeps.

... and I hate the fact that we do so on demand, instead of modifying
the values when semop is called. This makes the whole semctl calls less
accurate, and in fact its mentioned in the code.

> The following patches fix that and make the code conform to the
> documentation.
>
> The series got fairly long, because I also noticed that semzcnt was calculated
> incorrectly.
>
> What do you think?

I'm still going through the changes, sems make my brain hurt. But
conceptually they do make sense... and hey, if semctl(GETNCNT,GETZCNT)
calls are currently incomplete, then yeah, we should fix it.

> I ran a few test cases, and the semncnt and semzcnt counts now match
> the expectation.
>
> Is anyone aware of an application that uses GETNCNT or GETZCNT?

Given how Oracle uses sysv semaphores I wouldn't be surprised if they
make use of these, specially GETNCNT, for something like "get the amount
of waiters" as opposed to "are there waiters"... but I'm just
speculating here.

I did find that LTP does some calls to GETZNCT, GETNCNT, and these
patches do not break those tests. However, they are pretty bogus since
they always test for zero. That reminds me, it might be worthwhile
adding some more tests in the selftests/ipc dir, we only have some
trivial msgq program, for the rest I pretty much rely on LTP for
correctness runs.

Thanks,
Davidlohr

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/