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 E3EF2A0542; Wed, 5 Oct 2022 11:04:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A5FD040A7D; Wed, 5 Oct 2022 11:04:43 +0200 (CEST) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mails.dpdk.org (Postfix) with ESMTP id DC59C40694 for ; Wed, 5 Oct 2022 11:04:42 +0200 (CEST) Received: by mail-wm1-f44.google.com with SMTP id l8so10367034wmi.2 for ; Wed, 05 Oct 2022 02:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=ibNDUT8Yekwe+ndlBGQQa7IVk+fT2MWb1cD/pZdvClI=; b=ayiM6vVqJdM13wNMyYVif3agDUAfavfWsCD5ZHRBCx+32UKM2nW5aY5cPsEQ6XCEx2 Vkh9RIeD/9jGVYfJtaahRzikqDD+OnPiBo2NX4BoWjyKLaAvrFHKIDGetb2EN4BwxqMc An2+YWChHYgPfLVIal1YIssz23Szu86sm5npm0sAD+BS7DKo6Ssv2kr4I5qyMwXSry3N +Zg7E9racDUZaMpKjwCgfWAUhCoCUIWIuNSCmeYY+wLCrqVCNB/k2zQO2g9V9YXBccHy zTg3aeDRcCDJDvh2EUsCpFEXtkD8GXoqNPcWIKZJg2A9zaKek83lKMeBfjWJgZgDL0qH XP6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=ibNDUT8Yekwe+ndlBGQQa7IVk+fT2MWb1cD/pZdvClI=; b=iBZME1QXlltwdMk0CSGgT73VLrHv13JuWvu+n6bfp7D7grfgdDfcpa7yz3DPmue8Ty A3eDpaGD7BhwmmRzRS0eT71Vx83xYz6uL5/mE9HqaFJdDpXSrqyyRh50BRWaFVHvKfwf 6K2v3/KuskQzQFa6fW5S6oaysWkSgKzc/B4VPor1XTrL7DYnhgAIndzQmMPXCEAhBJaT i8xXbC2DU2yjF54IpU7l9Q3F31wcG/F9yYl9hQs0ajmFAk6CBHJqtlleoC0g/UJe3/g6 zEYAajs8PSACHPSdn8rKv8NOxO4EvH5IrgerZ81Ud/IdRO9hcsVI6omL2EwmPaoaTTfX i72Q== X-Gm-Message-State: ACrzQf1hreMyW/QarRQ51fVr+tj/XsN5Jx0vbUTQ+9azsuBwNDJYrsEo pjp9VN5v1xmXrGQGSFl30Faqmg== X-Google-Smtp-Source: AMsMyM7XnR/uBgpOCkCklwBQ11T6bnIVamXA+ZEn7SWRQ3EivYkmK4ZCfFJJwVe1rgDToOWdgLNWbQ== X-Received: by 2002:a05:600c:2d14:b0:3b4:86fe:bcec with SMTP id x20-20020a05600c2d1400b003b486febcecmr2522289wmf.16.1664960682594; Wed, 05 Oct 2022 02:04:42 -0700 (PDT) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id t19-20020a1c7713000000b003b4868eb6bbsm1734337wmi.23.2022.10.05.02.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 02:04:41 -0700 (PDT) Date: Wed, 5 Oct 2022 11:04:41 +0200 From: Olivier Matz To: David Marchand Cc: dev@dpdk.org, Ray Kinsella , Parav Pandit , Xueming Li , Hemant Agrawal , Sachin Saxena , Stephen Hemminger , Long Li , Ferruh Yigit , Andrew Rybchenko , Thomas Monjalon Subject: Re: [PATCH v2] drivers/bus: set device NUMA node to unknown by default Message-ID: References: <20221004145850.32331-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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. Thanks for the review Olivier