Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp962887lqh; Fri, 29 Mar 2024 02:43:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJPefynux8/R+kfE+38ACP4SCEDy3q8frCidPajiXfESYAf8ZRx10j1MaZvgGSrO7tGJqzyDlZff0eqn13Dcuu7fNFBlQkIrfl/20TBQ== X-Google-Smtp-Source: AGHT+IFW41AfWRFf7WPsDACFkFIb/723mnTnx/xtSPADh1s9NQm5MPjfLF+bovWOvYhu2o5zzweD X-Received: by 2002:a05:6870:390b:b0:229:e49f:8dc6 with SMTP id b11-20020a056870390b00b00229e49f8dc6mr1787691oap.7.1711705410998; Fri, 29 Mar 2024 02:43:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711705410; cv=pass; d=google.com; s=arc-20160816; b=kl6w/ttnqM3HhDhTb5U/MiKW6Aw2RI3AQIeUA89McC5bXlvwogSECvlIaEVrB6CqB5 eH8OTBrTg/nNsweyc98Iki6kylNt8H2GTgzvatHdXMkNWzGpB1rTdvC5tF3/0LbuBSjb DSFN3syicQnAHTmJ015HqfX02Yd9kQ4B9IEIs3l2NojK9NhSvstBEESY2ItptVMw1p5i 1vYIfgR5q8rdRr8NKEq/qgqi+p01+81UTOCJjAER8iHPnMkavzupbIXeNNhqqGXLmdOO DOzdhxQB7esD6jI406TR1KTToL2KF296scD9SLoqyZVCryV2wHxsz74juQLtzgja86t2 MHnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=jq5J+3hpMTsfHTgbS2ASWTSfU51EuKZyXWloCoK4DVI=; fh=yGMOTS9LTSPIMnjVMmhDFKsgSPzaslKAX28RyL7MFd0=; b=UYYw6TsGxHiPltNV4tKKfNamWySFeXpj0LTkxsuElDmYsLD2SQBRvP1cBZijGsXmmL A02PG9AZNv+phWVrrGQTmQNab2S5QGLwBuVI7qNjiN1fjM0Z+nL43bL8IrUQHBBkoRwq CVRkBOxRTPCOH27ygNXHVlHI4Sz8wPCUEe+wm4XQOlNERLBaT34ysXyfdoVP1M5bZAeK AL4HS0raOPh/2Bphc4Dfb9oR7grMS0CygThNQGar0DezHOAPYxStA36yQFWJB3uylKFJ HHFaqTfkZbXVuNwd+tDdOsuUYZxzsq1UtTgfG+s8A2v2oRmsF32qDp2pHeIlvMFtW0IO XKyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GWUxQpAP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-124361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j4-20020a056a00234400b006ea44a301e8si3489743pfj.334.2024.03.29.02.43.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 02:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=GWUxQpAP; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-124361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 38F7B282B66 for ; Fri, 29 Mar 2024 09:43:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70E3A4CB36; Fri, 29 Mar 2024 09:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GWUxQpAP" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A726B4594F; Fri, 29 Mar 2024 09:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711705399; cv=none; b=gxIU6HrPO0ZiDkapDQcogV+AaVoZomeHKDQ9l+oSNJHoMiH79Rwi4zRprFHGDjnk8AkOPU/VnnZFI+XBCCp7H8OYCKVgEsZqZ/Afo5RN4/sA6R+73B0F9YWtWhyRT+3tY3BXZFfeWeoYWSEPvHO9h4+6/r5OUXDFRBtb8B/QsJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711705399; c=relaxed/simple; bh=m/1irspid2yhG/ZRvOgLcpF7TGDSpxl6shghAlMMFM8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=txovwwNyz3DHL6QIs5JwttodHfBzCT58iFhMZgOvaNPsnhJS40gAjYJlw8rx28eILs6bzkf3uRWg1TcP/6FhSpAnhJFIBwD59NajtW44Gs2KPJbCbZoxc9Gcq9GkceekRlfWfUlfhk0Y6ZvA1MRo+95qmEH71F9O3Z3hCKGcvqA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GWUxQpAP; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-33ed7ba1a42so1209235f8f.2; Fri, 29 Mar 2024 02:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711705396; x=1712310196; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jq5J+3hpMTsfHTgbS2ASWTSfU51EuKZyXWloCoK4DVI=; b=GWUxQpAPGq6HH2Nj/6oX0fhluJqOAKcoC0tNS2jqAdK9Cjtg4OXk8m2Fq10cs+ktwI CA+oIYMRby5wi/Slnb1S6LYAjHUfN64DILk/MFbdk6R0pjmEErk+uEuLJ+E21Mteirr4 /XwdcEPCfmCVh3/1Jkl4HEj8DAKJ8gKz45a0Memvsnu2hSMnop6/ajm3B8prwvM9iV14 jQoZ6h0evPpcq+86dHvH77FMzAp6nJ2W0brkyViAx6xtxgEvN/jQPAroX3nEbq1KhMLC MCJKwxurubDYfUmaqP9MTKzvUulfb/VEYQwO/QFPRbYaFc0feiO+Ady9xw/t6NZnKuEr SjwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711705396; x=1712310196; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jq5J+3hpMTsfHTgbS2ASWTSfU51EuKZyXWloCoK4DVI=; b=Ib6K6pYYdLlUZBcjhZ0EuM7xotSKqNoa7r48YUwHvd6IsWEG1Nw7l29WPYU79rgctt LLnJaRVYXpXaRf9p+Q79YdBpwcACQMcQaqFWx50D04D77Ifp4TYlY8Z8JwR8cfiD4+80 dd8BOkAGM1W9iAzFDuxWQAqvA3TwCeNq/pXKRBL58EsnPvh9rdR5GGQEDyCqva0KTJIr KfB/iHrtMCGHCRdvzO7OysnkY8TihqxN4f7+nq4Xkr/UADGOcFmR/6MJXnA0+LdkrwNh HWF7St2ZbXAcrB+fTPThbLbX5FxKb0BmMY1oomLKdyhkg3plVK20NsF9NbwmFOFzylHP jpKw== X-Forwarded-Encrypted: i=1; AJvYcCXhxUVlwE4xsKGpz4BU+p+y6hG5GSxpD9pTA65aH9JDu78kQcLCwYBqwSXeXPOcBVf9UMVMMxUfOLv351IREp+Ro9UhKlXl9KlqjazofLOFb1rPMlMv0rj4ZRkBO95hL2ZsiDV6O63Qo68= X-Gm-Message-State: AOJu0YzfqFQ90mdR2xQROazpYsHZyQPnCeSh39f0MqMeSgl9CR5H1kqk gptUTC01frjTqZsogA1UE7Gb9sEOzvFm4D6K/Zv6kh8aWBjczcAR0PIHL1YHHw6tzAZ+yNqPbny uJ/BrdN5AzQoSF+e0wqGtLoQ+wv8= X-Received: by 2002:a5d:6102:0:b0:33d:f3c4:6002 with SMTP id v2-20020a5d6102000000b0033df3c46002mr1141766wrt.1.1711705395737; Fri, 29 Mar 2024 02:43:15 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <1711680261-5789-1-git-send-email-zhiguo.niu@unisoc.com> <5e10988d-5652-4e03-b866-7f0daccafcad@kernel.org> In-Reply-To: <5e10988d-5652-4e03-b866-7f0daccafcad@kernel.org> From: Zhiguo Niu Date: Fri, 29 Mar 2024 17:43:04 +0800 Message-ID: Subject: Re: [PATCH] block/mq-deadline: Fix WARN when set async_depth by sysfs To: Damien Le Moal Cc: Zhiguo Niu , axboe@kernel.dk, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, ke.wang@unisoc.com, hongyu.jin@unisoc.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 29, 2024 at 11:40=E2=80=AFAM Damien Le Moal wrote: > > On 3/29/24 11:44, Zhiguo Niu wrote: > > 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_q= ueue_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 BT= YPE=3D--) > > [ 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: 0000000= 000000000 > > [ 623.885799] x26: ffffff8087de8000 x25: 0000000000000000 x24: 0000000= 000000002 > > [ 623.886849] x23: ffffffc0820f2008 x22: ffffff8088ac3918 x21: ffffff8= 08c358f10 > > [ 623.887897] x20: ffffff808c358f00 x19: ffffffc08a073360 x18: ffffffc= 08bde70a8 > > [ 623.888946] x17: 000000007e57c819 x16: 000000007e57c819 x15: fffffff= dfe000000 > > [ 623.889993] x14: 0000000000000001 x13: 0000000000000004 x12: 0000000= 3c6c931ed > > [ 623.891038] x11: ffffff80939a3800 x10: ffffffc0801ac88c x9 : 0000000= 000000000 > > [ 623.892086] x8 : 0000000000000006 x7 : 0000000000000000 x6 : ffffffc= 080765204 > > [ 623.893131] x5 : 0000000000000000 x4 : 0000000000000001 x3 : 0000000= 000000000 > > [ 623.894174] x2 : ffffffc080765224 x1 : 0000000000000005 x0 : ffffff8= 08c358f10 > > [ 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 informati= on > > in deadline_async_depth_store. > > > > So a suitable value should be set to min_shallow_depth in dd_depth_upda= ted. > > > > 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 =3D hctx->queue; > > struct deadline_data *dd =3D q->elevator->elevator_data; > > struct blk_mq_tags *tags =3D hctx->sched_tags; > > + unsigned int shift =3D tags->bitmap_tags.sb.shift; > > + unsigned int dd_min_depth =3D max(1U, 3 * (1U << shift) / 4); > > Extra blank space before "/". Hi Damien Le Moal Thank you for this detailed review, I will fix it with suggestions from other reviewers. > That division could also be replaced with ">> 2". yes, I just refer to the original code "dd->async_depth =3D max(1UL, 3 * q->nr_requests / 4);" thanks! > > > > > dd->async_depth =3D max(1UL, 3 * q->nr_requests / 4); > > > > - sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, dd->async_dep= th); > > + sbitmap_queue_min_shallow_depth(&tags->bitmap_tags, dd_min_depth)= ; > > } > > > > /* Called by blk_mq_init_hctx() and blk_mq_init_sched(). */ > > -- > Damien Le Moal > Western Digital Research >