From patchwork Mon May 16 19:11:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 67914 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1693559qge; Mon, 16 May 2016 12:11:49 -0700 (PDT) X-Received: by 10.55.88.5 with SMTP id m5mr31543549qkb.134.1463425909099; Mon, 16 May 2016 12:11:49 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id i78si8543035qkh.237.2016.05.16.12.11.48; Mon, 16 May 2016 12:11:49 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B808D61761; Mon, 16 May 2016 19:11:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id D48C06174B; Mon, 16 May 2016 19:11:42 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 21D5C6174C; Mon, 16 May 2016 19:11:40 +0000 (UTC) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by lists.linaro.org (Postfix) with ESMTPS id A4F0661735 for ; Mon, 16 May 2016 19:11:38 +0000 (UTC) Received: by mail-lb0-f172.google.com with SMTP id h1so53566079lbj.3 for ; Mon, 16 May 2016 12:11:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CJCJ8i6zSBIq7X0FLy3YZCZ1YNBYdDYwKd8o2FLIb0Y=; b=bysee8fxvZ3rWhfOWKoKeqgQhAHRXLhqyEcI5QWJeAQ+KfjjaYC3HaGsUPBN/2H+DO DZz/kT9WKBebWBuJFrfUI5zifjQYHj18e88mkeZSDsYXqaQFiSGx1nQJB4GdrKThNzGM 6BGpbZvDiyL17v7WZe7lL1d7r83y9vxmewz5gpeC92XewjjeuaiGEllzqWJ8xcRCRder DX9H1YjH1UuXEHVPoJeC9Um6nRU9X2bHlyECpqADMrCF9IAxRMLtIT+2VCfAQsI5SXtP osQZ+BNmRaRdBQukAJ3N5BpeZpL03cWgFxJ4I8hdBxVYBd/scK+UGnOqv3pImDWmZE7y 01Wg== X-Gm-Message-State: AOPr4FWe3Qnba0WwLYaAQy8rwGkhcZHJqOBxUiK/mWpTiOA6TeZf8t1TAm2qIBDkbb1pdY8k604= X-Received: by 10.112.209.99 with SMTP id ml3mr11859202lbc.26.1463425897319; Mon, 16 May 2016 12:11:37 -0700 (PDT) Received: from localhost.localdomain (ppp91-77-173-31.pppoe.mtu-net.ru. [91.77.173.31]) by smtp.gmail.com with ESMTPSA id k66sm1460184lfe.32.2016.05.16.12.11.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 May 2016 12:11:36 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 16 May 2016 22:11:22 +0300 Message-Id: <1463425882-19752-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: timers patch Subject: [lng-odp] [PATCH] linux-generic: timer: remove dead 128 bit optimizations X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Remove totally untested branch with 128 bit optimizations for timer code. This also fixes static assert bug: https://bugs.linaro.org/show_bug.cgi?id=2211 Signed-off-by: Maxim Uvarov --- platform/linux-generic/odp_timer.c | 104 ------------------------------------- 1 file changed, 104 deletions(-) diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 6b84309..bf2405c 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -11,15 +11,7 @@ * */ -/* Check if compiler supports 16-byte atomics. GCC needs -mcx16 flag on x86 */ -/* Using spin lock actually seems faster on Core2 */ -#ifdef ODP_ATOMIC_U128 -/* TB_NEEDS_PAD defined if sizeof(odp_buffer_t) != 8 */ -#define TB_NEEDS_PAD -#define TB_SET_PAD(x) ((x).pad = 0) -#else #define TB_SET_PAD(x) (void)(x) -#endif #include @@ -70,11 +62,9 @@ * Mutual exclusion in the absence of CAS16 *****************************************************************************/ -#ifndef ODP_ATOMIC_U128 #define NUM_LOCKS 1024 static _odp_atomic_flag_t locks[NUM_LOCKS]; /* Multiple locks per cache line! */ #define IDX2LOCK(idx) (&locks[(idx) % NUM_LOCKS]) -#endif /****************************************************************************** * Translation between timeout buffer and timeout header @@ -102,13 +92,8 @@ typedef struct tick_buf_s { uint32_t pad;/* Need to be able to access padding for successful CAS */ #endif } tick_buf_t -#ifdef ODP_ATOMIC_U128 -ODP_ALIGNED(16) /* 16-byte atomic operations need properly aligned addresses */ -#endif ; -ODP_STATIC_ASSERT(sizeof(tick_buf_t) == 16, "sizeof(tick_buf_t) == 16"); - typedef struct odp_timer_s { void *user_ptr; odp_queue_t queue;/* Used for free list when timer is free */ @@ -378,34 +363,6 @@ static bool timer_reset(uint32_t idx, tick_buf_t *tb = &tp->tick_buf[idx]; if (tmo_buf == NULL || *tmo_buf == ODP_BUFFER_INVALID) { -#ifdef ODP_ATOMIC_U128 - tick_buf_t new, old; - do { - /* Relaxed and non-atomic read of current values */ - old.exp_tck.v = tb->exp_tck.v; - old.tmo_buf = tb->tmo_buf; - TB_SET_PAD(old); - /* Check if there actually is a timeout buffer - * present */ - if (old.tmo_buf == ODP_BUFFER_INVALID) { - /* Cannot reset a timer with neither old nor - * new timeout buffer */ - success = false; - break; - } - /* Set up new values */ - new.exp_tck.v = abs_tck; - new.tmo_buf = old.tmo_buf; - TB_SET_PAD(new); - /* Atomic CAS will fail if we experienced torn reads, - * retry update sequence until CAS succeeds */ - } while (!_odp_atomic_u128_cmp_xchg_mm( - (_odp_atomic_u128_t *)tb, - (_uint128_t *)&old, - (_uint128_t *)&new, - _ODP_MEMMODEL_RLS, - _ODP_MEMMODEL_RLX)); -#else #ifdef __ARM_ARCH /* Since barriers are not good for C-A15, we take an * alternative approach using relaxed memory model */ @@ -453,7 +410,6 @@ static bool timer_reset(uint32_t idx, /* Release the lock */ _odp_atomic_flag_clear(IDX2LOCK(idx)); #endif -#endif } else { /* We have a new timeout buffer which replaces any old one */ /* Fill in some (constant) header fields for timeout events */ @@ -468,19 +424,6 @@ static bool timer_reset(uint32_t idx, } /* Else ignore buffers of other types */ odp_buffer_t old_buf = ODP_BUFFER_INVALID; -#ifdef ODP_ATOMIC_U128 - tick_buf_t new, old; - new.exp_tck.v = abs_tck; - new.tmo_buf = *tmo_buf; - TB_SET_PAD(new); - /* We are releasing the new timeout buffer to some other - * thread */ - _odp_atomic_u128_xchg_mm((_odp_atomic_u128_t *)tb, - (_uint128_t *)&new, - (_uint128_t *)&old, - _ODP_MEMMODEL_ACQ_RLS); - old_buf = old.tmo_buf; -#else /* Take a related lock */ while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ @@ -496,7 +439,6 @@ static bool timer_reset(uint32_t idx, /* Release the lock */ _odp_atomic_flag_clear(IDX2LOCK(idx)); -#endif /* Return old timeout buffer */ *tmo_buf = old_buf; } @@ -510,18 +452,6 @@ static odp_buffer_t timer_cancel(odp_timer_pool *tp, tick_buf_t *tb = &tp->tick_buf[idx]; odp_buffer_t old_buf; -#ifdef ODP_ATOMIC_U128 - tick_buf_t new, old; - /* Update the timer state (e.g. cancel the current timeout) */ - new.exp_tck.v = new_state; - /* Swap out the old buffer */ - new.tmo_buf = ODP_BUFFER_INVALID; - TB_SET_PAD(new); - _odp_atomic_u128_xchg_mm((_odp_atomic_u128_t *)tb, - (_uint128_t *)&new, (_uint128_t *)&old, - _ODP_MEMMODEL_RLX); - old_buf = old.tmo_buf; -#else /* Take a related lock */ while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ @@ -537,7 +467,6 @@ static odp_buffer_t timer_cancel(odp_timer_pool *tp, /* Release the lock */ _odp_atomic_flag_clear(IDX2LOCK(idx)); -#endif /* Return the old buffer */ return old_buf; } @@ -548,34 +477,6 @@ static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick) tick_buf_t *tb = &tp->tick_buf[idx]; odp_buffer_t tmo_buf = ODP_BUFFER_INVALID; uint64_t exp_tck; -#ifdef ODP_ATOMIC_U128 - /* Atomic re-read for correctness */ - exp_tck = _odp_atomic_u64_load_mm(&tb->exp_tck, _ODP_MEMMODEL_RLX); - /* Re-check exp_tck */ - if (odp_likely(exp_tck <= tick)) { - /* Attempt to grab timeout buffer, replace with inactive timer - * and invalid buffer */ - tick_buf_t new, old; - old.exp_tck.v = exp_tck; - old.tmo_buf = tb->tmo_buf; - TB_SET_PAD(old); - /* Set the inactive/expired bit keeping the expiration tick so - * that we can check against the expiration tick of the timeout - * when it is received */ - new.exp_tck.v = exp_tck | TMO_INACTIVE; - new.tmo_buf = ODP_BUFFER_INVALID; - TB_SET_PAD(new); - int succ = _odp_atomic_u128_cmp_xchg_mm( - (_odp_atomic_u128_t *)tb, - (_uint128_t *)&old, (_uint128_t *)&new, - _ODP_MEMMODEL_RLS, _ODP_MEMMODEL_RLX); - if (succ) - tmo_buf = old.tmo_buf; - /* Else CAS failed, something changed => skip timer - * this tick, it will be checked again next tick */ - } - /* Else false positive, ignore */ -#else /* Take a related lock */ while (_odp_atomic_flag_tas(IDX2LOCK(idx))) /* While lock is taken, spin using relaxed loads */ @@ -600,7 +501,6 @@ static unsigned timer_expire(odp_timer_pool *tp, uint32_t idx, uint64_t tick) /* Else false positive, ignore */ /* Release the lock */ _odp_atomic_flag_clear(IDX2LOCK(idx)); -#endif if (odp_likely(tmo_buf != ODP_BUFFER_INVALID)) { /* Fill in expiration tick for timeout events */ if (odp_event_type(odp_buffer_to_event(tmo_buf)) == @@ -974,13 +874,9 @@ void odp_timeout_free(odp_timeout_t tmo) int odp_timer_init_global(void) { -#ifndef ODP_ATOMIC_U128 uint32_t i; for (i = 0; i < NUM_LOCKS; i++) _odp_atomic_flag_clear(&locks[i]); -#else - ODP_DBG("Using lock-less timer implementation\n"); -#endif odp_atomic_init_u32(&num_timer_pools, 0); block_sigalarm();