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 X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EA62C07E9B for ; Mon, 19 Jul 2021 10:16:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E2550608FE for ; Mon, 19 Jul 2021 10:16:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2550608FE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 69DDF8D00F4; Mon, 19 Jul 2021 06:16:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64DDB8D00EC; Mon, 19 Jul 2021 06:16:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A0158D00F4; Mon, 19 Jul 2021 06:16:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0218.hostedemail.com [216.40.44.218]) by kanga.kvack.org (Postfix) with ESMTP id 1B93E8D00EC for ; Mon, 19 Jul 2021 06:16:21 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BD6A421977 for ; Mon, 19 Jul 2021 10:16:18 +0000 (UTC) X-FDA: 78378932436.11.FF55B6A Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by imf14.hostedemail.com (Postfix) with ESMTP id 87FC960019A9 for ; Mon, 19 Jul 2021 10:16:18 +0000 (UTC) Received: by mail-il1-f173.google.com with SMTP id s5so8473952ild.5 for ; Mon, 19 Jul 2021 03:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RsTA6lCPJUSqFkf4kI50Ly+s7/7eeHMzPSdXglSoeiU=; b=fCF/wlFqLzoWUG6sB7JEQhqPMSNr0qNYYHAcrGNftTyFMaAxKtbGI0v+eASFWU5I8k j8EvuDGk/sotP6K0xugNeM6wScVJaoSbC0CDpDO4otpTZb6anM/A3oAesl6KKGHeIK6p KEDxWS86n9ONQf4whk7pTCFOfK5B7tJd32LP/Ie6LvP3f6SSuG4xlmoZ1cMd4dlurc5w C12NaHMsP4Wmfawd5cuSqf7J3egAZCZFBiw9TEOmxLiGeZxmYs4JRw/Wex8r2DQLM/ZU A5gGi42MWz3AwpAJwriJp7SF7ktQXocm9Jf7FGPLRmDMYHCnIzEuNB1k3gcJl2qAMCWI dvhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RsTA6lCPJUSqFkf4kI50Ly+s7/7eeHMzPSdXglSoeiU=; b=UOeoXiwmdDgnQNzwLwkf2lN9770G8iM77HuzjGIv06fT0fbLCvjYr4XUFx906wZNm5 3WYv69W1UKwrtha1TNnF5KZpDaQExN4cpCip6OOftwlbPWYZxGMHJUCTnfidlz1esdVs /3FJUUfJFiqlDnqKmO/V9EVocaNf/kMQ6HX7k4ZV7iLVDkLcBmmqJGOd87KMKbDrWXWq 1sA8WkXDo/qplEQSGNtRy2QPIOS76ouScpxpzQDjfXOZn7/4iXnv0f+xXRaXs30mbvll BlpqwxS0AHRB7VBNAA7lffQSuOrPUB9Kz8H5crLtJLXcjkWjs9VPmH9A3qoY//tH2t/3 EEtA== X-Gm-Message-State: AOAM530h2CJzCiDGlxhkwL+nyxzEMdLi/1Wi56kyLNrAOMpYTfg5YOln alWV/qf5Z0fzXmWZ5vV1iMM= X-Google-Smtp-Source: ABdhPJyg22NH0H96Cln4985p2ZO9QxyhhyxfxkKUd9PhaAdC91kNtz1JN47YbQKDW6ClGowUFMNR7Q== X-Received: by 2002:a05:6e02:54c:: with SMTP id i12mr16393080ils.103.1626689777961; Mon, 19 Jul 2021 03:16:17 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id l5sm10209774ion.44.2021.07.19.03.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 03:16:17 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 7C43C27C0054; Mon, 19 Jul 2021 06:16:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 19 Jul 2021 06:16:16 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrfedtgddvgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepuehoqhhunhcu hfgvnhhguceosghoqhhunhdrfhgvnhhgsehgmhgrihhlrdgtohhmqeenucggtffrrghtth gvrhhnpedvleeigedugfegveejhfejveeuveeiteejieekvdfgjeefudehfefhgfegvdeg jeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsoh hquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedq udejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmh gvrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 19 Jul 2021 06:16:14 -0400 (EDT) Date: Mon, 19 Jul 2021 18:14:21 +0800 From: Boqun Feng To: Matthew Wilcox Cc: Zhouyi Zhou , paulmck@kernel.org, Oleksandr Natalenko , linux-kernel , stable@vger.kernel.org, Chris Clayton , Chris Rankin , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu , Andrew Morton , Linux-MM , Miaohe Lin , "Huang, Ying" Subject: Re: linux-5.13.2: warning from kernel/rcu/tree_plugin.h:359 Message-ID: References: <2245518.LNIG0phfVR@natalenko.name> <6698965.kvI7vG0SvZ@natalenko.name> <20210718215914.GQ4397@paulmck-ThinkPad-P17-Gen-1> <20210719015313.GS4397@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="fCF/wlFq"; spf=pass (imf14.hostedemail.com: domain of boqunfeng@gmail.com designates 209.85.166.173 as permitted sender) smtp.mailfrom=boqunfeng@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: iseir9iuxgkojh9ni5zcp4cepz9rq3jc X-Rspamd-Queue-Id: 87FC960019A9 X-Rspamd-Server: rspam01 X-HE-Tag: 1626689778-13047 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 Mon, Jul 19, 2021 at 03:43:00AM +0100, Matthew Wilcox wrote: > On Mon, Jul 19, 2021 at 10:24:18AM +0800, Zhouyi Zhou wrote: > > Meanwhile, I examined the 5.12.17 by naked eye, and found a suspicious place > > that could possibly trigger that problem: > > > > struct swap_info_struct *get_swap_device(swp_entry_t entry) > > { > > struct swap_info_struct *si; > > unsigned long offset; > > > > if (!entry.val) > > goto out; > > si = swp_swap_info(entry); > > if (!si) > > goto bad_nofile; > > > > rcu_read_lock(); > > if (data_race(!(si->flags & SWP_VALID))) > > goto unlock_out; > > offset = swp_offset(entry); > > if (offset >= si->max) > > goto unlock_out; > > > > return si; > > bad_nofile: > > pr_err("%s: %s%08lx\n", __func__, Bad_file, entry.val); > > out: > > return NULL; > > unlock_out: > > rcu_read_unlock(); > > return NULL; > > } > > I guess the function "return si" without a rcu_read_unlock. > > Yes, but the caller is supposed to call put_swap_device() which > calls rcu_read_unlock(). See commit eb085574a752. Right, but we need to make sure there is no sleepable function called before put_swap_device() called, and the call trace showed the following happened: do_swap_page(): si = get_swap_device(): rcu_read_lock(); lock_page_or_retry(): might_sleep(); // call a sleepable function inside RCU read-side c.s. __lock_page_or_retry(): wait_on_page_bit_common(): schedule(): rcu_note_context_switch(); // Warn here put_swap_device(); rcu_read_unlock(); , which introduced by commit 2799e77529c2a [Copy the author] Regards, Boqun