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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7606C433EF for ; Fri, 15 Oct 2021 02:57:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 57B446109E for ; Fri, 15 Oct 2021 02:57:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 57B446109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 92E09900002; Thu, 14 Oct 2021 22:57:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DD346B0071; Thu, 14 Oct 2021 22:57:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7CBE8900002; Thu, 14 Oct 2021 22:57:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id 6D04C6B006C for ; Thu, 14 Oct 2021 22:57:29 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 139C88249980 for ; Fri, 15 Oct 2021 02:57:29 +0000 (UTC) X-FDA: 78697161018.28.DC42891 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf07.hostedemail.com (Postfix) with ESMTP id 80DBB10000AD for ; Fri, 15 Oct 2021 02:57:29 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id r2so7280987pgl.10 for ; Thu, 14 Oct 2021 19:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=le/SLWBaq+s1Gv3QEtlAfmFJOSkTdcO1dpWzJcQYRBc=; b=JotWmh/3QB2QsFQybTyc6mCbicTNLox1XdVaMz2D7+UXZp9fvuPqNnehuOrdb9VCip x8wLCuh9lYfvPq84ElmvI6tgjVSj0mTpaVLad54Jnu9KD9vK3k1ueyLAtM+ojG7OESm1 8iRuaXsOKj1zezeXkKnsoVXFAjoiQ/EVpleyhfesas5FKKfw2UuCp26wArfuG/FUF7HV 6WcReOMAM5Lr9k0RTzRxDkdbDMNtyCOHz3qltxUpQW1/UepBmuzpwMJ8GupcARlALwmV iZkpIF0bhmv0sXHRoP8zXV/s1OrVTLNjP1FMtwSBxWzxPeYTi01SPg1FijJLEOMQbkFJ Jf5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=le/SLWBaq+s1Gv3QEtlAfmFJOSkTdcO1dpWzJcQYRBc=; b=fEvAva440Lx2DQ55qjscho1XOaO9VXbfjtzeTjeIgxH9o18QVP9hE3e45EW04UwqOB FGewHrdcsjeeUhut5pBlIDn3wjT+iHzkEyjkQ7orq2bAfLUqU3m/17h/qOv1GTbvOByl wUT32cSMMFFiuGlKDanc5uwumkOhk/vLcbg8+i6eyKydooL5iPY+P+UkAWhC1jS2ECg1 2Nmftm2/GlSwZmAacoWj9CdEISvZ7ZfXuuEmbfhdfMmGhAyDe6tmD5NEAyKLmsV379qH 2IS1ORddBXtM5KfEbOEAwPrxSMnWonF6El0CQcRcaQBD2veDQ+92qzX82xuHlhytLHsd AVEA== X-Gm-Message-State: AOAM530Faegn2JANViDlzeBMy4Ikw8XLDW6N8xMdRT7nBVii0lm1MARU Pj2jepsr4Z2sG81yXBCVqyJF3oOuSNMequXVLuU= X-Google-Smtp-Source: ABdhPJzd7g6/H+6b4kYTRjfdS1l7QUvFk/dnPzfLuOePqxAija0u27bFSCpHKV8izyDeRIVlpzfR19fZgS5gDZ9JNjM= X-Received: by 2002:a05:6a00:1ad0:b0:44d:bd1:f392 with SMTP id f16-20020a056a001ad000b0044d0bd1f392mr8917323pfv.69.1634266647628; Thu, 14 Oct 2021 19:57:27 -0700 (PDT) MIME-Version: 1.0 References: <20211014082433.30733-1-qiang.zhang1211@gmail.com> In-Reply-To: From: Qiang Zhang Date: Fri, 15 Oct 2021 10:57:16 +0800 Message-ID: Subject: Re: [PATCH] mm: backing-dev: use kfree_rcu() instead of synchronize_rcu_expedited() To: Matthew Wilcox , hch@infradead.org Cc: akpm@linux-foundation.org, sunhao.th@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: multipart/alternative; boundary="000000000000000ef105ce5b5b7f" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 80DBB10000AD X-Stat-Signature: 77yxn1rybcagk6j11ej7oqcuz4hhrt8p Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="JotWmh/3"; spf=pass (imf07.hostedemail.com: domain of qiang.zhang1211@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=qiang.zhang1211@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1634266649-362068 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --000000000000000ef105ce5b5b7f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Matthew Wilcox =E4=BA=8E2021=E5=B9=B410=E6=9C=8814=E6= =97=A5=E5=91=A8=E5=9B=9B =E4=B8=8B=E5=8D=887:26=E5=86=99=E9=81=93=EF=BC=9A > On Thu, Oct 14, 2021 at 04:24:33PM +0800, Zqiang wrote: > > The bdi_remove_from_list() is called in RCU softirq, however the > > synchronize_rcu_expedited() will produce sleep action, use kfree_rcu() > > instead of it. > > > > Reported-by: Hao Sun > > Signed-off-by: Zqiang > > --- > > include/linux/backing-dev-defs.h | 1 + > > mm/backing-dev.c | 4 +--- > > 2 files changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/backing-dev-defs.h > b/include/linux/backing-dev-defs.h > > index 33207004cfde..35a093384518 100644 > > --- a/include/linux/backing-dev-defs.h > > +++ b/include/linux/backing-dev-defs.h > > @@ -202,6 +202,7 @@ struct backing_dev_info { > > #ifdef CONFIG_DEBUG_FS > > struct dentry *debug_dir; > > #endif > > + struct rcu_head rcu; > > }; > > >Instead of growing struct backing_dev_info, it seems to me this rcu_head > >could be placed in a union with rb_node, since it will have been removed > >from the bdi_tree by this point and the tree is never walked under > >RCU protection? > > Thanks for your advice, I find this bdi_tree is traversed under the protection of a spin lock, not under the protection of RCU. I find this modification does not avoid the problem described in patch, the flush_delayed_work() may be called in release_bdi() The same will cause problems. may be we can replace queue_rcu_work() of call_rcu(&inode->i_rcu, i_callback) or do you have any better suggestions? Thanks Zqiang --000000000000000ef105ce5b5b7f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
Matthew Wilcox <willy@infradead.org> =E4=BA=8E2021=E5=B9=B410= =E6=9C=8814=E6=97=A5=E5=91=A8=E5=9B=9B =E4=B8=8B=E5=8D=887:26=E5=86=99=E9= =81=93=EF=BC=9A
= On Thu, Oct 14, 2021 at 04:24:33PM +0800, Zqiang wrote:
> The bdi_remove_from_list() is called in RCU softirq, however the
> synchronize_rcu_expedited() will produce sleep action, use kfree_rcu()=
> instead of it.
>
> Reported-by: Hao Sun <sunhao.th@gmail.com>
> Signed-off-by: Zqiang <qiang.zhang1211@gmail.com>
> ---
>=C2=A0 include/linux/backing-dev-defs.h | 1 +
>=C2=A0 mm/backing-dev.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0| 4 +---
>=C2=A0 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-= dev-defs.h
> index 33207004cfde..35a093384518 100644
> --- a/include/linux/backing-dev-defs.h
> +++ b/include/linux/backing-dev-defs.h
> @@ -202,6 +202,7 @@ struct backing_dev_info {
>=C2=A0 #ifdef CONFIG_DEBUG_FS
>=C2=A0 =C2=A0 =C2=A0 =C2=A0struct dentry *debug_dir;
>=C2=A0 #endif
> +=C2=A0 =C2=A0 =C2=A0struct rcu_head rcu;
>=C2=A0 };

>Instead of growing struct backing_dev_info, it seems to me this rcu= _head
>could be placed in a union with rb_node, since it will have be= en removed
>from the bdi_tree by this point and the tree is never wal= ked under
>RCU protection?


Thanks for your advice, I find this bd= i_tree=C2=A0is traversed under the protection of a spin lock, not under the= protection of RCU.
I find this modification does not avoid the p= roblem described in patch, the=C2=A0flush_delayed_work() may be called in= =C2=A0release_bdi()
The same will cause problems.
= =C2=A0
may be=C2=A0 we can replace queue_rcu_work() of call_rcu(&= amp;inode->i_rcu, i_callback) or do you have any better suggestions?

Thanks
Zqiang
=C2=A0
<= /div> --000000000000000ef105ce5b5b7f--