Commit afb4894f authored by Maria Matejka's avatar Maria Matejka
Browse files

Worker: Pthread spinlock replaced by explicit spinning.

We want to check spinlock sanity and always clearly know who is spinning
right now.
parent a624d832
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -153,6 +153,10 @@ prepare: $(objdir)/sysdep/paths.h | $(objdir)/.dir-stamp
$(objdir)/.dir-stamp: Makefile
	$(E)echo MKDIR -p $(addprefix $(objdir)/,$(dirs) doc)
	$(Q)mkdir -p $(addprefix $(objdir)/,$(dirs) doc)
	$(E)echo RM -f $(objdir)/sysdep/arch
	$(Q)rm -f $(objdir)/sysdep/arch
	$(E)echo LN -s $(srcdir)/sysdep/@bird_target_cpu@ $(objdir)/sysdep/arch
	$(Q)ln -s $$(readlink -f $(srcdir)/sysdep/@bird_target_cpu@) $(objdir)/sysdep/arch
	$(Q)touch $@

$(client) $(daemon):
+11 −0
Original line number Diff line number Diff line
@@ -103,6 +103,16 @@ AC_SEARCH_LIBS([clock_gettime], [rt posix4],
)

AC_CANONICAL_HOST
AC_CANONICAL_TARGET

if test -d "sysdep/$target_cpu" ; then
  bird_target_cpu="$target_cpu"
else
  AC_MSG_NOTICE([Target CPU not known, disabling architecture tweaks: $target_cpu])
  bird_target_cpu=generic-arch
fi

AC_SUBST([bird_target_cpu])

# Store this value because ac_test_CFLAGS is overwritten by AC_PROG_CC
if test "$ac_test_CFLAGS" != set ; then
@@ -443,6 +453,7 @@ AC_OUTPUT

AC_MSG_RESULT()
AC_MSG_RESULT([BIRD was configured with the following options:])
AC_MSG_RESULT([        Target CPU:		$target_cpu])
AC_MSG_RESULT([        Source directory:	$srcdir])
AC_MSG_RESULT([        Object directory:	$objdir])
AC_MSG_RESULT([        Iproute2 directory:	$iproutedir])
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ static inline int uint_cmp(uint i1, uint i2)
static inline int u64_cmp(u64 i1, u64 i2)
{ return (int)(i1 > i2) - (int)(i1 < i2); }

#define TARGET_ARCH_INCLUDE_PATH(file) "sysdep/" TARGET_CPU file

/* Bitfield macros */

+14 −0
Original line number Diff line number Diff line
/*
 *	BIRD -- calls for other architectures
 *
 *	(c) 2019 Maria Matejka <mq@ucw.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#ifndef _BIRD_ASM_H_
#define _BIRD_ASM_H_

#define CPU_RELAX()  __asm__ __volatile__ ("" : : : "memory")

#endif
+2 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
#include <pthread.h>
#include <unistd.h>

#include <urcu.h>
#include "sysdep/arch/asm.h"

static volatile _Atomic u64 max_worker_id = 1;
static _Thread_local u64 worker_id;
@@ -105,7 +105,7 @@ static inline void WQ_LOCK(void)
    if (atomic_compare_exchange_weak_explicit(&wq->lock, &noworker, worker_id, memory_order_acq_rel, memory_order_acquire))
      break;

    caa_cpu_relax();
    CPU_RELAX();
  }

  WQ_STATELOG(WQS_LOCK,
Loading