diff options
author | Petri Savolainen <petri.savolainen@nokia.com> | 2016-01-13 15:21:40 +0200 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2016-02-08 20:45:23 +0300 |
commit | 714c9b67194518802c94cce5214dd02248471856 (patch) | |
tree | 57723621f8ac6cefc7d4ad9e608109fa536deb69 /platform | |
parent | 54b34bb48576fc6c7258a522871555388415bb69 (diff) |
linux-generic: removed spin_internal
Removed odp_spin() and replaced usage with odp_cpu_pause().
Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Conflicts:
platform/linux-generic/Makefile.am
Diffstat (limited to 'platform')
-rw-r--r-- | platform/linux-generic/Makefile.am | 1 | ||||
-rw-r--r-- | platform/linux-generic/include/odp_spin_internal.h | 58 | ||||
-rw-r--r-- | platform/linux-generic/odp_barrier.c | 4 | ||||
-rw-r--r-- | platform/linux-generic/odp_rwlock.c | 7 | ||||
-rw-r--r-- | platform/linux-generic/odp_schedule.c | 4 | ||||
-rw-r--r-- | platform/linux-generic/odp_spinlock.c | 5 | ||||
-rw-r--r-- | platform/linux-generic/odp_ticketlock.c | 4 | ||||
-rw-r--r-- | platform/linux-generic/odp_timer.c | 10 |
8 files changed, 16 insertions, 77 deletions
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index da8608ac4..91e635321 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -106,7 +106,6 @@ noinst_HEADERS = \ ${srcdir}/include/odp_posix_extensions.h \ ${srcdir}/include/odp_queue_internal.h \ ${srcdir}/include/odp_schedule_internal.h \ - ${srcdir}/include/odp_spin_internal.h \ ${srcdir}/include/odp_timer_internal.h \ ${srcdir}/Makefile.inc diff --git a/platform/linux-generic/include/odp_spin_internal.h b/platform/linux-generic/include/odp_spin_internal.h deleted file mode 100644 index 29c524fb1..000000000 --- a/platform/linux-generic/include/odp_spin_internal.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - - -#ifndef ODP_SPIN_INTERNAL_H_ -#define ODP_SPIN_INTERNAL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - * Spin loop for ODP internal use - */ -static inline void odp_spin(void) -{ -#if defined __x86_64__ || defined __i386__ - -#ifdef __SSE2__ - __asm__ __volatile__ ("pause"); -#else - __asm__ __volatile__ ("rep; nop"); -#endif - -#elif defined __arm__ - -#if __ARM_ARCH == 7 - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); -#endif - -#elif defined __OCTEON__ - - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - __asm__ __volatile__ ("nop"); - -#endif -} - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/odp_barrier.c b/platform/linux-generic/odp_barrier.c index 53d83c0dd..0bfc0f042 100644 --- a/platform/linux-generic/odp_barrier.c +++ b/platform/linux-generic/odp_barrier.c @@ -6,7 +6,7 @@ #include <odp/barrier.h> #include <odp/sync.h> -#include <odp_spin_internal.h> +#include <odp/cpu.h> #include <odp_atomic_internal.h> void odp_barrier_init(odp_barrier_t *barrier, int count) @@ -43,7 +43,7 @@ void odp_barrier_wait(odp_barrier_t *barrier) } else { while ((odp_atomic_load_u32(&barrier->bar) < barrier->count) == wasless) - odp_spin(); + odp_cpu_pause(); } _ODP_FULL_BARRIER(); diff --git a/platform/linux-generic/odp_rwlock.c b/platform/linux-generic/odp_rwlock.c index 47c15ef42..0b8bb46b7 100644 --- a/platform/linux-generic/odp_rwlock.c +++ b/platform/linux-generic/odp_rwlock.c @@ -8,8 +8,7 @@ #include <odp/atomic.h> #include <odp_atomic_internal.h> #include <odp/rwlock.h> - -#include <odp_spin_internal.h> +#include <odp/cpu.h> void odp_rwlock_init(odp_rwlock_t *rwlock) { @@ -25,7 +24,7 @@ void odp_rwlock_read_lock(odp_rwlock_t *rwlock) cnt = _odp_atomic_u32_load_mm(&rwlock->cnt, _ODP_MEMMODEL_RLX); /* waiting for read lock */ if ((int32_t)cnt < 0) { - odp_spin(); + odp_cpu_pause(); continue; } is_locked = _odp_atomic_u32_cmp_xchg_strong_mm(&rwlock->cnt, @@ -51,7 +50,7 @@ void odp_rwlock_write_lock(odp_rwlock_t *rwlock) cnt = _odp_atomic_u32_load_mm(&rwlock->cnt, _ODP_MEMMODEL_RLX); /* lock acquired, wait */ if (cnt != 0) { - odp_spin(); + odp_cpu_pause(); continue; } is_locked = _odp_atomic_u32_cmp_xchg_strong_mm(&rwlock->cnt, diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index e0fadfac0..1aa60c25b 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -19,10 +19,10 @@ #include <odp/time.h> #include <odp/spinlock.h> #include <odp/hints.h> +#include <odp/cpu.h> #include <odp_queue_internal.h> #include <odp_packet_io_internal.h> -#include <odp_spin_internal.h> odp_thrmask_t sched_mask_all; @@ -894,7 +894,7 @@ void odp_schedule_order_lock(unsigned lock_index) * some events in the ordered flow need to lock. */ while (sync != sync_out) { - odp_spin(); + odp_cpu_pause(); sync_out = odp_atomic_load_u64(&origin_qe->s.sync_out[lock_index]); } diff --git a/platform/linux-generic/odp_spinlock.c b/platform/linux-generic/odp_spinlock.c index f16572053..6a16dc4b9 100644 --- a/platform/linux-generic/odp_spinlock.c +++ b/platform/linux-generic/odp_spinlock.c @@ -5,9 +5,8 @@ */ #include <odp/spinlock.h> +#include <odp/cpu.h> #include <odp_atomic_internal.h> -#include <odp_spin_internal.h> - void odp_spinlock_init(odp_spinlock_t *spinlock) { @@ -23,7 +22,7 @@ void odp_spinlock_lock(odp_spinlock_t *spinlock) * the loop will exit when the lock becomes available * and we will retry the TAS operation above */ while (_odp_atomic_flag_load(&spinlock->lock)) - odp_spin(); + odp_cpu_pause(); } diff --git a/platform/linux-generic/odp_ticketlock.c b/platform/linux-generic/odp_ticketlock.c index 3e2a4ece1..6ab2b9a6a 100644 --- a/platform/linux-generic/odp_ticketlock.c +++ b/platform/linux-generic/odp_ticketlock.c @@ -8,7 +8,7 @@ #include <odp/atomic.h> #include <odp_atomic_internal.h> #include <odp/sync.h> -#include <odp_spin_internal.h> +#include <odp/cpu.h> void odp_ticketlock_init(odp_ticketlock_t *ticketlock) @@ -31,7 +31,7 @@ void odp_ticketlock_lock(odp_ticketlock_t *ticketlock) * all stores from the previous lock owner */ while (ticket != _odp_atomic_u32_load_mm(&ticketlock->cur_ticket, _ODP_MEMMODEL_ACQ)) - odp_spin(); + odp_cpu_pause(); } int odp_ticketlock_trylock(odp_ticketlock_t *tklock) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 01339ad86..1001af8d6 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -33,6 +33,7 @@ #include <odp_atomic_internal.h> #include <odp/buffer.h> #include <odp_buffer_inlines.h> +#include <odp/cpu.h> #include <odp/pool.h> #include <odp_pool_internal.h> #include <odp/debug.h> @@ -42,7 +43,6 @@ #include <odp_internal.h> #include <odp/queue.h> #include <odp/shared_memory.h> -#include <odp_spin_internal.h> #include <odp/spinlock.h> #include <odp/std_types.h> #include <odp/sync.h> @@ -410,7 +410,7 @@ static bool timer_reset(uint32_t idx, while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ while (_odp_atomic_flag_load(IDX2LOCK(idx))) - odp_spin(); + odp_cpu_pause(); /* Only if there is a timeout buffer can be reset the timer */ if (odp_likely(tb->tmo_buf != ODP_BUFFER_INVALID)) { @@ -457,7 +457,7 @@ static bool timer_reset(uint32_t idx, while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ while (_odp_atomic_flag_load(IDX2LOCK(idx))) - odp_spin(); + odp_cpu_pause(); /* Swap in new buffer, save any old buffer */ old_buf = tb->tmo_buf; @@ -498,7 +498,7 @@ static odp_buffer_t timer_cancel(odp_timer_pool *tp, while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ while (_odp_atomic_flag_load(IDX2LOCK(idx))) - odp_spin(); + odp_cpu_pause(); /* Update the timer state (e.g. cancel the current timeout) */ tb->exp_tck.v = new_state; @@ -552,7 +552,7 @@ static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick) while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ while (_odp_atomic_flag_load(IDX2LOCK(idx))) - odp_spin(); + odp_cpu_pause(); /* Proper check for timer expired */ exp_tck = tb->exp_tck.v; if (odp_likely(exp_tck <= tick)) { |