Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3593665pxv; Mon, 19 Jul 2021 04:16:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj3FxVX0Mia9fylIufria715dl0KEYMHLyqvLUSkiAHrjSr/aDoWCvMQH0HmNpDBfqpcl6 X-Received: by 2002:a05:6402:1d4d:: with SMTP id dz13mr33826170edb.67.1626693383758; Mon, 19 Jul 2021 04:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626693383; cv=none; d=google.com; s=arc-20160816; b=p+Mgbz5m473cW0Ub+aSLrnIGBgtapdacsk7SPkyu/iy4cOjPeJB/PHnXcYdRhCx2Qy /ae3Jkw5ng+tPeC0skGVUz4DvdOMI0YKclzm4ODcc+aKT2e5V1PYUO21GOOSA3aihJX9 cc7j0NJT8evXLmXWwAv1wK5G8u/ZwkXphiq7QMFHJq/FLOgKtlOdCCoywWur+9qigS7f PvXfaPmu52qvr/zlu9s0XRiwWd3B9sXjvAjAYaRKI2upyNNFAmXEPEj/OU7ZFP6vGtQk QUm9qSHNpqXzYgxUSq55ATVtFfXvsB2pYnj+iVskTk2G0fMbCE5Kt7K9oOdH8Zex9I5k a4pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Xq7FtM04DutdNwizN0FA8lCrzNPzNjMFyzTs109K6Q4=; b=aoo9DhCDhWUNA5ShKQb5gCUzaJXMwkvEPwbfdCQiyiqT2BWGzLSY4uZ2Nl6vBZj0IK oQqUnIhFeSR7TvGMgSeXuDUng/vGaYIP6gwYW5x4eCirWiqgBESQJDjYRZMckleKjOxN FSsoGafY8U/rgGQCxST4F8/88DbBc6U5VqRrmmZkOuMx82t75rFBM1oHYeUtehaUcEph TrGqhNWl8KppTU47335SOyB785UWBoYha8GAnX3EDASu9fC0wtD5PyTEHIKILhKFqJYa gWqV6bmr9qetDpoxua1cwMs252JThLLDc4/vtzfNQ9TdgC1dD13S6TIRd7OpX6VRf8hT 5piQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n14si18418282edx.144.2021.07.19.04.16.01; Mon, 19 Jul 2021 04:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236653AbhGSKcW (ORCPT + 99 others); Mon, 19 Jul 2021 06:32:22 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:11448 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236330AbhGSKcV (ORCPT ); Mon, 19 Jul 2021 06:32:21 -0400 Received: from dggeme703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GSzdG1B1WzcfkS; Mon, 19 Jul 2021 19:09:38 +0800 (CST) Received: from [10.174.177.180] (10.174.177.180) by dggeme703-chm.china.huawei.com (10.1.199.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 19 Jul 2021 19:12:58 +0800 Subject: Re: linux-5.13.2: warning from kernel/rcu/tree_plugin.h:359 To: Boqun Feng CC: Zhouyi Zhou , , Oleksandr Natalenko , linux-kernel , , Chris Clayton , Chris Rankin , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu , Andrew Morton , Linux-MM , "Huang, Ying" , Matthew Wilcox References: <2245518.LNIG0phfVR@natalenko.name> <6698965.kvI7vG0SvZ@natalenko.name> <20210718215914.GQ4397@paulmck-ThinkPad-P17-Gen-1> <20210719015313.GS4397@paulmck-ThinkPad-P17-Gen-1> From: Miaohe Lin Message-ID: <08803f78-3e99-6b3f-e809-5828fe47cf06@huawei.com> Date: Mon, 19 Jul 2021 19:12:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.180] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggeme703-chm.china.huawei.com (10.1.199.99) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: >>> >>> 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 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. Thanks. > > [Copy the author] > > Regards, > Boqun > > . >