On Fri, Oct 27, 2023 at 08:45:47PM +0000, Klemens Nanni wrote:
> On Fri, Oct 27, 2023 at 10:41:56PM +0200, Theo Buehler wrote:
> > On Fri, Oct 27, 2023 at 08:27:37PM +0000, Klemens Nanni wrote:
> > > Something installed this library on my machine, so it came up when
> > > looking for future fallout.
> > > 
> > > Patch looks simple, 'nm libtbb.so.* | grep syscall' shows the symbol
> > > gone and check_syms agrees:
> > > 
> > >   /l/lib/libtbb.so.1.0 --> 
> > > /p/pobj/tbb-2020.3.3/fake-amd64/usr/local/lib/libtbb.so.1.0
> > >   Dynamic export changes:
> > >   removed:
> > >           _ZN3tbb8internal3rml14private_worker14wake_or_launchEv
> > 
> > Do you know what leads to this symbol removal? That's not clear from
> > your patch and seems unrelated. I would have thought
> 
> Building -current without the diff shows no changes between installed
> and built libtbb.so.1.0, no that removal must stem from my diff.
> 
> > 
> >             tbb::internal::rml::private_worker::wake_or_launch()
> > 
> > should not have been exported in the first place.
> 
> Perhaps something picked up from the <sys/syscall.h>?

I should have looked more closely. The entire code is under
#if defined(SYS_futex) which is of course from syscall.h:

> +-/* Futex definitions */
> +-#include <sys/syscall.h>
> +
> + #if defined(SYS_futex)

The following does not result in dynamic export changes and switches the
external references from syscall to futex, as expected.

ok tb

if you want to commit.

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/tbb/Makefile,v
diff -u -p -r1.7 Makefile
--- Makefile    29 May 2023 17:50:03 -0000      1.7
+++ Makefile    27 Oct 2023 21:16:03 -0000
@@ -7,6 +7,7 @@ GH_ACCOUNT =            oneapi-src
 GH_PROJECT =           oneTBB
 GH_TAGNAME =           v${V}
 PKGNAME =              tbb-${V}
+REVISION =             0
 
 SHARED_LIBS +=         tbb             1.0     #2020.3
 SHARED_LIBS +=         tbbmalloc       1.0     #2020.3
Index: patches/patch-include_tbb_machine_linux_common_h
===================================================================
RCS file: patches/patch-include_tbb_machine_linux_common_h
diff -N patches/patch-include_tbb_machine_linux_common_h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-include_tbb_machine_linux_common_h    27 Oct 2023 21:17:11 
-0000
@@ -0,0 +1,35 @@
+Use futex(2) not syscall(2)
+
+Index: include/tbb/machine/linux_common.h
+--- include/tbb/machine/linux_common.h.orig
++++ include/tbb/machine/linux_common.h
+@@ -77,8 +77,8 @@ namespace tbb {
+ 
+ namespace internal {
+ 
+-inline int futex_wait( void *futex, int comparand ) {
+-    int r = syscall( SYS_futex,futex,__TBB_FUTEX_WAIT,comparand,NULL,NULL,0 );
++inline int futex_wait( void *uaddr, int comparand ) {
++    int r = futex( (volatile uint32_t *)uaddr,FUTEX_WAIT,comparand,NULL,NULL 
);
+ #if TBB_USE_ASSERT
+     int e = errno;
+     __TBB_ASSERT( r==0||r==EWOULDBLOCK||(r==-1&&(e==EAGAIN||e==EINTR)), 
"futex_wait failed." );
+@@ -86,14 +86,14 @@ inline int futex_wait( void *futex, int comparand ) {
+     return r;
+ }
+ 
+-inline int futex_wakeup_one( void *futex ) {
+-    int r = ::syscall( SYS_futex,futex,__TBB_FUTEX_WAKE,1,NULL,NULL,0 );
++inline int futex_wakeup_one( void *uaddr ) {
++    int r = ::futex( (volatile uint32_t *)uaddr,__TBB_FUTEX_WAKE,1,NULL,NULL 
);
+     __TBB_ASSERT( r==0||r==1, "futex_wakeup_one: more than one thread woken 
up?" );
+     return r;
+ }
+ 
+-inline int futex_wakeup_all( void *futex ) {
+-    int r = ::syscall( SYS_futex,futex,__TBB_FUTEX_WAKE,INT_MAX,NULL,NULL,0 );
++inline int futex_wakeup_all( void *uaddr ) {
++    int r = ::futex( (volatile uint32_t 
*)uaddr,__TBB_FUTEX_WAKE,INT_MAX,NULL,NULL );
+     __TBB_ASSERT( r>=0, "futex_wakeup_all: error in waking up threads" );
+     return r;
+ }

Reply via email to