From patchwork Fri Sep 11 10:04:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 53435 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 2CA0B215BF for ; Fri, 11 Sep 2015 10:10:24 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf22757585lbb.3 for ; Fri, 11 Sep 2015 03:10:23 -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=mAGzWsqIf/hqAQY/SQsPg4WZiXd4j7dvj5Qprl6p6S4ucXVuV/U78BcD4Wbe1u+TkX sGUeVzI1nOFOjPgBsfQZjciWMulNjIQzqaUAgxFwYahrAwrvEm68VUMYyV1mgxgl4lMf mJuBPGuGIZzNzOLVE94MVjpO3i578YoV6C1CSdY+ELmy/3nX1GT9FwQ1p7QCCnx3lB53 mnbgNoef2h9jtF35bkscNxdIzaP7Xl7tOFpqPTA/kZ4TbonT+gDpH1KrxLJ6siPZ1fAU d0snDjHJr55pA13CGiO4856WDTECfIjSTUiyV8rXmeTxuWIDydFTyBC0lqpkfZcghmHn H7lA== X-Gm-Message-State: ALoCoQkSIRnGWzFNQdkp9G1r7VoHjcOBet+PIMwqZJuJjYUFv7REHDS4VlH8qqbiAIjDXHGu6nvy X-Received: by 10.112.16.200 with SMTP id i8mr11116956lbd.20.1441966223129; Fri, 11 Sep 2015 03:10:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.227 with SMTP id z3ls264412lad.97.gmail; Fri, 11 Sep 2015 03:10:23 -0700 (PDT) X-Received: by 10.112.199.5 with SMTP id jg5mr40937568lbc.57.1441966222973; Fri, 11 Sep 2015 03:10:22 -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 d9si517789laf.139.2015.09.11.03.10.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 03:10:22 -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 lanb10 with SMTP id b10so44526945lan.3 for ; Fri, 11 Sep 2015 03:10:22 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr41779196lbb.56.1441966222831; Fri, 11 Sep 2015 03:10:22 -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 w3csp1486328lbq; Fri, 11 Sep 2015 03:10:22 -0700 (PDT) X-Received: by 10.140.148.203 with SMTP id 194mr64802976qhu.102.1441966221984; Fri, 11 Sep 2015 03:10:21 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a33si526414qga.123.2015.09.11.03.10.21; Fri, 11 Sep 2015 03:10:21 -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 1EF1061995; Fri, 11 Sep 2015 10:10:21 +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 DA0C561C7A; Fri, 11 Sep 2015 10:08:21 +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 419EB61BB8; Fri, 11 Sep 2015 10:08:13 +0000 (UTC) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by lists.linaro.org (Postfix) with ESMTPS id 10C8261963 for ; Fri, 11 Sep 2015 10:05:40 +0000 (UTC) Received: by wiclk2 with SMTP id lk2so58319201wic.0 for ; Fri, 11 Sep 2015 03:05:39 -0700 (PDT) X-Received: by 10.194.172.33 with SMTP id az1mr79264704wjc.57.1441965939328; Fri, 11 Sep 2015 03:05:39 -0700 (PDT) Received: from khorivan.synapse.com ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id ww8sm987313wjb.4.2015.09.11.03.05.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 03:05:38 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Fri, 11 Sep 2015 13:04:48 +0300 Message-Id: <1441965889-15727-5-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441965889-15727-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1441965889-15727-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v2 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.215.52 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 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) {