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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 762A4C433ED for ; Sun, 25 Apr 2021 03:09:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E2AB960233 for ; Sun, 25 Apr 2021 03:09:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2AB960233 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 761C86B006C; Sat, 24 Apr 2021 23:09:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 711596B006E; Sat, 24 Apr 2021 23:09:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B26C6B0070; Sat, 24 Apr 2021 23:09:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 3BACE6B006C for ; Sat, 24 Apr 2021 23:09:25 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E7E7A5DE7 for ; Sun, 25 Apr 2021 03:09:24 +0000 (UTC) X-FDA: 78069408648.36.A16140E Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf21.hostedemail.com (Postfix) with ESMTP id 17DD0E00010B for ; Sun, 25 Apr 2021 03:09:20 +0000 (UTC) IronPort-SDR: hZ6WF2DpCnjJ9hHeA7FKRFXaKgGJJ8TbSkfviuZBAYEUrkBwzpHvgnD5VbPA6cPQcP8ZqUyOC+ T6iEWQXFcaVA== X-IronPort-AV: E=McAfee;i="6200,9189,9964"; a="176327612" X-IronPort-AV: E=Sophos;i="5.82,249,1613462400"; d="scan'208";a="176327612" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2021 20:09:21 -0700 IronPort-SDR: CRUydiyRZCcxxUktF8ALsPsp7pExL6AWNIFbr0n9Xys2yPdRlAXCsK4upUlRT0+jxSkeQEOgDZ 9he9kPwURuvw== X-IronPort-AV: E=Sophos;i="5.82,249,1613462400"; d="scan'208";a="525371685" Received: from yhuang6-desk1.sh.intel.com (HELO yhuang6-desk1.ccr.corp.intel.com) ([10.239.13.1]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2021 20:09:16 -0700 From: "Huang, Ying" To: Miaohe Lin Cc: , , , , , , , , , , , , , , Subject: Re: [PATCH v4 3/4] mm/swap: remove confusing checking for non_swap_entry() in swap_ra_info() References: <20210425023806.3537283-1-linmiaohe@huawei.com> <20210425023806.3537283-4-linmiaohe@huawei.com> Date: Sun, 25 Apr 2021 11:09:14 +0800 In-Reply-To: <20210425023806.3537283-4-linmiaohe@huawei.com> (Miaohe Lin's message of "Sun, 25 Apr 2021 10:38:05 +0800") Message-ID: <8735vfxdph.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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 17DD0E00010B X-Stat-Signature: cqkz3gctwaohi97e6iakugi3qrdy6tkc Received-SPF: none (intel.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=mga17.intel.com; client-ip=192.55.52.151 X-HE-DKIM-Result: none/none X-HE-Tag: 1619320160-578053 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: Miaohe Lin writes: > The non_swap_entry() was used for working with VMA based swap readahead > via commit ec560175c0b6 ("mm, swap: VMA based swap readahead"). At that > time, the non_swap_entry() checking is necessary because the function is > called before checking that in do_swap_page(). Then it's moved to > swap_ra_info() since commit eaf649ebc3ac ("mm: swap: clean up swap > readahead"). After that, the non_swap_entry() checking is unnecessary, > because swap_ra_info() is called after non_swap_entry() has been checked > already. The resulting code is confusing as the non_swap_entry() check > looks racy now because while we released the pte lock, somebody else might > have faulted in this pte. So we should check whether it's swap pte first > to guard against such race or swap_type will be unexpected. But the race > isn't important because it will not cause problem. We would have enough > checking when we really operate the PTE entries later. So we remove the > non_swap_entry() check here to avoid confusion. > > Signed-off-by: Miaohe Lin Reviewed-by: "Huang, Ying" Best Regards, Huang, Ying > --- > mm/swap_state.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 272ea2108c9d..df5405384520 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -721,7 +721,6 @@ static void swap_ra_info(struct vm_fault *vmf, > { > struct vm_area_struct *vma = vmf->vma; > unsigned long ra_val; > - swp_entry_t entry; > unsigned long faddr, pfn, fpfn; > unsigned long start, end; > pte_t *pte, *orig_pte; > @@ -739,11 +738,6 @@ static void swap_ra_info(struct vm_fault *vmf, > > faddr = vmf->address; > orig_pte = pte = pte_offset_map(vmf->pmd, faddr); > - entry = pte_to_swp_entry(*pte); > - if ((unlikely(non_swap_entry(entry)))) { > - pte_unmap(orig_pte); > - return; > - } > > fpfn = PFN_DOWN(faddr); > ra_val = GET_SWAP_RA_VAL(vma);