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 965F8A0350; Thu, 25 Jun 2020 10:32:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id ACDE31B5E1; Thu, 25 Jun 2020 10:32:46 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9FBE35B3C for ; Thu, 25 Jun 2020 10:32:45 +0200 (CEST) IronPort-SDR: E1LJSIpyRfCWgwV8xQmoFNGVZ73+nNxQ/dcxI0IUeu5f+2i2f4hzWBg+0Yp0j5gs5ijbYZBk9B RAgB2yLSTDNA== X-IronPort-AV: E=McAfee;i="6000,8403,9662"; a="144851829" X-IronPort-AV: E=Sophos;i="5.75,278,1589266800"; d="scan'208";a="144851829" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2020 01:32:44 -0700 IronPort-SDR: pFR0DqZkipi8A08rmcNx7w9hrAaMOwk/YuTj+9MsnmQhM+Cudfd9zpQCP4RpUWYUvYrYISGNcE +whgZ2p1e7hg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,278,1589266800"; d="scan'208";a="423657993" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by orsmga004.jf.intel.com with ESMTP; 25 Jun 2020 01:32:44 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 25 Jun 2020 01:32:43 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.109) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 25 Jun 2020 01:32:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tmg57CE9BbUk2IZsrpe/nL+orX/t3m5FP56piEE9nw67bz+sRJRxJKRnJ9rE7NbHoVUOSr+Iw+DVgRwOOU945QkBCdD5LEfFji5nApOWluVyE2csQtugDwKE2Xm5K8eyWkAY2BQ0A1E632csbT8eUDqefnRySkzgfSFf+3ztb4xiYtYkXw+ptJfj/HvBksmjcVMXA9/MwiP7I9JNU27PRs6qo5UF5rCAHb9pfKMEgxC2trNOp3fO75ocuTX6IiRfCHYT9fO58KzZUZpIh462MLmY//uF+Mmw7Hk2+p6E98zvWfuWkDf47r4+y0fo+P2DLxfJD6PJY9mM81T/zi58Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uwoJdZ1xAYNjWA3PhAzCVwkcXoAU3U5AVCXht2nt0KE=; b=mzI9sSuGt9179lF7fIukqi+e5mOj9NGkaOZB97ZtDp24M64gdKSSmsQixxoLX3N0rIAybxk6XEPt5ErW5+MzcH0OSA6U+ylpSbMd0PnShqq3XGrMIfvylG07wUm6odn5CP/sQ5cwwLAOQcnzFcWUw3d6OiKzbhv5v0u7p5kf/LDFa404bMvO2amwRKT3ogPYFnlQNBCmr2e46936aaXJMDnXR+L3VgJKZqSpUxUdZ2moSU93DV1jGqKO583yLv8Uqg5v497Sfbv7qGXKGiwB7ygP5Z+ZQBbDShhFp3NyIlkzQrSQhAgCSHLUZlG5+6bIophPfveZzMQTq5NUI9R+aQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uwoJdZ1xAYNjWA3PhAzCVwkcXoAU3U5AVCXht2nt0KE=; b=jmy5fTZqr/jZW1plmHuGj4RKGONtnVeOEmsU2W5ja6Yt52e7IwMu4NzbqOefonPwCIfyaNQ8NUxG4r97p3JXvYbPbMkmo6iMXE3T1UH5K774Ovn9h9wCxKnQo74T2PO9I/CajmDvj79wonD3wQ6xmplB76s67rf2QUjcDPaXozA= Received: from CY4PR11MB0072.namprd11.prod.outlook.com (10.171.253.27) by CY4PR11MB1462.namprd11.prod.outlook.com (10.172.69.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Thu, 25 Jun 2020 08:32:42 +0000 Received: from CY4PR11MB0072.namprd11.prod.outlook.com ([fe80::e979:a537:4a97:afd5]) by CY4PR11MB0072.namprd11.prod.outlook.com ([fe80::e979:a537:4a97:afd5%5]) with mapi id 15.20.3131.021; Thu, 25 Jun 2020 08:32:42 +0000 From: "Singh, Jasvinder" To: Thomas Monjalon CC: "Dumitrescu, Cristian" , "'alangordondewar@gmail.com'" , "dev@dpdk.org" , 'Alan Dewar' , "Dewar, Alan" Thread-Topic: [dpdk-dev] [PATCH] sched: fix port time rounding error Thread-Index: AQHWSnnhAVBj6pORrEmBrpVcu1jLe6jpANOA Date: Thu, 25 Jun 2020 08:32:42 +0000 Message-ID: References: <20200416084821.12591-1-alan.dewar@att.com> <80847da6f3b44c49a3884da76818302e@intl.att.com> <2265604.5qLSFAYZse@thomas> In-Reply-To: <2265604.5qLSFAYZse@thomas> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.151.163] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f3b5ff76-ce9d-4ede-d2d6-08d818e253f0 x-ms-traffictypediagnostic: CY4PR11MB1462: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 0445A82F82 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: fDNiXENG0hGD4kGwd4C4Sehfk2vJ/e45BrhyvLfbgjnsXPxZgO95t7kpKUZybvsCDEviope7TpspWsoj8PDXMIpLNWBQZd1LZ77gJH/cr5WimJbdFkRQm45jI9NrZJ+iKYnYfp4SG5NEHiPnh57dQKFfG1gOxcIN61sHPb80SrdwQwrL/AH3DPXURCJoxfMpfbGw4L/E9Ugx5Ft5It0cDlT1MCI79C2Qjp2ipTrF0H+YV0TPzpeF8H3bKeM/ryoKWrONL9tt94EufN+wdP+CA6m9gkU06+kw5onk4gNEFJ/5iqnZ8fIQHhxu98Mc5halploy4+XOuHiALJfkrODX1g== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CY4PR11MB0072.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(136003)(346002)(376002)(396003)(39860400002)(66476007)(9686003)(6506007)(53546011)(26005)(7696005)(186003)(55016002)(54906003)(71200400001)(5660300002)(8676002)(86362001)(316002)(76116006)(478600001)(4326008)(8936002)(52536014)(64756008)(66946007)(66556008)(66446008)(6916009)(83380400001)(2906002)(33656002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: 4obFqEBJbOUWbkPs7RElRz7VfxGwYexEB/hUjCaOaeRYAbOiyayEFKd2m+byTCPvIsqgXpjyJd2Qf2Gm1xerCtJ6LFN9xJM+mWRmfFNC18dxn66JOC7gGwYaOQ//ocB+dyk+g3DU0nhTBiRo9M1RZ30DSXG1QEPCsPIT0H1vzFBOW2ICxZZjTDoqkw7xCaQdeSMEzmP/kCe2uuZkpa/Dr7e1l/5QT3WTFODjeQUgi2mhS8aWT1qtchJz3DMrCt1Ut87xLSzSGZWevgXMvKldBDh4xC5ypPPW82j1bxrWTU4C00Kqp7rWaHmpND99FzhgZ91qpEjDhBczgrhyx0cYZt5r5SoPOtmNhukxAEgiIwZMSsDis1EIuThOStgWEBTcmzt0lFPonITMqvu+N3KAQPGSpjCxh6MM9avyVDPKIRAPqfKzYF0XSfCZkshD22AP+rtY5Rpy02HtKMkk4fHnxaoZOsNyTfW3uUZSDzsCy9jv3quMki3MgPN2GzYPdjmd Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f3b5ff76-ce9d-4ede-d2d6-08d818e253f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2020 08:32:42.1882 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: haVFY5oL3uF0f2qtkUwJuwZQH7VZT8wdE0kBlGuc0lKstzfDdktEr5ZsNNO5+hYZJ3T3VRvnmlYztisPc6pMxQOI+vBFTE2+7/NT4+8MXUc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1462 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] sched: fix port time rounding error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Thomas Monjalon > Sent: Wednesday, June 24, 2020 11:50 PM > To: Singh, Jasvinder > Cc: Dumitrescu, Cristian ; > 'alangordondewar@gmail.com' ; > dev@dpdk.org; 'Alan Dewar' ; Dewar, Alan > > Subject: Re: [dpdk-dev] [PATCH] sched: fix port time rounding error >=20 > Jasvinder, what is the conclusion of this patch? >=20 > 21/04/2020 10:21, Dewar, Alan: > > From: Singh, Jasvinder > > > > > From: Alan Dewar > > > > > > > > > > The QoS scheduler works off port time that is computed from the > > > > > number of CPU cycles that have elapsed since the last time the po= rt > was > > > > > polled. It divides the number of elapsed cycles to calculate ho= w > > > > > 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 > > > > > --- > > > > > lib/librte_sched/rte_sched.c | 12 ++++++++++-- > > > > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > > > > > > > diff --git a/lib/librte_sched/rte_sched.c > > > > > b/lib/librte_sched/rte_sched.c index c0983ddda..c656dba2d 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 b= ytes > > > > > */ > > > > > uint64_t time; /* Current NIC TX time measured i= n 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 =3D (rte_get_tsc_hz() << RTE_SCHED_TIME_SHIFT) > > > > > / params->rate; > > > > > port->inv_cycles_per_byte =3D > > > > > rte_reciprocal_value(cycles_per_byte); > > > > > + port->cycles_per_byte =3D cycles_per_byte; > > > > > > > > > > /* Grinders */ > > > > > port->pkts_out =3D NULL; > > > > > @@ -2673,20 +2675,26 @@ static inline void > > > > > rte_sched_port_time_resync(struct rte_sched_port *port) { > > > > > uint64_t cycles =3D rte_get_tsc_cycles(); > > > > > - uint64_t cycles_diff =3D cycles - port->time_cpu_cycles; > > > > > + uint64_t cycles_diff; > > > > > uint64_t bytes_diff; > > > > > uint32_t i; > > > > > > > > > > + if (cycles < port->time_cpu_cycles) > > > > > + goto end; > > > > > > Above check seems redundant as port->time_cpu_cycles will always be > less than the current cycles due to roundoff in previous iteration. > > > > > > > This was to catch the condition where the cycles wraps back to zero (af= ter > 100+ years?? depending on clock speed). > > Rather than just going to end: the conditional should at least reset po= rt- > >time_cpu_cycles back to zero. > > So there would be a very temporary glitch in accuracy once every 100+ > years. >=20 Alan, Could you please resubmit the patch with above change? Other than tha= t, patch looks good to me.