From patchwork Thu Oct 15 13:02:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 54998 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 76CF72301F for ; Thu, 15 Oct 2015 13:02:54 +0000 (UTC) Received: by lbbms9 with SMTP id ms9sf9985465lbb.3 for ; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references: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=5cm5V3u0/jZtTAHyIjamfsew+1FJVUGyBmFCvVPAIMc=; b=dJX9QKV5LuKpik9mmeLfnQpajhfUbdPJZmf0ie01/BppS1LhBMrJXxG7b5TnUMUbMm gyqEl7KrUPP/499w5E19EJECNzsFzOUxpAH/fW7qP0K2A7pZWNqhdpoUqZIyAEZnGCA7 VpYo/pbdVm4v20ZuhPMG7BwcBjUUClenoRfKZEwgMHcnRSGRh/m4YFx5yuk3csmuA4IV OR+0/FwN5Do3KPugvxBXl2OnR7O+kTVPqt/MiLRjx9ZuCjXv7QGQOg9aRw6pYbkAyO99 +ygenQIlzF20KGtjMxR2moS5P7m+gsh4gTloIReh7k+7xBHdFAkzJ6mDX+bGLl3N4JPv xAwA== X-Gm-Message-State: ALoCoQm88aPF+Thn83X9/57PAallxgrUm//XXI9ai4eN0JQvyPB9zgwBoDAit8wt9twRPEr+oQTN X-Received: by 10.112.16.229 with SMTP id j5mr2146546lbd.6.1444914173398; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.151.79 with SMTP id z76ls138641lfd.104.gmail; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-Received: by 10.25.39.76 with SMTP id n73mr2883028lfn.60.1444914173264; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id n40si2510375lfi.20.2015.10.15.06.02.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 06:02:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbpp2 with SMTP id pp2so39190003lbb.0 for ; Thu, 15 Oct 2015 06:02:51 -0700 (PDT) X-Received: by 10.112.202.35 with SMTP id kf3mr4496535lbc.19.1444914171651; Thu, 15 Oct 2015 06:02:51 -0700 (PDT) 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.59.35 with SMTP id w3csp619735lbq; Thu, 15 Oct 2015 06:02:50 -0700 (PDT) X-Received: by 10.13.246.70 with SMTP id g67mr7063821ywf.116.1444914170727; Thu, 15 Oct 2015 06:02:50 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a29si12746838qkj.42.2015.10.15.06.02.46; Thu, 15 Oct 2015 06:02:50 -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; Received: by lists.linaro.org (Postfix, from userid 109) id B136A61FDC; Thu, 15 Oct 2015 13:02:46 +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_H3, RCVD_IN_MSPIKE_WL, 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 C2FDE61FAE; Thu, 15 Oct 2015 13:02:38 +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 84A6C61EB1; Thu, 15 Oct 2015 13:02:34 +0000 (UTC) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by lists.linaro.org (Postfix) with ESMTPS id 5D0F861D96 for ; Thu, 15 Oct 2015 13:02:33 +0000 (UTC) Received: by wicll6 with SMTP id ll6so18332618wic.1 for ; Thu, 15 Oct 2015 06:02:32 -0700 (PDT) X-Received: by 10.194.80.42 with SMTP id o10mr10284013wjx.31.1444914152638; Thu, 15 Oct 2015 06:02:32 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id z4sm11886602wjz.29.2015.10.15.06.02.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Oct 2015 06:02:31 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org, petri.savolainen@nokia.com Date: Thu, 15 Oct 2015 16:02:18 +0300 Message-Id: <1444914142-20587-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444914142-20587-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1444914142-20587-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v4 1/5] performance: odp_pktio_perf: fix potential overflow in wait loop X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@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.217.181 as permitted sender) smtp.mailfrom=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 There cannot be used direct comparison of timestamps of counter that can overflow, better to compare ranges. Signed-off-by: Ivan Khoronzhuk --- test/performance/odp_pktio_perf.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 018b7f5..09e1f6f 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -591,9 +591,13 @@ static int setup_txrx_masks(odp_cpumask_t *thd_mask_tx, */ static void busy_loop_ns(uint64_t wait_ns) { - uint64_t end = odp_time_cycles() + odp_time_ns_to_cycles(wait_ns); - while (odp_time_cycles() < end) - ; + uint64_t diff; + uint64_t start_time = odp_time_cycles(); + uint64_t wait = odp_time_ns_to_cycles(wait_ns); + + do { + diff = odp_time_diff_cycles(start_time, odp_time_cycles()); + } while (diff < wait); } /*