From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-3.cisco.com (rcdn-iport-3.cisco.com [173.37.86.74]) by dpdk.org (Postfix) with ESMTP id 19A35379B for ; Tue, 19 Jul 2016 15:52:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=1419; q=dns/txt; s=iport; t=1468936360; x=1470145960; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=74Ir+I+q25dVjqAYI6/xzQlj8olEHjzz/c38pnL0YxQ=; b=TSHz0OzocrG9UVvw5G7H3wU4Exs/nKmazcs2ZZ04lZcwh8+W/Ggs4ndB Yl9D50ufraH5XNi0eW41CaP4fOruYexSVSIDxsr8q+iJHj7GgOQbmOk7t doyF0E7N3MxFeMPhRglzyNsS3rNqjSwdybls2c1+Fx50JMSrW26P5hPG2 Y=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BPAgCoL45X/51dJa1cgz+BUga2UoIPg?= =?us-ascii?q?XqGGgKBLzgUAQEBAQEBAWUnhF0BBTo/EAIBCDYQHxMlAgQOBQiIKLxUAQEBAQE?= =?us-ascii?q?BAQEBAQEBAQEBAQEBAQEBHIp3ihsFmSQBGI5Cjz5Ij1UBHjaCCxyBTG6HJn8BA?= =?us-ascii?q?QE?= X-IronPort-AV: E=Sophos;i="5.28,389,1464652800"; d="scan'208";a="131096872" Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by rcdn-iport-3.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Jul 2016 13:52:38 +0000 Received: from XCH-RCD-019.cisco.com (xch-rcd-019.cisco.com [173.37.102.29]) by rcdn-core-6.cisco.com (8.14.5/8.14.5) with ESMTP id u6JDqdNP014445 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Tue, 19 Jul 2016 13:52:39 GMT Received: from xch-rcd-019.cisco.com (173.37.102.29) by XCH-RCD-019.cisco.com (173.37.102.29) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 19 Jul 2016 08:52:38 -0500 Received: from xch-rcd-019.cisco.com ([173.37.102.29]) by XCH-RCD-019.cisco.com ([173.37.102.29]) with mapi id 15.00.1210.000; Tue, 19 Jul 2016 08:52:38 -0500 From: "Jozef Martiniak -X (jozmarti - PANTHEON TECHNOLOGIES at Cisco)" To: Thomas Monjalon CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] rte_delay_us can be replaced with user function Thread-Index: AQHR4bsBfprqFCnJWkKCiqLaKvHL8KAgETCA//+0oIA= Date: Tue, 19 Jul 2016 13:52:38 +0000 Message-ID: References: <1468932143-9321-1-git-send-email-jozmarti@cisco.com> <81613915.CvR5looQMP@xps13> In-Reply-To: <81613915.CvR5looQMP@xps13> Accept-Language: en-US, sk-SK Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.61.201.239] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] rte_delay_us can be replaced with user function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jul 2016 13:52:40 -0000 Hi, On Tue, 2016-07-19 at 15:21 +0200, Thomas Monjalon wrote: Hi, >=20 > 2016-07-19 14:42, jozmarti@cisco.com: > > when running single-core, some drivers tend to call rte_delay_us for a > > long time, and that is causing packet drops. > > Attached patch introduces 2 new functions: > >=20 > > void rte_delay_us_callback_register(void(*userfunc)(unsigned)); > > void rte_delay_us_callback_unregister(void); > >=20 > > First one replaces rte_delay_us with userfunc and second one restores > > original rte_delay_us. >=20 > I think we could avoid the function unregister by exporting the > default implementation (let's say rte_delay_us_block). >=20 I think register/unregister is the standard way how to handle callbacks. Un= register func is now "empty" but can be extended in the future. > > +REGISTER_TEST_COMMAND(user_delay_us, test_user_delay_us); >=20 > Thanks for providing an unit test. >=20 >=20 > > --- a/lib/librte_eal/common/eal_common_timer.c > > +++ b/lib/librte_eal/common/eal_common_timer.c > > void > > rte_delay_us(unsigned us) > > { > > + if (unlikely(rte_delay_us_override !=3D NULL)) > > + { > > + rte_delay_us_override(us); > > + return; > > + } >=20 > Why not always call the registered callback and initialize it > to the default implementation (maybe using a constructor)? >=20 I wanted to touch as few things as possible with this patch.