From patchwork Wed Jul 3 21:29:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13722798 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 78716C31D97 for ; Wed, 3 Jul 2024 21:29:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98EA26B008A; Wed, 3 Jul 2024 17:29:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 966F66B008C; Wed, 3 Jul 2024 17:29:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79CD96B0092; Wed, 3 Jul 2024 17:29:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 612A86B008A for ; Wed, 3 Jul 2024 17:29:31 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1CC6A160E9E for ; Wed, 3 Jul 2024 21:29:31 +0000 (UTC) X-FDA: 82299732942.18.E63A358 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 0B06EA0017 for ; Wed, 3 Jul 2024 21:29:28 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FPAwxZhl; spf=pass (imf25.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720042156; a=rsa-sha256; cv=none; b=L3EmKIE22jDs/4KLZJM331S/AINOfjTP1CuVNT5gGslMquk3s5NibHkmDXCnfdzFMuapft UVn+cIY2EGstOqZJhrfaCQzYVYx0heuHpDDKCROEHC8DI2xDqG4y/A+Mybb0O+sbWwyH83 tX6yZmhbTxKXAJVp0lBlqigFwFJoqEU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FPAwxZhl; spf=pass (imf25.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720042156; 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=kBb1WRgJKUF/BrRD+S08V86bZ4GMpbM7jlZuutVuXiIOvsXGymeSzR2Xo5gEwpRwWpvU5x 4f4rApXNOyMZOJa/+UYw2T9jUZO/GMsKorcqrXWo65hg4QOtsGhRS3fB01dsjiqrtRtZkh 7zG2tefqqwzvZQhSIvHq0dFIcKpCOps= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720042168; 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=FPAwxZhlakaX8irDqeiSJUbBAK0a6XO/kZJUkmo/l1fIh/Emb7bdnHlyv61MnNjx9Soq1i UQ6obd3e6s68xJifAIP+2S6ucK5Z53P+59Y4s4ks5RStsSgHGFkeWV7Q3zErbknu9vSzrL CIhQu5un+ieWcWMJyM2Hw1NHPRQUYrw= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-8kQ0VApiPgypKsWY1gy0pg-1; Wed, 03 Jul 2024 17:29:26 -0400 X-MC-Unique: 8kQ0VApiPgypKsWY1gy0pg-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4464454e329so1957721cf.1 for ; Wed, 03 Jul 2024 14:29:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720042166; x=1720646966; 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=GKexdPEncSrcXbpefNcOovB/cKVgqbikGSrtbi4cqFpQFmEUrLCPAO2iWPmjqFW+DS G6tv05s0yiQdje5RICoel/nQgznGttQcsxfTEszyq9iZ0iNxWBscl8pvQcbKzIu05pXs +1AnSq+0q3a7fyMo4tXy0byRe5uFpRz0j0VKHGMSbKzTTUrjjOAhrQETvf+Rh/DB/FpQ Er3qRD5FxNQXZBw6ELCDpIQzCy145oAba8Flxsk2UKEcK7Wa31ZDyPCjeLa6AEPKxXou FbrT4q2A99e5RI8OuxOpZNq49yMZVTBY65dUn8j0G+dr6OM7KdC1IYKLJgCopku8DoBD A7Bw== X-Forwarded-Encrypted: i=1; AJvYcCXnQtuw0Kza0Him4lx2yqyGTr29lIIkgO4FhLarUN3joq7L5//6cPmykbY+bk4f4c0KbqAH5U4Qf14OQzmrLqPRZkI= X-Gm-Message-State: AOJu0YwO/CICJ766kp4vsMQHLVKe7AitZQXUknh8adBsqTbc6atYFGTm iNTYStkyfH5HQSai8SI7XQXL6/rd4pQhbgrM7VLZebHV/qvHNhPmaIxb8TmrJZ0HYQV0om9/pCl dlAlvvhWtgDSY8cow4FdxdC9juval85JbplaSmu4Qdoreeko0 X-Received: by 2002:a05:622a:1a29:b0:446:5c96:3e39 with SMTP id d75a77b69052e-44662c7b9b6mr149928221cf.2.1720042165791; Wed, 03 Jul 2024 14:29:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMMhz5U/uaY0swHE/aSBQQusLb0Xfs1HUkfM825Vkmolo2nubsLeOfdQnkewhNugg6U8gw9g== X-Received: by 2002:a05:622a:1a29:b0:446:5c96:3e39 with SMTP id d75a77b69052e-44662c7b9b6mr149928031cf.2.1720042165404; Wed, 03 Jul 2024 14:29:25 -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 d75a77b69052e-4465143eb1csm54337481cf.57.2024.07.03.14.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 14:29:25 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox , Mel Gorman , Dave Jiang , linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Rik van Riel , Vlastimil Babka , Nicholas Piggin , Christophe Leroy , Andrew Morton , Huang Ying , Oscar Salvador , "Aneesh Kumar K . V" , Thomas Gleixner , Dave Hansen , x86@kernel.org, Ingo Molnar , "Kirill A . Shutemov" , Dan Williams , Borislav Petkov , peterx@redhat.com, Hugh Dickins , Rick P Edgecombe , Alex Thorlton Subject: [PATCH v2 2/8] mm/mprotect: Remove NUMA_HUGE_PTE_UPDATES Date: Wed, 3 Jul 2024 17:29:12 -0400 Message-ID: <20240703212918.2417843-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240703212918.2417843-1-peterx@redhat.com> References: <20240703212918.2417843-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: d14jrsiohfu4iddwhzbk1e9iq8y9g5ng X-Rspamd-Queue-Id: 0B06EA0017 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1720042168-456845 X-HE-Meta: U2FsdGVkX19BrY6bsKlUsqwHissgtvqXwSU5wwromwalC8eNPbjChyRgmn4m576jMJYMkwD4dbR5o0nFXRTIbNKnDdGuHeor5kK191NSDLc33avq8WklHsyuGO8l0ppRnPS5VPgIehJIBvimVEjwYlJsoihdeVJ3AXFNEuU7BpAlnQYvOueQeGrwtQNqtwWKYyojAUj5uVkGEdDF1CqwX4WMZUbeqDM7V9gp2c1PODoKuNSrQznErlXKI21/WuWEyHP7c+V5aSLURAcllujPjaH60NO114K5PX73oU/ACC3mNIkG7y1kRWH/XykFYf9z6VnxRWFMqB85azzOSwx6tV4F7L+5hEagdRtsq+tiPeBSk/T7dN/QIkQcg9pxzLBXf9gaSJD3nsg1tLmNt/0ydCSIj/7wd2uMrbEcq8GDBh4RZWXmGRdSPZLw8qyeE6QH3ImntJ5/MT7XN7kmgaixJZskL0y6XWdnKsQe5rNvm5OLmLjVosMNDnfFKAjrh8mXz5murVvdBk7SYfNk7JpDCmuZkoAtBMMl2/FXMtVUaGH8ymPIYpCGnA23YG4kZ0GZna8lf56f4hKNMwOnHzCVTd2GNqAmcTOLzD0lNE2ma7n+vzK9JiNV9S1b6Tv+2LmlT8GeWU7jpfxPG0BVOX4M1Sy3ffTysQRg5sw7YEkDz8FOoQNIZntpqKH8umL0Rn7ewWFIqGVwMtrjv3He6x9nRj0UVrdRlDnwxEE0/aGnYKz3+sML1sgR8zQBJxBIeyNPZVdYyUIq88Dm2s7zie8ZjUp2y4r+M3/6Br7VP3zDpLBfRJfyxOO+dp4NGEEhInGqsdrnOK9XDN6sAY1JY5zgCmhksQiG+QGCTG6R+Cjd7Sar06Wfil0stRqd5efnJDICHIuECSBGFY0OVM9AZiaMdE0rW2Vj0aIGM35UneH+iRO3CCP+LfP6SiGqnlXafoanxYtlwN0AGyf6GBn09Ce tKgIcDhg DsjhCPnZ+DFvfUV5To1uhISz5AVctOcUFbsIHE55mLprpM+9LAqeOk0DtwOjDrur6eCG9vAvcna9NdYkTcKEE+q+tcbyKs6zlZ0mkWzIeZJArBcbWcX+itr2pahr0tFyOwTP04l9x6lG43jV7s6KQPdFKf3JqW3VLvj+TB1mzV2anKm1GpY1p1FpSDbhsqklh3oA6C7i0XuX4FibFznEe/bu1xb6gnGh3h0ehMLrFv+GnbGdQy8XBJJriF74z65vEbVtSHEIPpSDRekzTfiIN2IZY1kdVAfik7USnOt29UXZFAz2iBtXJwqJAKu1Ruj+Rdn+y9kH6UghTbMEnk6SIg4VHi7eskWsI5N+g4+E4d+VfCuRuK9WbpKIIp8zdZJgK5meefWdbeK29qg/09czFDM/UzluT95P6zGnB0J9kAs/+WEoBOISedg/GjR9F4UuYin8ToBH+sBU/Owa8Jf00fV1wnt4noXIdomVdGQpn9wabD+wqzy0O95+U1pOGaIwpzoYoOsoi90yyYXbT1nfHb0KmWL9vWqLMFORo 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",