Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2405439pxb; Tue, 13 Apr 2021 00:42:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk2nBhBe8cVLCmATBtaJHJhu+uYP42KseNw3Dt8WPsu0Jf8JsNE7drEwvKdBHcknGAefZh X-Received: by 2002:a17:906:d110:: with SMTP id b16mr1270152ejz.146.1618299733078; Tue, 13 Apr 2021 00:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618299733; cv=none; d=google.com; s=arc-20160816; b=mJ7WZOrLxtZE2Iuu+ITCqnKku24/++FRFiNrg+2FMpagQ0zM2rod2Z3T/g9/HDddxw Y1f+UrxHVPHVj5k3lWWZBpUifrdfcNEjXdAtoUm+q9LgVXz23pa1lCKhiw2elWkpmij4 TXR1Hw/FQMSKBKO3rUnBicdBEsP3wPJ0Zt+KakhPPgXm3CP60uM0IUGHg7IMe+68lTnH h84XU2pLn719gwPBw7qGFJfh7Y4CxdzK+xv5AvYyaCBQ/kRUPAMFdiAxJDDxYqElXMTS qgkFX1cEgQI0FJ1fK2qsoQx+2Qaxs32aDUjjoUzTwaYQizthn7hp76UB0x3M7uHV1aug CHXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=ZwV6d1B4Fv1YGvw/Hm+lZQxwveJOqK62JWZCMofgOvA=; b=zNfiVZDrEpkDyEHfK1JplAZ0ols5ZkdjDAHOG1+OUyTeOQGVyKR/rLCRSRR14w68P/ DalXs/6Y/jeNBKLTf7lVcsMi27xy24yeULs95B4HxEn5yDAqEPHEtfU0cUzZ4HmUIa+T gB9WI11tfCiRDsOJxvdtZgmPglEZ5EgXuw0hybsoC3LTV1Y9Bzu0aenlZj2z9fjCfVqx 16i5c8QZoabNb6Mi5NX5Rk47kM2VviueV8kG87mPfsibp2NNP4Tq7C2CDMBqs2EBeuLP NkM8Q/s0t9w6jd9PSsd+zJXPgrdodzMnKFjl60VYkyPoB9Umz9URasPq054V+J7jB1/j rn+g== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g26si9046073ejc.32.2021.04.13.00.41.49; Tue, 13 Apr 2021 00:42:13 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245114AbhDMBeK (ORCPT + 99 others); Mon, 12 Apr 2021 21:34:10 -0400 Received: from mga06.intel.com ([134.134.136.31]:12986 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240410AbhDMBeG (ORCPT ); Mon, 12 Apr 2021 21:34:06 -0400 IronPort-SDR: xriSWE7X+l81K39k/JdOQdTrIypVQtJJwqHl7DCknnb8tC78ih3qmtDrM+RJ7n7xCJx8gM9Xew 86TUuxCpwhGw== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="255638438" X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="255638438" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 18:33:46 -0700 IronPort-SDR: V+KbEoJUqwsneLAH9VH89rfVsf/Uhl9NaAxRjjUEWOfN0vy1NAvE2WdOJLzodsBna4aeGc5PvU P/F7QieILvaQ== X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="424042790" Received: from yhuang6-desk1.sh.intel.com (HELO yhuang6-desk1.ccr.corp.intel.com) ([10.239.13.1]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 18:33:43 -0700 From: "Huang, Ying" To: Miaohe Lin Cc: , , , , , , , , , , , , Subject: Re: [PATCH 3/5] mm/swap_state: fix get_shadow_from_swap_cache() race with swapoff References: <20210408130820.48233-1-linmiaohe@huawei.com> <20210408130820.48233-4-linmiaohe@huawei.com> Date: Tue, 13 Apr 2021 09:33:41 +0800 In-Reply-To: <20210408130820.48233-4-linmiaohe@huawei.com> (Miaohe Lin's message of "Thu, 8 Apr 2021 09:08:18 -0400") Message-ID: <87im4rufwq.fsf@yhuang6-desk1.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Miaohe Lin writes: > The function get_shadow_from_swap_cache() can race with swapoff, though > it's only called by do_swap_page() now. > > Fixes: aae466b0052e ("mm/swap: implement workingset detection for anonymous LRU") > Signed-off-by: Miaohe Lin This is unnecessary. The only caller has guaranteed the swap device from swapoff. Best Regards, Huang, Ying > --- > mm/swap_state.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 272ea2108c9d..709c260d644a 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -83,11 +83,14 @@ void show_swap_cache_info(void) > > void *get_shadow_from_swap_cache(swp_entry_t entry) > { > - struct address_space *address_space = swap_address_space(entry); > - pgoff_t idx = swp_offset(entry); > + struct swap_info_struct *si; > struct page *page; > > - page = xa_load(&address_space->i_pages, idx); > + si = get_swap_device(entry); > + if (!si) > + return NULL; > + page = xa_load(&swap_address_space(entry)->i_pages, swp_offset(entry)); > + put_swap_device(si); > if (xa_is_value(page)) > return page; > return NULL;