From patchwork Wed Mar 6 09:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 13583635 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 947831426B; Wed, 6 Mar 2024 09:19:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716779; cv=none; b=T9y6+G5lorAz0AJiKr56QaPsZzopI52fPSqynsJuX/m7koc+tWeFgDxsy4Yl3JE0ei8Vx0838pDNkebGZfJz12Kq9fTpj9IuA42RZx+1Ol6L0iwrkMTrfQfMHm/Dr9JZCMPAKILbvjS35Y8RE/L9GT+Ty4LspLGtbdrrRyyT4hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716779; c=relaxed/simple; bh=7Nr4IPt40Xh0GYx6TBamWZqIdVZ2XKs/n5BaTVUeY0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TSEDI+0SEzb4fI9uk6EJMzIkHAWKCjg862J4BLvKmka2Qtmaygro01+7JCWD2zcqBiWEaSfA+zUn+M2t7v1eI+JJ234xqPgHgtMApvAw4M2+Lq5Qw5N06dEgxP9DvifH0EsFXPoCwXdWj7alA+Hfg/GDyjtHW0DkAfHoYvWGvOs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gGUcKZaw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gGUcKZaw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD14EC433F1; Wed, 6 Mar 2024 09:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709716779; bh=7Nr4IPt40Xh0GYx6TBamWZqIdVZ2XKs/n5BaTVUeY0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gGUcKZawmRDkrDUi3pOv1ueG35NdRXq8qnFW2jBIJ7WibLJHQhltxFbBrjw8/T+A3 xsvNOllVlhiWEwJkQn3AmfroOFx18O7xtIHo5h/LVvdkb4mnSMq80fDC8t3S3ONCuy 5C3i5GqtFM9qJ51C91CEEa+eh2Ka8K54U/roohDr8QvDi2tKItyuLn4AQ+M22jq4+R cTgUVHByTXq+e/9UYgX0zYpaSW4y5wjHgFYSpOzjoXLbZ+TzcJc2KMUsgw41Uvwb9a EABeCWveGpr3cEqtCFQ2yFWjxI+24Vw58Q1oqekb9DFYoit0VjaWaLb18XBckqionC ko+708WjNKrdw== From: Zorro Lang To: fstests@vger.kernel.org Cc: io-uring@vger.kernel.org Subject: [PATCH 1/3] fsstress: check io_uring_queue_init errno properly Date: Wed, 6 Mar 2024 17:19:33 +0800 Message-ID: <20240306091935.4090399-2-zlang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240306091935.4090399-1-zlang@kernel.org> References: <20240306091935.4090399-1-zlang@kernel.org> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 As the manual of io_uring_queue_init says "io_uring_queue_init(3) returns 0 on success and -errno on failure". We should check if the return value is -ENOSYS, not the errno. Fixes: d15b1721f284 ("ltp/fsstress: don't fail on io_uring ENOSYS") Signed-off-by: Zorro Lang Reviewed-by: Darrick J. Wong Reviewed-by: Jeff Moyer --- ltp/fsstress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 63c75767..482395c4 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -763,8 +763,8 @@ int main(int argc, char **argv) #ifdef URING have_io_uring = true; /* If ENOSYS, just ignore uring, other errors are fatal. */ - if (io_uring_queue_init(URING_ENTRIES, &ring, 0)) { - if (errno == ENOSYS) { + if ((c = io_uring_queue_init(URING_ENTRIES, &ring, 0)) != 0) { + if (c == -ENOSYS) { have_io_uring = false; } else { fprintf(stderr, "io_uring_queue_init failed\n"); From patchwork Wed Mar 6 09:19:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 13583636 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06F5A1426B; Wed, 6 Mar 2024 09:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716781; cv=none; b=X/KQLWYZ0PMHNQ4lapEGJR3Jrd1b1Z8xYvR5CeTWGw+CumH+8gBzWJb+24b7bqZQWFfT8qJF6XLuTKQ4/cZaMZ8QBxyJ4gnOUldQLok49m+JsafmmsQ5eBip0iIihauaBoaHvHjopQEbM+mkIyIGbRFjlx79tfD20Ww5cwsE3bo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716781; c=relaxed/simple; bh=P/9E+9Wao7oLG3ZlbYvcTCGHeDQh/bPyn+jnVILfdGo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E3Df2JKGtEH45F0pHpoU5r+crq1HSUCAEjT2I93Fg+4JyOuExb2g5+MhxOYamg7HrYS6/v8Exqk8mB+00iYyOypKi2yCuHGzIi1bQODVmCHsZVdVlSEXMGVJ6FZM2o2ffQjhaOiFSAeevZ13aVtxnT6JNXZkafkNyqW9Z64SkJw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B1QU0lc4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B1QU0lc4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC659C433F1; Wed, 6 Mar 2024 09:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709716780; bh=P/9E+9Wao7oLG3ZlbYvcTCGHeDQh/bPyn+jnVILfdGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1QU0lc405a2IlXgbXGhhwkpo1Ev0xUHOwNgeY/d1Nf/mApwFcdQxpRrHdGvwqC4r 9KpUk9IJDzXU3dt7PuFxNBhM56CS0a5ctbNLSD19ZtFDLhhsQJzKBdVbBOaf6G5mWu NJrFca/PaAoFTjUW256n+VwOwMwsEBT5ikBhbw4ym6ZG7GbRHmY3vKWyeQpHaXb6m0 NFebnh8Kr5tklt81XXK2AHnztoAXbD0OoFl7zdr3SAvmX3v/v3CUZQUyL7z3f2N7e/ MYZhRXXAjX/3aCeoZ+mCnYJrZwdAcei+PSx3k2RgmZl0PgvdxYNP70FFTDm6BySDA/ QYMYovR1bVZ7Q== From: Zorro Lang To: fstests@vger.kernel.org Cc: io-uring@vger.kernel.org Subject: [PATCH 2/3] fsstress: bypass io_uring testing if io_uring_queue_init returns EPERM Date: Wed, 6 Mar 2024 17:19:34 +0800 Message-ID: <20240306091935.4090399-3-zlang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240306091935.4090399-1-zlang@kernel.org> References: <20240306091935.4090399-1-zlang@kernel.org> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 I found the io_uring testing still fails as: io_uring_queue_init failed even if kernel supports io_uring feature. That because of the /proc/sys/kernel/io_uring_disabled isn't 0. Different value means: 0 All processes can create io_uring instances as normal. 1 io_uring creation is disabled (io_uring_setup() will fail with -EPERM) for unprivileged processes not in the io_uring_group group. Existing io_uring instances can still be used. See the documentation for io_uring_group for more information. 2 io_uring creation is disabled for all processes. io_uring_setup() always fails with -EPERM. Existing io_uring instances can still be used. So besides the CONFIG_IO_URING kernel config, there's another switch can on or off the io_uring supporting. And the "2" or "1" might be the default on some systems. On this situation the io_uring_queue_init returns -EPERM, so I change the fsstress to ignore io_uring testing if io_uring_queue_init returns -ENOSYS or -EPERM. And print different verbose message for debug. Signed-off-by: Zorro Lang Reviewed-by: Darrick J. Wong Reviewed-by: Jeff Moyer --- ltp/fsstress.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 482395c4..9c75f27b 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -762,12 +762,23 @@ int main(int argc, char **argv) #endif #ifdef URING have_io_uring = true; - /* If ENOSYS, just ignore uring, other errors are fatal. */ + /* + * If ENOSYS, just ignore uring, due to kernel doesn't support it. + * If EPERM, might due to sysctl kernel.io_uring_disabled isn't 0, + * or some selinux policies, etc. + * Other errors are fatal. + */ if ((c = io_uring_queue_init(URING_ENTRIES, &ring, 0)) != 0) { if (c == -ENOSYS) { have_io_uring = false; + if (verbose) + printf("io_uring isn't supported by kernel\n"); + } else if (c == -EPERM) { + have_io_uring = false; + if (verbose) + printf("io_uring isn't allowed, check io_uring_disabled sysctl or selinux policy\n"); } else { - fprintf(stderr, "io_uring_queue_init failed\n"); + fprintf(stderr, "io_uring_queue_init failed, errno=%d\n", c); exit(1); } } From patchwork Wed Mar 6 09:19:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zorro Lang X-Patchwork-Id: 13583637 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 675521426B; Wed, 6 Mar 2024 09:19:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716782; cv=none; b=LBfIhzy8ih2XuEtsBuptDQEpl82bNblJzBmQt4z6OFiLQpwxUm6ij9wHqGLnw4XoaEjvGvrK/OxaYSsguuYq+dAmpSQ5TFVxaPwtZEKgyoKt5Sqfg+b9T+aypNYglaEPQtZSIFr1YNsqkDxRo9hBm6RHIR5NEs6FfAh3nvNsGWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709716782; c=relaxed/simple; bh=576BNnDqwXwQ6YZRQiSOlSYy6Uiobq8Bw6/3h46gfGs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TGOZaJA+QojY/6r2MWC5Led782jf4Yx98Vx74NpWQR84onotRMpeqA8dPpgeDLnmsugWMJzb+ahe23zFO9XTDbAoBwvWyEEpcz75W1Vfu3Af/XB1Zn0CiFSUeIXO7jLZn14Gh9QWVWsI/1psX3tuuXIhQVuh6EMobiAuAj00uBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JYVR4908; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JYVR4908" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F5CBC43394; Wed, 6 Mar 2024 09:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709716781; bh=576BNnDqwXwQ6YZRQiSOlSYy6Uiobq8Bw6/3h46gfGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JYVR4908vGgev2/06Px7KxZCx6ywj1b8SjQLe5INNYbQZTKD7LxLkr+h7DKQracks fae4BSuJ5EJh1ORZa+tNxWRjSXN/DMF7LEO2iOOnZHU264LJ6eGSGFPeni+H3iXeaq qTHaRRwbT2nA4mr2QlAV+qbkMzRSHig0NojWhPHwifdbURcZmwgTbEQ9ZT+Q5e7uyM M9e4kHtXJC60AlJGWNfGXoGQ+zhWlJkZ6jrg16T6tUXC+opxc9xPU1R+hk7TCblG5G E5r0UB4YdXv+ji5XLtfjcGcr3Epxc9E8zFcjrHcuIdBHdeq0NF3djczRk2az/ERPft J3moPMZrlC8bw== From: Zorro Lang To: fstests@vger.kernel.org Cc: io-uring@vger.kernel.org Subject: [PATCH 3/3] common/rc: force enable io_uring in _require_io_uring Date: Wed, 6 Mar 2024 17:19:35 +0800 Message-ID: <20240306091935.4090399-4-zlang@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240306091935.4090399-1-zlang@kernel.org> References: <20240306091935.4090399-1-zlang@kernel.org> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If kernel supports io_uring, userspace still can/might disable that supporting by set /proc/sys/kernel/io_uring_disabled=2. Let's set it to 0, to always enable io_uring (ignore error if there's not that file). Signed-off-by: Zorro Lang --- common/rc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/rc b/common/rc index 50dde313..966c92e3 100644 --- a/common/rc +++ b/common/rc @@ -2317,6 +2317,9 @@ _require_aiodio() # this test requires that the kernel supports IO_URING _require_io_uring() { + # Force enable io_uring if kernel supports it + sysctl -w kernel.io_uring_disabled=0 &> /dev/null + $here/src/feature -R case $? in 0)