Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp867998rdb; Fri, 26 Jan 2024 13:20:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGK6uOaNAQXUD5enpzGtA9aUQPIaoV7bYLQLspKbr6uJdCKKonSEBy8wV0E1o6QSFvRZ7dX X-Received: by 2002:a05:6358:728f:b0:175:9a9c:5725 with SMTP id w15-20020a056358728f00b001759a9c5725mr425809rwf.55.1706304013760; Fri, 26 Jan 2024 13:20:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706304013; cv=pass; d=google.com; s=arc-20160816; b=XZ1gTq0ec38rwF18J8ZNVJKRikcyWaX6J9gpu90u2AMgskMY9JwVAD6STc3Iiea4b3 pbeHrTg284/y9c+EImlxdNBM6v3Lv0x2Y9sxjWcHz2SaxQ7X4S/D81nlwzpEXZvm41H7 VaWXihGytfHyc/jmT7/C7Nnpl2vre03D+fzzhGTjAcwkp3r96Tq+mHjP5u/f9REsVoPF 5/khVw6DmStnn5N3axBVEaia7MXQl7OomqnvDI/PKe0ULq+qpIHU2dvc94s1NUWbGP2u l6zxmf3nDv1ceu6r/Y7NU+rYdd77xy/mU1/rj+4HjC2mY1J9Dlt0Jh7y5klbI8DBMtKK UeFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=ZevVAc9vtWOD6kK22wSFQG27u38LXBsFOf5paXbFIt8=; fh=jkPtnd50W+EavItawuIebG6l2v2GLCKzNzFCDZWvM38=; b=ymzvUOnMzkOR6+vPVs+PksrOCYa1VJCWLKlDrp23HtyOoGPFiLm4y9zPBYHr2kOsr8 i4VUQLNx78g9LHOdN562ZbViyyO414WARWbaRyiSAscg0y3Khe8vOB2jsdFjPKDC/z+2 K2+XhDARNhOrHDoSY0E4fzz4KPk0YVMwZ17qEhb6+oszBXXh8DzTZrF26RwumfYrtE6u vEXInG1/4u65Om+tBFpB85x89ViC++6S4biNPmUKkF2f6XIByC1k488xtV/Oykt7opix /E1Tzv9NhdlX31Xi2NAwoPVnAcpdXildkloZzQ7ognqhiDINsfVlWF9apfB6K7NUdaO6 sUzg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KPqrGKi+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-40663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40663-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q12-20020a65684c000000b005d6b0d96852si1661959pgt.131.2024.01.26.13.20.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 13:20:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KPqrGKi+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-40663-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40663-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5EAA12868D0 for ; Fri, 26 Jan 2024 21:20:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F2E924B2A; Fri, 26 Jan 2024 21:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KPqrGKi+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99F27241F8 for ; Fri, 26 Jan 2024 21:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706303992; cv=none; b=B2eWLee0GQUQGIrV7C+FfKQw67fxM+DqWotnFYmvyKugkMnamcDuA65Kr2AE8Q2zwDLZFAMY1OGuSJsqTQvkqJS5+f2oPy/B4L7lvqni3A3opfWKG9UPDgZE4BouJFAazsHtAbAiKu7NCxM9coouWSUZ9ft1JGUaVQ1vyXp0mLY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706303992; c=relaxed/simple; bh=g+ueImr0RPbrGmsoFelyQwne/GFqsa3s9BFQ3P7pP6E=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=osmKlq4gbg5+gNQzJYGMexPLA9i5joAt6aKtWz15Zkxf4nJPR0qy2Mh8KQOFKwGeg6C7dKaQWdTMXU4JgemjDGkA0KqJWHZq/tpco+SfQgoxsE70jcXVLoWQttpylKSit4nyBH7RoqdhmP/fPDqwIbrXh3rAZ/PKp0VoSSFef7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KPqrGKi+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16E79C43394 for ; Fri, 26 Jan 2024 21:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706303992; bh=g+ueImr0RPbrGmsoFelyQwne/GFqsa3s9BFQ3P7pP6E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KPqrGKi+69qOSpmZ+KbmvKosdLUluUxXRyfLOKziZHf9SYTF5dg5nDohrX04Mtd2f O9MzBiJ0xZjyddx5W9BmphG4RxbxpQpVAb4JqJOJGJYRD2AFNboETG8o3V1RW0bvy2 IyBqnUBcZBH0p51/eWSIp6C6LumoSXi3fUcD4MlxQkqg103La62mLfa7tb9J/f4d13 kvfVJCw5Wk0YUa2YnsZrEFGlrr3ihDzOWvuQRu8DVU4Swg/I4A/bPjkiBKx4ZU6vAq 82POnO6+1+sAv35vwdkN02k0HnnUIaTPrdHfMjLhPUWIMvDimgSKFettCpXQKKB8I3 zS39aLdK7Dj9g== Received: by mail-il1-f169.google.com with SMTP id e9e14a558f8ab-361a38dd171so1312845ab.0 for ; Fri, 26 Jan 2024 13:19:52 -0800 (PST) X-Gm-Message-State: AOJu0YzXDW9k9llTLlsnOC9v2FRkNTEttdpqtsgSsIL5kB5n7bIfU3QO Ens8QcsIfB6bcDKvVy3AOIrcuWUKzussGXRgzWHdYo8f4aQmu/6FOkbVO9vvjvIcEQrOhDwURUt m5iULB9InJ7cU/4qktMWRsjmhjIW93dbzVDm2 X-Received: by 2002:a05:6e02:1d15:b0:362:8bdf:45cc with SMTP id i21-20020a056e021d1500b003628bdf45ccmr516586ila.17.1706303991343; Fri, 26 Jan 2024 13:19:51 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240123184552.59758-1-ryncsn@gmail.com> <20240123184552.59758-2-ryncsn@gmail.com> In-Reply-To: From: Chris Li Date: Fri, 26 Jan 2024 13:19:39 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/3] mm, lru_gen: try to prefetch next page when scanning LRU To: Kairui Song Cc: linux-mm , Andrew Morton , Yu Zhao , Wei Xu , Matthew Wilcox , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jan 26, 2024 at 2:31=E2=80=AFAM Kairui Song wrot= e: > > > > > > > > > This makes the code flow much harder to follow. Also for architectu= re > > > > that does not support prefetch, this will be a net loss. > > > > > > > > Can you use refetchw_prev_lru_folio() instead? It will make the cod= e > > > > much easier to follow. It also turns into no-op when prefetch is no= t > > > > supported. > > > > > > > > Chris > > > > > > > > > > Hi Chris, > > > > > > Thanks for the suggestion. > > > > > > Yes, that's doable, I made it this way because in previous series (V1 > > > & V2) I applied the bulk move patch first which needed and introduced > > > the `prev` variable here, so the prefetch logic just used it. > > > For V3 I did a rebase and moved the prefetch commit to be the first > > > one, since it seems to be the most effective one, and just kept the > > > > Maybe something like this? Totally not tested. Feel free to use it any = way you want. > > > > Chris > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 4f9c854ce6cc..2100e786ccc6 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -3684,6 +3684,7 @@ static bool inc_min_seq(struct lruvec *lruvec, in= t type, bool can_swap) > > > > while (!list_empty(head)) { > > struct folio *folio =3D lru_to_folio(head); > > + prefetchw_prev_lru_folio(folio, head, flags); > > > > VM_WARN_ON_ONCE_FOLIO(folio_test_unevictable(fo= lio), folio); > > VM_WARN_ON_ONCE_FOLIO(folio_test_active(folio),= folio); > > @@ -4346,7 +4347,10 @@ static int scan_folios(struct lruvec *lruvec, st= ruct scan_control *sc, > > > > while (!list_empty(head)) { > > struct folio *folio =3D lru_to_folio(head); > > - int delta =3D folio_nr_pages(folio); > > + int delta; > > + > > + prefetchw_prev_lru_folio(folio, head, flags); > > + delta =3D folio_nr_pages(folio); > > > > VM_WARN_ON_ONCE_FOLIO(folio_test_unevictable(fo= lio), folio); > > VM_WARN_ON_ONCE_FOLIO(folio_test_active(folio),= folio); > > > > Thanks! > > Actually if benefits from 2/3 and 3/3 is trivial compared to the complexi= ty and not appealing, then let's only keep the prefetch one, which will be = just a one liner change with good result. That is great. I did take a look at 2/3 and 3/3 and come to the same conclusion regarding the complexity part. If you resend the one liner for 1/3, you can consider it having my Ack. Chris