From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1F0D8A0542; Wed, 5 Oct 2022 11:32:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B341D40A7D; Wed, 5 Oct 2022 11:32:23 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mails.dpdk.org (Postfix) with ESMTP id 246C340694 for ; Wed, 5 Oct 2022 11:32:22 +0200 (CEST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 795CB5C0130; Wed, 5 Oct 2022 05:32:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 05 Oct 2022 05:32:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1664962341; x= 1665048741; bh=TiXfX8jr9+zIybd372jitBpw+7oFPGxMKrQqQ7getkk=; b=z D16nzoRP7IdoYeFIVNmjss4cCs4Td5tfKMETxyTCP61RNTnUxnje9c88FcFEIE9Z D54XO8gtWBgXr2BsgDUVjBQAx0Wamkcaj+cGcKa862N+Y5Rt89YwbpvXJrBvXNpK TZXhEdKB4doOBqze3kKq4xdt9XUp9yYTd311IbJvSVRIftYkNuMIaDpt421+7BVf d9hMmwveaK4w3oX/qtl/l5nbgOAHS74gMCREiqY19VgQXBQ8AmHOqDe9MoUqVY0B CjwRug1lQLqS5kCO9Ox3REP+IFzCI/RsZewbQoAAzS1Kfz1qbQeE5FDgypHrzM8s pptiHLdsLUVBsqWLRTf7g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1664962341; x= 1665048741; bh=TiXfX8jr9+zIybd372jitBpw+7oFPGxMKrQqQ7getkk=; b=j FWhWeKuaiJeX6I4aBkEmKdccSGwsFz7/hgpWzjcBBc0P5GNhAEg2aO+E9MsRKmDl wyvZnieNoYZU3NwXBWySVMDpe6o0cz5vvnQvSj2dOWIrNB7V2wkx16rq3+4BR672 r0n4IDsgG5cUEcehEsLTNXQEA+QUA1WBpJE3dLJIN4j+lpRWZvDe63WKS2DHieOh Ky+TsAY36uzLFOkyRE5Q/RJwQ/T1EfZS3ghLdHNCw1MMWocxxN8LsE37ZM19vNRK MBngshVHSkVUZkAT78zCZHa9vtqqqV+xoWKHFMPlcXgVuPokeiJ+kLfHD9GmHORs UqLMZyQjDk5fFkKCou0ng== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeifedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpedtjeeiieefhedtfffgvdelteeufeefheeujefgueetfedttdei kefgkeduhedtgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 5 Oct 2022 05:32:19 -0400 (EDT) From: Thomas Monjalon To: David Marchand , Olivier Matz Cc: dev@dpdk.org, Ray Kinsella , Parav Pandit , Xueming Li , Hemant Agrawal , Sachin Saxena , Stephen Hemminger , Long Li , Ferruh Yigit , Andrew Rybchenko Subject: Re: [PATCH v2] drivers/bus: set device NUMA node to unknown by default Date: Wed, 05 Oct 2022 11:32:17 +0200 Message-ID: <32019833.aRNtrjHk3s@thomas> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 05/10/2022 11:04, Olivier Matz: > Hi David, > > On Wed, Oct 05, 2022 at 10:52:49AM +0200, David Marchand wrote: > > On Tue, Oct 4, 2022 at 4:59 PM Olivier Matz wrote: > > > > > > The dev->device.numa_node field is set by each bus driver for > > > every device it manages to indicate on which NUMA node this device lies. > > > > > > When this information is unknown, the assigned value is not consistent > > > across the bus drivers. > > > > > > Set the default value to SOCKET_ID_ANY (-1) by all bus drivers > > > when the NUMA information is unavailable. This change impacts > > > rte_eth_dev_socket_id() in the same manner. > > > > > > Signed-off-by: Olivier Matz > > > --- > > > > > > v2 > > > * use SOCKET_ID_ANY instead of -1 in drivers/dma/idxd (David) > > > * document the behavior change of rte_eth_dev_socket_id() > > > * fix few examples where rte_eth_dev_socket_id() was expected to > > > return 0 on unknown socket > > > > Cc: ethdev maintainers. > > > > [snip] > > > > > diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst > > > index 53fe21453c..d52f823694 100644 > > > --- a/doc/guides/rel_notes/release_22_11.rst > > > +++ b/doc/guides/rel_notes/release_22_11.rst > > > @@ -317,6 +317,12 @@ ABI Changes > > > * eventdev: Added ``weight`` and ``affinity`` fields > > > to ``rte_event_queue_conf`` structure. > > > > > > +* bus: Changed the device numa node to -1 when NUMA information is unavailable. > > > + The ``dev->device.numa_node`` field is set by each bus driver for > > > + every device it manages to indicate on which NUMA node this device lies. > > > + When this information is unknown, the assigned value was not consistent > > > + across the bus drivers. This similarly impacts ``rte_eth_dev_socket_id()``. > > > + > > > > > > Known Issues > > > ------------ > > > > [snip] > > > > > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h > > > index a21f58b9cd..dd8d25d6d4 100644 > > > --- a/lib/ethdev/rte_ethdev.h > > > +++ b/lib/ethdev/rte_ethdev.h > > > @@ -2445,8 +2445,8 @@ int rte_eth_hairpin_unbind(uint16_t tx_port, uint16_t rx_port); > > > * The port identifier of the Ethernet device > > > * @return > > > * The NUMA socket ID to which the Ethernet device is connected or > > > - * a default of zero if the socket could not be determined. > > > - * -1 is returned is the port_id value is out of range. > > > + * a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. > > > + * -1 is also returned if the port_id is invalid. > > > */ > > > int rte_eth_dev_socket_id(uint16_t port_id); > > > > It would be better to distinguish the two cases, using rte_errno. > > Something like: > > > > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > > index 2821770e2d..1baf302804 100644 > > --- a/lib/ethdev/rte_ethdev.c > > +++ b/lib/ethdev/rte_ethdev.c > > @@ -562,8 +562,16 @@ rte_eth_dev_owner_get(const uint16_t port_id, > > struct rte_eth_dev_owner *owner) > > int > > rte_eth_dev_socket_id(uint16_t port_id) > > { > > - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1); > > - return rte_eth_devices[port_id].data->numa_node; > > + int socket_id = SOCKET_ID_ANY; > > + > > + if (!rte_eth_dev_is_valid_port(port_id)) > > + rte_errno = EINVAL; > > + } else { > > + socket_id = rte_eth_devices[port_id].data->numa_node; > > + if (socket_id == SOCKET_ID_ANY) > > + rte_errno = 0; > > + } > > + return socket_id; > > } > > > > void * > > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h > > index dd8d25d6d4..03456b2dbb 100644 > > --- a/lib/ethdev/rte_ethdev.h > > +++ b/lib/ethdev/rte_ethdev.h > > @@ -2444,9 +2444,11 @@ int rte_eth_hairpin_unbind(uint16_t tx_port, > > uint16_t rx_port); > > * @param port_id > > * The port identifier of the Ethernet device > > * @return > > - * The NUMA socket ID to which the Ethernet device is connected or > > - * a default of -1 (SOCKET_ID_ANY) if the socket could not be determined. > > - * -1 is also returned if the port_id is invalid. > > + * - The NUMA socket ID which the Ethernet device is connected to. > > + * - -1 (which translates to SOCKET_ID_ANY) if the socket could not be > > + * determined. rte_errno is then set to: > > + * - EINVAL is the port_id is invalid, > > + * - 0 is the socket could not be determined, > > */ > > int rte_eth_dev_socket_id(uint16_t port_id); > > > > WDYT? > > As discussed off-list, it is indeed better. +1 Note that the decision to take in case of EINVAL requires some work for each call to rte_eth_dev_socket_id(). I suppose we can leave it as a future exercise.