Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1326018lqj; Mon, 3 Jun 2024 19:06:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5/AABPRWWDLvAFiMDGNl7Ox5cucYSXwhIvbXveujZmDyOmf428AAsgFJlTq+wjzgVuJllOIfhay+Qlw8xcj76BDr3vYRPXJkOrVDzhw== X-Google-Smtp-Source: AGHT+IEdUjAv6rWMnQvXuyEghlvqlnfWbs5pEgEALpna9avHgDy0KxXAweebTM/aoW6MDTW6rtYy X-Received: by 2002:a17:906:350c:b0:a69:ba7:2dc7 with SMTP id a640c23a62f3a-a690ba72dfemr294145866b.27.1717466792877; Mon, 03 Jun 2024 19:06:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717466792; cv=pass; d=google.com; s=arc-20160816; b=SvAB2XLORmEyOR1msA3snyyNEItxvIF2hRRSWRrnkrLhJfJYy4ebVkAHA3ulpnP4fR VJOEk/jOAfYkBv3Celll8NoRvFvBT4eoAGyfTSxtWjVtkOGEKCgl+04jorKcXKBbEPqg TNh8HJELqjTUdy9mNIjX7q9tDidgdRPzDJgCno7C3t+5EjK8BBg7/0FOeHdCxjUk7f0M 1L7J+/4Mmcaxunrf6AlfIRrr1xKgNvFH8Bx5s/yt/yR3bqBIuHeHYBj24EJ9Gv0W6dBo 3BYid8tUrs7qc/ICnUjePmBChFBQ00D5E5OPQQWQRf4h3aC+qb+YdaiJpX5eC3tG2Z8Z yl7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=TjWUm/jwk/hpgAY6bYVVdFyPbNpQM4PAlbOY34rPVUc=; fh=jgu7yTXrsEHyohEXAxk8Ce4GRTq5FSCPTtMAGFIYzvw=; b=CKO/aQAo88REOhQLdhmxIvWyb4+p0Vv0ECxf5SV5JAyUXpYuFP5qIxism8435/6Sc1 Ax/Ehw1oz2ZCYHrBhB3jXnmQYY67Qam/+G+ga5JYUV7u12nRMgyU0rSnF4qw4u+1seYO mlyVw+4fCQwNfcLeJdrgoYEamulUCR6cddBFPpIq9+npUB5102lpScO95dV3TAJkVGar stDhyWB6tdCQl4fsLZKbYNEzVBJiqjd58ikhIGEbHqvxHogIUbsPlvtEVZ05nF74sl69 +E0TnxylCHPhohu04FQriQrJmrsrief0GzTDLJr6ouKoaRHv0idoMQgonapfKSC1a1MU 2oJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=taLOJr1h; arc=pass (i=1 spf=pass spfdomain=flex--yuanchu.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199949-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a68f493e5c5si218508566b.144.2024.06.03.19.06.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 19:06:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=taLOJr1h; arc=pass (i=1 spf=pass spfdomain=flex--yuanchu.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-199949-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199949-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9A0F31F259C1 for ; Tue, 4 Jun 2024 02:06:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 033CB13D88F; Tue, 4 Jun 2024 02:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="taLOJr1h" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 B3D4713D2BA for ; Tue, 4 Jun 2024 02:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466772; cv=none; b=YWo3mQZaT5aERDXdejpMnXbGfiZAUFrKPHBTsYDjQFKygQDU+cF/HE4zT2sAogZ2gvD+fdmOPSPG7WO1vHEvxcr+uQcnPXCqsJ0NHbAmSzgcehkk6dMmxEmqFVeLvNBEqQFxVxPKIK97I9kVEfoMvQbNh0XS9oDFyffi5/q4t2k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717466772; c=relaxed/simple; bh=msjeUsgEzzOjOpUWHfas3LCKMX1t6e6yDLl0uelE9mg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dM3741wbQ/d20iLyB3fGeYj0NL3lncmOd/nOznuiB4tUGyWMAe2oXI//MvWCDy40UcKjg7ahsZeq5sNTTlxRnFWvc7hMsrjfIBM8/iS7A3bm3kGGytruW8KlbXP9eCl/yp+3IMDwv/nx1rzvkV918l8QTR3RklG7tNvHTcnBSdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yuanchu.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=taLOJr1h; arc=none smtp.client-ip=209.85.219.202 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=flex--yuanchu.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dfa744fe2f9so870793276.0 for ; Mon, 03 Jun 2024 19:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717466769; x=1718071569; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TjWUm/jwk/hpgAY6bYVVdFyPbNpQM4PAlbOY34rPVUc=; b=taLOJr1helQgcs2JhlL6kdfSnGBKeG/3LVHEiZ9Vdl5nRWjTl5YAUPzrEnyV9eehYF Lxvqu8GQguXVjnt+E+h3sKyGTdazv6oYbh8jbATK48mqlft9bxuGvXpzkMlcyxx0SnvY uK3Fo+k11KYaD5fnNdh0XSdJXpm0XxUECkpBf5a9g/8WjBtjJH7prgII0v8mCsdMx+sB 6HOcbPdetq7ONLQaH6i/lEDQVMtbHmv66iCpffsbl3f64k351lwEFGmYo0KLSjcYCVLu Y26QnOD9lh4PL5F7kOCHx3MAeDrCH9lAaXONfMbsCVOuGbF2hygVxJUi0b9fw26gH59t xUdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717466769; x=1718071569; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TjWUm/jwk/hpgAY6bYVVdFyPbNpQM4PAlbOY34rPVUc=; b=R8qBfC2H1w7RyE2ybp0wQ965IknmrUwW5nM+DX6C/f7CypeRFablcSp0vVx4dccBMt xWZYKBLTe0THNjPcjuAdHMGyJxEysj7ktbqmbOA4VYGVZgDNxm6Z7upL6dqEkvg3WNao 3jNpvvXrO3aIkzTRhnrZUtvSBF+nh/ndW3eNAaDGspr1zUxk/akak4vEjUS/kEKve75c O76Hw9PQ5qmt3HMTc2e+C5ZJUBL90R9rM+PR4jgAlHs/9VKMqFxlNKUfYj/EQAgHDZpj QWZ91W6TlhSHXxVv5pPjCrnV69M3ZcwBJi+dImFrbz34kpl8i+AAabgQLL40ONZADGUA zEwQ== X-Forwarded-Encrypted: i=1; AJvYcCV4mL4LurP3ECNNTYKCN1Qq8uPRaD/lszopaGUrAYiTeGRRjfAx0Y0VVFhHo49MamuQ1QMmBEleZ4sgmlcn/RfxPzTmnCOBqUM28hhk X-Gm-Message-State: AOJu0YynT3ZS2sPvLfWTOIonQ142AAQRqzfvPZN0REhmL6OqRwMqLGx0 Cb1Sw7bcSr0+DQ5t9njrL+UHCdVk8NtZWVoLNguDOub7547tEYXXN/8GtE/dkcYKwbxZueyXZvT GxZ/2xw== X-Received: from yuanchu-desktop.svl.corp.google.com ([2620:15c:2a3:200:367f:7387:3dd2:73f1]) (user=yuanchu job=sendgmr) by 2002:a05:6902:110d:b0:df1:d00c:130c with SMTP id 3f1490d57ef6-dfa73bf59bcmr1176974276.5.1717466768619; Mon, 03 Jun 2024 19:06:08 -0700 (PDT) Date: Mon, 3 Jun 2024 19:05:42 -0700 In-Reply-To: <20240604020549.1017540-1-yuanchu@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240604020549.1017540-1-yuanchu@google.com> X-Mailer: git-send-email 2.45.1.467.gbab1589fc0-goog Message-ID: <20240604020549.1017540-2-yuanchu@google.com> Subject: [PATCH v2 1/8] mm: multi-gen LRU: ignore non-leaf pmd_young for force_scan=true From: Yuanchu Xie To: David Hildenbrand , "Aneesh Kumar K.V" , Khalid Aziz , Henry Huang , Yu Zhao , Dan Williams , Gregory Price , Huang Ying , Muhammad Usama Anjum Cc: Kalesh Singh , 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 , Yuanchu Xie , 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" When non-leaf pmd accessed bits are available, MGLRU page table walks can clear the non-leaf pmd accessed bit and ignore the accessed bit on the pte if it's on a different node, skipping a generation update as well. If another scan occurrs on the same node as said skipped pte. 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 workingset estimation of a of a node/memcg. In more detail, get_pfn_folio returns NULL if the folio's nid != node under scanning, so the page table walk skips processing of said pte. Now the pmd_young flag on this pmd is cleared, and if none of the pte's are accessed before another scan occurrs on the folio's node, the pmd_young check fails and the pte accessed bit is skipped. 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 d55e8d07ffc4..73f3718b33f7 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3548,7 +3548,7 @@ static void walk_pmd_range(pud_t *pud, unsigned long 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; -- 2.45.1.467.gbab1589fc0-goog