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 897AF46054; Fri, 17 Jan 2025 17:47:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5441D40294; Fri, 17 Jan 2025 17:47:55 +0100 (CET) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 232844028F for ; Fri, 17 Jan 2025 17:47:53 +0100 (CET) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2eeb4d643a5so4236635a91.3 for ; Fri, 17 Jan 2025 08:47:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737132472; x=1737737272; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=FBOQtqvJpXF8WaVnHXR7sd4uvHiCmnPkQSzJekkS3+o=; b=wnyN7rH7XRjUsipHM2yiLVpIAPVS2D/8kXQc4dsk0tMCmlcX/V08PxhP2R8gUEqq7D guCfAwvGfJSkMzdKHDJG4IaoPONNEScb7FosfS33hc36h1o9eML0kKrt2yj22EwXV0SJ 1RsyAJOA0vwOUcoztL2FofOlHb07v3Fl6agKEwmENzwh9qMJ/2d+f98m0zOwjtyAdbWw Qg/n49jT2JAJy7dB63JSEYBclvPo9MUt9UXryZHAJHGOSmWQCIgrwtamuRZ1j9odeEiS BtH1mRYX/Po3jUGpDnyx72PIlRaYd9342GBvX5SxflmRV3iJjsOLl1qxNBbtoXNe86JK YcoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737132472; x=1737737272; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FBOQtqvJpXF8WaVnHXR7sd4uvHiCmnPkQSzJekkS3+o=; b=vZ1+Es+47s+1bXM5cqq+mxuZm5mW2WwQP0NJjQkPQ+G6Es28QJgQbHnG6EXQU8WgN2 OOApi0KvZJ8CrBHH2HhvCAAfxFosQmHKkJSZ1c6xi163bxbckht4gtTY+cWgQ92T9fnQ evpwriK89hkGdysxFkiN3BsCq1WM5G77ryJYNgnw+Wkwiaih6/0UPLimixFSkBIDAkyL xMbJJmKLlvpjrOI/al9vWjoBD0tBjpo82jKb5Bg88oFONHhD7pCsge92ifMe0mASMfrQ tQBRfgojuE5gbRckmL4S6E2gCDMQbeiuUJ3dvrAjmlPC/U2mU3gIUwib/V2TVaMtCQqm VODw== X-Forwarded-Encrypted: i=1; AJvYcCXKMnwPKKu4VORweZ2gZOS3G3fG4NCivZp/wgZIeYSmzn3ZlzRzGpjiCBw5exHSqxGH340=@dpdk.org X-Gm-Message-State: AOJu0YxTNKLQ1H7cHv/Wozbmc37o2oWKHJNB8wwtIwcZwITwgNHymld2 6MAijGRiFMAPWRVPU73fRcgmzLVBShDaXJ8dFfIfVI9U41g3QKIu9u0j4XThPXQ= X-Gm-Gg: ASbGncvyXyW7BLtPrQLuz8RAn/aiqqCQpje4zuYVSltelXTIkrhD2FAB2JYqW6P1D1a EtFHltKFnkVoBEEcwaG0ho9Ymntu+HY6il2N2gGoRmd6Uc4g0e/TKtdMNz+WlYPJmnbkyUZEkwn JrQxm5PbfwDA6UdYeQNoRD9WZYL+V0vv6jFLLW9SfCCXYfiDYNAeIrqtCDpuBga7JdMFx0T5NZp LVv9TdBFyB/bbsuxGlg/Zjt/pMLKGDtY0G44vQYr7ylZdNZUeMUA9+4HveE+C39MDU+Oo09eUKJ x9yG9VS3JxxIsPvkbP72sRxqaz3zG0bIHg== X-Google-Smtp-Source: AGHT+IHq84EDpbDueuxX/ebQr8y6c4trlKE0+ydQDKDaaPefqlkK+1gtU9jT79RnsJ7UJjzwv87I4g== X-Received: by 2002:a17:90b:4b8c:b0:2ee:cddd:2454 with SMTP id 98e67ed59e1d1-2f782cbdb9fmr5092723a91.15.1737132472245; Fri, 17 Jan 2025 08:47:52 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f77611a295sm2313528a91.7.2025.01.17.08.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 08:47:52 -0800 (PST) Date: Fri, 17 Jan 2025 08:47:50 -0800 From: Stephen Hemminger To: Yang Ming Cc: Anatoly Burakov , dev@dpdk.org Subject: Re: [PATCH] Skip vfio in the scenario of non-privileged mode Message-ID: <20250117084750.3259cfa3@hermes.local> In-Reply-To: <20250117072847.2741-1-ming.1.yang@nokia-sbell.com> References: <20250117072847.2741-1-ming.1.yang@nokia-sbell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Fri, 17 Jan 2025 15:28:47 +0800 Yang Ming wrote: > DPDK detect vfio container according the existence of vfio > module. But for container with non-privileged mode, there is > possibility that no VFIO_DIR(/dev/vfio) mapping from host to > container when host have both Intel NIC and Mellanox NIC but > this conntainer only allocate VFs from Mellanox NIC. > In this case, vfio kernel module has already been loaded from > the host. > This scenario will cause the error log occurs in DPDK primary > process as below: > 'EAL: cannot open VFIO container, error 2 (No such file or > directory)' > 'EAL: VFIO support could not be initialized' > Because `rte_vfio_enable()` call `rte_vfio_get_container_fd()` > to execute `vfio_container_fd = open(VFIO_CONTAINER_PATH, > O_RDWR);` but VFIO_CONTAINER_PATH(/dev/vfio/vfio) doesn't exist > in this container. > This scenario will also lead to the delay of DPDK secondary > process because `default_vfio_cfg->vfio_enabled = 0` and > `default_vfio_cfg->vfio_container_fd = -1`, socket error will > be set in DPDK primary process when it sync this info to > the secondary process. > This patch use to skip this kind of useless detection for this > scenario. > > Signed-off-by: Yang Ming > --- > lib/eal/linux/eal_vfio.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/lib/eal/linux/eal_vfio.c b/lib/eal/linux/eal_vfio.c > index 7132e24cba..1679d29263 100644 > --- a/lib/eal/linux/eal_vfio.c > +++ b/lib/eal/linux/eal_vfio.c > @@ -7,6 +7,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -1083,6 +1084,7 @@ rte_vfio_enable(const char *modname) > /* initialize group list */ > int i, j; > int vfio_available; > + DIR *dir; > const struct internal_config *internal_conf = > eal_get_internal_configuration(); > > @@ -1119,6 +1121,15 @@ rte_vfio_enable(const char *modname) > return 0; > } > > + /* return 0 if VFIO directory not exist for container with non-privileged mode */ > + dir = opendir(VFIO_DIR); > + if (dir == NULL) { > + EAL_LOG(DEBUG, > + "VFIO directory not exist, skipping VFIO support..."); > + return 0; > + } > + closedir(dir); You need to test the non-container cases. If vfio is loaded /dev/vfio is a character device (not a directory) Also looks suspicious that VFIO_DIR is defined but never used currently.