From patchwork Mon Sep 26 15:26:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 12988973 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 9EB86C32771 for ; Mon, 26 Sep 2022 15:26:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 349466B00FC; Mon, 26 Sep 2022 11:26:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F8176B00FD; Mon, 26 Sep 2022 11:26:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C0118E0066; Mon, 26 Sep 2022 11:26:32 -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 0CCA86B00FC for ; Mon, 26 Sep 2022 11:26:32 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D149BA62FF for ; Mon, 26 Sep 2022 15:26:31 +0000 (UTC) X-FDA: 79954613382.10.93672C6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 3FCBE2000A for ; Mon, 26 Sep 2022 15:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664205989; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=YcUAoJPx/293KJLL46ZZ2kLyCO3l5xX7bQLDqEviC+8=; b=IlWrkZbQ5lrv6Gs4okatuS0CdAbXeesfiRMaODrRksrV7xKFd7kPNLBkOLjSAncdySTZZu f0Sz8TJz0L5paBlscOhTarH8LstHcRyMlyRU6iIlyhIbn2POOcNMZoGkQhbJF8yIPjR5PU EV/llk+xxVVdpbGrddUls2beDSIc+1A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-vIy5ixN0PjmWNTQVGUCBmg-1; Mon, 26 Sep 2022 11:26:24 -0400 X-MC-Unique: vIy5ixN0PjmWNTQVGUCBmg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8541858F13; Mon, 26 Sep 2022 15:26:23 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.106]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBAFDC15BA5; Mon, 26 Sep 2022 15:26:19 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, David Hildenbrand , Linus Torvalds , Andrew Morton , Mel Gorman , Dave Chinner , Nadav Amit , Peter Xu , Andrea Arcangeli , Hugh Dickins , Vlastimil Babka , Michael Ellerman , Nicholas Piggin , Mike Rapoport , Anshuman Khandual Subject: [PATCH RFC 0/5] mm/autonuma: replace savedwrite infrastructure Date: Mon, 26 Sep 2022 17:26:13 +0200 Message-Id: <20220926152618.194810-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664205990; a=rsa-sha256; cv=none; b=HCz2Vj+5ajo3dFcaNBAsXmgCPH5z5Pl22KN206ofgkBQcefE4N010t0HieHDVwyY9n93HE zapX0VoWmlcs6Y15syVCUbvSewAscO84rDBkdI33THGMdARprYVcjKyoJOHln4k5DT1LBY srwxropQidwY1oLRaqyblaDBDD4TMaA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IlWrkZbQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664205990; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=YcUAoJPx/293KJLL46ZZ2kLyCO3l5xX7bQLDqEviC+8=; b=QiOiCsT04s7j2PT17Dmrv+cvllv0thlaKo/o7d7YYA5/4W/nT7ESHqLRlrVV2aa6o0BL8u Ygzpfow1NBMV50YHMZ9VY50/nbTwcN1tYU/uwziEQR3l1Bef+kFyj+LM394xhdT3xXThJ3 cRIyINTfn84YdtQ2gh0tT+CQ9x0PihQ= X-Rspamd-Server: rspam03 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IlWrkZbQ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com X-Stat-Signature: 7yjoj1a5jw11xd3dwc1gohzc7ch9spam X-Rspamd-Queue-Id: 3FCBE2000A X-HE-Tag: 1664205990-509282 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: As discussed in my talk at LPC, we can reuse the same mechanism for deciding whether to map a pte writable when upgrading permissions via mprotect() -- e.g., PROT_READ -> PROT_READ|PROT_WRITE -- to replace the savedwrite infrastructure used for NUMA hinting faults (e.g., PROT_NONE -> PROT_READ|PROT_WRITE). Instead of maintaining previous write permissions for a pte/pmd, we re-determine if the pte/pmd can be writable. The big benefit is that we have a common logic for deciding whether we can map a pte/pmd writable on protection changes. For private mappings, there should be no difference -- from what I understand, that is what autonuma benchmarks care about. I ran autonumabench on a system with 2 NUMA nodes, 96 GiB each via: perf stat --null --repeat 10 The numa1 benchmark is quite noisy in my environment. I suspect that there is no actual change in performance, even though the numbers indicate that this series might improve performance slightly. numa1: mm-stable: 156.75 +- 11.67 seconds time elapsed ( +- 7.44% ) mm-stable++: 147.50 +- 9.35 seconds time elapsed ( +- 6.34% ) numa2: mm-stable: 15.9834 +- 0.0589 seconds time elapsed ( +- 0.37% ) mm-stable++: 16.1467 +- 0.0946 seconds time elapsed ( +- 0.59% ) It is worth noting that for shared writable mappings that require writenotify, we will only avoid write faults if the pte/pmd is dirty (inherited from the older mprotect logic). If we ever care about optimizing that further, we'd need a different mechanism to identify whether the FS still needs to get notified on the next write access. In any case, such an optimiztion will then not be autonuma-specific, but mprotect() permission upgrades would similarly benefit from it. Cc: Linus Torvalds Cc: Andrew Morton Cc: Mel Gorman Cc: Dave Chinner Cc: Nadav Amit Cc: Peter Xu Cc: Andrea Arcangeli Cc: Hugh Dickins Cc: Vlastimil Babka Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Mike Rapoport Cc: Anshuman Khandual David Hildenbrand (4): mm/mprotect: minor can_change_pte_writable() cleanups mm/huge_memory: try avoiding write faults when changing PMD protection mm/autonuma: use can_change_(pte|pmd)_writable() to replace savedwrite mm: remove unused savedwrite infrastructure Nadav Amit (1): mm/mprotect: allow clean exclusive anon pages to be writable arch/powerpc/include/asm/book3s/64/pgtable.h | 80 +------------------- arch/powerpc/kvm/book3s_hv_rm_mmu.c | 2 +- include/linux/mm.h | 2 + include/linux/pgtable.h | 24 ------ mm/debug_vm_pgtable.c | 32 -------- mm/huge_memory.c | 66 ++++++++++++---- mm/ksm.c | 9 +-- mm/memory.c | 19 ++++- mm/mprotect.c | 23 +++--- 9 files changed, 93 insertions(+), 164 deletions(-)