From patchwork Mon Aug 31 13:05:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 52892 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 C2E842127E for ; Mon, 31 Aug 2015 13:08:45 +0000 (UTC) Received: by wizs10 with SMTP id s10sf385577wiz.3 for ; Mon, 31 Aug 2015 06:08:45 -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=T97K+2nO93agMQp7hmsVcyo+a+h5+GPC/8aX/OlfdUdt+7Sujf7i7TpeqykFHRHc19 4ejNa2VpUvYMkEzTxBIr+cVX5wuPhmjge8jn6BeGBLzWLpxi7scXvnDn/0AP/RAQekLh WAlWAyJSrO9GTPDIYJ8H227AZo+UQUvhO1ST4eu+GPqk4WZ4bWCMAqrUVXZDg3eLyeO4 0N5Y0qIma11cMu1oTQ5WWE2ktki4U2OdonNBFyU1YXT4/tQuJtIabP1lloNXWEj6TIeD peuy/LzZ8ZCpT9m8U6CVGrzH+Mtm44Y/DV7IV2fpeYR3aossS0py/NTgp7MLWJcS/MOU FJxA== X-Gm-Message-State: ALoCoQkxjwnoa6Rhzty3PfGJ4UjnPNORhiWH5IUhh0w/wUdcUgQrX3DlofckVJ/QGq1In8gwC2VX X-Received: by 10.194.184.6 with SMTP id eq6mr6205107wjc.4.1441026525093; Mon, 31 Aug 2015 06:08:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.224.129 with SMTP id rc1ls173455lac.6.gmail; Mon, 31 Aug 2015 06:08:44 -0700 (PDT) X-Received: by 10.152.5.69 with SMTP id q5mr10336615laq.92.1441026524944; Mon, 31 Aug 2015 06:08:44 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id w5si2908019lal.38.2015.08.31.06.08.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 06:08:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbtg9 with SMTP id tg9so60097081lbb.1 for ; Mon, 31 Aug 2015 06:08:44 -0700 (PDT) X-Received: by 10.152.5.228 with SMTP id v4mr10601166lav.36.1441026524839; Mon, 31 Aug 2015 06:08:44 -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 us2csp1626201lbb; Mon, 31 Aug 2015 06:08:43 -0700 (PDT) X-Received: by 10.55.195.17 with SMTP id a17mr8965290qkj.84.1441026523483; Mon, 31 Aug 2015 06:08:43 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p28si16943714qkh.92.2015.08.31.06.08.42; Mon, 31 Aug 2015 06:08:43 -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 509C861970; Mon, 31 Aug 2015 13:08:42 +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 3DB8361CBE; Mon, 31 Aug 2015 13:06:50 +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 8AFDF61970; Mon, 31 Aug 2015 13:06:17 +0000 (UTC) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by lists.linaro.org (Postfix) with ESMTPS id 42A4761988 for ; Mon, 31 Aug 2015 13:06:15 +0000 (UTC) Received: by wicpl12 with SMTP id pl12so27061638wic.1 for ; Mon, 31 Aug 2015 06:06:14 -0700 (PDT) X-Received: by 10.194.97.196 with SMTP id ec4mr27399528wjb.3.1441026373949; Mon, 31 Aug 2015 06:06:13 -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.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 06:06:13 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Mon, 31 Aug 2015 16:05:51 +0300 Message-Id: <1441026351-5378-5-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 4/4] 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.217.176 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)