From patchwork Fri Jun 21 14:24:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13707655 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 15F45C2BBCA for ; Fri, 21 Jun 2024 14:25:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEC398D0175; Fri, 21 Jun 2024 10:25:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C5498D0176; Fri, 21 Jun 2024 10:25:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E75B8D0174; Fri, 21 Jun 2024 10:25:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id DF1388D0175 for ; Fri, 21 Jun 2024 10:25:18 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A2F07120F9E for ; Fri, 21 Jun 2024 14:25:18 +0000 (UTC) X-FDA: 82255118316.16.D79EC13 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 3F6D640007 for ; Fri, 21 Jun 2024 14:25:16 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BPQNmZsd; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1718979908; 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=MJ/z3oUyfvIT45NLtsICo4unaxlXJrC1yYznR3c5j0M=; b=tZzktPgehqUETGTc+OzwsYiE8UxkkAqp66EtwD2+F3gr0C4nB/Md38VCHYllDnqPN6INob cno5fQRf3GdacRKdlAvJU5ZegWp5saiE20eErgCQtU+9BO8DumRi8xXhInwdvgAjOtXSng OqvWJpEHxoCxaMuZAFO/imtstBo3Jao= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BPQNmZsd; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1718979908; a=rsa-sha256; cv=none; b=3bPgVeT8J+kYO2ckhcilBLpwgpcxcYQqbUB7so8DS3SC6c4y1mPMDkbn7kdr9fkQbyFx5l q9U+o+yBv7OG4ehoQEDuLZQ+M0Z+iXBlsxDAead2hCPS8Bzku+MVg4hJw+ZjL06e9WR3df s+DoBZ7iD93tDp6w6cRHEMMpXuz1/R0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718979915; 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=MJ/z3oUyfvIT45NLtsICo4unaxlXJrC1yYznR3c5j0M=; b=BPQNmZsdO0WoRm/VCXOJpG0k9qIztnE/gmqf0kxL8HNySvuLI0pa6d7kE1UsvUTlV94iU/ h59C2e1LAJOJpwY9HQyF5c0xJjSLuumapYErq8ffRf/+OtAXA6KkRhBjNsJ9n7rtCzbCLn /TbyXGGR6/PMSNj7OER4QiCwNMu47UA= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-s31wfH44OY-UMNJccsgR6g-1; Fri, 21 Jun 2024 10:25:12 -0400 X-MC-Unique: s31wfH44OY-UMNJccsgR6g-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-79560b25fc4so14964985a.3 for ; Fri, 21 Jun 2024 07:25:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718979911; x=1719584711; 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=MJ/z3oUyfvIT45NLtsICo4unaxlXJrC1yYznR3c5j0M=; b=YP/1dobzDciaMSXIzCr1MUs+C08siTwQ5pRLsh2WY23dX/yWAB17CFq9bNLUx1pW+Q MHO1MyywMlqF52B6u5NKb+mUB+z7OxJ2a50AmOrELln/azt6xst63zndceQuTIfm8QjR dCN1hk2StEzOqqipG3YVjMIlD2tvaiP7j3TqeYS4JPU7FMNCVW+vYkjK6hkUFBRLqT3q G7h/TuzeqOAhACxXl59frwRiAHbA7XDcU6PiJ65ZZNC6O2Esak7pZ5eJy9PzqdTVdPxT qXdW4/fMiC3ZbvT4Fx98P0sJAX3U//WgnLHEHtmLMa93pZG0CQyns35X0hunrGZmU/1V bWQQ== X-Forwarded-Encrypted: i=1; AJvYcCVsTnvIFfxWLwZE9UKm+2abPG9ViJJkuFzUFdbn5gfrXNzZFAnk7VBqeZAYXgMvQRrR6HfI45lCfRlrxS4m+0oGjHw= X-Gm-Message-State: AOJu0Yyl4/J6fNCKxPc+4YoL/lZpNwJGH5LqKQSA1fQK0Nwh21WfixDD NEUA9kaakW2Ddaj6LOEne0KJq7n9fabf88cPSQLbfWYr2qYghXhiIMbRCJXQMDMTJknt5F2cYF9 KeHwdetPglv89BsLBFV/L5835Si6+cDeJadp/lBwOPuMs0F1F X-Received: by 2002:a05:620a:4610:b0:79b:be0b:7815 with SMTP id af79cd13be357-79bbe0b7c0fmr735910685a.1.1718979911259; Fri, 21 Jun 2024 07:25:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1JVg4Gm5x1JzvXAIal9/bHLuF/aojpegzJFLEbRVA7h1M8KnWp/bZUR1LNlUwbmLSWaEiNQ== X-Received: by 2002:a05:620a:4610:b0:79b:be0b:7815 with SMTP id af79cd13be357-79bbe0b7c0fmr735907585a.1.1718979910823; Fri, 21 Jun 2024 07:25:10 -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 af79cd13be357-79bce944cb2sm90564785a.125.2024.06.21.07.25.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jun 2024 07:25:10 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: x86@kernel.org, Borislav Petkov , Dave Jiang , "Kirill A . Shutemov" , Ingo Molnar , Oscar Salvador , peterx@redhat.com, Matthew Wilcox , Vlastimil Babka , Dan Williams , Andrew Morton , Hugh Dickins , Michael Ellerman , Dave Hansen , Thomas Gleixner , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Rik van Riel , Mel Gorman , "Aneesh Kumar K . V" , Nicholas Piggin , Huang Ying , Alex Thorlton Subject: [PATCH 2/7] mm/mprotect: Remove NUMA_HUGE_PTE_UPDATES Date: Fri, 21 Jun 2024 10:24:59 -0400 Message-ID: <20240621142504.1940209-3-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240621142504.1940209-1-peterx@redhat.com> References: <20240621142504.1940209-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: afmfdohchyrcfndd6jthg4eutpp8mddq X-Rspam-User: X-Rspamd-Queue-Id: 3F6D640007 X-Rspamd-Server: rspam02 X-HE-Tag: 1718979916-271813 X-HE-Meta: U2FsdGVkX1/e9U4BqnN2V1434iGHpoqiNHw9OjFxXrqpWlgw+iqLASQr7edltv9CE45X1UHpEGIFgjcXuVAQcTXIiG0EfzInOf4D0ABfLPSFE7No4IV/scoOnrbZVSnwlAsAvOD5A47Ib6rp2cgzxhefZiAMj9rBombVUKisXB5D5+pzLvq022w/WCaOiJa3qET8v/ON/1FE0B1o2P0gFNEEps2Wdh0y8zbwCI7e/gwCFen7VFjSQE/5zi2gKgM0g4790DTYrnFiAcCb+Cf/CIQqyIQ5IguTIpYPcrdU4dVSpBFoC8Hau9UCg+b7eD9qbDKg241vRGFd8djUTdUhVsuI2C+48clZZasQh7GyAU98GvGbP5qNBPJgsKweubGPwWGSTRgN0ctXpLUFCB9FRi6LEM7PxtGmZY5LvJSKq/6NUHkNqcQ2b2f8+wKx0V1gcgK+Imx4WDaf6/gu/yQ7KM0behJu42rqoa10Q6xHgO6iMzqNKPtKNe50omEmIJQ+Vak0juaJBFGEjg5j43c7wUQPZLQL8mhx/t9BMm0sr0UDlIxHRaPVHnmHJzHzHqnLynU0xcLS5lj5Wdc9qOPXG5zF9mODW1qDAF8+jdbJhq8e7Ihean27JS5QSSRQtJKl0a+VQijP/r8ZDaPgwIFNIbdSLEcjc2vzsm/yAOSGll15KLqftfNOQv3tTlC0sMV3P7MjaYDuvwIZhNWdE/Xr6jXIanocwb0X/bC6hTMHz0SRXtSjJe72ysN2Zmn0jp183li1qZoh3iaRLqDDoQpePVOoQ1aJfY4uojWT5xehcz/UdwSycBiRGQYuhf1WbGnFsF8ZvD2TZAqA68KWvVj3BV0MKfeJZZ3UMm0SHXgLcc77INMUSlEyZHxI/43BfqlnMkbDVXLW+6ge8j+rOplf/jDQbBAMi48TsskqJU4hIDwxGKXdKmbFGOVFelLvd9aToE4cS491ksBDwhRqcuQ ekuBNmMZ lSS1BnnTerxUMO/UZh04QKJWcg6mxKYNJHKKb3Zzzp6d80f7MlkC+0QsVLRMN7JjPP46kJ75jARr0VFMTqLqrPpxqw94jvOmaiDLyne27ZaSS6f5PjhsjbwB04bI8URr8XYg//d4aqqJnwJ/TxLgI/yoMmpXbF5YXxk+ZVfXxxE52w0zI0b60nIj1wdtxq5VI2Z3i9a/eW/7F5Ihzpoe93rDUo0Z7Skn5kuOtNTb18vJDboB2eF5ZJhG+G6HBadSEPa4RpXY/qkuY8m9loeMIYBieq869KsOfNKcfSUojaFem+yZMe5nAlTuY7SR8YnPQHcaq1E8snkJCVgG+aA+OnE30F7yRQEMhmKLnKOOQAe4jP5CTnxsG9rBnqpPZlsoYOyJuU2TrisMta4bWrzZP+xFbaL/FLSuoGczseCRv47t27QfnImzN/bT64M/k/MvixRHZuKjJizb0kwisHNJFg/PYjQQhHReHSkhgdmOZGtopRiX08JQ7zaHSUx1OfqYYMJskLmxmcr6OPMeIDwbFhAMuyIS6yQs/Iv0eUkHfmfn2rnrrBt0Wm9ym8F1rDgQ24ysfZj7Z6UBFkCsabp1sTOv0GQ== 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 73fa5fbf33a3..a76b75d6a8f4 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 6e3347789eb2..be774893f69e 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",