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.7 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 B1F99C433B4 for ; Wed, 21 Apr 2021 00:58:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2043861410 for ; Wed, 21 Apr 2021 00:58:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2043861410 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 ADBE26B006C; Tue, 20 Apr 2021 20:58:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB22D8D0003; Tue, 20 Apr 2021 20:58:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D7436B006C; Tue, 20 Apr 2021 20:58:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id 814226B006C for ; Tue, 20 Apr 2021 20:58:13 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 46DCF3657 for ; Wed, 21 Apr 2021 00:58:13 +0000 (UTC) X-FDA: 78054562866.14.B95E2E6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by imf05.hostedemail.com (Postfix) with ESMTP id C68A8E00011D for ; Wed, 21 Apr 2021 00:58:11 +0000 (UTC) IronPort-SDR: AOSb4RHKmjffLLqyA6/WsfOCKBw07yAsye5ejWiWj8nyqfZSU5RFC/ccZRDFwpnKpBR1iVPcDq q+eOKncrk3mg== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="280950525" X-IronPort-AV: E=Sophos;i="5.82,238,1613462400"; d="scan'208";a="280950525" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 17:58:11 -0700 IronPort-SDR: q/pXegkeoB3Nibz1+jCT1mt/7nLI3QUPwzj5d5LEtYCiJDc6efVnJAgRFLx3AL7fL1YOgZK4iL qW0/WRm2Is+A== X-IronPort-AV: E=Sophos;i="5.82,238,1613462400"; d="scan'208";a="427312591" 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; 20 Apr 2021 17:58:06 -0700 From: "Huang, Ying" To: Miaohe Lin Cc: , , , , , , , , , , , , , Subject: Re: [PATCH v3 3/4] mm/swap: remove confusing checking for non_swap_entry() in swap_ra_info() References: <20210420133048.6773-1-linmiaohe@huawei.com> <20210420133048.6773-4-linmiaohe@huawei.com> Date: Wed, 21 Apr 2021 08:58:04 +0800 In-Reply-To: <20210420133048.6773-4-linmiaohe@huawei.com> (Miaohe Lin's message of "Tue, 20 Apr 2021 09:30:47 -0400") Message-ID: <8735vk3143.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: C68A8E00011D X-Stat-Signature: p4zhqs8aednppiw9wi6yybyiqwy4b1ge Received-SPF: none (intel.com>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=mga05.intel.com; client-ip=192.55.52.43 X-HE-DKIM-Result: none/none X-HE-Tag: 1618966691-635888 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. > But this makes the code confusing. The non_swap_entry() check > looks racy 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. The race isn't important because it will not cause problem. Best Regards, Huang, Ying > But the swap_entry > isn't used in this function and we will have enough checking when we really > operate the PTE entries later. So checking for non_swap_entry() is not > really needed here and should be removed to avoid confusion. > > Signed-off-by: Miaohe Lin > --- > 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);