linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Qilong <zhangqilong3@huawei.com>
To: <akpm@linux-foundation.org>, <david@kernel.org>,
	<lorenzo.stoakes@oracle.com>, <corbet@lwn.net>
Cc: <ziy@nvidia.com>, <baolin.wang@linux.alibaba.com>,
	<Liam.Howlett@oracle.com>, <npache@redhat.com>,
	<ryan.roberts@arm.com>, <dev.jain@arm.com>, <baohua@kernel.org>,
	<lance.yang@linux.dev>, <vbabka@suse.cz>, <rppt@kernel.org>,
	<surenb@google.com>, <mhocko@suse.com>, <willy@infradead.org>,
	<wangkefeng.wang@huawei.com>, <sunnanyong@huawei.com>,
	<linux-mm@kvack.org>, <linux-doc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <lianux.mm@gmail.com>,
	<zhangqilong3@huawei.com>
Subject: [PATCH next v2 2/2] mm/huge_memory: Use per-VMA hugepage flag hints for exec THP COW
Date: Fri, 26 Dec 2025 18:03:37 +0800	[thread overview]
Message-ID: <20251226100337.4171191-3-zhangqilong3@huawei.com> (raw)
In-Reply-To: <20251226100337.4171191-1-zhangqilong3@huawei.com>

Using the per-VMA hugepage flag to avoid system wide default
behavior. If 'vma->vm_flags' indicates a preference for huge pages,
then the exec THP COW can be attempted.

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
v2:
- Use 'vma->vm_flags' as hint for exec THP COW suggested by David

---
 mm/memory.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/mm/memory.c b/mm/memory.c
index 691e3ca38cc6..eb2bb36e284c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -6128,10 +6128,17 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf)
 		}
 	}
 
 	if (is_exec_mapping(vm_flags) &&
 	    is_cow_mapping(vm_flags)) {
+		/*
+		 * Reuse the per-VMA flag, only if VM_HUGEPAGE is
+		 * set, do exec THP COW.
+		 */
+		if (!(vm_flags & VM_HUGEPAGE))
+			goto split;
+
 		ret = do_huge_pmd_exec_cow(vmf);
 		if (!(ret & VM_FAULT_FALLBACK))
 			return ret;
 	}
 
-- 
2.43.0



  parent reply	other threads:[~2025-12-26 10:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-26 10:03 [PATCH next v2 0/2] THP COW support for private executable file mmap Zhang Qilong
2025-12-26 10:03 ` [PATCH next v2 1/2] mm/huge_memory: Implementation of THP COW for " Zhang Qilong
2025-12-26 10:03 ` Zhang Qilong [this message]
2025-12-28  3:42 ` [PATCH next v2 0/2] THP COW support for private " Matthew Wilcox
2025-12-30 21:42   ` David Hildenbrand (Red Hat)
2025-12-30 21:39 ` David Hildenbrand (Red Hat)

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=20251226100337.4171191-3-zhangqilong3@huawei.com \
    --to=zhangqilong3@huawei.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=lance.yang@linux.dev \
    --cc=lianux.mm@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=npache@redhat.com \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=sunnanyong@huawei.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=ziy@nvidia.com \
    /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