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 13CB3A04B3; Fri, 20 Dec 2019 23:43:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2CDC91F1C; Fri, 20 Dec 2019 23:43:13 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 0E6111252 for ; Fri, 20 Dec 2019 23:43:10 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2019 14:43:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,337,1571727600"; d="scan'208";a="366506792" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga004.jf.intel.com with ESMTP; 20 Dec 2019 14:43:08 -0800 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 20 Dec 2019 14:43:08 -0800 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 20 Dec 2019 14:43:08 -0800 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.173) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 20 Dec 2019 14:43:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q6tJT/OMZfXdEPWxi29ognwxPKqbfsuoTPDZLv8W13MKctDdNH0NW+reApNBaiKnMPahwt3lW35T/UuB0T0m/sdmrmAfgwkZ2VgyrR2yjmi60PiiyWok1w3KslbFaKF2HTceHWgbPugbHTsBy/dsOL7PDIsaWXiBTCDvwuneDNV3i6Vfzjt81Pk++erB1NlX8d7SXETeGx3O3B/hiU82RbDzQSijZqwA49W1MO74ZDeFwYlt6jd+1nooxCcC/dZFNMy3c0h5QvcU46CqWtHigcbWlwnFcZDl7HPgURJamlt1wADMWIA/ETlYtOR4LuQ+TjM4ZgE5qupF6Z0Zrbn6cg== 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=x1XzElJbL646LCv7++UWB60lArLwCUMFygjj6Zkqcbg=; b=IxBlxf21cLXjBRbSq1UUBfSebCbj3WsQgI7xztn0SNbTgJcXauyfBLESbwKVFjVym167QAGEQgiZhLtGj+OrowynaTR78Vg1xM8rx5ypu5b4TPx8jJjH0k5FnA8RC4m3BCh6qSMmTju+oZ2TCtCU8sJ6Fgir+vzndOtOXTN9ZNQ/c3Z+5NFbTaJ2GKQQ0pifJCx/kxNfRdlIbA2uDSbwXCmncyM6R+45NCnRWoXEHkcMVQQaC84pfhKggqO/XPPnF+L+9Er0J5W/R6ExsEyonlXlwb8dZ5JFTTh8PJ7rGQdz9x4/o+lLyXeeHDRh5ul0dIcmA1KgsL233nPd+dcAzA== 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=x1XzElJbL646LCv7++UWB60lArLwCUMFygjj6Zkqcbg=; b=ccvtVDHCIdnJzh6pMPYQEvM44QLAp+XBU43mEcbbjMdSnAxAxPmjcWZ/VbuYuw/ooSgNcHHjoc476vJq58+YfeYIttcx+laJwUiPkRI1/GwIpJiq+ppWm56uxhLgJG3YGQCr+ZDTs93qXcM1bTLUItjrEIVVCO0jmUDJ+piD7NQ= Received: from BYAPR11MB3415.namprd11.prod.outlook.com (20.177.187.222) by BYAPR11MB2806.namprd11.prod.outlook.com (52.135.227.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14; Fri, 20 Dec 2019 22:43:06 +0000 Received: from BYAPR11MB3415.namprd11.prod.outlook.com ([fe80::895a:efc5:3d43:82dd]) by BYAPR11MB3415.namprd11.prod.outlook.com ([fe80::895a:efc5:3d43:82dd%6]) with mapi id 15.20.2559.016; Fri, 20 Dec 2019 22:43:06 +0000 From: "Carrillo, Erik G" To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [PATCH v1] rte_timer: add rte_timer_next_ticks Thread-Index: AQHVtHS+j/7sPmmjh0SjC1IbrqHOEKfDoeCA Date: Fri, 20 Dec 2019 22:43:06 +0000 Message-ID: References: <20190610224441.5461-1-stephen@networkplumber.org> <20191217005503.31196-1-stephen@networkplumber.org> In-Reply-To: <20191217005503.31196-1-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: spf=none (sender IP is ) smtp.mailfrom=erik.g.carrillo@intel.com; x-originating-ip: [192.55.52.220] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cbbef546-dfa4-49fc-222a-08d7859dfb10 x-ms-traffictypediagnostic: BYAPR11MB2806: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 025796F161 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(39860400002)(346002)(376002)(136003)(396003)(189003)(13464003)(199004)(66556008)(71200400001)(8676002)(53546011)(66476007)(8936002)(66446008)(55016002)(6506007)(26005)(2906002)(64756008)(66946007)(81166006)(76116006)(478600001)(81156014)(316002)(33656002)(52536014)(9686003)(86362001)(110136005)(186003)(7696005)(5660300002); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR11MB2806; H:BYAPR11MB3415.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: H3xfJ4ztyGa8VTcPgIueZJZx8NdnDdvlk62ThWK7IfMSWsvlBkj6F3QShTL0XKWTlHKV7m4+fzDLWG1Zr3TZeuLiyuAEdJd6naeRp59wM3LT1bF25ki2pm5spnNGg/QaIF+Pzoej83yCO/tyXKVW5YYcMwrxxN4N9fvifJADiA8g6BdmK/jyTb5RDSFeblqz/T5JffCj9leLAlPujXjGKGF+exkLpIvWhfjnXiLHrRMlwWgboSf0snVuuuGReB2USN+xlIYWJyflwunJJJFuTfSh03ZW+wk/4mmtnJfO6ZcfKdCl6f269ubCFONXSsPmdzl5P/qaD5/5f0doVRCDiZvyXN2pixAuTZ5xMhJMIy49nEUTWlRBbtpntL141zoki+gdBeJ8Q/khST4ecaZ0vaV4jifmqJgCxEAqfgmPirToT13bSRPeIBDCt76qqk3kLozIzhuIWdkveuS7jnwQaeqtAiArLlRS+2uZcPT9QzZDEGoNHNWsmUcVlwK2avna x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: cbbef546-dfa4-49fc-222a-08d7859dfb10 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Dec 2019 22:43:06.2933 (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: Oivaq8ekkRrQhJy/qmfefvFGY2JMGUnIyooF+DgwhN+g5Y63caHx1kjeOjx6bgL4m90uD1KL3R5qAj5NyTdNJBWjMXB0o/sMntnC6Zbpj1w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2806 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v1] rte_timer: add rte_timer_next_ticks 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" Hi Stephen, I added a comment in-line. With that change, it looks good to me: Acked-by: Erik Gabriel Carrillo Regards, Erik > -----Original Message----- > From: Stephen Hemminger > Sent: Monday, December 16, 2019 6:55 PM > To: dev@dpdk.org > Cc: Carrillo, Erik G ; Stephen Hemminger > > Subject: [PATCH v1] rte_timer: add rte_timer_next_ticks >=20 > It is useful to know when the next timer will expire when using > rte_epoll_wait (or sleep when idle). This experimental API provides a hoo= k > to query the number of ticks remaining. >=20 > Signed-off-by: Stephen Hemminger > --- > v1 - incorporate feedback from old RFC >=20 > lib/librte_timer/rte_timer.c | 27 ++++++++++++++++++++++++++ > lib/librte_timer/rte_timer.h | 16 +++++++++++++++ > lib/librte_timer/rte_timer_version.map | 1 + > 3 files changed, 44 insertions(+) >=20 > diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c = index > ca88454ff68a..a1ed186cf591 100644 > --- a/lib/librte_timer/rte_timer.c > +++ b/lib/librte_timer/rte_timer.c > @@ -978,6 +978,33 @@ rte_timer_stop_all(uint32_t timer_data_id, > unsigned int *walk_lcores, > return 0; > } >=20 > +int64_t > +rte_timer_next_ticks(void) > +{ > + unsigned int lcore_id =3D rte_lcore_id(); > + struct rte_timer_data *timer_data; > + struct priv_timer *priv_timer; > + const struct rte_timer *tm; > + uint64_t cur_time; > + int64_t left =3D -ENOENT; > + > + TIMER_DATA_VALID_GET_OR_ERR_RET(default_data_id, > timer_data, -EINVAL); > + > + priv_timer =3D timer_data->priv_timer; > + cur_time =3D rte_get_timer_cycles(); > + > + rte_spinlock_lock(&priv_timer[lcore_id].list_lock); > + tm =3D priv_timer[lcore_id].pending_head.sl_next[0]; > + if (tm) { > + left =3D tm->expire - cur_time; > + if (left < 0) > + left =3D 0; > + } > + rte_spinlock_unlock(&priv_timer[lcore_id].list_lock); > + > + return left; > +} > + > /* dump statistics about timers */ > static void > __rte_timer_dump_stats(struct rte_timer_data *timer_data __rte_unused, > FILE *f) diff --git a/lib/librte_timer/rte_timer.h b/lib/librte_timer/rte= _timer.h > index 9dc5fc309249..c5031d0448ba 100644 > --- a/lib/librte_timer/rte_timer.h > +++ b/lib/librte_timer/rte_timer.h > @@ -331,6 +331,22 @@ void rte_timer_stop_sync(struct rte_timer *tim); > */ > int rte_timer_pending(struct rte_timer *tim); >=20 > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > + * Time until the next timer s/next timer/next timer on the current lcore > + * This function gives the ticks until the next timer will be active. > + * > + * @return > + * - -EINVAL: invalid timer data instance identifier > + * - -ENOENT: no timer pending > + * - 0: a timer is pending and will run at next rte_timer_manage() > + * - >0: ticks until the next timer is ready > + */ > +__rte_experimental > +int64_t rte_timer_next_ticks(void); > + > /** > * Manage the timer list and execute callback functions. > * > diff --git a/lib/librte_timer/rte_timer_version.map > b/lib/librte_timer/rte_timer_version.map > index 2a59d3f081c4..4471cef92be5 100644 > --- a/lib/librte_timer/rte_timer_version.map > +++ b/lib/librte_timer/rte_timer_version.map > @@ -23,6 +23,7 @@ EXPERIMENTAL { > rte_timer_alt_stop; > rte_timer_data_alloc; > rte_timer_data_dealloc; > + rte_timer_next_ticks; > rte_timer_stop_all; > rte_timer_subsystem_finalize; > }; > -- > 2.20.1