linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-s390@vger.kernel.org
Cc: shu wang <malate_wangshu@hotmail.com>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Peter Xu <peterx@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Matthew Wilcox <willy@infradead.org>,
	Michel Lespinasse <walken@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mike Kravetz <mike.kravetz@oracle.com>
Subject: [RFC PATCH 4/5] hugetlb: don't permit pmd sharing if soft dirty in use
Date: Wed, 10 Feb 2021 16:03:21 -0800	[thread overview]
Message-ID: <20210211000322.159437-5-mike.kravetz@oracle.com> (raw)
In-Reply-To: <20210211000322.159437-1-mike.kravetz@oracle.com>

If page modifications are being monitoried with the soft dirty mechanism,
then this information is contained in page table entries.  Tracking is
enabled on a 'per-process' basis.  hugetlb pmd sharing allows processes
to share page table entries.  This makes pmd sharing incompatible with
soft dirty monitoring.  So, pmd sharing must be disabled if soft dirty
tracking is in use.

The VM_SOFTDIRTY flag is set in all vma's by default.  When soft dirty
monitoring is started, the flag is cleared.  We can therefore allow pmd
sharing in vmas with the VM_SOFTDIRTY flag set.  Check this when deciding
to perform pmd sharing.

A subsequent patch will add code to allow soft dirty monitoring for hugetlb
vmas.  Any existing pmd sharing will be undone at that time.

Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
 mm/hugetlb.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index b561b6867ec1..cf4aa63be9b1 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5285,6 +5285,13 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr)
 	unsigned long base = addr & PUD_MASK;
 	unsigned long end = base + PUD_SIZE;
 
+	/*
+	 * Do not allow pmd sharing if soft dirty tracking is in use.
+	 */
+	if (IS_ENABLED(CONFIG_MEM_SOFT_DIRTY) &&
+				!(vma->vm_flags & VM_SOFTDIRTY))
+		return false;
+
 	/*
 	 * check on proper vm_flags and page table alignment
 	 */
-- 
2.29.2


  parent reply	other threads:[~2021-02-11  0:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11  0:03 [RFC PATCH 0/5] Add hugetlb soft dirty support Mike Kravetz
2021-02-11  0:03 ` [RFC PATCH 1/5] hugetlb: add hugetlb helpers for " Mike Kravetz
2021-02-17 16:24   ` Peter Xu
2021-02-18 22:58     ` Mike Kravetz
2021-02-24 16:46     ` Gerald Schaefer
2021-02-24 16:55       ` Gerald Schaefer
2021-02-11  0:03 ` [RFC PATCH 2/5] hugetlb: enhance hugetlb fault processing to support soft dirty Mike Kravetz
2021-02-17 19:32   ` Peter Xu
2021-02-18 23:26     ` Mike Kravetz
2021-02-11  0:03 ` [RFC PATCH 3/5] mm proc/task_mmu.c: add soft dirty pte checks for hugetlb Mike Kravetz
2021-02-17 19:35   ` Peter Xu
2021-02-18 23:59     ` Mike Kravetz
2021-02-11  0:03 ` Mike Kravetz [this message]
2021-02-17 19:44   ` [RFC PATCH 4/5] hugetlb: don't permit pmd sharing if soft dirty in use Peter Xu
2021-02-11  0:03 ` [RFC PATCH 5/5] mm proc/task_mmu.c: add hugetlb specific routine for clear_refs Mike Kravetz
2021-02-17 20:25   ` Peter Xu
2021-02-19  0:14     ` Mike Kravetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210211000322.159437-5-mike.kravetz@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=aarcange@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=malate_wangshu@hotmail.com \
    --cc=peterx@redhat.com \
    --cc=walken@google.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).