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 77EE8A00C5; Mon, 6 Jul 2020 23:20:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0A6491D716; Mon, 6 Jul 2020 23:20:56 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 18C2C1D658 for ; Mon, 6 Jul 2020 23:20:53 +0200 (CEST) IronPort-SDR: 4IiNccopcrkMO2b9TnksjXhkXZPvWvnFGqC9JpLKp80IVt+DF1Z/6byDCrYG1vMFQWTIBjWtZc GTFlx/LdNNeA== X-IronPort-AV: E=McAfee;i="6000,8403,9674"; a="134966509" X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="134966509" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2020 14:20:53 -0700 IronPort-SDR: 9H+molerW3zFY648PbSswGTIwRcARaL5muqx22EXevL/mZXaE4VuK22fEhwCQsl1sDgdDSxdYq Oflv2okEtOYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,321,1589266800"; d="scan'208";a="314074915" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2020 14:20:52 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 14:20:52 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 6 Jul 2020 14:20:50 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 6 Jul 2020 14:20:50 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 6 Jul 2020 14:20:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MDn2fan4QNP5aCHA4z+7e84Mrtn5kWC9ioM4USrfspIAou5XFZJWQJOM8sALJlWn2JzyU8KmoJytQnF+mRzqrpJzGdhc0qc0UMJBGyWlHLbOWsZ0cbfXmH7TlOE43inTVBInJxjM3/RLKvf7dYCh93+ovzOU32dnMGYuaOKg4pgLur6I2BhVWXvYF4wziFvy5kIw+1fCNHwRuzo7MbW2lhD/vmleCABWIxKNfr2mV6bZNvIDqjiN/L1OmHMylyEXkmFSJvu/Jhb/O8PdInOLzBp3yNcQJxW7m//6DxET61FdA90f/NSlkV59TKookJYB9BLSOQQIRzuB7uOam2vKrg== 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=0ikOoqrJx37GMVPonpP4Pw1HAEi1o5gf5PFqY9cEC64=; b=Na1vyNZPCt/6OOCbe2WL0bg6yhURzc+FUjDS0giSNPkYaH/eNEHrPGRu6mKYdtfH01cFtnsIlbyy0CDVG9jLKFW+QJmUtyu9dr1Fru50kbd5Lqm2vvWHBKwiuME1Af+3nTbqt7e2Yvs7ae+rszAOzo4TMht1fYk0df2C/TbLe6V4h2w/C+hy4BbQxXXWYokBCeYHYBeWyG7DgRFlYEB8DxVooiMVJNb/dtQsGDbet5bNGLK+d4Rah6ZoXZRjWBX6L5KrUCW3Ir16aiiM6ToIoMbzAyvsIwY1VzHtrSARzv/1BS7fm3oeW4Gz2jbqsbmM++Q0+JEaYg2INQFP+1g8XA== 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=0ikOoqrJx37GMVPonpP4Pw1HAEi1o5gf5PFqY9cEC64=; b=iuMJ0096B3O4adDkrvCslD5/vEGeh4LcIHJwQ+NpdEqQr1TbWelrsS9FvyqQbVaZO/UxB9QpwWr1SneECjLsh0NxRpPZvO532j6/mzlFum+ZCpgilUH2ckS0OEkQTu+FwnsrcOFV9OHyqiJPmRpIOm/zINl4zhUdlesUG+imcyY= Received: from CY4PR11MB0072.namprd11.prod.outlook.com (2603:10b6:910:76::27) by CY4PR11MB1831.namprd11.prod.outlook.com (2603:10b6:903:11d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.27; Mon, 6 Jul 2020 21:20:49 +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.3153.029; Mon, 6 Jul 2020 21:20:49 +0000 From: "Singh, Jasvinder" To: "dev@dpdk.org" , Alan Dewar CC: "alangordondewar@gmail.com" , Thomas Monjalon , "Dumitrescu, Cristian" Thread-Topic: [dpdk-dev] [PATCH v2] sched: fix port time rounding error Thread-Index: AQHWStdska6bgWJB70Oq3FrZrqlAGaj5g7sAgAGb36A= Date: Mon, 6 Jul 2020 21:20:48 +0000 Message-ID: References: <20200416084821.12591-1-alan.dewar@att.com> <20200625095930.18429-1-alan.dewar@att.com> <1765563.QPqcEuCtyy@thomas> In-Reply-To: <1765563.QPqcEuCtyy@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: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=intel.com; x-originating-ip: [109.76.22.53] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e64a6dcc-f1ea-456f-abf4-08d821f27468 x-ms-traffictypediagnostic: CY4PR11MB1831: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 04569283F9 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0EJC+8yNKJvBRGMNKRkbcuT7MVLZPyJwhKlpaWkIsRVzTOyzgOjzAx0sVjpUNHifarijAGuw1b79b2yUpdXyNlko3Vor0tq5AMIJ36/UW/wRo1qi4NlRyu8Aqconlr4M700xNz5WFtcFM1auHyl7grb37atfF9XbDjYj9d3xcwQuh2tUyhCAhbWvMy7VsiH1LAp9jg9mJnql3Z1r1agt2iwc0RzC607MjNGFQ8F65uu6QHIEusp/Hge/uf6wFoy+0V2GK6Gm+1vwwGeBdTmhVMaOZRMiOEFkUJudERLCi5Gs4lpknQJ0WV9v30ApYkWXNEfBoG63/as3Nm63iz9VEQ== 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)(136003)(396003)(346002)(39860400002)(366004)(376002)(66476007)(66556008)(53546011)(83380400001)(6506007)(2906002)(8936002)(33656002)(71200400001)(26005)(8676002)(186003)(316002)(110136005)(7696005)(54906003)(86362001)(66946007)(107886003)(66446008)(64756008)(55016002)(4326008)(76116006)(5660300002)(478600001)(9686003)(52536014); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: V4lGRrijQGjZOMkW4NdEqdXadzNHC0NVtOK4A16L/dM1mZcZqvQT7bBJY8IbchhIJ/EFnsNJXTj8BUlRR9r5sg0cIB5UhBZ7TXcu24obPE4r2Srr5gkyNrgQ4mezWO6xBMCf2KEoTWdncT5wQrWPW3mPgp/1429VZGG4dGfzn9siKYcT5hc1UGdc3nm8wT25GuUXhM28jA2byTDB5cdXfaz29PGusR8DjaZlQwHI6RdZmEsEPVNvEbPDQQ2+H0pWv+L9WIgWwKuBKuWf2fEB8GifmJrnCt6fm01OLDrQMc/L8oxWsUBn7vMK5sOrdX6OWC3oAu52aVppNaeTuSxqNoATapQRo0ovHCmRgpmhQHqVfQpQsyAkPHNEhEaNHffxTFv5G+7ZL99NqaboWxe+AnOJxRONDh1wG8iAErECrAJ2AKbVJpK5PYpUTx5p3Ve5m2z2qTGc8K5wfctVMT3RHLCSzMm08a4FC+2hH/9LutI= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB0072.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e64a6dcc-f1ea-456f-abf4-08d821f27468 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jul 2020 21:20:49.0035 (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: u3NkAahRKzNyrTU/dxjO0B5cTHKgEF0QplAa67vobRlqVE41T0gSWNtDReTf1ELltpKY3Gr7zlGfgJkM8UmblHAhdl0+SohHOiVZpAyNt+w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1831 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2] 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: Sunday, July 5, 2020 9:42 PM > To: Dumitrescu, Cristian ; Singh, Jasvinde= r > > Cc: dev@dpdk.org; Alan Dewar ; > alangordondewar@gmail.com > Subject: Re: [dpdk-dev] [PATCH v2] sched: fix port time rounding error >=20 > Cristian, Jasvinder, please review. >=20 > 25/06/2020 11:59, alangordondewar@gmail.com: > > 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 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. > > > > v2: > > If the cycles value wraps (100 year+) reset the port's cpu cycle back > > to zero. > > > > Fixes: de3cfa2c98 ("sched: initial import") > > > > Signed-off-by: Alan Dewar > > --- > > 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 c0983ddda..7c022cd61 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 byte= s */ > > 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,16 +2675,21 @@ 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) > > + port->time_cpu_cycles =3D 0; > > + > > + cycles_diff =3D cycles - port->time_cpu_cycles; > > /* Compute elapsed time in bytes */ > > bytes_diff =3D rte_reciprocal_divide(cycles_diff << > RTE_SCHED_TIME_SHIFT, > > port->inv_cycles_per_byte); > > > > /* Advance port time */ > > - port->time_cpu_cycles =3D cycles; > > + port->time_cpu_cycles +=3D > > + (bytes_diff * port->cycles_per_byte) >> > RTE_SCHED_TIME_SHIFT; > > port->time_cpu_bytes +=3D bytes_diff; > > if (port->time < port->time_cpu_bytes) > > port->time =3D port->time_cpu_bytes; > > >=20 Acked-by: Jasvinder Singh