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 6CE6FA0561; Mon, 20 Apr 2020 13:23:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 79F8A1D441; Mon, 20 Apr 2020 13:23:23 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id ACAA11C23D for ; Mon, 20 Apr 2020 13:23:21 +0200 (CEST) IronPort-SDR: nBCjCm3H9q9p+GvYEPXV/EU5L8HN/lLeQCi8ZzOj3TlIM4EjSVIsjbodzNnj8Igruzzz/0TPLT LwkzHTZZAlvA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2020 04:23:20 -0700 IronPort-SDR: soocabUEbaqVzAClDU1ZvjpFJZ9Sfy87zlV5WAeezECvhsct5oMqCUenAIockAzITZpcG/5gna HZ7vAcpMRaCw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,406,1580803200"; d="scan'208";a="254910571" Received: from orsmsx103.amr.corp.intel.com ([10.22.225.130]) by orsmga003.jf.intel.com with ESMTP; 20 Apr 2020 04:23:20 -0700 Received: from orsmsx162.amr.corp.intel.com (10.22.240.85) by ORSMSX103.amr.corp.intel.com (10.22.225.130) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 20 Apr 2020 04:23:20 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX162.amr.corp.intel.com (10.22.240.85) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 20 Apr 2020 04:23:20 -0700 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.52) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 20 Apr 2020 04:23:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MfbfKpq1bsyKDt/ggVC6J3vLvcO8Ed6/waWmzZD1lhXGyVHyVzwJDcbVPIpyOVMdPlLxXUh9M9IVOjqcsRUEpcLSc+2ytyyt8UcjkyQvAoAPVS5oJ7BjjHOiZWLmeQYnixKTbF2p3JCmp7OdYt3/ECQQA3uvPiNqKyuOV27NVZ1kufrlO8NVFsdfa3680jA+wQHevLnLu7uKT7e8FQRVpHXkg7rDSFJOeLUCKx04LZCXQALkEV1vE6AVD1btu27y3DZsyPJn3pE4oyrOITEuyCS5ImPZpUabWgW1tre57nfFnbwurLcCcDZrzd1nt5NBx0O1H4X9CvOZ6M7iGLfrSg== 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=O5+mpoDMXfjfrSjVAm5/X40GcV4Q589uiH6K1mHEzvY=; b=Qu3NNLZlhE2I1HCnnl0CW96sgJ8iT+pXzHJmJtLVHKXHs1sjB+IrdjvI6753YmRsqZVLlnK0KJRcVBGQFQ3Njam+sWJYjKXfMAVawUgPvzAuOSplBb7sZzQzWOi+2LfEXD7lURTYkHETrt4pOWcE9CVhsYWT2tdSSj3kEzaKfyJpxPVYnXqk1bcRYe1RfPnavSGZ5+blUshzofoYXh4yWEzeRlS73c9AprPboDJXgogcbKvqI7Zk8FPh/vx2UlH0pkmW9bz5li7eBmv43QSHtRwVcRLBbub4jrQGcgpgcc806WIXUJsDJGxcA/XqiI60VmGX8ON5xcVB0NPMm4EUOw== 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=O5+mpoDMXfjfrSjVAm5/X40GcV4Q589uiH6K1mHEzvY=; b=mraVUaY1xwCBViIE9l6ChrmWrfgcPDMknf/ejMuvGHMq8N2rl/D5/Y5aD/Bw3yycN7jjuXyXeO2VzOVIHeE8i5SMeArJY/DhQ5m+5CE3zK8i5CQzPclVkXpvy+YFkthwTtF4ik1eJEmqcgQkoHWszQoAIII+2cdySTnJB5sIrEo= Received: from CY4PR11MB0072.namprd11.prod.outlook.com (2603:10b6:910:76::27) by CY4PR11MB0069.namprd11.prod.outlook.com (2603:10b6:910:79::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Mon, 20 Apr 2020 11:23:16 +0000 Received: from CY4PR11MB0072.namprd11.prod.outlook.com ([fe80::e850:5d21:3c97:a66b]) by CY4PR11MB0072.namprd11.prod.outlook.com ([fe80::e850:5d21:3c97:a66b%6]) with mapi id 15.20.2921.027; Mon, 20 Apr 2020 11:23:16 +0000 From: "Singh, Jasvinder" To: "Dumitrescu, Cristian" , "alangordondewar@gmail.com" CC: "dev@dpdk.org" , Alan Dewar Thread-Topic: [PATCH] sched: fix port time rounding error Thread-Index: AQHWFP3W9stmFbOvSk6m+sp8ghfjr6iB3V4g Date: Mon, 20 Apr 2020 11:23:16 +0000 Message-ID: References: <20200416084821.12591-1-alan.dewar@att.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: spf=none (sender IP is ) smtp.mailfrom=jasvinder.singh@intel.com; x-originating-ip: [109.77.175.95] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7d94b8ec-d11f-415f-1aac-08d7e51d38b9 x-ms-traffictypediagnostic: CY4PR11MB0069: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 03793408BA 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:(10019020)(136003)(396003)(346002)(39860400002)(376002)(366004)(26005)(7696005)(6506007)(5660300002)(53546011)(478600001)(110136005)(66476007)(54906003)(186003)(66446008)(64756008)(66556008)(316002)(33656002)(66946007)(52536014)(76116006)(9686003)(86362001)(8676002)(71200400001)(8936002)(55016002)(4326008)(81156014)(2906002); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: EUQXOOApNVbcvvBStXsYDbGYsZwCeTPivC2btZcX3pG9B2jp90J25j9bpFn9R/O+F9OI1AxEc6YXaLHHYdJRTxI7GPdvZXHvmVFFKyO8Q/xZunSy4IpSyKci5EbGTEMz/L1/YmCS8due6a94JUJIbaJoI7ew2AOU3WpMFyrngXbCs1qBXuIqhXvWeGFLpQhPzZ1eaMhe1wrcpOHfhg6ij3CA91SbS5dOJBpAH9ep6m5gDn7fle0yQL7/BrLNlgujYvt7lL5jmwEc/icarKx2K3t/Mdk8yK3hCxuDa8KBS+A5Ad9qhCrD+hy0B3u/VZyKmt86BaBgsXtQcgnv/DR/73QA/3UOdS+ZmjQElqU2PgmSuB/ouTRhRyIEr+uc2Pu9vm6IehHsIaG5BbYvGaWF/7zIM7qcYu7yqUtBS9kiGQ4+axtHz8dk6sb/e8zmgtcc x-ms-exchange-antispam-messagedata: S8ujUkeX0/HH+11VUhQ6tf8TLFSVJs7MoX0XTXKqj8vUkUaZHqDMaC5qM9Y7A8gQb1o7gnNa9EPhUS8w6+GbAiw4Dabzf9tUieLGeAovfH453/x6zQH7DPa1cFg/kwIM8qCjDSEToyVn+/beiCqDfA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7d94b8ec-d11f-415f-1aac-08d7e51d38b9 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2020 11:23:16.3622 (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: qsmCHt+McOGbhcToahWSaDphH8aUo7umEb87AgDRDZl3e73bTw1ATFwd7VIbxfWk0GsteecR97u7ansL2qmKgd+YYCjre9In/QdHMr06tGM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB0069 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: Dumitrescu, Cristian > Sent: Friday, April 17, 2020 10:19 PM > To: alangordondewar@gmail.com > Cc: dev@dpdk.org; Alan Dewar ; Singh, Jasvinder > > Subject: RE: [PATCH] sched: fix port time rounding error >=20 >=20 >=20 > > -----Original Message----- > > From: alangordondewar@gmail.com > > Sent: Thursday, April 16, 2020 9:48 AM > > To: Dumitrescu, Cristian > > Cc: dev@dpdk.org; Alan Dewar > > Subject: [PATCH] sched: fix port time rounding error > > > > 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. > > > > 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 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,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 th= an the current cycles due to roundoff in previous iteration. > > + 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; > > > > +end: > > /* Reset pipe loop detection */ > > for (i =3D 0; i < port->n_subports_per_port; i++) > > port->subports[i]->pipe_loop =3D RTE_SCHED_PIPE_INVALID; > > -- > > 2.17.1 >=20 > Adding Jasvinder.