From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH] rte_delay_us can be replaced with user function Date: Tue, 19 Jul 2016 15:21:11 +0200 Message-ID: <81613915.CvR5looQMP@xps13> References: <1468932143-9321-1-git-send-email-jozmarti@cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org To: jozmarti@cisco.com Return-path: Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by dpdk.org (Postfix) with ESMTP id B46669E3 for ; Tue, 19 Jul 2016 15:21:13 +0200 (CEST) Received: by mail-wm0-f54.google.com with SMTP id q128so19201131wma.1 for ; Tue, 19 Jul 2016 06:21:13 -0700 (PDT) In-Reply-To: <1468932143-9321-1-git-send-email-jozmarti@cisco.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, 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: > > void rte_delay_us_callback_register(void(*userfunc)(unsigned)); > void rte_delay_us_callback_unregister(void); > > First one replaces rte_delay_us with userfunc and second one restores > original rte_delay_us. I think we could avoid the function unregister by exporting the default implementation (let's say rte_delay_us_block). > +REGISTER_TEST_COMMAND(user_delay_us, test_user_delay_us); Thanks for providing an unit test. > --- 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 != NULL)) > + { > + rte_delay_us_override(us); > + return; > + } Why not always call the registered callback and initialize it to the default implementation (maybe using a constructor)?