From patchwork Mon Jul 15 19:21:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13733833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF549C3DA62 for ; Mon, 15 Jul 2024 19:21:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41F746B0096; Mon, 15 Jul 2024 15:21:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A8CA6B0099; Mon, 15 Jul 2024 15:21:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 221E86B009A; Mon, 15 Jul 2024 15:21:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 052E36B0096 for ; Mon, 15 Jul 2024 15:21:57 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B09EB16020D for ; Mon, 15 Jul 2024 19:21:57 +0000 (UTC) X-FDA: 82342957074.10.8B65B71 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id A9B261C001F for ; Mon, 15 Jul 2024 19:21:53 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OIoH/AOi"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721071271; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uDSHiwJLCIYvvzv2DOw1kewa0irBZ6HqHLZp2ORNUK8=; b=c/nRKj2W/545ko3nXsbiL/TvCRUQz/JXNi8+54jXzZGOmPTyxJ0DVR2pTATJIH3raIlKMx PjzkkUQEsB2z1jYTv4YRZL8FnBKFAf4K61OSEAYyLYaex7Gc0Y1LyZk7vH+BkNq7bEPYK9 pU1CHInIaJ3KgmpEjegRp3JNukzbIRc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721071271; a=rsa-sha256; cv=none; b=t4RsyckG0CA3avfM0Zcbusk/cqYvhVF3Zz76+AocgbPHd0+fmDQAkqCoM/HAq+ZE+J3mQH B7zKY+YIwxXo0KNgQ3CLqnlV1GlrhdXFbaaUHFhiJGVUNfwY9kk866VFEEgbfD1QW3A76I tDuDBasN8uIoxnWcQROIY5uR99o+f9c= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OIoH/AOi"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721071313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uDSHiwJLCIYvvzv2DOw1kewa0irBZ6HqHLZp2ORNUK8=; b=OIoH/AOiD3qYfJfwY44rEsCVdJMdanjLQczMJJVZPohWBgYl42+Cx/9BlJsAGASrEQAS6N B0CFIouvagTF6M7bR01iRf0EOH/ssQzFByKNEkoq33J6tRkFd+V+cagpeNZ7zt+6XpnkSS 1HpZoFQVe/x0ob8hM2yhEa/I0PYRD8A= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-phhHxa1VOi6L7hToVnuusQ-1; Mon, 15 Jul 2024 15:21:51 -0400 X-MC-Unique: phhHxa1VOi6L7hToVnuusQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6b5e41e09b6so6993436d6.1 for ; Mon, 15 Jul 2024 12:21:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721071311; x=1721676111; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uDSHiwJLCIYvvzv2DOw1kewa0irBZ6HqHLZp2ORNUK8=; b=RDCZLpyfYjFvgc0JJFUPz9XpUwBKXYZHxa6ps5EBR7hUQUru4xnvZlWZdpTHd++pgK t0SM8RnxORFut4DU3KLsQqbvejq66PidURmkHCbKZIO6ZjpylrFKlZa8xrJyd6elplg6 XrHvnKyeJDAxkm42gum48FiyMNRi0aHKRlCViXhwcBgeTvcIhzZ5gW8Wr1pT3tv5poEn 1u1JOII6AWmhHKUlK0axT4DFx4QebOqyNPdlQeowY488T1rQ4ntL3LUqLp/xmOCJHJuA d3XhQo55ADPrcXcHleYuTwN8oIjuToX6z/P+pwJQAdb5VJLDlfU2C8IfM0Sj+v73vG+V cCsg== X-Gm-Message-State: AOJu0YyNrndOBc2Uowl5k0NJEzp7mlpzZdkDqtjMT0LWrPTyjDdvRDEa fnDlvahjp8swY49XOXtARpHlQL1hdu+kltEE7Y00aA7Ijctlidx94ClHaT+p7GGzma6LegIH9hJ kmd0S23rcZhIgyFlTim63TFi1tr+DRqUXPeca+jKtnqPQyuxOXvAmCE4KRp69ghWCJQbBEbTsIf qnASb8Am7PeF2WQDW1rltVf5kMMNt6AA== X-Received: by 2002:a05:6214:2d44:b0:6b5:4bf:e0b2 with SMTP id 6a1803df08f44-6b77df230d0mr4738446d6.6.1721071310748; Mon, 15 Jul 2024 12:21:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXNZWcX+OGChgQMRYaFRNal2nxEfRlz+I/X26JLEslV+UpQEodY5JY9Fmq0XZviJ4grHRk9w== X-Received: by 2002:a05:6214:2d44:b0:6b5:4bf:e0b2 with SMTP id 6a1803df08f44-6b77df230d0mr4738076d6.6.1721071310396; Mon, 15 Jul 2024 12:21:50 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b761978d30sm24039356d6.31.2024.07.15.12.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 12:21:49 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Dave Jiang , Rik van Riel , Dave Hansen , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Matthew Wilcox , Rick P Edgecombe , peterx@redhat.com, Oscar Salvador , Mel Gorman , Andrew Morton , Borislav Petkov , Christophe Leroy , Huang Ying , "Kirill A . Shutemov" , "Aneesh Kumar K . V" , Dan Williams , Thomas Gleixner , Hugh Dickins , x86@kernel.org, Nicholas Piggin , Vlastimil Babka , Ingo Molnar , Alex Thorlton Subject: [PATCH v3 2/8] mm/mprotect: Remove NUMA_HUGE_PTE_UPDATES Date: Mon, 15 Jul 2024 15:21:36 -0400 Message-ID: <20240715192142.3241557-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240715192142.3241557-1-peterx@redhat.com> References: <20240715192142.3241557-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 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It6mD0XcGBIE5HqP7ZZCwmSqDFXOjvJBv1T69vFz7PdU1eNCI 1PMpja3+ bAVvePaNLDLwCjWmoCtdplkVRRRFcffC1eaFUGRtY3ylVgU08pFweOhT9sunQGkwOIrgaeoycj8earuYcYzC7HvTWifKeshtcJaVY39UaBurscm/5d96J3HgnvPgR3g7JVExo7aSuxzdf+1mSz39dsgOXBWZXGAsd+o4Xget6wiMOpzCKNDMM7OnOERddl1LRpuXfGmXgOiB7p0MqVQEgCWbYigMpUqtf8x6iUZgq4DwI7HsKjHDxi3m+0wR+YtVOFLw6O2o0UVRzp4sumSVfQ9+WwaWXuMGBa278JxzbkiGrHmSDn1IY8CgWd9Bhm7XLgSfWzApzYL8DdyISOazriclc8QfmjAdSfQPiMJoB9cLgKMLIGV5xrUsw8HKsSr6Pnu76elQCDwHwOyWOMJSr4SgwLLV0vnbDzj8/6DkuVpoxzub10rTer8cnY6BoRV5ycMkAtrw7vYqTIleMcGTnyNlhp3lMp8AYk3yzS551r4saooC5SY5FLF6fKVxozxyYb02mAMmxTJaTgazXpzorZP/oKh+jLBw5f/3lcemf07wzPGfJA7TyYlLl7pD4jwBPkOLX7Cu+Jp4/vKWHrLueroyfLL3z7LfHSopbteDhVhqLeKZAWrOS6+Zk0CyC3mPNZgMs8APmi0u/pZrKf8AoFoZMBQuMJZzZj/33 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In 2013, commit 72403b4a0fbd ("mm: numa: return the number of base pages altered by protection changes") introduced "numa_huge_pte_updates" vmstat entry, trying to capture how many huge ptes (in reality, PMD thps at that time) are marked by NUMA balancing. This patch proposes to remove it for some reasons. Firstly, the name is misleading. We can have more than one way to have a "huge pte" at least nowadays, and that's also the major goal of this patch, where it paves way for PUD handling in change protection code paths. PUDs are coming not only for dax (which has already came and yet broken..), but also for pfnmaps and hugetlb pages. The name will simply stop making sense when PUD will start to be involved in mprotect() world. It'll also make it not reasonable either if we boost the counter for both pmd/puds. In short, current accounting won't be right when PUD comes, so the scheme was only suitable at that point in time where PUD wasn't even possible. Secondly, the accounting was simply not right from the start as long as it was also affected by other call sites besides NUMA. mprotect() is one, while userfaultfd-wp also leverages change protection path to modify pgtables. If it wants to do right it needs to check the caller but it never did; at least mprotect() should be there even in 2013. It gives me the impression that nobody is seriously using this field, and it's also impossible to be serious. We may want to do it right if any NUMA developers would like it to exist, but we should do that with all above resolved, on both considering PUDs, but also on correct accountings. That should be able to be done on top when there's a real need of such. Cc: Huang Ying Cc: Mel Gorman Cc: Alex Thorlton Cc: Rik van Riel Signed-off-by: Peter Xu --- include/linux/vm_event_item.h | 1 - mm/mprotect.c | 8 +------- mm/vmstat.c | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 747943bc8cc2..2a3797fb6742 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -59,7 +59,6 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, OOM_KILL, #ifdef CONFIG_NUMA_BALANCING NUMA_PTE_UPDATES, - NUMA_HUGE_PTE_UPDATES, NUMA_HINT_FAULTS, NUMA_HINT_FAULTS_LOCAL, NUMA_PAGE_MIGRATE, diff --git a/mm/mprotect.c b/mm/mprotect.c index 222ab434da54..21172272695e 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -363,7 +363,6 @@ static inline long change_pmd_range(struct mmu_gather *tlb, pmd_t *pmd; unsigned long next; long pages = 0; - unsigned long nr_huge_updates = 0; struct mmu_notifier_range range; range.start = 0; @@ -411,11 +410,8 @@ static inline long change_pmd_range(struct mmu_gather *tlb, ret = change_huge_pmd(tlb, vma, pmd, addr, newprot, cp_flags); if (ret) { - if (ret == HPAGE_PMD_NR) { + if (ret == HPAGE_PMD_NR) pages += HPAGE_PMD_NR; - nr_huge_updates++; - } - /* huge pmd was handled */ goto next; } @@ -435,8 +431,6 @@ static inline long change_pmd_range(struct mmu_gather *tlb, if (range.start) mmu_notifier_invalidate_range_end(&range); - if (nr_huge_updates) - count_vm_numa_events(NUMA_HUGE_PTE_UPDATES, nr_huge_updates); return pages; } diff --git a/mm/vmstat.c b/mm/vmstat.c index 73d791d1caad..53656227f70d 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1313,7 +1313,6 @@ const char * const vmstat_text[] = { #ifdef CONFIG_NUMA_BALANCING "numa_pte_updates", - "numa_huge_pte_updates", "numa_hint_faults", "numa_hint_faults_local", "numa_pages_migrated",