Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp834836lqh; Thu, 28 Mar 2024 19:46:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXimZOZ0AjdH3gpNEhtitAqap4twV/dk6aEa9xIXiCWjxHWhHRg1ghOMXIF1yx1+xtX820sO3oUHMbQuDZ6Lv05o2dlf5zJX88LXduW2A== X-Google-Smtp-Source: AGHT+IFLekUCGbcSCnSy+KLXkjR6ZAnwj07QvFOeHyop5thGQLtr/074LFNBpbE6T8gtew0CmaeV X-Received: by 2002:a0c:c60f:0:b0:696:236b:c158 with SMTP id v15-20020a0cc60f000000b00696236bc158mr789655qvi.1.1711680385260; Thu, 28 Mar 2024 19:46:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711680385; cv=pass; d=google.com; s=arc-20160816; b=nFA8dm7hISwBLlQy83VbqDNVod6J19Y0xbbXxPVc8iwX+/JUQm6+uLqSNeUPiF7NQt 3/VeBo9M4V7eGXCPLqZb/lTAgGqfjUAvhEei0fr3kf3IywOnUq6aMqq6MVFPPuMhFQnB 5FvSRSprU8zy9stuoo7RUHkySfZ2Gpu4n1bG6sVAQMgnZ0HeqDJxFRO11dvKSKUghvfo lpAs4QXIC5Zvd+msdn3aZVZuRnwilC7vHdcPpTAj+bM/oA608q70GnzASdsWzScaM763 Di3RCf/AKO698qsJS+LXpcWx99v/iRMusrhg+UAikug3WNbnJJMp3yOSSxXyV2hd78h3 cwMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=ngoJLoIyjVWpHhoqeikzQs+rgHbPGJsL8jVuMfJMmGg=; fh=uPWjNSOhstu5Vx0I0nnmly5JAbIVtVRnrAY3ZE8aow4=; b=G6SzuWwpixHNIzPsQfNdzkFBOfOT9wpWb8rf9ecrsyHexaDeXBCYg27gfGsGWwcnto SqO91StQWRyzt/Y+hLfiZgcVRWlvmIz3FMGrqtI1jVqLj7GfXlb7UpgWkdx8+HhQgB78 hnkIOQZjCrl3RqlNgbpmyovM2QE8qSK1zp0r5Vzx8CBiAMjcoi02Ifp9jwBjqKFAKm8O Lgn/BBFQ2HvqoP1DvaY1FSI8rrgvVJH71lZarq2dqrHFgqqoOqRFxTplbjs1fa7dXE6a hqm8V7rPKOOL7PEb/Dz8dJTxTd7C7xwqAI04GkhpfJjZhNCRsoYF8Gm8ECa/iAbyQYVm M3hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-124066-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124066-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id o9-20020a0cfa89000000b006968fe2fadesi2787983qvn.124.2024.03.28.19.46.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 19:46:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124066-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=unisoc.com); spf=pass (google.com: domain of linux-kernel+bounces-124066-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124066-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D859C1C247AB for ; Fri, 29 Mar 2024 02:46:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24FDF36B08; Fri, 29 Mar 2024 02:46:17 +0000 (UTC) Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (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 37E7C33070; Fri, 29 Mar 2024 02:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711680376; cv=none; b=vAlaJ7EFWujuY+/pXfCLtfW86vpjSrW4goXdStI6bQSw6sksjC6iSuc28gn/liF9PB1+laltM8rdQ+ZADLwPxaJ174vWF+WlzlxarLXPovDPlJdBMm8VbUZepw0/yeVFBuBT/pdyyMcL6JF7NkR2uk67MEONtLr0c94hWP5cSaM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711680376; c=relaxed/simple; bh=mO5pDF4ppVBRq6mSFl/EZBnRAtwgeKIJXHKAIeHEMZs=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=lRVWNffwth5CFzl6guRW4mprjGqiCdnn4UJLf8PmiG3qT2HbkKq80EogLyAgzBTAyyGB+r5qbQZn0KBv7aXBNlUUcAdwpKCkBUNMQDHcNB+1+EpfhBHu1u5jyJt/tb0dc090Jvkm3VHKZEFSDvdkvF2ff5YElIrlojMSGX8hXgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 42T2iY6c066183; Fri, 29 Mar 2024 10:44:34 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4V5PpH2xSzz2L8K10; Fri, 29 Mar 2024 10:42:47 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 29 Mar 2024 10:44:31 +0800 From: Zhiguo Niu To: CC: , , , , , Subject: [PATCH] block/mq-deadline: Fix WARN when set async_depth by sysfs Date: Fri, 29 Mar 2024 10:44:21 +0800 Message-ID: <1711680261-5789-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 42T2iY6c066183 A WARN may occur when async_depth is set from user by sysfs, the warning log is as following: [ 623.848659] WARNING: CPU: 0 PID: 7798 at lib/sbitmap.c:537 sbitmap_queue_get_shallow+0x2c/0x38 [ 623.878550] CPU: 0 PID: 7798 Comm: kworker/u16:2 Tainted: G W OE 6.6.0-mainline-g8d9254e6f4a0-dirty-ab000013 #1 [ 623.880091] Hardware name: Unisoc UMS9621-base Board (DT) [ 623.880906] Workqueue: writeback wb_workfn (flush-254:48) [ 623.881748] pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 623.882763] pc : sbitmap_queue_get_shallow+0x2c/0x38 [ 623.883525] lr : __blk_mq_get_tag+0x50/0xd4 [ 623.884198] sp : ffffffc08a073230 [ 623.884745] x29: ffffffc08a073230 x28: ffffffc0821445e0 x27: 0000000000000000 [ 623.885799] x26: ffffff8087de8000 x25: 0000000000000000 x24: 0000000000000002 [ 623.886849] x23: ffffffc0820f2008 x22: ffffff8088ac3918 x21: ffffff808c358f10 [ 623.887897] x20: ffffff808c358f00 x19: ffffffc08a073360 x18: ffffffc08bde70a8 [ 623.888946] x17: 000000007e57c819 x16: 000000007e57c819 x15: fffffffdfe000000 [ 623.889993] x14: 0000000000000001 x13: 0000000000000004 x12: 00000003c6c931ed [ 623.891038] x11: ffffff80939a3800 x10: ffffffc0801ac88c x9 : 0000000000000000 [ 623.892086] x8 : 0000000000000006 x7 : 0000000000000000 x6 : ffffffc080765204 [ 623.893131] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000000000000 [ 623.894174] x2 : ffffffc080765224 x1 : 0000000000000005 x0 : ffffff808c358f10 [ 623.895221] Call trace: [ 623.895660] sbitmap_queue_get_shallow+0x2c/0x38 [ 623.896379] blk_mq_get_tag+0xa0/0x350 [ 623.896992] __blk_mq_alloc_requests+0x218/0x300 [ 623.897715] blk_mq_submit_bio+0x314/0x774 [ 623.898369] __submit_bio+0xb4/0xe0 [ 623.898950] submit_bio_noacct_nocheck+0x110/0x324 [ 623.899692] submit_bio_noacct+0x278/0x3f8 [ 623.900344] submit_bio+0xcc/0xe8 [ 623.900900] f2fs_submit_write_bio+0x100/0x428 [ 623.901605] __submit_merged_bio+0x74/0x1ac [ 623.902269] __submit_merged_write_cond+0x188/0x1f4 [ 623.903022] f2fs_write_data_pages+0xb10/0xc2c [ 623.903727] do_writepages+0xf4/0x618 [ 623.904332] __writeback_single_inode+0x78/0x60c [ 623.905055] writeback_sb_inodes+0x294/0x520 [ 623.905734] __writeback_inodes_wb+0xa0/0xf4 [ 623.906413] wb_writeback+0x188/0x4e8 [ 623.907014] wb_workfn+0x420/0x608 [ 623.907582] process_one_work+0x23c/0x55c [ 623.908227] worker_thread+0x2ac/0x3e4 [ 623.908838] kthread+0x108/0x12c [ 623.909389] ret_from_fork+0x10/0x20 The rootcause is user may set async_depth to a value which is less than its initial value from dd_init_hctx->dd_depth_updated, and this initial value is set to sbq->min_shallow_depth, when async_depth is modified by user from sysfs, sbq->min_shallow_depth will not be changed simultaneously, and it is also not easy to obtain tag sbitmap information in deadline_async_depth_store. So a suitable value should be set to min_shallow_depth in dd_depth_updated. Signed-off-by: Zhiguo Niu --- block/mq-deadline.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/mq-deadline.c b/block/mq-deadline.c index 02a916b..89c516e 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -646,10 +646,12 @@ static void dd_depth_updated(struct blk_mq_hw_ctx *hctx) struct request_queue *q = hctx->queue; struct deadline_data *dd = q->elevator->elevator_data; struct blk_mq_tags *tags = hctx->sched_tags; + unsigned int shift = tags->bitmap_tags.sb.shift; + unsigned int dd_min_depth = max(1U, 3 * (1U << shift) / 4); dd->async_depth = max(1UL, 3 * q->nr_requests / 4); - sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, dd->async_depth); + sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, dd_min_depth); } /* Called by blk_mq_init_hctx() and blk_mq_init_sched(). */ -- 1.9.1