From patchwork Thu Oct 14 08:24:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zqiang X-Patchwork-Id: 12558003 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 04D17C433FE for ; Thu, 14 Oct 2021 08:24:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8C74C600D4 for ; Thu, 14 Oct 2021 08:24:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8C74C600D4 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 1423694002C; Thu, 14 Oct 2021 04:24:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F21C94001C; Thu, 14 Oct 2021 04:24:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F228094002C; Thu, 14 Oct 2021 04:24:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id DFD1C94001C for ; Thu, 14 Oct 2021 04:24:40 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7CCC68249980 for ; Thu, 14 Oct 2021 08:24:40 +0000 (UTC) X-FDA: 78694356720.27.798D735 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf13.hostedemail.com (Postfix) with ESMTP id 84F1710405BA for ; Thu, 14 Oct 2021 08:24:39 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id k23-20020a17090a591700b001976d2db364so4226686pji.2 for ; Thu, 14 Oct 2021 01:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=Y1wcCJ10AMkbngtu0ZVsB2vKXfB5ndZJY8Kk89G1094=; b=Du7sLLmAp7rOYRynO6tGncdrjvNGW9V+5ICwMdQs4zj20vLCKphyt4oqz61sCfQa/M 9ixj+l1NhjXgtiAQXDdhd6XnqCLLzpnCJ7Iljh//b/pmgESEgyh5GXeRl1Vn3sIOTQg+ CUoF09sg3SfHW17Xd7AMZ7qHGyVh2Wd4GjHUwIQ7MzoVgjYrbQSI4jatpCpnmpVWHedA MqRif7sWQ9U1pKxi9v4UTLZktG6bMM5pgPkd1NRa8y2myhaTP5PGhmDHDjBkNx4wp/tS nlKpxul01nZTBwS8lhZUgV8z+nErQufQWM2ik4ksmkAU3yU4T3w2HqUxR+hnX2oHfOV/ w5zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Y1wcCJ10AMkbngtu0ZVsB2vKXfB5ndZJY8Kk89G1094=; b=XA7iSgCdEqJDZFb/AtZlPzOcv9GWK0AUGvOyRfVh+b0mTpi65k1i8c600QZNAd1SNY Kk+PK/sojPc4iNfhLUy3tgwTQkR5j3oIHUFbhnHBAojjnhhGhBZJGGYxzsG7D02xUlV4 K043PJm5Un62Y88mvQo+jOlKVW2krQWnFMCHdfXBf3z75lBHaik05aCJmDRrpq5P8e/a 4VQ4SHDafM4a2ejGn4ZAVEFuAciSq12f3AtD2XNSFgeRgwdHGIabmi1PMhgUG45UjvOr zFGQupos1qwwndOpLkP9fmQxz6kFDta4f+q3mUFYW2M+coZUy4kiJOHgA6Dsf0CC+psE LJjA== X-Gm-Message-State: AOAM530s23/WUYE0U17CuaS+wolOuzjNrYaoxbxlmZLZRoMvAxz/omzq ByjKeBrxBRC0XJTrNtB4XwE= X-Google-Smtp-Source: ABdhPJyQvTmIrEB/glBuN8GZ1dbA8a1pX+jcZclwX2WaLQOI2psDuW8hGGc7Z1DZI+vyhcv55h5p+g== X-Received: by 2002:a17:90a:b105:: with SMTP id z5mr18438907pjq.64.1634199879137; Thu, 14 Oct 2021 01:24:39 -0700 (PDT) Received: from BJ-zhangqiang.qcraft.lan ([137.59.101.13]) by smtp.gmail.com with ESMTPSA id r31sm8153943pjg.28.2021.10.14.01.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 01:24:38 -0700 (PDT) From: Zqiang To: akpm@linux-foundation.org, sunhao.th@gmail.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Zqiang Subject: [PATCH] mm: backing-dev: use kfree_rcu() instead of synchronize_rcu_expedited() Date: Thu, 14 Oct 2021 16:24:33 +0800 Message-Id: <20211014082433.30733-1-qiang.zhang1211@gmail.com> X-Mailer: git-send-email 2.17.1 X-Rspamd-Queue-Id: 84F1710405BA X-Stat-Signature: yno73c5kqo3wnq8xsz73brty16pc8e89 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Du7sLLmA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.hostedemail.com: domain of qiang.zhang1211@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=qiang.zhang1211@gmail.com X-Rspamd-Server: rspam02 X-HE-Tag: 1634199879-109734 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: __init_work+0x2d/0x50 synchronize_rcu_expedited+0x3af/0x650 bdi_remove_from_list [inline] bdi_unregister+0x17f/0x5c0 release_bdi+0xa1/0xc0 kref_put [inline] bdi_put+0x72/0xa0 bdev_free_inode+0x11e/0x220 i_callback+0x3f/0x70 rcu_do_batch [inline] rcu_core+0x76d/0x16c0 __do_softirq+0x1d7/0x93b invoke_softirq [inline] __irq_exit_rcu [inline] irq_exit_rcu+0xf2/0x130 sysvec_apic_timer_interrupt+0x93/0xc0 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; }; enum { diff --git a/mm/backing-dev.c b/mm/backing-dev.c index c878d995af06..45d866a3a4a2 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -935,8 +935,6 @@ static void bdi_remove_from_list(struct backing_dev_info *bdi) rb_erase(&bdi->rb_node, &bdi_tree); list_del_rcu(&bdi->bdi_list); spin_unlock_bh(&bdi_lock); - - synchronize_rcu_expedited(); } void bdi_unregister(struct backing_dev_info *bdi) @@ -969,7 +967,7 @@ static void release_bdi(struct kref *ref) bdi_unregister(bdi); WARN_ON_ONCE(bdi->dev); wb_exit(&bdi->wb); - kfree(bdi); + kfree_rcu(bdi, rcu); } void bdi_put(struct backing_dev_info *bdi)