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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 C167CC12002 for ; Mon, 19 Jul 2021 11:17:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 51FEE610D2 for ; Mon, 19 Jul 2021 11:17:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51FEE610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=natalenko.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A1C048D00F4; Mon, 19 Jul 2021 07:17:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F2988D00EC; Mon, 19 Jul 2021 07:17:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 893BF8D00F4; Mon, 19 Jul 2021 07:17:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id 658208D00EC for ; Mon, 19 Jul 2021 07:17:16 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id F3C872289A for ; Mon, 19 Jul 2021 11:17:14 +0000 (UTC) X-FDA: 78379086030.39.EA34019 Received: from vulcan.natalenko.name (vulcan.natalenko.name [104.207.131.136]) by imf04.hostedemail.com (Postfix) with ESMTP id 547E050000A2 for ; Mon, 19 Jul 2021 11:17:12 +0000 (UTC) Received: from spock.localnet (unknown [151.237.229.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by vulcan.natalenko.name (Postfix) with ESMTPSA id 695A1B3F3D1; Mon, 19 Jul 2021 13:17:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=natalenko.name; s=dkim-20170712; t=1626693429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wrtAMp8n8lOfYMpdjEfS7NS2+/lTSHmoD6u2/ln0m0M=; b=TUtaLbEqSNYuzc0eN7Y8ZZEE82uB4YSU4usOV9A63uQh9EV1ZVvdPzRFFHrIW9iVWiJbi8 Q4UzzAQomutjXIc6CBkHdg8QNK+TWjSFTMONW7yFd6grqHJvuemKiH7uuvtLDlvjAsns/+ ejiX7ahR4cTe1KXWi/drpvktUGSQemc= From: Oleksandr Natalenko To: Boqun Feng , Miaohe Lin Cc: Zhouyi Zhou , paulmck@kernel.org, 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 , "Huang, Ying" , Matthew Wilcox Subject: Re: linux-5.13.2: warning from kernel/rcu/tree_plugin.h:359 Date: Mon, 19 Jul 2021 13:17:07 +0200 Message-ID: <11144384.Jnp629F0a1@natalenko.name> In-Reply-To: <08803f78-3e99-6b3f-e809-5828fe47cf06@huawei.com> References: <08803f78-3e99-6b3f-e809-5828fe47cf06@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 547E050000A2 X-Stat-Signature: o1461kq7ee7otwajtkmxtjg3bfaf4xdq Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=natalenko.name header.s=dkim-20170712 header.b=TUtaLbEq; dmarc=pass (policy=reject) header.from=natalenko.name; spf=pass (imf04.hostedemail.com: domain of oleksandr@natalenko.name designates 104.207.131.136 as permitted sender) smtp.mailfrom=oleksandr@natalenko.name X-HE-Tag: 1626693432-877731 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: Hello. On pond=C4=9Bl=C3=AD 19. =C4=8Dervence 2021 13:12:58 CEST Miaohe Lin wrote: > On 2021/7/19 18:14, Boqun Feng wrote: > > 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: > >>>=20 > >>> struct swap_info_struct *get_swap_device(swp_entry_t entry) > >>> { > >>>=20 > >>> struct swap_info_struct *si; > >>> unsigned long offset; > >>> =20 > >>> if (!entry.val) > >>> =20 > >>> goto out; > >>> =20 > >>> si =3D swp_swap_info(entry); > >>> if (!si) > >>> =20 > >>> goto bad_nofile; > >>> =20 > >>> rcu_read_lock(); > >>> =20 > >>> if (data_race(!(si->flags & SWP_VALID))) > >>> =20 > >>> goto unlock_out; > >>> =20 > >>> offset =3D swp_offset(entry); > >>> if (offset >=3D si->max) > >>> =20 > >>> goto unlock_out; > >>> =20 > >>> return si; > >>>=20 > >>> bad_nofile: > >>> pr_err("%s: %s%08lx\n", __func__, Bad_file, entry.val); > >>>=20 > >>> out: > >>> return NULL; > >>>=20 > >>> unlock_out: > >>> rcu_read_unlock(); > >>> return NULL; > >>>=20 > >>> } > >>> I guess the function "return si" without a rcu_read_unlock. > >>=20 > >> Yes, but the caller is supposed to call put_swap_device() which > >> calls rcu_read_unlock(). See commit eb085574a752. > >=20 > > 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 > >=20 > > happened: > > do_swap_page(): > > si =3D get_swap_device(): > > rcu_read_lock(); > > =20 > > lock_page_or_retry(): > > might_sleep(); // call a sleepable function inside RCU read-side=20 c.s. > > =20 > > __lock_page_or_retry(): > > wait_on_page_bit_common(): > > schedule(): > > rcu_note_context_switch(); > > // Warn here > > =20 > > put_swap_device(); > > =20 > > rcu_read_unlock(); > >=20 > > , which introduced by commit 2799e77529c2a >=20 > When in the commit 2799e77529c2a, we're using the percpu_ref to serialize > against concurrent swapoff, i.e. there's percpu_ref inside > get_swap_device() instead of rcu_read_lock(). Please see commit > 63d8620ecf93 ("mm/swapfile: use percpu_ref to serialize against concurrent > swapoff") for detail. The problem here is that 2799e77529c2a got pulled into stable, but=20 63d8620ecf93 was not pulled. Are you suggesting that 63d8620ecf93 should be= =20 pulled into the stable kernel as well? Thanks. =2D-=20 Oleksandr Natalenko (post-factum)