From patchwork Sun Nov 19 19:47:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13460668 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ABB3C54FB9 for ; Sun, 19 Nov 2023 19:48:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF5046B03A2; Sun, 19 Nov 2023 14:48:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA2B56B03A7; Sun, 19 Nov 2023 14:48:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1DC46B03AD; Sun, 19 Nov 2023 14:48:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BC6AC6B03A2 for ; Sun, 19 Nov 2023 14:48:44 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9E79B140372 for ; Sun, 19 Nov 2023 19:48:44 +0000 (UTC) X-FDA: 81475741368.11.EA5848C Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf27.hostedemail.com (Postfix) with ESMTP id D392D40007 for ; Sun, 19 Nov 2023 19:48:42 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NWfze253; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700423322; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ppA1yq5tSXPW7Cplga4R0sTrIzgEEoc6Te1dihtlR90=; b=Go8DyjSahnnj5dXchVs7TTf1P9+Ht2nRKvTqeEzqEGtUPCzqWJMCbhJAHejw0c/S7PSHJ+ n3ZWxMlWnf9b2UerfULXhcbtUOtw3qB//nDclp3bCPgKZgZ86meC8PsmSxOuT2AvPedccS QMnn2IidNqn9cg4Fq6NwEua1MYygbug= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NWfze253; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700423322; a=rsa-sha256; cv=none; b=kosNjcs71C4z6rLbx6vof9hzR/lX/baAV09AW8o6bVuO6gNwipCmwCxOiONf4VJtdUV7It yHsSuyXLCAYIHqgTzyegJ6RiguEmJ16yoIKNslCoe7XevbxsU7s2gvZRAXWh2bIZyT8pel i0aeVTKGctX+pneDefN8iLq2pLuzNo4= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6b1d1099a84so3605939b3a.1 for ; Sun, 19 Nov 2023 11:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423320; x=1701028120; darn=kvack.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=ppA1yq5tSXPW7Cplga4R0sTrIzgEEoc6Te1dihtlR90=; b=NWfze253qK1uUkO/Vtlo8UYefEtw3Rakd9vCRzU/b71AV0jS2Fdn5ud7wcUCoW505t wkIWuR5sVNnup/yeJF3ynnaEmDHfolYMlrk3hBvoLABB+Xe3RpWTUfmHCJctjHNQAavJ HaccM84YbVXmspPqDJi3eoM9HFeZlsHCzo0j6GvYdQdsrtN9yx40DvWh2VM9ZgdlF2au Vq55fPkkZCHbmDJP0dvnudlsK1QBF84gV4sPvTb1TmTXP4XSVkZoS35BlG/UW+9ISPcG lgt2uUAW/ZUz8ivP1DociXxhDejQQDl4TN3CHoIzUqAzkrXkAi3IQ9DvK08yOjMfQQyY BhXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423320; x=1701028120; 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=ppA1yq5tSXPW7Cplga4R0sTrIzgEEoc6Te1dihtlR90=; b=htapcwKdCGUFINIe1HPEa4WculOawxqMAqhvflHinJi9cTGorg6peuhOyjsPYkwtfY R2Zzz0Y71RPvMF9xRK/fZ8PuDmgFUlHLJsQwjokO1kRUwS78nT/lsFTEJ24SMF936bjU qde9p4rHAJP21LTGNj1ySO3utc4WAFpzOsAtitb4v64/IqsC/UaCElX7SCVn1m+bQsys S7V5wjP9XM/ptntXxQiWdxZZO92iA6jB4mCgYNGhd3hbRVvMJor+/ePm2qPlRTmpyfFO bP8/CQWkEf8qoM9IZQKyoU5YjJ/+ilTnIxm63TbEiEf0kcn4WFI7enQ/ku5cu5OP68Ku yqLw== X-Gm-Message-State: AOJu0YxAXQe2+QBn18AwrKBqchaS5mRnwD5bfuTeUqe3jjLn3AfI1cx9 /JiLjemv1pbSR7hmqOG+WOVayjFOpIVyjCrE X-Google-Smtp-Source: AGHT+IEBKHSE8kWnJJK8rM1dJTQqf5O5zE26MX7FuQ337U8kKzHMmekWO97Hh8Tc9mKAekA3sDGJiw== X-Received: by 2002:a05:6a00:1ca9:b0:6cb:a434:b58f with SMTP id y41-20020a056a001ca900b006cba434b58fmr619405pfw.33.1700423320649; Sun, 19 Nov 2023 11:48:40 -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.48.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 11:48:40 -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 12/24] mm/swap: simplify arguments for swap_cache_get_folio Date: Mon, 20 Nov 2023 03:47:28 +0800 Message-ID: <20231119194740.94101-13-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D392D40007 X-Stat-Signature: 4w83zan941f7gwh5gioxwou7sys68ndy X-HE-Tag: 1700423322-706899 X-HE-Meta: U2FsdGVkX1+06HIxZUgrI9BMwDDRfuej5Sl/bs//OjnTF7GogVHlMxkEjbQTdJEAuyQWWMaZ/xsTxLJB9VKCtF+NjTbL9Mlqf87WB265ntE22TaJQRypVbQJTbxpYpgYjn99lRODhyWD0wuXmS/i1029EY6TbD/5s+2w+rccAYONZdPSFFZPCq1yxskCA1MUIYZLEJFjO1e92my3WlfowwDYOJLWznZv7wLt51F5VXT5R4tacAIX6HqI1Y0utji1Yf4/bTrJOzQbrieYKrXiQ2b6mo+eRrUL17+o1AonyRV/a+5P+1jT6BriD0j+aiAggiJJ4XB5mPy2D0UiJOvHMYCpKmVd4S2gX5EKx+UWSHVYOgtF1lHpUKjBwSHeNJqqQE7lbIChb9nv1QOZG4chEdHg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kmvHZJlOlJOgheyAnTa5zXVhg0z4D3xuamGUskSWsRMPH/QLPUEPCqXvdC78L8FFpcERZ06WOdDtx/64cMiUU6nzj0M7RFE8b44W/WZamKa9Ib0ZTLgAgay0lPjyP+8pbMK8QKyvJ0ZdbZW1J/ZOg2v7syb4z+eHMfRRdFOQF4zbhwoCw6zF2ZCtfSmU7E= 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: List-Subscribe: List-Unsubscribe: From: Kairui Song There are only two caller now, simplify the arguments. Signed-off-by: Kairui Song --- mm/shmem.c | 2 +- mm/swap.h | 2 +- mm/swap_state.c | 15 +++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 0d1ce70bce38..72239061c655 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1875,7 +1875,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index, } /* Look it up and read it in.. */ - folio = swap_cache_get_folio(swap, NULL, 0); + folio = swap_cache_get_folio(swap, NULL); if (!folio) { /* Or update major stats only when swapin succeeds?? */ if (fault_type) { diff --git a/mm/swap.h b/mm/swap.h index ac9136eee690..e43e965f123f 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -47,7 +47,7 @@ void delete_from_swap_cache(struct folio *folio); void clear_shadow_from_swap_cache(int type, unsigned long begin, unsigned long end); struct folio *swap_cache_get_folio(swp_entry_t entry, - struct vm_area_struct *vma, unsigned long addr); + struct vm_fault *vmf); struct folio *filemap_get_incore_folio(struct address_space *mapping, pgoff_t index); diff --git a/mm/swap_state.c b/mm/swap_state.c index e96d63bf8a22..91461e26a8cc 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -334,8 +334,7 @@ static inline bool swap_use_vma_readahead(struct swap_info_struct *si) * * Caller must lock the swap device or hold a reference to keep it valid. */ -struct folio *swap_cache_get_folio(swp_entry_t entry, - struct vm_area_struct *vma, unsigned long addr) +struct folio *swap_cache_get_folio(swp_entry_t entry, struct vm_fault *vmf) { struct folio *folio; @@ -352,22 +351,22 @@ struct folio *swap_cache_get_folio(swp_entry_t entry, return folio; readahead = folio_test_clear_readahead(folio); - if (vma && vma_ra) { + if (vmf && vma_ra) { unsigned long ra_val; int win, hits; - ra_val = GET_SWAP_RA_VAL(vma); + ra_val = GET_SWAP_RA_VAL(vmf->vma); win = SWAP_RA_WIN(ra_val); hits = SWAP_RA_HITS(ra_val); if (readahead) hits = min_t(int, hits + 1, SWAP_RA_HITS_MAX); - atomic_long_set(&vma->swap_readahead_info, - SWAP_RA_VAL(addr, win, hits)); + atomic_long_set(&vmf->vma->swap_readahead_info, + SWAP_RA_VAL(vmf->address, win, hits)); } if (readahead) { count_vm_event(SWAP_RA_HIT); - if (!vma || !vma_ra) + if (!vmf || !vma_ra) atomic_inc(&swapin_readahead_hits); } } else { @@ -926,7 +925,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask, struct page *page; pgoff_t ilx; - folio = swap_cache_get_folio(entry, vmf->vma, vmf->address); + folio = swap_cache_get_folio(entry, vmf); if (folio) { page = folio_file_page(folio, swp_offset(entry)); cache_result = SWAP_CACHE_HIT;