You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Davi Arnaut <da...@haxent.com.br> on 2007/07/01 01:47:59 UTC

RFC: nptl runtime enforcement

Hi,

Posting to the list before committing since this may be a little bit
controversial.

The patch adds a new argument to the --enable-threads option, which
enables a nptl-only build of apr. This enables the build process to make
better assumptions regarding the behavior (and speed) of a few lock
primitives (ie: apr_posixsem_is_global, much faster on nptl for
inter-process mutexes).

The patch still needs some tweaking here and there, but any comments or
feedback would be greatly appreciated.

--
Davi Arnaut

Re: RFC: nptl runtime enforcement

Posted by Paul Querna <ch...@force-elite.com>.
Davi Arnaut wrote:
> Hi,
> 
> Posting to the list before committing since this may be a little bit
> controversial.
> 
> The patch adds a new argument to the --enable-threads option, which
> enables a nptl-only build of apr. This enables the build process to make
> better assumptions regarding the behavior (and speed) of a few lock
> primitives (ie: apr_posixsem_is_global, much faster on nptl for
> inter-process mutexes).
> 
> The patch still needs some tweaking here and there, but any comments or
> feedback would be greatly appreciated.

wish: We didn't have to return APR_ENOTIMPL inside apr_initialize() if
we were compiled with NPTL, but the runtime is missing it.

request: I'm not sure about overloading --enable-threads.  The --help
output will need to be updated to reflect the availability of this
option too.

the idea: I like it. I think we should do it.

-Paul


Re: RFC: nptl runtime enforcement

Posted by Joe Orton <jo...@redhat.com>.
On Mon, Jul 02, 2007 at 10:15:12AM -0300, Davi Arnaut wrote:
> apr_posixsem_is_global was just an example, there are many
> incompatibilities between LinuxThreads and NPTL (process shared
> resources, fork()/wait() on the child, thread termination on execve(), etc.
> 
> What I want is to let the developer enforce that the build of APR he is
> distributing is only guaranteed to work linked with NPTL -- given that
> on almost any 2.6 distro the user may switch the pthread implementation
> using LD_ASSUME_KERNEL.

I'm not entirely comfortable with putting this kind of thing in APR.  
APR *must* be able to presume that the run-time environment is equally 
capable as the build environment - otherwise there is little point in 
having a configure script at all.  Having APR attempt to verify the 
capabilities of the run-time environment seems like a long road to start 
down.

Where the NPTL features are actually exposed by the APR API - and note 
that things like execve() behaviour in threaded apps are not - it must 
already be the case that the relevant APIs will fail gracefully if the 
user chooses to cripple the run-time environment.

Regards,

joe


Re: RFC: nptl runtime enforcement

Posted by Davi Arnaut <da...@haxent.com.br>.
Joe Orton wrote:
> On Sat, Jun 30, 2007 at 08:47:59PM -0300, Davi Arnaut wrote:
>> Posting to the list before committing since this may be a little bit
>> controversial.
>>
>> The patch adds a new argument to the --enable-threads option, which
>> enables a nptl-only build of apr. This enables the build process to make
>> better assumptions regarding the behavior (and speed) of a few lock
>> primitives (ie: apr_posixsem_is_global, much faster on nptl for
>> inter-process mutexes).
>>
>> The patch still needs some tweaking here and there, but any comments or
>> feedback would be greatly appreciated.
> 
> Tying this to the name of the particular threading implementation seems 
> ugly; if all you want to do is enable apr_posixsem_is_global then why 
> not just use a hint in apr_hints.m4 for Linuxes >= 2.6?

apr_posixsem_is_global was just an example, there are many
incompatibilities between LinuxThreads and NPTL (process shared
resources, fork()/wait() on the child, thread termination on execve(), etc.

What I want is to let the developer enforce that the build of APR he is
distributing is only guaranteed to work linked with NPTL -- given that
on almost any 2.6 distro the user may switch the pthread implementation
using LD_ASSUME_KERNEL.

> (FWIW, there are more considerations than speed when choosing an 
> inter-process locking mechanism: 
> http://marc.info/?l=apr-dev&m=108720968023158&w=2)

Sure. That's why Robust Mutexes exist, and IIRC recent 2.6 kernels have
robust futex support.

Also, shouldn't we let the developer make the choice if he wants a
robust mutex? Maybe a apr_proc_mutex_create flag, APR_LOCK_ROBUST
meaning to use the safest mutex available on the platform and
APR_LOCK_FAST for the fastest.

--
Davi Arnaut

Re: RFC: nptl runtime enforcement

Posted by Joe Orton <jo...@redhat.com>.
On Sat, Jun 30, 2007 at 08:47:59PM -0300, Davi Arnaut wrote:
> Posting to the list before committing since this may be a little bit
> controversial.
> 
> The patch adds a new argument to the --enable-threads option, which
> enables a nptl-only build of apr. This enables the build process to make
> better assumptions regarding the behavior (and speed) of a few lock
> primitives (ie: apr_posixsem_is_global, much faster on nptl for
> inter-process mutexes).
> 
> The patch still needs some tweaking here and there, but any comments or
> feedback would be greatly appreciated.

Tying this to the name of the particular threading implementation seems 
ugly; if all you want to do is enable apr_posixsem_is_global then why 
not just use a hint in apr_hints.m4 for Linuxes >= 2.6?

(FWIW, there are more considerations than speed when choosing an 
inter-process locking mechanism: 
http://marc.info/?l=apr-dev&m=108720968023158&w=2)

joe