From patchwork Tue Sep 3 23:22:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Yznaga X-Patchwork-Id: 13789500 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 D2076CD37B1 for ; Tue, 3 Sep 2024 23:23:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 622768D01F4; Tue, 3 Sep 2024 19:23:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D1FC8D01E4; Tue, 3 Sep 2024 19:23:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 474D48D01F4; Tue, 3 Sep 2024 19:23:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 25F4D8D01E4 for ; Tue, 3 Sep 2024 19:23:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A0283C08FF for ; Tue, 3 Sep 2024 23:23:52 +0000 (UTC) X-FDA: 82525006704.22.2B5058F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 74722C0002 for ; Tue, 3 Sep 2024 23:23:50 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Lgqq6CIz; spf=pass (imf28.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725405755; 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:in-reply-to:references:references:dkim-signature; bh=IZQX5Rr0ub/XJMfRdfY262glhjZWupIHzaraDs2Ywu8=; b=eySIjwgR8Rx66LE2ID5SK8OKEOaB0DE3Jqr+a/C4OI37W6XzEKQBrO9tZYxUEnvyV4cUGj u3rEdah/GBMB2zpDkq64KtyuLl4k8FMMlgJHUpWa1M/xoHYaFFDZpDBtjdfhW58QLSVD7Z RaCK+0wW3l0czp69OnyFHh7wHac39ag= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=Lgqq6CIz; spf=pass (imf28.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com; dmarc=pass (policy=reject) header.from=oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725405755; a=rsa-sha256; cv=none; b=52AtqbIq08N68DN9vruIC0aLG5/yuErzu8mrRAj2jwPdHHswnJKYyzP1BO/cod2upBnGkH NxiKGnCHrbUr86L9MeNG1JECKZbKZnhiN8lpn4ElRu4v3s48JXCxd6qDQwmhWyXTA07pPU BqCYBzPDPTxeGGEfYiURw7NdpxLj//Q= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483LBXtV019214; Tue, 3 Sep 2024 23:23:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=corp-2023-11-20; bh=I ZQX5Rr0ub/XJMfRdfY262glhjZWupIHzaraDs2Ywu8=; b=Lgqq6CIzpuQX3U9X6 iDa58SGs4E0AAapCVCBdEQV877eZHX/dUHEHyK6LTiS6pGCk5JUG8g43WwdiC9jJ ZrKgW8RSINLnh7hb74L3mn/6X7muQGneLkQSOvvOnXiVKWY5ACbPi1G5jZF/GYtY 6tWLZdVZ9UleXIrnz9Q8Ho4mtzdsmuB6jSwuFYHJZ6KmSD4BZYVfAy+KXYlDUBmR i/iHccgvQVxuoJQshtVXcBUs3OktK3mu3Wv5ja0oR1UjkbM1G1H+uBz2iAsfYWE4 ktReTIrdKQ/MpcGjsU5QimzV0roVztQ0ppHy13/qvSRm1rCYpdhxzoUEfLcszL1E fhY/Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41dw51t439-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 23:23:36 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 483MmNpe001958; Tue, 3 Sep 2024 23:23:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 41bsmfmnf8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 23:23:35 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 483NMkfI040456; Tue, 3 Sep 2024 23:23:34 GMT Received: from localhost.us.oracle.com (dhcp-10-159-133-114.vpn.oracle.com [10.159.133.114]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 41bsmfmmwr-7; Tue, 03 Sep 2024 23:23:33 +0000 From: Anthony Yznaga To: akpm@linux-foundation.org, willy@infradead.org, markhemm@googlemail.com, viro@zeniv.linux.org.uk, david@redhat.com, khalid@kernel.org Cc: anthony.yznaga@oracle.com, andreyknvl@gmail.com, dave.hansen@intel.com, luto@kernel.org, brauner@kernel.org, arnd@arndb.de, ebiederm@xmission.com, catalin.marinas@arm.com, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mhiramat@kernel.org, rostedt@goodmis.org, vasily.averin@linux.dev, xhao@linux.alibaba.com, pcc@google.com, neilb@suse.de, maz@kernel.org Subject: [RFC PATCH v3 06/10] mm/mshare: Add vm flag for shared PTEs Date: Tue, 3 Sep 2024 16:22:37 -0700 Message-ID: <20240903232241.43995-7-anthony.yznaga@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240903232241.43995-1-anthony.yznaga@oracle.com> References: <20240903232241.43995-1-anthony.yznaga@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-03_11,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 mlxlogscore=679 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2409030187 X-Proofpoint-ORIG-GUID: atzil67mt7N0tlp4YnnhsIyhWgXr7t7D X-Proofpoint-GUID: atzil67mt7N0tlp4YnnhsIyhWgXr7t7D X-Stat-Signature: z13z74b4fs9ghdtcqkrqn7hkt37ambc5 X-Rspam-User: X-Rspamd-Queue-Id: 74722C0002 X-Rspamd-Server: rspam02 X-HE-Tag: 1725405830-150626 X-HE-Meta: U2FsdGVkX183Uuw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g4GTFRf16knAouq5THTW+hcqK2qnJSJsSrHBKs7QxSjtECe1WNzfnlWBelWm/MvP02OxBMUkbJ4xjEQxx89UfCwtDYOJWJdMVRz7O4W1XbU1uqVitrTArc2gmocYN3kswKdZF/3mqQCYchOVz6GLkOaugjm4Kx+kdgzDiScgfrKYY0y+MRFUizcoogiDb4G812L35IbFLoERsvDVw9vuzm6jwrhsyloPEoSps= 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: From: Khalid Aziz Add a bit to vm_flags to indicate a vma shares PTEs with others. Add a function to determine if a vma shares PTEs by checking this flag. This is to be used to find the shared page table entries on page fault for vmas sharing PTEs. Signed-off-by: Khalid Aziz Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Anthony Yznaga --- include/linux/mm.h | 7 +++++++ include/trace/events/mmflags.h | 3 +++ mm/internal.h | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 6549d0979b28..3aa0b3322284 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -413,6 +413,13 @@ extern unsigned int kobjsize(const void *objp); #define VM_DROPPABLE VM_NONE #endif +#ifdef CONFIG_64BIT +#define VM_SHARED_PT_BIT 41 +#define VM_SHARED_PT BIT(VM_SHARED_PT_BIT) +#else +#define VM_SHARED_PT VM_NONE +#endif + #ifdef CONFIG_64BIT /* VM is sealed, in vm_flags */ #define VM_SEALED _BITUL(63) diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index b63d211bd141..e1ae1e60d086 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -167,8 +167,10 @@ IF_HAVE_PG_ARCH_X(arch_3) #ifdef CONFIG_64BIT # define IF_HAVE_VM_DROPPABLE(flag, name) {flag, name}, +# define IF_HAVE_VM_SHARED_PT(flag, name) {flag, name}, #else # define IF_HAVE_VM_DROPPABLE(flag, name) +# define IF_HAVE_VM_SHARED_PT(flag, name) #endif #define __def_vmaflag_names \ @@ -204,6 +206,7 @@ IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY, "softdirty" ) \ {VM_HUGEPAGE, "hugepage" }, \ {VM_NOHUGEPAGE, "nohugepage" }, \ IF_HAVE_VM_DROPPABLE(VM_DROPPABLE, "droppable" ) \ +IF_HAVE_VM_SHARED_PT(VM_SHARED_PT, "sharedpt" ) \ {VM_MERGEABLE, "mergeable" } \ #define show_vma_flags(flags) \ diff --git a/mm/internal.h b/mm/internal.h index b4d86436565b..8005d5956b6e 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -1578,4 +1578,9 @@ void unlink_file_vma_batch_init(struct unlink_vma_file_batch *); void unlink_file_vma_batch_add(struct unlink_vma_file_batch *, struct vm_area_struct *); void unlink_file_vma_batch_final(struct unlink_vma_file_batch *); +static inline bool vma_is_shared(const struct vm_area_struct *vma) +{ + return VM_SHARED_PT && (vma->vm_flags & VM_SHARED_PT); +} + #endif /* __MM_INTERNAL_H */