From patchwork Thu Aug 6 14:30: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: 52005 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id EFFF520539 for ; Thu, 6 Aug 2015 14:32:12 +0000 (UTC) Received: by labia3 with SMTP id ia3sf6297140lab.1 for ; Thu, 06 Aug 2015 07:32:11 -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=HSdL3gfXZc/MrzMdJ5Yjfe0XJKzXax25u5KnJ1vin9w=; b=Gvr73MMpZoid0OzZObWnifbHjck8cgRuXb0rk9rQc5ZB+PVzKvAKJHdZctHX4xwj1g /E8uS4O0I9K3Cwn8WEi3QgN6gAcQHDf5jf7Qbh6YjOuLf2VQw7OMoX1dMjpHbQUz+vQO L9LxcOuufFRCfB/9GuVDOiHGncIUsfGzziX6+q+O3UanJsTTs0f3ybWllkThdZPaoFBj csz9gDHT5Ovr5Cer5+OxF1tNV14vRTvVjFTI8A3WVRlVjXqYLmzH8PdtamGdBRcU1mlP KhHaKF53/Q3HQ8+CFUaA5ZSjJ4dz0g3qCi8/uu6ffnzrQyMZmqrVV+0EQFaR0xSX4ece zkWg== X-Gm-Message-State: ALoCoQlWKGRfrdv8Tw+vg5aw9bWR7YJrdAcTupHS5+JZ+jMfenjnNalDd7c3NaaahdxIi/1PPvTD X-Received: by 10.112.218.10 with SMTP id pc10mr611890lbc.8.1438871531603; Thu, 06 Aug 2015 07:32:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.73 with SMTP id k9ls314591lam.66.gmail; Thu, 06 Aug 2015 07:32:11 -0700 (PDT) X-Received: by 10.152.30.100 with SMTP id r4mr2121272lah.92.1438871531320; Thu, 06 Aug 2015 07:32:11 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id ef7si4971757lbb.44.2015.08.06.07.32.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Aug 2015 07:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by labkb6 with SMTP id kb6so28299626lab.2 for ; Thu, 06 Aug 2015 07:32:11 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr2092371lbc.41.1438871531177; Thu, 06 Aug 2015 07:32: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 l6csp986671lba; Thu, 6 Aug 2015 07:32:10 -0700 (PDT) X-Received: by 10.141.28.2 with SMTP id f2mr3829780qhe.9.1438871529771; Thu, 06 Aug 2015 07:32:09 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j67si12063282qhc.87.2015.08.06.07.32.09; Thu, 06 Aug 2015 07:32:09 -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 04FF0620DE; Thu, 6 Aug 2015 14:32:08 +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 EF53E620F4; Thu, 6 Aug 2015 14:30:59 +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 BDA01620D0; Thu, 6 Aug 2015 14:30:46 +0000 (UTC) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 7E65F620D2 for ; Thu, 6 Aug 2015 14:30:39 +0000 (UTC) Received: by labkb6 with SMTP id kb6so28268400lab.2 for ; Thu, 06 Aug 2015 07:30:38 -0700 (PDT) X-Received: by 10.112.135.131 with SMTP id ps3mr2125885lbb.84.1438871438285; Thu, 06 Aug 2015 07:30:38 -0700 (PDT) Received: from khorivan.itg.ti.com ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id kl3sm489437lbb.28.2015.08.06.07.30.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Aug 2015 07:30:37 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 6 Aug 2015 17:30:30 +0300 Message-Id: <1438871431-27825-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438871431-27825-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1438871431-27825-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [Patch v2 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.50 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..360d832 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) {