From patchwork Fri Sep 11 10:04:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 53436 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id CBEF9215BF for ; Fri, 11 Sep 2015 10:10:51 +0000 (UTC) Received: by lamp12 with SMTP id p12sf23642424lam.2 for ; Fri, 11 Sep 2015 03:10:50 -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=2d5LO8NNofUGQv68k2Q+HCIbdQMzaQzAwsTi2AO2oBM=; b=cs1kh59LbKZIxL5Bnm9yxy8Czmo266JGwcQiioqqHbXlm+M+VYw6eujExW4uzzPDCE HwsQRm13TUzTaQksa8BZUcs/9wHwzHTtCXRvmNfjxR6IdC0ser+e+MWm41l+IM5XN9a2 aggWqjfj2FAzTQcaUBE3wYBN1cZ6oG01pPgRzNMfEbubIgVjXtSfbCpDMPgGnlyUyfln SxnsIk+b+7DoF6gRgroHTGkNoqdm1VJjlv7TZWoJNjPZNEyrhlFm+UdCtuiladSOwFZ/ ojMB9g4GHhkPDpnnIGfGB9+aJxTXYMJQqTeokaxlEuzffCua/K1aNPLcG87Kcqz9+TKU R02w== X-Gm-Message-State: ALoCoQkz5nrmR1Ru3T+vqpWyaehjy/zYn0muH5BiQR919DsX0yMuXWq5GFTAcF1vA4DIpvuwgwaN X-Received: by 10.112.199.5 with SMTP id jg5mr10938089lbc.14.1441966250812; Fri, 11 Sep 2015 03:10:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.163 with SMTP id w3ls352250lae.21.gmail; Fri, 11 Sep 2015 03:10:50 -0700 (PDT) X-Received: by 10.152.37.9 with SMTP id u9mr27060605laj.75.1441966250637; Fri, 11 Sep 2015 03:10:50 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id z5si538551laj.38.2015.09.11.03.10.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 03:10:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lahg1 with SMTP id g1so14672896lah.1 for ; Fri, 11 Sep 2015 03:10:50 -0700 (PDT) X-Received: by 10.152.7.210 with SMTP id l18mr5880970laa.86.1441966250521; Fri, 11 Sep 2015 03:10:50 -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 w3csp1486564lbq; Fri, 11 Sep 2015 03:10:49 -0700 (PDT) X-Received: by 10.140.102.166 with SMTP id w35mr34985123qge.82.1441966249454; Fri, 11 Sep 2015 03:10:49 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e13si558849qhc.3.2015.09.11.03.10.48; Fri, 11 Sep 2015 03:10:49 -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 83F3161995; Fri, 11 Sep 2015 10:10:48 +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 349CD61C8C; Fri, 11 Sep 2015 10:08:23 +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 A6AB961BC2; Fri, 11 Sep 2015 10:08:15 +0000 (UTC) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by lists.linaro.org (Postfix) with ESMTPS id 384086199C for ; Fri, 11 Sep 2015 10:05:41 +0000 (UTC) Received: by wiclk2 with SMTP id lk2so52370766wic.1 for ; Fri, 11 Sep 2015 03:05:40 -0700 (PDT) X-Received: by 10.194.242.166 with SMTP id wr6mr76509058wjc.31.1441965940506; Fri, 11 Sep 2015 03:05:40 -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.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 03:05:39 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Fri, 11 Sep 2015 13:04:49 +0300 Message-Id: <1441965889-15727-6-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 5/5] performance: odp_pktio_perf: fix potential overflow for burst_gap 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.48 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 "next_tx_cycles" is not valid, as "next_tx_cycles" can be overflowed and comparison will give wrong result. So use odp_time_diff_cycles() for that, as it takes in account ticks overflow. Signed-off-by: Ivan Khoronzhuk --- test/performance/odp_pktio_perf.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/performance/odp_pktio_perf.c b/test/performance/odp_pktio_perf.c index ac32b15..85ef2bc 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, start_cycles, cur_cycles, send_duration; + uint64_t burst_start_cycles, start_cycles, cur_cycles, send_duration; uint64_t burst_gap_cycles; uint32_t batch_len; int unsent_pkts = 0; @@ -334,11 +334,12 @@ static void *run_thread_tx(void *arg) cur_cycles = odp_time_cycles(); start_cycles = cur_cycles; - next_tx_cycles = cur_cycles; + burst_start_cycles = odp_time_diff_cycles(cur_cycles, burst_gap_cycles); while (odp_time_diff_cycles(start_cycles, cur_cycles) < send_duration) { unsigned alloc_cnt = 0, tx_cnt; - if (cur_cycles < next_tx_cycles) { + if (odp_time_diff_cycles(burst_start_cycles, cur_cycles) + < burst_gap_cycles) { cur_cycles = odp_time_cycles(); if (idle_start == 0) idle_start = cur_cycles; @@ -351,7 +352,7 @@ static void *run_thread_tx(void *arg) idle_start = 0; } - next_tx_cycles += burst_gap_cycles; + burst_start_cycles += burst_gap_cycles; alloc_cnt = alloc_packets(tx_event, batch_len - unsent_pkts); if (alloc_cnt != batch_len)