From patchwork Fri Jan 16 10:34:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 43227 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 76248240BA for ; Fri, 16 Jan 2015 10:34:39 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id l15sf1479782wiw.0 for ; Fri, 16 Jan 2015 02:34:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=tXXKedG8Y8xJFASncyyu1fKmhXUb+APBD8ijW1VmeBA=; b=Dp/FrNaxFVaMeoJl5XIZ0B7BQGJglp6peFf04g1Zg7LxRG+eg3XCtYeB8aGNVX2Zkf Ewk2gOmaYUw+YUnK31qtUjBnl2Cl4B/KZasB3ftwi8Mwf44eOCkDM5QR7kr/6jwRVFnG JISbnOE+NmlHN9NazkejlXfnJ5zLZZKjv0q2x3j7HoDws4YMkLhzNHhZtvA4mO1OWbJY dziM4ixnkskLhnN5wp6LhuJfVmaaZIcJ2fmn9ktsyoOm50VnFrBchecB4FpXlaEjp2cq 4ibeSqQLr81KaGOv3zgsdrA0/YeAY1b2bsJt7Ea4d5RrCsYxIH+GmKxSdYGOVz+ub2oR by6g== X-Gm-Message-State: ALoCoQler6c134J2BnCOtjtQeei6PQUTJfsVQegdRS6HN/8qsIb3bzUKgOtcO/FHeYZoHNgWzJ/T X-Received: by 10.194.77.1 with SMTP id o1mr1871996wjw.1.1421404478787; Fri, 16 Jan 2015 02:34:38 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.235 with SMTP id jf11ls345354lac.74.gmail; Fri, 16 Jan 2015 02:34:38 -0800 (PST) X-Received: by 10.112.125.41 with SMTP id mn9mr14709476lbb.80.1421404478619; Fri, 16 Jan 2015 02:34:38 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id xo9si1188551lac.57.2015.01.16.02.34.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 02:34:38 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id q1so2813227lam.2 for ; Fri, 16 Jan 2015 02:34:38 -0800 (PST) X-Received: by 10.152.6.132 with SMTP id b4mr14962384laa.59.1421404478461; Fri, 16 Jan 2015 02:34:38 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp259739lbb; Fri, 16 Jan 2015 02:34:37 -0800 (PST) X-Received: by 10.229.102.68 with SMTP id f4mr14209370qco.15.1421404477038; Fri, 16 Jan 2015 02:34:37 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id n74si5408308qgd.96.2015.01.16.02.34.34 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Jan 2015 02:34:37 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YC4Ea-0000LS-DI; Fri, 16 Jan 2015 10:34:32 +0000 Received: from mail-lb0-f182.google.com ([209.85.217.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YC4EU-0000L8-Ar for lng-odp@lists.linaro.org; Fri, 16 Jan 2015 10:34:26 +0000 Received: by mail-lb0-f182.google.com with SMTP id u10so17652706lbd.13 for ; Fri, 16 Jan 2015 02:34:20 -0800 (PST) X-Received: by 10.152.19.7 with SMTP id a7mr14762927lae.16.1421404460027; Fri, 16 Jan 2015 02:34:20 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id kw10sm1349108lac.45.2015.01.16.02.34.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 02:34:19 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Fri, 16 Jan 2015 11:34:16 +0100 Message-Id: <1421404456-14002-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: timers patch Subject: [lng-odp] [PATCHv2] example: odp_timer_test.c: odp_timer_test aborts X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ola.liljedahl@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Since the scheduler does not guarantee fairness in scheduling, threads must time out and check if the example is still running. If so, just restart the scheduling, not the whole example loop which has (undesired) side effects. The bug was caused by restarting the example loop which then reset the last used timer with an old tick value, this could eventually fail (because that tick value was in the past) with the too late error message. https://bugs.linaro.org/show_bug.cgi?id=1068 Reported-by: anders.roxell@linaro.org Reported-by: ola.dahl@enea.com Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) example/timer/odp_timer_test.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 5de499b..d18378a 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -125,14 +125,23 @@ static void test_abs_timeouts(int thr, test_args_t *args) timerset2str(rc)); } - /* Get the next expired timeout */ - /* Use 1.5 second timeout for scheduler */ - uint64_t sched_tmo = odp_schedule_wait_time(1500000000ULL); - buf = odp_schedule(&queue, sched_tmo); - /* Check if odp_schedule() timed out, possibly there are no - * remaining timeouts to receive */ + /* Get the next expired timeout. + * We invoke the scheduler in a loop with a timeout because + * we are not guaranteed to receive any more timeouts. The + * scheduler isn't guaranteeing fairness when scheduling + * buffers to threads. + * Use 1.5 second timeout for scheduler */ + uint64_t sched_tmo = + odp_schedule_wait_time(1500000000ULL); + do { + buf = odp_schedule(&queue, sched_tmo); + /* Check if odp_schedule() timed out, possibly there + * are no remaining timeouts to receive */ + } while (buf == ODP_BUFFER_INVALID && + (int)odp_atomic_load_u32(&remain) > 0); + if (buf == ODP_BUFFER_INVALID) - continue; /* Re-check the remain counter */ + break; /* No more timeouts */ if (odp_buffer_type(buf) != ODP_BUFFER_TYPE_TIMEOUT) { /* Not a default timeout buffer */ EXAMPLE_ABORT("Unexpected buffer type (%u) received\n",