From patchwork Thu Sep 17 08:31:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 53779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 6ACD822E57 for ; Thu, 17 Sep 2015 08:34:47 +0000 (UTC) Received: by wicgb1 with SMTP id gb1sf4791289wic.3 for ; Thu, 17 Sep 2015 01:34:46 -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=xL1IA+DO6qTBSjjBiAogWvg6BgegWUOga7CgdDfEZ3Q=; b=nNtQDJUL3RRfCPkEO5/Nw6YmUEyeyu9wbwQbQMKGVUMKJK+b38qDoxpiWKfxc6ZFPM zSU6oNIVe97Gjk6wL/eOFtluzhQnnQ1wNwwDtTVOzRS7Wmjb4sX2tFAocI8gMM+e17dW UmiYx3b572rLgLAcvr6Y2h3oxqhAi9pIc0dKMHztpC/dK9qYL7whg0CgGjs1bB+kCsT2 T7I/eV8dsgiLAlkRQ/W8ZJ/OSCud3Zzfpe88fSpq3kboJri5LNCq5vppO5B/XZFo1hdf o21lsKHXrEmUlSUP1lIQQKI7PrFpXIUeLX9rrO5xkMWOCgPxUVk37YEJ4sEVy4jFP2L/ SThQ== X-Gm-Message-State: ALoCoQlQEvxbVtzeURcQDjjU4n0cQXEhGN7mq7LsjzzsjvRRAbJWmRdzpsd8fz76qg+MeXs3iLhy X-Received: by 10.152.9.36 with SMTP id w4mr3777610laa.7.1442478886251; Thu, 17 Sep 2015 01:34:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.137 with SMTP id k9ls64985lak.79.gmail; Thu, 17 Sep 2015 01:34:46 -0700 (PDT) X-Received: by 10.112.168.66 with SMTP id zu2mr34505529lbb.29.1442478886102; Thu, 17 Sep 2015 01:34:46 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id xl6si1497720lac.66.2015.09.17.01.34.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 01:34:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lanb10 with SMTP id b10so6592509lan.3 for ; Thu, 17 Sep 2015 01:34:46 -0700 (PDT) X-Received: by 10.112.156.167 with SMTP id wf7mr34609641lbb.88.1442478885974; Thu, 17 Sep 2015 01:34:45 -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 w3csp2926658lbq; Thu, 17 Sep 2015 01:34:45 -0700 (PDT) X-Received: by 10.107.3.94 with SMTP id 91mr3850462iod.178.1442478884995; Thu, 17 Sep 2015 01:34:44 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p125si587427ioe.162.2015.09.17.01.34.44; Thu, 17 Sep 2015 01:34:44 -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 729BA62C51; Thu, 17 Sep 2015 08:34:44 +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 7FE9162D5A; Thu, 17 Sep 2015 08:32: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 52F0361A22; Thu, 17 Sep 2015 08:32:16 +0000 (UTC) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by lists.linaro.org (Postfix) with ESMTPS id 5B82262C21 for ; Thu, 17 Sep 2015 08:31:43 +0000 (UTC) Received: by wicgb1 with SMTP id gb1so107158025wic.1 for ; Thu, 17 Sep 2015 01:31:42 -0700 (PDT) X-Received: by 10.180.240.172 with SMTP id wb12mr27569745wic.64.1442478702615; Thu, 17 Sep 2015 01:31:42 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id s16sm8743445wik.13.2015.09.17.01.31.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Sep 2015 01:31:42 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Sep 2015 11:31:31 +0300 Message-Id: <1442478691-30098-6-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442478691-30098-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1442478691-30098-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 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.43 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 into 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 61ff312..4dfeb6a 100644 --- a/test/performance/odp_pktio_perf.c +++ b/test/performance/odp_pktio_perf.c @@ -305,7 +305,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; @@ -336,11 +336,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(burst_gap_cycles, cur_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; @@ -353,7 +354,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)