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 6D57BC433EF for ; Mon, 18 Oct 2021 02:16:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFF2460F9F for ; Mon, 18 Oct 2021 02:15:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CFF2460F9F 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 1340D900002; Sun, 17 Oct 2021 22:15:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BD316B0071; Sun, 17 Oct 2021 22:15:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2A28900002; Sun, 17 Oct 2021 22:15:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id D01926B006C for ; Sun, 17 Oct 2021 22:15:58 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7CC438249980 for ; Mon, 18 Oct 2021 02:15:58 +0000 (UTC) X-FDA: 78707942796.39.06C8793 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf24.hostedemail.com (Postfix) with ESMTP id 3F64DB00009E for ; Mon, 18 Oct 2021 02:15:56 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id v8so9384161pfu.11 for ; Sun, 17 Oct 2021 19:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=i+wLhpixPoyOpckI8HRAvFPHKMx2lqvriuIvfx/+fps=; b=pox9pxe0ZHP23awv/t6xhYokmtWPhfDwd6LEWnAQkTzwXYAdOeYvPWnL43q3QtT95l xhYmPe8qCvmed3KYngpKkegppqpIIsHFDnguHoojdkTRzYa99v5TdTS49L3V2HdY00n7 cnV3FDBguH+FzLxi2QLk1i7zc5wP1lHqAcaNy+ERHvTIPDOsklxXASqSOnl9om/GTndN 0qs/9Z25HFkcXBzUOMMbbMcBKAkCP3CrWjx1YY4SEf6AlJR5/8RY8eZtFLnaWCt8zSYR 4KjQwzNYfidcnRnXI3BZ0h+0NSgjVJUMj6WDGfPJGKwd4Kfy0+6t2DiKix7K4K1y/oZK 33Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=i+wLhpixPoyOpckI8HRAvFPHKMx2lqvriuIvfx/+fps=; b=d5HEqMv6JeAXUPrKLAkwiANWQZ/GZ4bL4uCok29JesuE1KQvttSZyxsGVjpe/35Mwh KXLR5dJA+5wWDttKrjxPHzU0jEAJ0kUrdVBNz03l1C5oJ0bLci/v94ODMiMjPg59mij9 a4aEOCulQm170vxWxLGvvwBGQIQvHQaHkHtrDCv4fjtKQlai3R0C0VOgV9eKPpvx8nCx ifApXbUqiT7XxQSryYPq1M3YW5XD2CeCZrPZSPhgh4DzrqQNzFMATzmBC8Lnf18AiJPD fOXvmcMQfV9gcezkXVwke9ozFxso8mZPsDSSPKhtfrudeCT9oizO2VjbDXVVtpPchjuS Sq1w== X-Gm-Message-State: AOAM532kbC4IlQSWgZTmx0x5E5S4j7ANXHFJ3vno++3gtNloKzLXeVoU s2dhUC4vmLnlcsgkJy/w4W0= X-Google-Smtp-Source: ABdhPJzB2dc32dSOondd6EGAXBDmMcqVsB5HjS9NFCXssR7aTr+QUFmhzaWcb1ERDK1z/vjfQl/bWA== X-Received: by 2002:a63:954a:: with SMTP id t10mr14425342pgn.89.1634523357225; Sun, 17 Oct 2021 19:15:57 -0700 (PDT) Received: from [172.18.2.138] ([137.59.101.13]) by smtp.gmail.com with ESMTPSA id x184sm11173379pfc.44.2021.10.17.19.15.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 17 Oct 2021 19:15:56 -0700 (PDT) Subject: Re: [PATCH] mm: backing-dev: use kfree_rcu() instead of synchronize_rcu_expedited() To: Matthew Wilcox Cc: hch@infradead.org, akpm@linux-foundation.org, sunhao.th@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mikulas Patocka , Jens Axboe , Tejun Heo References: <20211014082433.30733-1-qiang.zhang1211@gmail.com> From: Zqiang Message-ID: <2357d7fe-0679-768e-7319-2f141860af2e@gmail.com> Date: Mon, 18 Oct 2021 10:15:53 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Queue-Id: 3F64DB00009E Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=pox9pxe0; spf=pass (imf24.hostedemail.com: domain of qiang.zhang1211@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=qiang.zhang1211@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: xyh1ytk5xcuwqwpgihw31c6oakeza4mt X-Rspamd-Server: rspam05 X-HE-Tag: 1634523356-52116 Content-Transfer-Encoding: quoted-printable 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: On 2021/10/15 =E4=B8=8B=E5=8D=888:35, Matthew Wilcox wrote: > On Fri, Oct 15, 2021 at 01:06:02PM +0800, Zqiang wrote: >> On 2021/10/15 =E4=B8=8A=E5=8D=8810:57, Qiang Zhang wrote: >>> >>> 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 t= he >>> > synchronize_rcu_expedited() will produce sleep action, use >>> kfree_rcu() >>> > instead of it. >>> > >>> > Reported-by: Hao Sun >> > >>> > Signed-off-by: Zqiang >> > >>> > --- >>> >=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 bee= n >>> removed >>> >from the bdi_tree by this point and the tree is never walked un= der >>> >RCU protection? >>> >>> >>> Thanks for your advice, I find this bdi_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 problem described in patc= h, >>> the=C2=A0flush_delayed_work() may be called in=C2=A0release_bdi() >>> The same will cause problems. >>> may be=C2=A0 we can replace queue_rcu_work() of call_rcu(&inode->i_rc= u, >>> i_callback) or do you have any better suggestions? > What? All I was suggesting was: > > +++ b/include/linux/backing-dev-defs.h > @@ -168,7 +168,10 @@ struct bdi_writeback { > =20 > struct backing_dev_info { > u64 id; > - struct rb_node rb_node; /* keyed by ->id */ > + union { > + struct rb_node rb_node; /* keyed by ->id */ > + struct rcu_head rcu; > + }; > struct list_head bdi_list; > unsigned long ra_pages; /* max readahead in PAGE_SIZE units */ > unsigned long io_pages; /* max allowed IO size */ > > > Christoph, independent of the inode lifetime problem, this actually see= ms > like a good approach to take. I don't see why we should synchronize_rc= u() > here? Adding Jens (original introducer of the synchronize_rcu()), Miku= las > (converted it to use _expedited) and Tejun (worked around a problem whe= n > using _expedited). Sorry=EF=BC=8Cthis my mistake. =C2=A0 this problem and the inode lifetime= cycle are=20 two different problems Can this modification which use kfree_rcu() instead of synchronize_rcu()=20 be accepted? Thanks Zqiang