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 04A62A0542; Wed, 5 Oct 2022 10:53:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA3A540A7D; Wed, 5 Oct 2022 10:53:05 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 5EF0140694 for ; Wed, 5 Oct 2022 10:53:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664959983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pwJtnmvRYwKnlXF6XFplS1qB2A7AA1uywk/Y5HVPcUs=; b=i9EJUS0dFeqwx/UGx+RQRoX6phaewLYFvUEjZcFb5ko34tG0gYrWMCZW02A3ktbrTBRMqo JVHoPt5y9NxaJ9E3bPIqB4pZ3G0si32YyW0LJ/oKwwNzQYOAaTtslhFKk8aQwSEWnXDlF8 DNZ1LlfJw/e4V1ir/pWXigRi2kKoaM8= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-335-o2Ay1HLHNNqttf-yvF-IYw-1; Wed, 05 Oct 2022 04:53:02 -0400 X-MC-Unique: o2Ay1HLHNNqttf-yvF-IYw-1 Received: by mail-pl1-f199.google.com with SMTP id j3-20020a170902da8300b001782a6fbc87so11820503plx.5 for ; Wed, 05 Oct 2022 01:53:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=pwJtnmvRYwKnlXF6XFplS1qB2A7AA1uywk/Y5HVPcUs=; b=ueL/g+2IkNKCFxJOb6TGAJKQn/SYghRBPikmUdNhvNYi+Bbd5gcfRT/lIphOz1Jg9t BwJHSjeSt718kqzJMD73WQNpL/TH95NBh4KR0Ulo34V7tusl3Hk54mYJlwXBc0eWUVIl QJeA+biG10tc6pucGovXoJr/0rEwZsn/aoFr315agKiSiNlc2O8QcyDfZpqVkhQ6cwtB 5U/XjnImUE2LRv4q7U7vF2bcgdN59rysrVxPoU8xTwDN0bWjSw4UxhwIj8r2DY9ltCMj +9Sp9WhUlsc9YEyerAS+2VPdyFuHuqtx/ffgLKI506emrhWmoHrYxScV+Hyvr8+b6SE5 gf5Q== X-Gm-Message-State: ACrzQf3qC/9kLa5YJeFwoQrb4NwSDEl9YCxl/K8q4HMgacKRzz35ihjY 8hWZzbmCQFR10MvlakmSACeuzseAF+NfoZxwtsQRLz4v9KHBRK8j+zhKzM1hDD421z1CQDdAO0O 9hkT5Mnv3NPDCP3HoFt4= X-Received: by 2002:a63:2a97:0:b0:457:23e9:586d with SMTP id q145-20020a632a97000000b0045723e9586dmr4243054pgq.190.1664959981437; Wed, 05 Oct 2022 01:53:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM77LT5NtlDRh9c48Onvaw0beaxMcic+z3R7z1D44GWDvszBRmzxFdbW9eLej0LgDPRPZbtg4v4BjUg9VCiyZiE= X-Received: by 2002:a63:2a97:0:b0:457:23e9:586d with SMTP id q145-20020a632a97000000b0045723e9586dmr4243032pgq.190.1664959981127; Wed, 05 Oct 2022 01:53:01 -0700 (PDT) MIME-Version: 1.0 References: <20221004145850.32331-1-olivier.matz@6wind.com> In-Reply-To: <20221004145850.32331-1-olivier.matz@6wind.com> From: David Marchand Date: Wed, 5 Oct 2022 10:52:49 +0200 Message-ID: Subject: Re: [PATCH v2] drivers/bus: set device NUMA node to unknown by default To: Olivier Matz Cc: dev@dpdk.org, Ray Kinsella , Parav Pandit , Xueming Li , Hemant Agrawal , Sachin Saxena , Stephen Hemminger , Long Li , Ferruh Yigit , Andrew Rybchenko , Thomas Monjalon X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 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? -- David Marchand