Re: [patch 0/9] mutex subsystem, -V4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrew Morton writes:

> Ingo Molnar <[email protected]> wrote:
> >  - 'struct mutex' is smaller: on x86, 'struct semaphore' is 20 bytes, 
> >    'struct mutex' is 16 bytes. A smaller structure size means less RAM 
> >    footprint, and better CPU-cache utilization.
> 
> Because of the .sleepers thing.  Perhaps a revamped semaphore wouldn't need
> thsat field?

Note that semaphores on 32-bit PPC are only 16 bytes already, since I
got rid of the sleepers field ages ago.  The fast path is just
atomic_dec/inc, and the slow path needs an atomic op that does

	x = max(x, 0) + inc

atomically and returns the old value of x.  That's easy to do with
lwarx/stwcx (just two more instructions than an atomic inc), and can
also be done quite straightforwardly with cmpxchg.  Alpha, mips, s390
and sparc64 also use this scheme.

In fact I would go so far as to say that I cannot see how it would be
possible to do a mutex any smaller or faster than a counting semaphore
on these architectures.

Regards,
Paul.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux