Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp861305rdf; Tue, 21 Nov 2023 21:02:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqt5Esxgjh1nVT/RqcHS35eR8OnQqEGhf3ssou2XAvFt2KRSAeX/Ui/JiiCvgXk+Hi9CfN X-Received: by 2002:a05:6a00:6ca2:b0:6be:334c:6fd1 with SMTP id jc34-20020a056a006ca200b006be334c6fd1mr1742050pfb.26.1700629342199; Tue, 21 Nov 2023 21:02:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700629342; cv=none; d=google.com; s=arc-20160816; b=iCiRA2lAT5ODsYFjbAxk26dRH7tzu52d0UchlcOL6tRY8iENRvQLcSIvR7tftXsfqR MJKRT5+34hNjnYXrwu4xba9yNTP1e4WXGx3OdZcvi24foZtDW7snbS0zEsyV5S3bo0Jv +NeIxDXk9gSHQQyQ7YlmAvhqzPg+YQ+gKy2oszsQjvDzRodsb90uK6A4MOkbMEjjCR1D qF9xNGbck51DJAsVPaTAY+zHCtsFQ9pR4Rf5s+10ja/ISQSsrK8SEyL2lykgci9kwkIB eZIRyN1zHU0jjnhg+3GespO0naHMic8VipFQORLbJePKPhMKN/Y4b9Vjlv0FnuUFKOnP +pLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=J535/WlMO7BeONpMdstmdQQ81BBPx1uC58ui/w2oQYc=; fh=v/j7QEwtsj+94eMIzch1qbwAijHXRMR6IcasrHCGlTE=; b=v6FJsXZTR2hz39aMm+9sptc2sVVWHHIyLNWLNyR4nKuhgKZHBKQIv30WnBmepxYLZv 6Mz6gj8APg0GWWaEa/00Hh5JzYakozaXaiq5b1A5RRpYVDlbEiP+w6c18L0lIBpfpRem CWpokEpputf9dbN3fOFus6icIN1rmBBoIbUp9e6RTxp8JDvRiRHemqsP0fby/7a9YlgE f38Rd0dhM880ey43M0OpgP+RbPycj3TynQ6kz46wQwSGj0xoQjqkNY6xwwOQWxqE1M+6 XBgAs08S5CcZPnTKg/LDafxa72L6h899X9HaOEl43OFq6CRQbntQ7S0bURtBonoAuRVc LP/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ng9pOFQI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id n26-20020a634d5a000000b005b869e53b1csi11437834pgl.797.2023.11.21.21.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 21:02:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ng9pOFQI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4A38C8090796; Tue, 21 Nov 2023 21:01:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229576AbjKVFBS (ORCPT + 99 others); Wed, 22 Nov 2023 00:01:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjKVFBQ (ORCPT ); Wed, 22 Nov 2023 00:01:16 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A6B112 for ; Tue, 21 Nov 2023 21:01:12 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA246C43395 for ; Wed, 22 Nov 2023 05:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700629272; bh=u7DV6cTNrN7b/2qEFKGmtHVpBCHzyuXO2gggNSplrUQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ng9pOFQIoS9qLahi/YyX4F1ALlWYEaZSKiVnr76zOlIUH0LLDn9SdL3CC73JSDNJm 6nsiQVVKrwxTFvnJIh8tq764heth0p/uI79/dam0utu9sLMgNjnpimFmFagw+bEYmq NH8xHvK45gocepA4LA3ffJM5cdcAOkQKm0l4DUK86YG1l8sa/OJBaqXcj1YOMT0bYR bZ9WmvPC5aU1CP/RC1M5DQlQfIXg/gHL1u3dQOKqCpFq0G42SYUg1U6lRtSdKlbPXR WlxAcPz78z1bQFeOxu0Illo6EtH89q9GRcA4ZUQmzBZojVoZhb9/cmUN03cLEQXhly NpfZbP2jSHdCA== Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6b2018a11efso6444834b3a.0 for ; Tue, 21 Nov 2023 21:01:11 -0800 (PST) X-Gm-Message-State: AOJu0Yzl3eUI2FtjI85hKC5hwDupkHAOLDq/ltpYRoQ2+3UEh04f2CGM A66cGQ8e/nI1ul8fty3EoFp4ZB3YA1APO7G8H2Oa3w== X-Received: by 2002:a05:6a20:918f:b0:184:3233:679c with SMTP id v15-20020a056a20918f00b001843233679cmr1356784pzd.12.1700629271360; Tue, 21 Nov 2023 21:01:11 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-21-ryncsn@gmail.com> In-Reply-To: <20231119194740.94101-21-ryncsn@gmail.com> From: Chris Li Date: Tue, 21 Nov 2023 21:01:00 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 20/24] swap: simplify and make swap_find_cache static To: Kairui Song Cc: linux-mm@kvack.org, Andrew Morton , "Huang, Ying" , David Hildenbrand , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 21:01:25 -0800 (PST) On Sun, Nov 19, 2023 at 11:49=E2=80=AFAM Kairui Song wro= te: > > 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 sw= ap_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 *v= mf, void **shadowp) > +static struct folio *swap_cache_get_folio(swp_entry_t entry, struct vm_f= ault *vmf, void **shadowp) > { > bool vma_ra, readahead; > struct folio *folio; > > folio =3D filemap_get_entry(swap_address_space(entry), swp_offset= (entry)); > if (xa_is_value(folio)) { > - if (shadowp) > - *shadowp =3D folio; > + *shadowp =3D folio; I prefer to keep the original code to perform the check before assigning it. The caller usage situation might change. It is more defensive. Does not seem to justify it as a standalone patch. Chris