From patchwork Thu Aug 6 14:07:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 52002 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 patches.linaro.org (Postfix) with ESMTPS id F2C5520539 for ; Thu, 6 Aug 2015 14:08:12 +0000 (UTC) Received: by wibdx1 with SMTP id dx1sf6961559wib.2 for ; Thu, 06 Aug 2015 07:08:12 -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=ZPSFvkqpR+1ZjzcFgxzJhRcqcTVe0iftBdh8wcEklxU=; b=QJ0VbLe95l9cg5GDG2yOEE7e008SNOO8TCRmfQxy9Le3zOWuhYwj8FAUejJSTDJJc8 X9evbseIsZDT88vWur+w4YqpNpxvvx0+FikEtypjpMYMqJqYJmgLLUnpQx2vV09CD7Lw xtxPQpABQjLRpX1sRQCNEM60/AuaHD/3eoet6qvp0yGXplR13YsT1Cre4HeZOlND5Y7d Jk+GEVpk8bnEBOOithQ2RG5PI+qWbpWiSavgD5t6g+9AFfx5PHsTz9JX/LMJiVzs+tSR 3vg1fZz3mV7bHZBvSX0kxAQuCVlmbsVo6cebqA382Q0VieOR+DW4Dmk5+ser1QZvXNg+ KUIQ== X-Gm-Message-State: ALoCoQnIdzqOePPa6lnbXLw1exfWZUAnnWK5bxy0pa8c3Bh4YbRn4vrZdfKz3uCWwUU+gGgsCzpm X-Received: by 10.112.173.230 with SMTP id bn6mr546156lbc.15.1438870092232; Thu, 06 Aug 2015 07:08:12 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.35 with SMTP id s3ls352567lae.29.gmail; Thu, 06 Aug 2015 07:08:12 -0700 (PDT) X-Received: by 10.152.10.97 with SMTP id h1mr1929439lab.45.1438870092092; Thu, 06 Aug 2015 07:08:12 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id pc6si4810899lbc.178.2015.08.06.07.08.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Aug 2015 07:08:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labjt7 with SMTP id jt7so32087568lab.0 for ; Thu, 06 Aug 2015 07:08:12 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr1953763lal.35.1438870091986; Thu, 06 Aug 2015 07:08:11 -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.7.198 with SMTP id l6csp973463lba; Thu, 6 Aug 2015 07:08:10 -0700 (PDT) X-Received: by 10.107.129.225 with SMTP id l94mr2191584ioi.96.1438870090308; Thu, 06 Aug 2015 07:08:10 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z3si1797199igl.13.2015.08.06.07.08.09; Thu, 06 Aug 2015 07:08:10 -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 20C0F62068; Thu, 6 Aug 2015 14:08:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6905A6207E; Thu, 6 Aug 2015 14:07:32 +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 8E2DA62079; Thu, 6 Aug 2015 14:07:27 +0000 (UTC) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com [209.85.215.47]) by lists.linaro.org (Postfix) with ESMTPS id 50C4762068 for ; Thu, 6 Aug 2015 14:07:25 +0000 (UTC) Received: by lagz9 with SMTP id z9so3979024lag.3 for ; Thu, 06 Aug 2015 07:07:24 -0700 (PDT) X-Received: by 10.152.37.102 with SMTP id x6mr1901726laj.69.1438870044217; Thu, 06 Aug 2015 07:07:24 -0700 (PDT) Received: from khorivan.itg.ti.com ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id gg1sm1407529lbc.27.2015.08.06.07.07.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Aug 2015 07:07:23 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 6 Aug 2015 17:07:17 +0300 Message-Id: <1438870038-25155-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438870038-25155-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1438870038-25155-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [Patch 1/2] 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.215.52 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 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 --- 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 fcbc4ec..8f1daeb 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -303,7 +303,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, end_cycles, cur_cycles, send_duration; uint64_t burst_gap_cycles; uint32_t batch_len; int unsent_pkts = 0; @@ -331,12 +331,11 @@ static void *run_thread_tx(void *arg) odp_barrier_wait(&globals->tx_barrier); + send_duration = odp_time_ns_to_cycles(targs->duration * ODP_TIME_SEC); cur_cycles = odp_time_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) { + end_cycles = cur_cycles + send_duration; + while (odp_time_diff_cycles(cur_cycles, end_cycles) < send_duration) { unsigned alloc_cnt = 0, tx_cnt; if (cur_cycles < next_tx_cycles) {