Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2125656rwb; Thu, 8 Dec 2022 20:47:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Cl76r/4XdTZF91aVVaGHMtyDAb/u1W3laz5QyAs2QY4SJ7FwvK+zPyDMw8tORUzFXk8I1 X-Received: by 2002:a17:906:d18f:b0:7b2:75c6:6d3c with SMTP id c15-20020a170906d18f00b007b275c66d3cmr3853946ejz.74.1670561276681; Thu, 08 Dec 2022 20:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670561276; cv=none; d=google.com; s=arc-20160816; b=p6uHmn5DIfpmFeaiju+WujYmRN4nseDkRrvb2XY1s1h1Gcb9fxiL8N4Ao+PPj2Mej5 K4AcixKsRzIIKPC8bWWwzW4IQS8ORJa99KIMUcfXgHWzv6cXb/LHah0s/2+PaRRTpatb w4DbsK+E7c6/+ClOyykAhgl3P1eci2FYaYcdGkx9dTQS60ya8IndIPcmf5PGkiJQlCGd GFUATy+69jy0BZ4H0cOHkH7fbFPgVrDbdoZLl2QhwXbBE5rKUTTNvBfsYsINYb8eNDww uCLnft8n5YWXlcHsjxuy/290rdF0QlOq13Zwfd8mTvgJB2ru0y36gRYI0AkaPs1wtayR PYKQ== 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:dkim-signature; bh=HHhgDHeMvYl8qUYtDwuYYkJvTc+w8vcQDPUooKyunFw=; b=G6Y6eXtcnsRRrK9SG3kRFYnCfs0XO3CCbYYuFGhBM1pup0QX0I2Pk6TCR1jkUyK12l DVXj6XwPoZ4WuhtBp1jBEW7i88hBqKY4KgmgWLk+KkE46Eidn2JzAYruJZWmVnDEHdmq sKNnlJ45jsZXhgn9qNtLI2ep5KUp7hfmHZAQJp71QDRsxisn7SFjSRUIQeEmGx52FesY ArXi/98dxmDF1W+YB1IB/Jho7Z7ExwIIXMBXLamEH/0ectkt9z3KilHbLvrZ5AceE69O MCoFI/F+yICQURe53BXF0bRKjqbZhqaZWVOEGE/1bmtEAywYXF4vUa0tOEIzFLBCLdAh WwRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QPlCk6OG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tl2-20020a170907c30200b007c08a2c240dsi359555ejc.70.2022.12.08.20.47.38; Thu, 08 Dec 2022 20:47:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QPlCk6OG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbiLIDYe (ORCPT + 73 others); Thu, 8 Dec 2022 22:24:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbiLIDYd (ORCPT ); Thu, 8 Dec 2022 22:24:33 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D35A1C930 for ; Thu, 8 Dec 2022 19:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670556272; x=1702092272; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=vp6xMOdRn/5zWi/yiPp1W1YaQj05xOxBN9Fzkz5Mw+I=; b=QPlCk6OG9sotxfVN/U1jX+qm5CBDZR7GumKgKJmGvSjUaRQLvHkA8JBW IwgXFOQkrNSAILQLdD2BzoeRETY/xqfFweXmG2bbT7qSkZ+68oYzS+DKa HNnfYhk2kYdpOHXeMlyaZFUk46mRf75QYrLLbWDT3zowEVxyNLsglNIcu a6WWvFU5ykTccuLD9uxPt1I8utbymLpXeB7sH8oAY3xb7nHb3kktP/T2z oOr/8SsOTF6ERZNF9CbIQs0biDDb1F8ALnw38qA4diRD0URcgWrBHAwZZ taIr5kWOCeDPEHj4PN+AXyGB5fPXNMB6l2DfEjFLj2uYyivAHXG1841SC g==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="344402948" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="344402948" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 19:24:31 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="821590312" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="821590312" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 19:24:28 -0800 From: "Huang, Ying" To: Kairui Song Cc: linux-mm@kvack.org, Kairui Song , linux-kernel@vger.kernel.org, Andrew Morton , Miaohe Lin , David Hildenbrand , Hugh Dickins Subject: Re: [PATCH 3/5] swap: fold swap_ra_clamp_pfn into swap_ra_info References: <20221208180209.50845-1-ryncsn@gmail.com> <20221208180209.50845-4-ryncsn@gmail.com> Date: Fri, 09 Dec 2022 11:23:39 +0800 In-Reply-To: <20221208180209.50845-4-ryncsn@gmail.com> (Kairui Song's message of "Fri, 9 Dec 2022 02:02:07 +0800") Message-ID: <87r0x9qmys.fsf@yhuang6-desk2.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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kairui Song writes: > From: Kairui Song > > This make the code cleaner. This helper is made of only two line of > self explanational code and not reused anywhere else. > > And this actually make the compiled object smaller by a bit: > > text data bss dec hex filename > Before: 9502 976 12 10490 28fa mm/swap_state.o > After: 9470 976 12 10458 28da mm/swap_state.o > > Signed-off-by: Kairui Song > --- > mm/swap_state.c | 44 +++++++++++++++++++------------------------- > 1 file changed, 19 insertions(+), 25 deletions(-) LGTM, Thanks! Reviewed-by: "Huang, Ying" > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 60136bda78e3..19089417abd1 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -696,28 +696,15 @@ void exit_swap_address_space(unsigned int type) > swapper_spaces[type] = NULL; > } > > -static inline void swap_ra_clamp_pfn(struct vm_area_struct *vma, > - unsigned long faddr, > - unsigned long lpfn, > - unsigned long rpfn, > - unsigned long *start, > - unsigned long *end) > -{ > - *start = max3(lpfn, PFN_DOWN(vma->vm_start), > - PFN_DOWN(faddr & PMD_MASK)); > - *end = min3(rpfn, PFN_DOWN(vma->vm_end), > - PFN_DOWN((faddr & PMD_MASK) + PMD_SIZE)); > -} > - > static void swap_ra_info(struct vm_fault *vmf, > - struct vma_swap_readahead *ra_info) > + struct vma_swap_readahead *ra_info) > { > struct vm_area_struct *vma = vmf->vma; > unsigned long ra_val; > - unsigned long faddr, pfn, fpfn; > + unsigned long faddr, pfn, fpfn, lpfn, rpfn; > unsigned long start, end; > pte_t *pte, *orig_pte; > - unsigned int max_win, hits, prev_win, win, left; > + unsigned int max_win, hits, prev_win, win; > #ifndef CONFIG_64BIT > pte_t *tpte; > #endif > @@ -745,16 +732,23 @@ static void swap_ra_info(struct vm_fault *vmf, > > /* Copy the PTEs because the page table may be unmapped */ > orig_pte = pte = pte_offset_map(vmf->pmd, faddr); > - if (fpfn == pfn + 1) > - swap_ra_clamp_pfn(vma, faddr, fpfn, fpfn + win, &start, &end); > - else if (pfn == fpfn + 1) > - swap_ra_clamp_pfn(vma, faddr, fpfn - win + 1, fpfn + 1, > - &start, &end); > - else { > - left = (win - 1) / 2; > - swap_ra_clamp_pfn(vma, faddr, fpfn - left, fpfn + win - left, > - &start, &end); > + if (fpfn == pfn + 1) { > + lpfn = fpfn; > + rpfn = fpfn + win; > + } else if (pfn == fpfn + 1) { > + lpfn = fpfn - win + 1; > + rpfn = fpfn + 1; > + } else { > + unsigned int left = (win - 1) / 2; > + > + lpfn = fpfn - left; > + rpfn = fpfn + win - left; > } > + start = max3(lpfn, PFN_DOWN(vma->vm_start), > + PFN_DOWN(faddr & PMD_MASK)); > + end = min3(rpfn, PFN_DOWN(vma->vm_end), > + PFN_DOWN((faddr & PMD_MASK) + PMD_SIZE)); > + > ra_info->nr_pte = end - start; > ra_info->offset = fpfn - start; > pte -= ra_info->offset;