tech-kern archive

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

Re: [RFC][PATCH] _UC_TLSBASE for all ports



David Holland <dholland-tech%netbsd.org@localhost> wrote:

> (1) What is the C&V of the pertinent standards that describe
> setcontext and getcontext?

As explained in their man page, they are obsolete in the 2004 edition of
POSIX.1, and were removed in the 2008 edition. Standards are of little
help here.
 
> (2) What is the ostensible point of programming with setcontext and
> getcontext?
> (3) What (possibly misguided, possibly not) things is glusterfs
> actually attempting to do by mucking with setcontext and getcontext in
> the way it is?

They have tasks that map to thread pools. A task may be suspended
because it awaits a FUSE or network reply, and when it resumes, it may
be executed by another thread in the pool, because the original thread
is busy with another task. swapcontext() is used to resume a task from
any thread.

A glusterfs contributor claims he tested a pure pthread implementation
against swapcontext+pthread, and he reports the latter is 9 time faster.
In order to avoid crashes, I tweaked glusterfs parameters so that all
tasks map on the same thread, and indeed the result was crash-free, but
much slower. Barely usable, I would say.

Using _UC_TLSBASE it gets reliable without the need to reduce the
task/thread mapping to N:1, and therefore performances are good. 

The only drawback of  _UC_TLSBASE is that its name is not consistent
among ports (it is called _UC_UNIQUE on alpha), and is missing on sh3,
sparc, and powerpc. This is what I propose to address.

-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index