From patchwork Thu Nov 5 15:33:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 56061 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp474832lbr; Thu, 5 Nov 2015 07:34:15 -0800 (PST) X-Received: by 10.140.85.175 with SMTP id n44mr7898394qgd.65.1446737655126; Thu, 05 Nov 2015 07:34:15 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z36si4857077qge.79.2015.11.05.07.34.14; Thu, 05 Nov 2015 07:34:15 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id 5ACD361A43; Thu, 5 Nov 2015 15:34:14 +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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID, 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 CCBF561A12; Thu, 5 Nov 2015 15:34:07 +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 03C9E619C1; Thu, 5 Nov 2015 15:34:04 +0000 (UTC) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by lists.linaro.org (Postfix) with ESMTPS id 137AD61988 for ; Thu, 5 Nov 2015 15:34:03 +0000 (UTC) Received: by lbbes7 with SMTP id es7so38010065lbb.2 for ; Thu, 05 Nov 2015 07:34:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V2fCWItO614rBGBeThwtUqT+jheoNAw2o//JclFqCIs=; b=guum7g7rqUen3/S6gZn+t+S/dRbIuYU23N4CORfDAj0G0kpih88F2kMkKQ2W6MhrWH fYXmz4C3Ry0EelS/6j53zdZSkPwa72hkeK+V8ev/d08dSPnnisaAqJNUetNs2fOjXOLF RLSe+YHIMm7mY2afDxS1PsN7djH/KkZ2SwtmiNFC3iD017VSxdAsk/Y17kqoZ3MyHNYS iszafeJX7dcGjuqS/Oq8IFv4On8hh64H5VBf/o6lvHiSt6nDBjoeIke0oXkCH/wjYkpN YceQHvknY/thfZEZ73plimAFWV0M9aM5fOZGjZ1721n2LU+676UHAuIv7lYJjqDLadz4 Kq7A== 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:in-reply-to :references; bh=V2fCWItO614rBGBeThwtUqT+jheoNAw2o//JclFqCIs=; b=g9PdpTmSx12q1vmV3YfR3jUUDnqK3FjgmwZE0yUx2wmMwUq2yuKYorDwX+KeoVMDJZ 0qUS4gj4qgl7DmfbqeEXTj9VfVFuiiLDBQ4nBl4+8dRpkm8YPXNix8/r5juiKl3eplQ1 Ow19FLn9PYWBkTHmZWsVDlQdijSUFY6mq7nqmBy6oxMOo2V9BvDxvYGXbz6Ztf409mPy aa2agVjH1jaoH5h/nTBsYv9XniuAwIa6i5EsikBuXiwRg3M7Y7HP1vk6dfcUKH3fCWR4 3EAaK1D2qOT8zClIMvFuFC8OaKKPkbRvsew9k1vLGxY+OSG1rqsQEW5zy/L4sSZYNwNF ymBw== X-Gm-Message-State: ALoCoQnRSDQ5dxBKtdYhXAf/xdjWQgsTCzwe7edcujBPLZAkgei6tR0fyqPpzjpMySFytja9eoai X-Received: by 10.112.201.1 with SMTP id jw1mr4005773lbc.107.1446737641927; Thu, 05 Nov 2015 07:34:01 -0800 (PST) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id oi5sm1034061lbb.13.2015.11.05.07.34.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Nov 2015 07:34:01 -0800 (PST) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 5 Nov 2015 17:33:45 +0200 Message-Id: <1446737630-2323-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446737630-2323-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1446737630-2323-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCH v7 1/6] 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: "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" 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 efd26dc..ae5b4c0 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); } /*