Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp526081rdf; Tue, 21 Nov 2023 08:54:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHr19izTBDyWoF1AMuh84vOCFezs67eBFsLyIF9FlnhwPtGcUyiqT7SiT0A0vzxE2HCbs17 X-Received: by 2002:a17:90b:3e8d:b0:27d:348:94a8 with SMTP id rj13-20020a17090b3e8d00b0027d034894a8mr12048550pjb.6.1700585663335; Tue, 21 Nov 2023 08:54:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700585663; cv=none; d=google.com; s=arc-20160816; b=DSwN3R9sfhFYLcCTchai3se1YCxTWkRIPiTssQePHv+hsrXoilxFe7l6oF94z5TsUl yIgQg/wJoYDFNryCY5LR+quSXkDhdmHml/vSWQJBpC+Pq3cWX4wFvsL9vmnyZh6//FpC dmFsX6nC77iuOeu9Y9uCwfr4D+lfnaUMNuzwzcCkKFy6pjgbikkoT9XMO31YlQMX2lzV 3vm4V2S/4ugPfwgwqtPiBjcbtM5FyJYSYiWBTiB3QSZCmV1dHWUv6RofXXskElRPi6bW aW6FzZntvSOgnVOpd1/2oVM+qXXRVsqmV2mGHofzLNsaLto0N7T331DGBgmq6QAKG+yo aLpQ== 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=KAxtWpzK81kXYb0ctFh98qsvRwpoa426B7zOq4D5210=; fh=v/j7QEwtsj+94eMIzch1qbwAijHXRMR6IcasrHCGlTE=; b=rEagnCF1iSNjQpax+1mwwIxYTP/oYE4uG4lkkS9NyJNwMEpdH4BPpm+HodIoGfXSMR U8Z8iDD0ZMuDHtruZDkGaxdDjTt6qXQc+Bl71noAk0TWjNZWoJiSVhy3pR4jSny+M9Y3 h/hLqSIlbIxFv7dE2pmiqq4vhqQlg0SQO7Hl09R6UQnniZqufZKGRuZjG8iSFT+gfaFr KOqDwArmzbEBbdc/3boqd+HoKx4eP3ISFuJMl1lmryYAhB/v9P0MsBJ1psbtTZoXxN9A pf7W5DC5XsKNDPo4N68kHGjPWD6Lp+NjLbX+c05c1pwfb7Vy+WlMBzD8c2ghC+ZuV85y JrQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fj+SX4vd; 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 z19-20020a170902ee1300b001cc33933e45si10442560plb.42.2023.11.21.08.54.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:54:23 -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=Fj+SX4vd; 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 093D580941E7; Tue, 21 Nov 2023 08:51:02 -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 S231202AbjKUQux (ORCPT + 99 others); Tue, 21 Nov 2023 11:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230399AbjKUQuu (ORCPT ); Tue, 21 Nov 2023 11:50:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86AB092 for ; Tue, 21 Nov 2023 08:50:47 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F068C433CD for ; Tue, 21 Nov 2023 16:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700585447; bh=KpSLWpoYDnujgiguvqs0R2yyZ8foM4ACeYZogrkU4I0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Fj+SX4vd92/6IemEiaZl2gnc4DSB2SfGdJOOqij4ynK4zkVgM7aRMiRUzjuWiIyZh Ewnanqnc+KrE260cYqPD5RM0DTRyDBkOBvwDUevGWzWcdfKbrhuHriLTLI7GcRHSIi QOfSvA8+uhUmPkp+8SuuXD9SdD3aQb961yIzH16NDjhk0irH0j4wtqPth50VLMqti4 fI31pVxWLVwUnTKVxIUoi/ENz4G/qEo8h6IHHfkz/UbQzdNE1pC9GoPxD5AjwrSeXo NcCUWFj1Ux1f320IlRuIlrt5d/bWx4y7lWkrSQmLzwqG73iGiv++e+xNYFekFnXk1S 7HtdRJ7DW4qVA== Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6c115026985so5878287b3a.1 for ; Tue, 21 Nov 2023 08:50:47 -0800 (PST) X-Gm-Message-State: AOJu0YzVwVIK93AYfFYcIMlQH1fTnRY5qUpwlNwbA9rnUol/2MJ9BWiL XBDqxpEXDm7vmLEO47TP7ICDp8cWnO0AryLqJ4LW8w== X-Received: by 2002:a05:6a20:394a:b0:18b:284f:e725 with SMTP id r10-20020a056a20394a00b0018b284fe725mr114850pzg.16.1700585446584; Tue, 21 Nov 2023 08:50:46 -0800 (PST) MIME-Version: 1.0 References: <20231119194740.94101-1-ryncsn@gmail.com> <20231119194740.94101-14-ryncsn@gmail.com> In-Reply-To: <20231119194740.94101-14-ryncsn@gmail.com> From: Chris Li Date: Tue, 21 Nov 2023 08:50:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 13/24] swap: simplify 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:51:02 -0800 (PST) Hi Kairui, I agree the resulting code is marginally better. However, this change does not bring enough value to justify a stand alone p= atch. It has no impact on the resulting kernel. It would be much better if the code was checkin like this, or if you are modifying this function, rewrite it better. In my opinion, doing very trivial code shuffling for the sake of cleaning up is not justifiable for the value it brings. For one it will make the git blame less obvious who actually changed that code for what reason. I am against trivial code shuffling. Chris On Sun, Nov 19, 2023 at 11:48=E2=80=AFAM Kairui Song wro= te: > > From: Kairui Song > > Rearrange the if statement, reduce the code indent, no feature change. > > Signed-off-by: Kairui Song > --- > mm/swap_state.c | 58 ++++++++++++++++++++++++------------------------- > 1 file changed, 28 insertions(+), 30 deletions(-) > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index 91461e26a8cc..3b5a34f47192 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -336,41 +336,39 @@ static inline bool swap_use_vma_readahead(struct sw= ap_info_struct *si) > */ > struct folio *swap_cache_get_folio(swp_entry_t entry, struct vm_fault *v= mf) > { > + bool vma_ra, readahead; > struct folio *folio; > > folio =3D filemap_get_folio(swap_address_space(entry), swp_offset= (entry)); > - if (!IS_ERR(folio)) { > - bool vma_ra =3D swap_use_vma_readahead(swp_swap_info(entr= y)); > - bool readahead; > + if (IS_ERR(folio)) > + return NULL; > > - /* > - * At the moment, we don't support PG_readahead for anon = THP > - * so let's bail out rather than confusing the readahead = stat. > - */ > - if (unlikely(folio_test_large(folio))) > - return folio; > - > - readahead =3D folio_test_clear_readahead(folio); > - if (vmf && vma_ra) { > - unsigned long ra_val; > - int win, hits; > - > - 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(&vmf->vma->swap_readahead_info, > - SWAP_RA_VAL(vmf->address, win, hi= ts)); > - } > + /* > + * At the moment, we don't support PG_readahead for anon THP > + * so let's bail out rather than confusing the readahead stat. > + */ > + if (unlikely(folio_test_large(folio))) > + return folio; > > - if (readahead) { > - count_vm_event(SWAP_RA_HIT); > - if (!vmf || !vma_ra) > - atomic_inc(&swapin_readahead_hits); > - } > - } else { > - folio =3D NULL; > + vma_ra =3D swap_use_vma_readahead(swp_swap_info(entry)); > + readahead =3D folio_test_clear_readahead(folio); > + if (vmf && vma_ra) { > + unsigned long ra_val; > + int win, hits; > + > + 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_HITS_MAX); > + atomic_long_set(&vmf->vma->swap_readahead_info, > + SWAP_RA_VAL(vmf->address, win, hits)); > + } > + > + if (readahead) { > + count_vm_event(SWAP_RA_HIT); > + if (!vmf || !vma_ra) > + atomic_inc(&swapin_readahead_hits); > } > > return folio; > -- > 2.42.0 > >