Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp516692rdf; Tue, 21 Nov 2023 08:39:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpeZiLQM2MlgorxjjhjDWr1cWm1BbfQKPtTZUxicF6qA1EgvYOPtjz3TmPyuZDDHhLDg6t X-Received: by 2002:a05:6a00:1946:b0:6c4:9672:9a17 with SMTP id s6-20020a056a00194600b006c496729a17mr13097273pfk.1.1700584741417; Tue, 21 Nov 2023 08:39:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700584741; cv=none; d=google.com; s=arc-20160816; b=gSz44kxTcPX28aljmCm8s1ZrsASykEo357um46ZyCXh6hP3LKQ3bUOFufMVAhxpOjL b2iBxeb4ipTn6ku4qaeVo5hj4Bk8kuriJiKlIkrBT5Rt58/NREponizgAbB9WkXZrwTY SeCF4vZCgTNXQhR7z8aQowKyQ3ok3gZZx4naIcIWIE6JDA9F4/9FE4lHuCFjVX7F5aUl I+IUkzDfLMULJOpwEcfjyPPJLs37/BsbX6gn8CbpjWH+G6v+iTXv1eeyaBp+B5Kw/2b3 wOms3WCWLYY78sfSg9bEe5rK76hRzqgbx2XJAzpYwocS2Aiyh46bgUWK2f0RIouXKW8d HWoQ== 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=7h/vwD8dA52z/EdIu49Xlj27Q0AIS6LgIrDKn6iqxSw=; fh=v/j7QEwtsj+94eMIzch1qbwAijHXRMR6IcasrHCGlTE=; b=ciXVo55SHlR7oTmf5pwLvybP+THOH3nuPcaP3tModPWQCLQCz0eGylMV8vjrlF+uW1 gDsu/2AeGvfit809dNPsB1rPGMV1hE7nkFlch8OKWiBgDv4/BSIl72J8f/FURSIA7a7P 2/KF0yA9AEE4/ku+RkHUc7h7e29P+FnMVvjLMzW17mE8uu091TrDpGQLwnXOh8+Cyc0m GT//A3w/39kv1etUxNV3DozGMZQmmtECiwgm5yLY7O5GA1ek5q46AjhWRCos2RdopAtD R9F49g8F/K08Zi/uWxNzsDzc9x47RU00BMcn8+NxaL2rLhWo1S0VibgQTA7nfPFNc7/n VyhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BgoUGj0o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w10-20020a63d74a000000b005b884a11fdcsi10380001pgi.28.2023.11.21.08.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:39:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BgoUGj0o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 8944E80BE2DC; Tue, 21 Nov 2023 08:36:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233556AbjKUQgp (ORCPT + 99 others); Tue, 21 Nov 2023 11:36:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233677AbjKUQgn (ORCPT ); Tue, 21 Nov 2023 11:36:43 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1190F199 for ; Tue, 21 Nov 2023 08:36:40 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF569C433CC for ; Tue, 21 Nov 2023 16:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700584599; bh=xTCdppnNrLRTcBODBfq5VC+EuncNcZtVGMcvlAsIibA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BgoUGj0oDfEZAUdRUYuX4JDhOar8o4U1ifqa+rJ2kRXQ5aVWZqKDVJhmwQs5RRu9k 04Eyb+uqa4EXDQZd1i4LfvdRni3fCgcboktrp1bBhUHFTlgGgLr9rO6N/EPH3um1SR HmpuaVlcGkJ9IoK8WqHm7d8UR+SF1UDI3BRX4z1rsOH1gKF4rAgfRPBH3rkR01Q+vI 8Ed35lMkh2/1hm99hbPDgJsv/bcr8KA5T74S+Rqmvu8PmyYuf5MV+TrJMMLjQCF8sJ +XP00xqz5/UhAxZkM+hXQkrwks5LcbZS2b3/9L+47IZlBbvYNes//7aiH8jqo9z9vQ 154A2jevKg/aw== Received: by mail-pj1-f52.google.com with SMTP id 98e67ed59e1d1-280351c32afso4626371a91.1 for ; Tue, 21 Nov 2023 08:36:39 -0800 (PST) X-Gm-Message-State: AOJu0Yw2PzqSGAYIPsaakHR+Bjog3mNzebaCciBW/XNNxU36c+AQZuwg zGbS+DzRJr+jP5UCfT1yzZfdZZO+ooFiFio+C+rMdg== X-Received: by 2002:a17:90a:ea88:b0:280:1dfc:1302 with SMTP id h8-20020a17090aea8800b002801dfc1302mr11830833pjz.17.1700584599143; Tue, 21 Nov 2023 08:36:39 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-13-ryncsn@gmail.com> In-Reply-To: <20231119194740.94101-13-ryncsn@gmail.com> From: Chris Li Date: Tue, 21 Nov 2023 08:36:27 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 12/24] mm/swap: simplify arguments for swap_cache_get_folio 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=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 08:36:47 -0800 (PST) On Sun, Nov 19, 2023 at 11:48=E2=80=AFAM Kairui Song wro= te: > > From: Kairui Song > > There are only two caller now, simplify the arguments. I don't think this patch is needed. It will not have a real impact on the resulting kernel. > > 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 =3D swap_cache_get_folio(swap, NULL, 0); > + folio =3D 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 *v= mf) I actually prefer the original code. The vm_fault is a much heavier object. vma and address is really what this function needs minimally. I consider vma and address, even though two arguments are simpler than vm_fault struct. It is possible some other non fault patch wants to lookup the swap_cache, then construct a vmf just for the vma and address is kind of unnatural. Chris > { > struct folio *folio; > > @@ -352,22 +351,22 @@ struct folio *swap_cache_get_folio(swp_entry_t entr= y, > return folio; > > readahead =3D folio_test_clear_readahead(folio); > - if (vma && vma_ra) { > + if (vmf && vma_ra) { > unsigned long ra_val; > int win, hits; > > - ra_val =3D GET_SWAP_RA_VAL(vma); > + ra_val =3D GET_SWAP_RA_VAL(vmf->vma); > win =3D SWAP_RA_WIN(ra_val); > hits =3D SWAP_RA_HITS(ra_val); > if (readahead) > hits =3D min_t(int, hits + 1, SWAP_RA_HIT= S_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, hi= ts)); > } > > 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 =3D swap_cache_get_folio(entry, vmf->vma, vmf->address); > + folio =3D swap_cache_get_folio(entry, vmf); > if (folio) { > page =3D folio_file_page(folio, swp_offset(entry)); > cache_result =3D SWAP_CACHE_HIT; > -- > 2.42.0 > >