From patchwork Sun Nov 19 19:47:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 166880 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp1810496vqn; Sun, 19 Nov 2023 11:51:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IECiGYvI/xtPVQYvtNPp5bdbRSLhXW7xizPwXbMzYiaMbEx+26lOhI0aOTn6sgx8b5gzTB1 X-Received: by 2002:a05:6871:5cd:b0:1f4:d347:df08 with SMTP id v13-20020a05687105cd00b001f4d347df08mr6675199oan.17.1700423493780; Sun, 19 Nov 2023 11:51:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700423493; cv=none; d=google.com; s=arc-20160816; b=CbPadiWvHzbz3kcStyzyxGpzXpGmOfycjO6majTnE7TOp41mzNW349bMWR5JTv/nhh bWXeEoYtmS2IP/LXHOfLEMj/8Ap7qJi69JoozMFyIC0bqhKn7MVs3WT+O2V3vGTqZ98N 21hlD9XgqNNrROMVk2IapGDbWMYfCULJ52KtO1P0Xtkiq0vSJkpLMxE+ypt5BJiHjlXO DtKAwxlKPtDN0erTMNFuLkrerb5lacg88uVg1bs8Fzd5iR9uAVJbqhgGUTZJVldwT+r+ d49v95LUFCnB95Fk4+3oeHjW+PFrPIIiI22F91axqfaEEbRx48wrAoYZm6VpJlvgXZgb DPDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ujyhaBmVKqUCILaG0//cQCFqqP/+VsPiP59qcIbNEbE=; fh=4HE/piJoUCKuBTCCBiej4//zvvzywHdOLL9QM/KYjYM=; b=uG5UQC/WWuwndu9NcTmVVT+GHgzf6I1v2zVXrBpf+VHtx49Qr3df1atRfbpdEraX6v P3SxFoSv15fSII43h/ov+LrKxO2w9rGR0g8O4nmfr+XIAnD06jBEkUZwfNT20u1LEFrp NZ3J6XRaFUi7gv6UcOZk2pWENtvGOsSNF7dm8awyoPk/ljWYFpSllvHLOtIyjW8+NMQ5 fIM6j97bYAew1WzwnMqba21O/ZdvuRskz4YlxYPpuUxnzz7rRE1EykdnR8w6MmkTGzLN wg85Z68fbZ76RpAVNUwDUQz6MqViB5A8XR9O31hvpho4sGqEZZiUf5OQZnMusjMolyRN JPuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fX0Qw+da; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h1-20020a170902748100b001cc7c079304si6558190pll.97.2023.11.19.11.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 11:51:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fX0Qw+da; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9D5A38080D44; Sun, 19 Nov 2023 11:51:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231748AbjKSTuh (ORCPT + 29 others); Sun, 19 Nov 2023 14:50:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231919AbjKSTuF (ORCPT ); Sun, 19 Nov 2023 14:50:05 -0500 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB17E171E for ; Sun, 19 Nov 2023 11:49:19 -0800 (PST) Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3b2e4107f47so2778864b6e.2 for ; Sun, 19 Nov 2023 11:49:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423359; x=1701028159; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=ujyhaBmVKqUCILaG0//cQCFqqP/+VsPiP59qcIbNEbE=; b=fX0Qw+daECB1rjTwNoau70a5cC0VHEPhHZPMPF3Y4iA51CSDOJ/i8EPffWP3fHqtDR Ws803bFEgujnXb4Qcmmc5kvfCykRnh8s9YfTLjenNd0xIUC6p3tMyTOIB4NEbu8VvBiM XQk08s+K22SPV6bSTWAry3AhQhVhBtjIPBy5hO0/1z/ixGYD5icy0PoTl73jNlU4bO94 wkwhj5UmkiGuyTlq5UcYnWF745ih4oBi7GRSNfHJ3xDJEbBBbcrttCmlFUx4jTV1mYDU rHDpRgtYBZ634H2Bq3IbzKPAC7yq6uvjIaMNUbl0S3tn1X3O2JEAO4aukOQ+52j++IGC 8xAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423359; x=1701028159; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ujyhaBmVKqUCILaG0//cQCFqqP/+VsPiP59qcIbNEbE=; b=cxqKx6FtQlbcby+UVIL0PKP9YTvmaAQnrq6zO6ICJ7SST9tOMhFfKl//Mn1H7y0opW Lg6neE4lG80XVbhXOXTPbXmn0RVAvbiM3NAl5uE6IfecXMxoN6DVC6Vq97RibBjuv90k vmR5kGPa8YTkspP2z/jsZevegXmh1K7iqS/8wgqHB8vdR2uXuVH4YdGYJAFRjk0JAx0A LFfC/gkd10oeBMKhVGepO22P5ZfMaE50csm08ETgFq/DcuJJ7m3ydtYTrHyJOA8OX6lY eMWScE2lJyEK1c6OW7gc+iUF7iJ3KvsZIr/Xlt1IA7ZGOfuRKo3LCN0BnlqTINZRv2Sp HciQ== X-Gm-Message-State: AOJu0YzH1pIthriCU/JeyE2uX5r0YOGCCOMVj6yxv065ncJakHz1zZou ebZkGmVjz6gjY8FoU2NQuLpSl7WClKC2+01u X-Received: by 2002:a05:6808:2389:b0:3b5:75d3:14aa with SMTP id bp9-20020a056808238900b003b575d314aamr9092741oib.25.1700423359201; Sun, 19 Nov 2023 11:49:19 -0800 (PST) Received: from KASONG-MB2.tencent.com ([115.171.40.79]) by smtp.gmail.com with ESMTPSA id a6-20020aa78646000000b006cb7feae74fsm1237140pfo.164.2023.11.19.11.49.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 11:49:18 -0800 (PST) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH 24/24] mm/swap: change swapin_readahead to swapin_page_fault Date: Mon, 20 Nov 2023 03:47:40 +0800 Message-ID: <20231119194740.94101-25-ryncsn@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119194740.94101-1-ryncsn@gmail.com> References: <20231119194740.94101-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 19 Nov 2023 11:51:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783023265488396788 X-GMAIL-MSGID: 1783023265488396788 From: Kairui Song Now swapin_readahead is only called from direct page fault path, so rename it and drop the gfp argument, since there is only one caller always using the same flag for userspace page fault. Signed-off-by: Kairui Song --- mm/memory.c | 4 ++-- mm/swap.h | 6 +++--- mm/swap_state.c | 15 +++++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 620fa87557fd..4907a5b1b75b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3844,8 +3844,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) goto out; } - page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, - vmf, &cache_result); + page = swapin_page_fault(entry, GFP_HIGHUSER_MOVABLE, + vmf, &cache_result); if (IS_ERR_OR_NULL(page)) { /* * Back out if somebody else faulted in this pte diff --git a/mm/swap.h b/mm/swap.h index 4374bf11ca41..2f8f8befff89 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -56,8 +56,8 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, struct page *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask, struct mempolicy *mpol, pgoff_t ilx, struct mm_struct *mm, bool *new_page_allocated); -struct page *swapin_readahead(swp_entry_t entry, gfp_t flag, - struct vm_fault *vmf, enum swap_cache_result *result); +struct page *swapin_page_fault(swp_entry_t entry, gfp_t flag, + struct vm_fault *vmf, enum swap_cache_result *result); struct page *swapin_page_non_fault(swp_entry_t entry, gfp_t gfp_mask, struct mempolicy *mpol, pgoff_t ilx, struct mm_struct *mm, @@ -91,7 +91,7 @@ static inline void show_swap_cache_info(void) { } -static inline struct page *swapin_readahead(swp_entry_t swp, gfp_t gfp_mask, +static inline struct page *swapin_page_fault(swp_entry_t swp, gfp_t gfp_mask, struct vm_fault *vmf, enum swap_cache_result *result) { return NULL; diff --git a/mm/swap_state.c b/mm/swap_state.c index 362a6f674b36..2f51d2e64e59 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -899,7 +899,7 @@ static struct page *swapin_no_readahead(swp_entry_t entry, gfp_t gfp_mask, } /** - * swapin_readahead - swap in pages in hope we need them soon + * swapin_page_fault - swap in a page from page fault context * @entry: swap entry of this memory * @gfp_mask: memory allocation flags * @vmf: fault information @@ -911,8 +911,8 @@ static struct page *swapin_no_readahead(swp_entry_t entry, gfp_t gfp_mask, * it will read ahead blocks by cluster-based(ie, physical disk based) * or vma-based(ie, virtual address based on faulty address) readahead. */ -struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, - struct vm_fault *vmf, enum swap_cache_result *result) +struct page *swapin_page_fault(swp_entry_t entry, gfp_t gfp_mask, + struct vm_fault *vmf, enum swap_cache_result *result) { struct swap_info_struct *si; struct mempolicy *mpol; @@ -936,15 +936,18 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, mpol = get_vma_policy(vmf->vma, vmf->address, 0, &ilx); if (swap_use_no_readahead(si, swp_offset(entry))) { *result = SWAP_CACHE_BYPASS; - page = swapin_no_readahead(entry, gfp_mask, mpol, ilx, vmf->vma->vm_mm); + page = swapin_no_readahead(entry, GFP_HIGHUSER_MOVABLE, + mpol, ilx, vmf->vma->vm_mm); if (shadow) workingset_refault(page_folio(page), shadow); } else { *result = SWAP_CACHE_MISS; if (swap_use_vma_readahead(si)) - page = swap_vma_readahead(entry, gfp_mask, mpol, ilx, vmf); + page = swap_vma_readahead(entry, GFP_HIGHUSER_MOVABLE, + mpol, ilx, vmf); else - page = swap_cluster_readahead(entry, gfp_mask, mpol, ilx); + page = swap_cluster_readahead(entry, GFP_HIGHUSER_MOVABLE, + mpol, ilx, vmf->vma->vm_mm); } mpol_cond_put(mpol); done: