From patchwork Mon Aug 31 13:05:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 52893 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 E79002127E for ; Mon, 31 Aug 2015 13:09:27 +0000 (UTC) Received: by wibgu7 with SMTP id gu7sf5188981wib.2 for ; Mon, 31 Aug 2015 06:09:27 -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=pKfV9h9AL8/7YWVnySSovT7V0Kbi3joL3wwERuJzo0E=; b=lh3i7xm5L7hV4qkFvvIN3cxgBQVTiFI0acjSTLi5MYXtoIuFLhgLqdwEgm8PKovH5D sT44/ppn1IqPNxDOFGYdnEV/nr+wKYdZaks5RcIlQeMrEEa1sz7mmhl1QPprxhB9nrjs P1xhMPgrDmWAbpuYIMh14k2NVPomZv5l9hJlBu92kUF86kSQts2oKbppLuBI81aiWmg2 TKy+PGnYJWCFvtUTS9bOvh9NB1N9qVRfSLAky9ZZhED+Bbd/Wb+hWW8aUSomrEDsmiGg 8+w4QnTkKGhhOi2jBwaQ5MkUZZoRW/GaJS0Z5IzawzCOHu1iYYY8Q0+Hari7GDkeYghY y2aQ== X-Gm-Message-State: ALoCoQnEkPm6NbMsC8msqnFbzKB7FWRs4FV+HR82olUyCOXlnujWoaCo9zA7JU83bEnQm10bOKXU X-Received: by 10.112.17.106 with SMTP id n10mr6169127lbd.18.1441026567222; Mon, 31 Aug 2015 06:09:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.73 with SMTP id b9ls457186laf.43.gmail; Mon, 31 Aug 2015 06:09:27 -0700 (PDT) X-Received: by 10.112.182.42 with SMTP id eb10mr10214056lbc.62.1441026567081; Mon, 31 Aug 2015 06:09:27 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id xk9si13108232lac.145.2015.08.31.06.09.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 06:09:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labnh1 with SMTP id nh1so45638778lab.3 for ; Mon, 31 Aug 2015 06:09:26 -0700 (PDT) X-Received: by 10.112.166.106 with SMTP id zf10mr10601336lbb.36.1441026566631; Mon, 31 Aug 2015 06:09:26 -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.151.194 with SMTP id us2csp1626664lbb; Mon, 31 Aug 2015 06:09:25 -0700 (PDT) X-Received: by 10.140.237.140 with SMTP id i134mr38772570qhc.81.1441026565300; Mon, 31 Aug 2015 06:09:25 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 53si16980470qgx.6.2015.08.31.06.09.23; Mon, 31 Aug 2015 06:09:25 -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 CAA4F619A3; Mon, 31 Aug 2015 13:09:23 +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 82E8B61CA1; Mon, 31 Aug 2015 13:06:52 +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 605D461970; Mon, 31 Aug 2015 13:06:19 +0000 (UTC) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by lists.linaro.org (Postfix) with ESMTPS id B8F2361839 for ; Mon, 31 Aug 2015 13:06:14 +0000 (UTC) Received: by wicne3 with SMTP id ne3so74147680wic.0 for ; Mon, 31 Aug 2015 06:06:14 -0700 (PDT) X-Received: by 10.180.107.39 with SMTP id gz7mr20210361wib.82.1441026372932; Mon, 31 Aug 2015 06:06:12 -0700 (PDT) Received: from khorivan.synapse.com ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id ne7sm17955341wic.12.2015.08.31.06.06.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 06:06:11 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Mon, 31 Aug 2015 16:05:50 +0300 Message-Id: <1441026351-5378-4-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441026351-5378-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1441026351-5378-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [odp-lng] [Patch 3/4] 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.51 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 --- 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 709becf..ac32b15 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, start_cycles, cur_cycles, send_duration; uint64_t burst_gap_cycles; uint32_t batch_len; int unsent_pkts = 0; @@ -328,15 +328,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) {