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 C39A9C636CE for ; Mon, 19 Jul 2021 10:16:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9649D6120D for ; Mon, 19 Jul 2021 10:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236274AbhGSJfj (ORCPT ); Mon, 19 Jul 2021 05:35:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236215AbhGSJfi (ORCPT ); Mon, 19 Jul 2021 05:35:38 -0400 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6E3AC061574; Mon, 19 Jul 2021 02:21:35 -0700 (PDT) Received: by mail-il1-x132.google.com with SMTP id a7so15472792iln.6; 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=lKU9TdY8yP6eTRQHsAHOww8UaShGEauHyeGoMkhjLVaxDqZ4bLn1XzOGPlBiFd3N9k /TMr5iNehHufgACFYxyKMejaW88l6U1T1s5+4PD8coD27s4hy8IzG3U2T2itw8tMqyMJ mFXlP2e3EcnP7qg8MIz7x6SlK3FqD2mlKgCI+2ehasgi1Km9YxsgEk03CTY/bPxac3ui vAddUinG1i8EUcj36je6dQi56Z2+teXnhWReuDi5fPiEcSapWj+Y/ShM623BMinH97T4 QOrn90w9iZhq0YILjwmH8jNA66ICAKMYpFfMthW1OI57JhoHpORxtO7sPDCmUaJ+6/Xi WLaA== X-Gm-Message-State: AOAM5320loqBtEgaoa7oAAhchdx8/YSLROW+wVVnoxR92iL/k2nQdGmD QGy7bZEkO/AGUxsiK4qmY1M= 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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