From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58705C282DC for ; Wed, 22 May 2019 20:04:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DCD220821 for ; Wed, 22 May 2019 20:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558555475; bh=doNg1gXw6eyhwf7280nikzntpuqn8BhVuwpCh91jyuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GgPl3DrbCq35Iw02qdD5Udjv0UmvZrMllLzAIxk/PiNf/HcvDInFCIuHitaaaxPab /PWFceWrDCYmk6J61M8MDLVgTi3CIXXeLCSeF5zBBb1vja1tJTBjp3MN3BiYt1cc7z QQDml7HxGm4sqJxbaUmkwF7ceXiJ0iRDu5Tm0WIg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729866AbfEVTVY (ORCPT ); Wed, 22 May 2019 15:21:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:41792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729790AbfEVTVX (ORCPT ); Wed, 22 May 2019 15:21:23 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DFD821841; Wed, 22 May 2019 19:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558552882; bh=doNg1gXw6eyhwf7280nikzntpuqn8BhVuwpCh91jyuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yv5Viyw/JPFlMiGQY3QDwNVJMTJE9bwA0Jxb1HzkIdrry6rulvzV/FqGfFAqQvmqJ 21M63oxpODoH15MttF2Zs9tSaoLpo3wqPTZ+JV5V9j4XSIYUEPqmTmNPvGEr5bgMHu h1IVlQNVnDFW7WMWHCIoT/CegtgwezVV4a+M8c3A= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shenghui Wang , Jeff Moyer , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.1 006/375] io_uring: use cpu_online() to check p->sq_thread_cpu instead of cpu_possible() Date: Wed, 22 May 2019 15:15:06 -0400 Message-Id: <20190522192115.22666-6-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190522192115.22666-1-sashal@kernel.org> References: <20190522192115.22666-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Shenghui Wang [ Upstream commit 7889f44dd9cee15aff1c3f7daf81ca4dfed48fc7 ] This issue is found by running liburing/test/io_uring_setup test. When test run, the testcase "attempt to bind to invalid cpu" would not pass with messages like: io_uring_setup(1, 0xbfc2f7c8), \ flags: IORING_SETUP_SQPOLL|IORING_SETUP_SQ_AFF, \ resv: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000, \ sq_thread_cpu: 2 expected -1, got 3 FAIL On my system, there is: CPU(s) possible : 0-3 CPU(s) online : 0-1 CPU(s) offline : 2-3 CPU(s) present : 0-1 The sq_thread_cpu 2 is offline on my system, so the bind should fail. But cpu_possible() will pass the check. We shouldn't be able to bind to an offline cpu. Use cpu_online() to do the check. After the change, the testcase run as expected: EINVAL will be returned for cpu offlined. Reviewed-by: Jeff Moyer Signed-off-by: Shenghui Wang Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 84efb8956734f..30a5687a17b65 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2334,7 +2334,7 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx, nr_cpu_ids); ret = -EINVAL; - if (!cpu_possible(cpu)) + if (!cpu_online(cpu)) goto err; ctx->sqo_thread = kthread_create_on_cpu(io_sq_thread, -- 2.20.1