From patchwork Thu Sep 17 08:31:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 53777 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 5D8AB22E57 for ; Thu, 17 Sep 2015 08:33:58 +0000 (UTC) Received: by lbot4 with SMTP id t4sf3681996lbo.0 for ; Thu, 17 Sep 2015 01:33:57 -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=pdcTqi5swb+2JD0N0Bjq/kN59ASJgARXL74hGmrv36M=; b=BvSwSfHWNiGSCeea4yWN4l03Gy5ak3VURNWcEJv7JWz7mVJYOyqSZKSU6DAnsiow3+ WR+uHtH1RouK1uKcPyAihDpNbxR5VQoG8VMiMXkZWa/0p7PtkXH4DS50EzRWrsfD18zi J/7zmHJlezpTDZXmbLUfsLFHYtewynbI1C446fZsqu+IGaM1kszfMFYLws/OfD2XwN0c YINsDgmDyAfkMzRcTYAVI7+/rcCCi+q5lmbulIQ6/a+9RdysWZrvnjRKTIUxwQXOlvvX Kaynv/TijBdV9mL5qKBfU6iSXcK7maXG3T5bUvpOqyCdrFwxLnFFk7CZjt7Pc0AYvEGB TX8A== X-Gm-Message-State: ALoCoQkG5CHBAtcRxtLk9dzlmKBjrcNLx9/ZL4I471S5HviCNf/WYCZ3jtQWJSIkXzTzefaEFHX9 X-Received: by 10.194.118.65 with SMTP id kk1mr6324616wjb.5.1442478837325; Thu, 17 Sep 2015 01:33:57 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.180.75 with SMTP id dm11ls56088lac.102.gmail; Thu, 17 Sep 2015 01:33:57 -0700 (PDT) X-Received: by 10.112.205.69 with SMTP id le5mr34676479lbc.89.1442478837143; Thu, 17 Sep 2015 01:33:57 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id z5si1503161laj.38.2015.09.17.01.33.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 01:33:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbmp1 with SMTP id mp1so5465557lbb.1 for ; Thu, 17 Sep 2015 01:33:57 -0700 (PDT) X-Received: by 10.112.135.9 with SMTP id po9mr29945420lbb.56.1442478836950; Thu, 17 Sep 2015 01:33:56 -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 w3csp2926262lbq; Thu, 17 Sep 2015 01:33:56 -0700 (PDT) X-Received: by 10.50.50.177 with SMTP id d17mr23446409igo.55.1442478835900; Thu, 17 Sep 2015 01:33:55 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 42si1538348iok.146.2015.09.17.01.33.53; Thu, 17 Sep 2015 01:33:55 -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 4E46562C21; Thu, 17 Sep 2015 08:33:53 +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 11ADF62D4F; Thu, 17 Sep 2015 08:32:24 +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 AB77E62C51; Thu, 17 Sep 2015 08:32:10 +0000 (UTC) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by lists.linaro.org (Postfix) with ESMTPS id 8A53262D46 for ; Thu, 17 Sep 2015 08:31:42 +0000 (UTC) Received: by wicge5 with SMTP id ge5so107934713wic.0 for ; Thu, 17 Sep 2015 01:31:41 -0700 (PDT) X-Received: by 10.194.239.167 with SMTP id vt7mr32890903wjc.5.1442478701802; Thu, 17 Sep 2015 01:31:41 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id s16sm8743445wik.13.2015.09.17.01.31.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Sep 2015 01:31:41 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Sep 2015 11:31:30 +0300 Message-Id: <1442478691-30098-5-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442478691-30098-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1442478691-30098-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 4/5] performance: odp_pktio_perf: fix potential overflow for send_duration 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.171 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 The direct comparing of "cur_cycles" and "end_cycles" is not valid, as "end_cycles" can be overflowed and comparison will give wrong result. So use odp_time_diff_cycles() for that, as it takes in account cycles overflow. Signed-off-by: Ivan Khoronzhuk Reviewed-by: Stuart Haslam --- test/performance/odp_pktio_perf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index 185375e..61ff312 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -305,7 +305,7 @@ static void *run_thread_tx(void *arg) int thr_id; odp_queue_t outq; pkt_tx_stats_t *stats; - uint64_t next_tx_cycles, end_cycles, cur_cycles; + uint64_t next_tx_cycles, start_cycles, cur_cycles, send_duration; uint64_t burst_gap_cycles; uint32_t batch_len; int unsent_pkts = 0; @@ -330,15 +330,14 @@ static void *run_thread_tx(void *arg) burst_gap_cycles = odp_time_ns_to_cycles( ODP_TIME_SEC / (targs->pps / targs->batch_len)); + send_duration = odp_time_ns_to_cycles(targs->duration * ODP_TIME_SEC); odp_barrier_wait(&globals->tx_barrier); cur_cycles = odp_time_cycles(); + start_cycles = cur_cycles; next_tx_cycles = cur_cycles; - end_cycles = cur_cycles + - odp_time_ns_to_cycles(targs->duration * ODP_TIME_SEC); - - while (cur_cycles < end_cycles) { + while (odp_time_diff_cycles(start_cycles, cur_cycles) < send_duration) { unsigned alloc_cnt = 0, tx_cnt; if (cur_cycles < next_tx_cycles) {