From patchwork Sun Nov 19 19:47:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13460676 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 AC74EC072A2 for ; Sun, 19 Nov 2023 19:49:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C0046B03C6; Sun, 19 Nov 2023 14:49:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 254796B03CB; Sun, 19 Nov 2023 14:49:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 09B086B03CF; Sun, 19 Nov 2023 14:49:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E699F6B03C6 for ; Sun, 19 Nov 2023 14:49:09 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BD8911604AB for ; Sun, 19 Nov 2023 19:49:09 +0000 (UTC) X-FDA: 81475742418.08.ACF5D90 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by imf04.hostedemail.com (Postfix) with ESMTP id B318040008 for ; Sun, 19 Nov 2023 19:49:07 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VE21LzHN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.167.173 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=1700423347; 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=Ze1Psd2Ie5OovBPk7SmUTsWgEFqDeyPvhXbgqpZhXY8=; b=3HmcqYX7NjNiXXJKy496DdtZ7LDc/vp4Eh40D8F9Yjq1zxC8BAloq4EpY+Tn00PB9JG2Uy EOuEwMSZFvggR/HEkY/apcp7VlNk3ocbIeT8Nck2nPGs/PHsiTX2PcV9yNCxvCEUYeOsN7 vzeJs/7O/XDw7+SmMkpEmG0jFTUzqz8= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VE21LzHN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.167.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700423347; a=rsa-sha256; cv=none; b=4N+82dWQiSB0AOOuQPTpTIo9+eMy2xREM6xODgYzFF8ZiV788LF0Uy7RDHFEXyo607jh2/ fmeGbttPp02q/M8aP7DDEa/JBNzp1NpQGJ23Ty6GVyeGnDcJrDqAp3Vc0+LbBWD31BVIa1 NyL93Cm68KFBWZeGIn3jE31B3eNM97Y= Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3b2e73a17a0so2542981b6e.3 for ; Sun, 19 Nov 2023 11:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423346; x=1701028146; 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=Ze1Psd2Ie5OovBPk7SmUTsWgEFqDeyPvhXbgqpZhXY8=; b=VE21LzHNwvpLhDJuCuWzR+0zGkq2DB7Gt2qulsmiHYyoYkKlLUcb5QmJimckbmWLn5 ckGjUreicUkoQP28TJvojjRk+EPfSxwFJJalAzIDvbe8XTa+x6L8eMj2IhXRKWl+6S8i 8OiUleXura6T1D439ODlNiCfosVFVqDtagXDfvKRiVaf2rALWXpkyhoeVPC4lR2WoOHx MRBA6sriKTOGm6Vg/vCb0V4aDKZYmpjW083TsAcVKKAsINUlzIMeRFjPrjnvFDWFHICy 3lmZ2wqP8mEYecmP5Jo0E4xJA6gcaT09RqOsoH0lRJxjsOzX6r58lhMX/VUFjeo3aR1O jDzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423346; x=1701028146; 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=Ze1Psd2Ie5OovBPk7SmUTsWgEFqDeyPvhXbgqpZhXY8=; b=qmHQjHC4N3tf0lBB7y5GAokV5+EOvTzc8lM5Z3HiUPWVxLD9W3zwjsvKwKfG1dV8/u UrW6BbqgHJQ5+/lC63fkp5bZW5QS949ZTIm3puzTZ7bph1Gnd1me9xOWEGAH5LIenKba XXhMD9NT+DFzgVn326FbpLJLu1AHdD9zJoZEtHZpc4BjWx4mjrVs/WWMm2mPGlJiwC0L F8y3dG8b2KLDIVr8uoPSTXlFXoJAzSHFB/9OGrBNq9QW+mUhHt3+d2GdkxGEdqMPiYj/ 0PGNpfnj1uGlYHgc9f/Lpgrgd9ZYgkep2Sct/NhvxyJEXlmfeJZo+HAZziw5vl/5Cb44 Pndw== X-Gm-Message-State: AOJu0Yzg90q+C2JwfpCXUYmCJ+qOWAitodLk3CXuHQVO9LN3YjXh7Eig HMWoX9UIWfbGjnZz53F4Y6y/0b/DxBL9kOZ7 X-Google-Smtp-Source: AGHT+IGTlsOhMDU+nbF9BiKSPMYiu1dnBRu6RvVsGq1/cPrbFHBN7F+llm4LzYDPkkR6tdAEcGAOgQ== X-Received: by 2002:a05:6808:1451:b0:3b2:dcff:9e54 with SMTP id x17-20020a056808145100b003b2dcff9e54mr8319167oiv.24.1700423346359; Sun, 19 Nov 2023 11:49:06 -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.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 11:49:05 -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 20/24] swap: simplify and make swap_find_cache static Date: Mon, 20 Nov 2023 03:47:36 +0800 Message-ID: <20231119194740.94101-21-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-Rspamd-Queue-Id: B318040008 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 5d55utfepoco37s5f9q97z7bui91yjjh X-HE-Tag: 1700423347-635675 X-HE-Meta: U2FsdGVkX19j0VYnQIuxgHo5Xk+s0PA7pBlY6zt2RSoVSB9vcr1tY+2131J8Wz0zdCySCwE1Xz4XoZdGXlAR4PthTIc/9T8i0Fy5nNexlc/C6ivIgRLO/60OD5Zfz4/hhNM3wPCmGpp+s9WoC2ECF5QbaKymtqDIa9rBwC96dUjVF5n+P9mazHdP54twgi36B9NgyDidmXS1CrU5u+IfFVGepvodDpWAdlL5QLZMoLH4YNEfyE2vGal/bWYSU+4Db9+/6XiW02ZFk5EurCgJSRwHT6wmHExDRrlUuJvbaDHtBlaVmfk0ahiyQ3+sfKEUP5jj0Lg/tBcLVdrrOkpA1223bvbI1SN41Ld1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HFG3yK5fCzIYuC9ZO0M+ykmbikyCqfHG1cdx246POAuLiexuMgAjKzj29TogjPpYVMzPryXPWQvmCIA9r3uu2D1iXQ+6iuSN0COQf/qNuqHRK7MjblPFZVYzbP+MtdRJPlhMMqmT1jDDFKpTxviZtmOYoM52nyzci/g/g9K6WqJlbPvKCic4bpOk/o9Qe27iW5kKxieat4Zu5VFVpmomPnln5M3SwrjGFn0YWOuXxDRVNN8= 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 callers within the same file now, make it static and drop the redundant if check on the shadow variable. Signed-off-by: Kairui Song --- mm/swap.h | 2 -- mm/swap_state.c | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/swap.h b/mm/swap.h index b073c29c9790..4402970547e7 100644 --- a/mm/swap.h +++ b/mm/swap.h @@ -46,8 +46,6 @@ void __delete_from_swap_cache(struct folio *folio, 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_fault *vmf, void **shadowp); 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 eef66757c615..6f39aa8394f1 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -334,15 +334,14 @@ 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_fault *vmf, void **shadowp) +static struct folio *swap_cache_get_folio(swp_entry_t entry, struct vm_fault *vmf, void **shadowp) { bool vma_ra, readahead; struct folio *folio; folio = filemap_get_entry(swap_address_space(entry), swp_offset(entry)); if (xa_is_value(folio)) { - if (shadowp) - *shadowp = folio; + *shadowp = folio; return NULL; }