From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C8F5A0518 for ; Fri, 24 Jul 2020 14:06:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 94FB91C0C6; Fri, 24 Jul 2020 14:06:01 +0200 (CEST) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by dpdk.org (Postfix) with ESMTP id 7F9B31C0D4 for ; Fri, 24 Jul 2020 14:05:59 +0200 (CEST) Received: by mail-wm1-f48.google.com with SMTP id 3so1117932wmi.1 for ; Fri, 24 Jul 2020 05:05:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZA0usvYp9OwWMeeiabxl0nT8NTdsKliuzwPKEDhrCrs=; b=aP8yQxdH0+m6RjXEf+obzIrBl7GVCRVamU2R6cwHH4Zxn2BbUkJluAZX2i5KfaLBjf wOOo8MYflX8paeM1rvf6B4XDw1JzF0KZvptn4APMw7vkPDKGaGw0IR8ryxKg4EphJ4fw ryu7M3v7JKitwwp8SGdy3j6Hc3ZHpAtIsisCDSGDCxVGwpMhx7GKuEkef+g9HGhHURtI 7Cf3z2rGqIQEXS6dqyN384LLuNnKUwjv20QBZMBtKQT59jiyiNGl8QO/O9P/Vg7Yip5I 2ZSPgAEy6f279JnGRIWlk/EUNRRGPqbRTRYv2+W+9q+ZzftSiCkw3cjYLMuTAWX75V+2 tGNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZA0usvYp9OwWMeeiabxl0nT8NTdsKliuzwPKEDhrCrs=; b=WLHBFBZUNF3PYzACQGovH+lBDfmSNbLCYBUIfBkVZCkEtPaU5ugHvX7ngq+PyTavr9 DYXPPqHxwaj20BoydCYjYKDltiYKqeOn0EqRol4c56ydcQi+MtKCDCxQpJStGXIDCrUb kQ2f43EpD4n4rA1QO5f7hRiMAbnx+cfDjrZ0YOiCWrHY1G8OanlwmLjj4lVj6sb+kpbj vI4x8zZn4InSvXvej2YKpUZL5wnF15/UaNfEBZYSF0nfk78aOBE8VNx3/L0jX00U8BLg CGXC+kkMTF8786S/8cfYBs3TciZUJ43NM9xZLuN8gq8wNqQs01x+3+8Nhw+Sg6ydOW5g YC+A== X-Gm-Message-State: AOAM530Qs+3BQqQcqw6CrAIKbc74PGqxtSOeBChCco3RjoOqkdhfP7nh t6YWtt9HisQX+tp04fdaado= X-Google-Smtp-Source: ABdhPJzZmCNvFMGc4NNv41+/dHkcd+GTEOzYHvaBmDQMo5XJ1qqCnesjKgAQWnMoCMhKtcdOj6kemg== X-Received: by 2002:a1c:2d89:: with SMTP id t131mr8802842wmt.151.1595592359194; Fri, 24 Jul 2020 05:05:59 -0700 (PDT) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id 62sm1214155wrq.31.2020.07.24.05.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 05:05:58 -0700 (PDT) From: luca.boccassi@gmail.com To: Alan Dewar Cc: Jasvinder Singh , dpdk stable Date: Fri, 24 Jul 2020 12:58:36 +0100 Message-Id: <20200724120030.1863487-78-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200724120030.1863487-1-luca.boccassi@gmail.com> References: <20200724120030.1863487-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'sched: fix port time rounding' has been queued to stable release 19.11.4 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 19.11.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/20. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 7dfa5c18513abc6734cd47c0ce4851456d09c255 Mon Sep 17 00:00:00 2001 From: Alan Dewar Date: Thu, 25 Jun 2020 10:59:30 +0100 Subject: [PATCH] sched: fix port time rounding [ upstream commit 83415d4fd88c925002655aa755601998a3cdef2c ] The QoS scheduler works off port time that is computed from the number of CPU cycles that have elapsed since the last time the port was polled. It divides the number of elapsed cycles to calculate how many bytes can be sent, however this division can generate rounding errors, where some fraction of a byte sent may be lost. Lose enough of these fractional bytes and the QoS scheduler underperforms. The problem is worse with low bandwidths. To compensate for this rounding error this fix doesn't advance the port's time_cpu_cycles by the number of cycles that have elapsed, but by multiplying the computed number of bytes that can be sent (which has been rounded down) by number of cycles per byte. This will mean that port's time_cpu_cycles will lag behind the CPU cycles momentarily. At the next poll, the lag will be taken into account. Fixes: de3cfa2c98 ("sched: initial import") Signed-off-by: Alan Dewar Acked-by: Jasvinder Singh --- lib/librte_sched/rte_sched.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c index 68a171b50..0fa074166 100644 --- a/lib/librte_sched/rte_sched.c +++ b/lib/librte_sched/rte_sched.c @@ -222,6 +222,7 @@ struct rte_sched_port { uint64_t time_cpu_bytes; /* Current CPU time measured in bytes */ uint64_t time; /* Current NIC TX time measured in bytes */ struct rte_reciprocal inv_cycles_per_byte; /* CPU cycles per byte */ + uint64_t cycles_per_byte; /* Grinders */ struct rte_mbuf **pkts_out; @@ -852,6 +853,7 @@ rte_sched_port_config(struct rte_sched_port_params *params) cycles_per_byte = (rte_get_tsc_hz() << RTE_SCHED_TIME_SHIFT) / params->rate; port->inv_cycles_per_byte = rte_reciprocal_value(cycles_per_byte); + port->cycles_per_byte = cycles_per_byte; /* Grinders */ port->pkts_out = NULL; @@ -2673,16 +2675,21 @@ static inline void rte_sched_port_time_resync(struct rte_sched_port *port) { uint64_t cycles = rte_get_tsc_cycles(); - uint64_t cycles_diff = cycles - port->time_cpu_cycles; + uint64_t cycles_diff; uint64_t bytes_diff; uint32_t i; + if (cycles < port->time_cpu_cycles) + port->time_cpu_cycles = 0; + + cycles_diff = cycles - port->time_cpu_cycles; /* Compute elapsed time in bytes */ bytes_diff = rte_reciprocal_divide(cycles_diff << RTE_SCHED_TIME_SHIFT, port->inv_cycles_per_byte); /* Advance port time */ - port->time_cpu_cycles = cycles; + port->time_cpu_cycles += + (bytes_diff * port->cycles_per_byte) >> RTE_SCHED_TIME_SHIFT; port->time_cpu_bytes += bytes_diff; if (port->time < port->time_cpu_bytes) port->time = port->time_cpu_bytes; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2020-07-24 12:53:51.570962574 +0100 +++ 0078-sched-fix-port-time-rounding.patch 2020-07-24 12:53:48.303006758 +0100 @@ -1,8 +1,10 @@ -From 83415d4fd88c925002655aa755601998a3cdef2c Mon Sep 17 00:00:00 2001 +From 7dfa5c18513abc6734cd47c0ce4851456d09c255 Mon Sep 17 00:00:00 2001 From: Alan Dewar Date: Thu, 25 Jun 2020 10:59:30 +0100 Subject: [PATCH] sched: fix port time rounding +[ upstream commit 83415d4fd88c925002655aa755601998a3cdef2c ] + The QoS scheduler works off port time that is computed from the number of CPU cycles that have elapsed since the last time the port was polled. It divides the number of elapsed cycles to calculate how @@ -21,7 +23,6 @@ account. Fixes: de3cfa2c98 ("sched: initial import") -Cc: stable@dpdk.org Signed-off-by: Alan Dewar Acked-by: Jasvinder Singh