Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp84495lqe; Tue, 9 Apr 2024 15:36:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUd3sJksK46GE1RDZedapGlb7uDuLgSZ63ZCix8BfDpnbGKgcyjZLnqgSce7xx5E+hlFZVgiNXpxdZVyi2rHNCF4sTeBKPLiPZRbYi+YA== X-Google-Smtp-Source: AGHT+IF47i6DiyA6ju/WPxY3pY1nsdU/UtF8ppQVeGau9CLiye6dL54eUqQ+jcUiJkMitwuPslEu X-Received: by 2002:a05:620a:1a0f:b0:78d:61e8:2f12 with SMTP id bk15-20020a05620a1a0f00b0078d61e82f12mr1310453qkb.57.1712702189261; Tue, 09 Apr 2024 15:36:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712702189; cv=pass; d=google.com; s=arc-20160816; b=ICnJ4ubrBCV2JBrWTcKI3gy3dgm6he+mV0oDRIBQSbA9s4Ei8xAHVwbnESgic4cecj eCpSWpt6FFtOShUVvIrfRP63o98i1C64AESf7CkdTozicnBjjHEdJDGlsWzwaomv/kwg 8Tnbq4VQVi2LwUzQI9gYENal21mV4GpzQybxrjP8mbHfT/B8lfYiHYvUZ7LIoOeWcaXB P8Alj65k+QRXiEq7uGaV66kwz9DmtX6rS6tu+gVLFldNi+tZzuPYwTLhFIkccnI6k8oX gLjmIfD8BptpviU76j1zpr5r8OrmmAA5rW/BkF1TrzbaBIwro8mTVyStuHaBrka3oJus uViQ== 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=Ox3JYk/1gJ5SrPOhe25hcg8/9Pb6Gx6InXbQ2HJ+0as=; fh=cHq5U71+CFJhLTaw9nAuBxeh+xFzHXi0wid99M8+XIw=; b=WCPRMVJ3DTYfXr70e3tSVgWx5WRa0/ofSYRg6Rh34WW1PYfQi3LS16LPQOYF8+jUDP DMb5p519dFnQY1ojFWzV609gqpCINzkFAk50+qkDGe4CFLeek98qFzYPtsJpSzXQwUjq IsHCgDZnZTYnezFFdD5hqwjEDYqd/ylDwLC524KZ+dgJXodw/cYqnKf7345NOjTkzm9N QHlkYkqQ6GCZml/6TkBOv90D4/ylXJI2XbbTvzN9SwiKGgnlzkCl9YnfggQU7LPCdqiX cKBNp/DbnmswkZ0u11FaIgWnG+8UouyXUuR/4P1Vn3B9vqmmP/YzxF796Bg/2gtFqKZz GwOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=y2vU3YEW; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-137668-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137668-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c30-20020a05620a269e00b00789e9aa2d1bsi12517739qkp.508.2024.04.09.15.36.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 15:36:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-137668-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=y2vU3YEW; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-137668-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-137668-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EA68C1C21F1E for ; Tue, 9 Apr 2024 22:36:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CC311586D5; Tue, 9 Apr 2024 22:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="y2vU3YEW" Received: from mail-yb1-f177.google.com (mail-yb1-f177.google.com [209.85.219.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 835F853AC for ; Tue, 9 Apr 2024 22:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712702181; cv=none; b=a7QjmTscvIkx+eis6HqKZFRSidGKY6Ff16l6+dz8x1k9dusAk2eBahlneWS7/nA/Z9wkMFyNFlNJ9vz9RBgcMxidyyF2U9JRDZZtqSPEf7P70jepX2jXf/oVBzPrGxxdz59hfjYPB3zGsp/8oQKAhDoQQrdc0meXV8AmrLg1ogA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712702181; c=relaxed/simple; bh=01XOupmLACYxSiT5YVfOYtUF98Rdioy4SXxTYQ4XjpQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=caTFCUygYy5+y5bc/iQtXDRpRE1JBM7u2bQqdUJJl19OA+JDKY1LWbJaUBnvCP9f4gVbqZ35DA7nGkDZPcZRBwZvFZHKvz5th46BKHjgUYFGn2rRuvF0qFiNXjH+xQ8S9m3wSvavJMRvHT4dtIXs8VbAosPBae6kE1gE85uTPbQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=y2vU3YEW; arc=none smtp.client-ip=209.85.219.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-yb1-f177.google.com with SMTP id 3f1490d57ef6-dc6d9a8815fso6295454276.3 for ; Tue, 09 Apr 2024 15:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712702177; x=1713306977; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ox3JYk/1gJ5SrPOhe25hcg8/9Pb6Gx6InXbQ2HJ+0as=; b=y2vU3YEWtLr9DcAMgHMdVsJGi4ujGy/APrDDuJDMxGVa3l0xxJud9S8z20sjKTsDtm K2SPC4iKN26j4r8Hgooo+W87rjiLXYrzrIRfVpCQqpXuDh3IOUYiXHeiA7KsTwDr/FGL dC2JgALI9eS2bF9rgXiCEelwRHyCKYFDpt/JgqQ+LSwiu8yl93J7p+oqjq8xCpaYEQWV zesGmHrTW4hnHMdjnNggMA3xwfWr+kYMc2oEXVgLniHlgdFJt1aA8CezhAsRrb7VT1dK Xrc4NXTReJcFqWYkNkU7BwSkgJINp0C2Z5k4vm1MkgHPyQu6MveUIENsgHag76uMmL9i /+xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712702177; x=1713306977; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ox3JYk/1gJ5SrPOhe25hcg8/9Pb6Gx6InXbQ2HJ+0as=; b=HLvMf2UNnjI0cTMKnmAiMCFARaDELje3Cjms2YJBFTszVlh0DHri2Bc4bjeAQd410N Dbeu6j7SneBclgSiDipTfIiJ8Q9WiDjyQyadBDDJSB6tttlM/1M8Rd+4Qjej+kq1hgd3 tfgqtYQAJtj01IR/gmTROsLNwgrDUFALPXFIv7GYJGomsNqDh0TSEfN1O8AaHEJ83ATw pMHxBd9Ol4xMlKCyQnpLW2UOUHTZW8jqwIlKOID+0XBO2OFaWzSHaTMN0LpgxKd5eF9H bVBgBfMR2xpTQvFSP13jRnP4gGjXOSMfDHtn8PgCG2vN2oJ+RKiOb7uGu090dT/hAcfL aWtQ== X-Forwarded-Encrypted: i=1; AJvYcCVXKkvMefxbtq5gGIWondb+LmwFJ4YV+D/J6DWX6KpvQe9mkjeqIuREBgQMVcK3MUJH0jaj4Xa7mcSEk3n14vrJ+4YFh9/vAfoUl6mP X-Gm-Message-State: AOJu0Ywdq84eLJKyIlS/KLn0CSArA0XMO52fdZ2hqVc9lP8+pL6c0Tg4 2GAqCLTuqdXcEugGcaZ6mBSFzMhUKJKLojlA4uxiwhSRW4LY1epXGNWseT+JL3zxb9nJeCv9lUt nzKaQV8P0+dNPThoVcvhUlwIu073qRgR2vRfx X-Received: by 2002:a25:aa8a:0:b0:dc6:2152:3889 with SMTP id t10-20020a25aa8a000000b00dc621523889mr1241238ybi.7.1712702177244; Tue, 09 Apr 2024 15:36:17 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240327213108.2384666-1-yuanchu@google.com> <20240327213108.2384666-2-yuanchu@google.com> <875xwr81x9.fsf@yhuang6-desk2.ccr.corp.intel.com> In-Reply-To: <875xwr81x9.fsf@yhuang6-desk2.ccr.corp.intel.com> From: Yuanchu Xie Date: Tue, 9 Apr 2024 15:36:04 -0700 Message-ID: Subject: Re: [RFC PATCH v3 1/8] mm: multi-gen LRU: ignore non-leaf pmd_young for force_scan=true To: "Huang, Ying" Cc: David Hildenbrand , "Aneesh Kumar K.V" , Khalid Aziz , Henry Huang , Yu Zhao , Dan Williams , Gregory Price , Wei Xu , David Rientjes , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Shuah Khan , Yosry Ahmed , Matthew Wilcox , Sudarshan Rajagopalan , Kairui Song , "Michael S. Tsirkin" , Vasily Averin , Nhat Pham , Miaohe Lin , Qi Zheng , Abel Wu , "Vishal Moola (Oracle)" , Kefeng Wang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 8, 2024 at 11:52=E2=80=AFPM Huang, Ying = wrote: > > Yuanchu Xie writes: > > > When non-leaf pmd accessed bits are available, MGLRU page table walks > > can clear the accessed bit and promptly ignore the accessed bit on the > > pte because it's on a different node, so the walk does not update the > > generation of said page. When the next scan comes around on the right > > node, the non-leaf pmd accessed bit might remain cleared and the pte > > accessed bits won't be checked. While this is sufficient for > > reclaim-driven aging, where the goal is to select a reasonably cold > > page, the access can be missed when aging proactively for measuring the > > working set size of a node/memcg. > > > > Since force_scan disables various other optimizations, we check > > force_scan to ignore the non-leaf pmd accessed bit. > > > > Signed-off-by: Yuanchu Xie > > --- > > mm/vmscan.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 4f9c854ce6cc..1a7c7d537db6 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -3522,7 +3522,7 @@ static void walk_pmd_range(pud_t *pud, unsigned l= ong start, unsigned long end, > > > > walk->mm_stats[MM_NONLEAF_TOTAL]++; > > > > - if (should_clear_pmd_young()) { > > + if (!walk->force_scan && should_clear_pmd_young()) { > > if (!pmd_young(val)) > > continue; > > Sorry, I don't understand why we need this. If !pmd_young(val), we > don't need to update the generation. If pmd_young(val), the bloom > filter will be ignored if force_scan =3D=3D true. Or do I miss something= ? If !pmd_young(val), we still might need to update the generation. The get_pfn_folio function returns NULL if the folio's nid !=3D node under scanning, so the pte accessed bit does not get cleared and the generation is not upda= ted. Now the pmd_young flag of this pmd is cleared, and if none of the pte's are accessed before another round of scanning occurs on the folio's node, the pmd_young = check fails and the pte accessed bit is skipped. This is fine for kswapd but can introduce inaccuracies when scanning proactively for workingset estimation. Thanks, Yuanchu