From patchwork Fri Jan 24 23:54:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Yznaga X-Patchwork-Id: 13950026 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 7869AC02181 for ; Fri, 24 Jan 2025 23:55:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0AFF2800B2; Fri, 24 Jan 2025 18:55:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CB90A2800B0; Fri, 24 Jan 2025 18:55:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B36572800B2; Fri, 24 Jan 2025 18:55:41 -0500 (EST) 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 85F2C2800B0 for ; Fri, 24 Jan 2025 18:55:41 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3E3D0B22B1 for ; Fri, 24 Jan 2025 23:55:41 +0000 (UTC) X-FDA: 83044005282.29.1E4615F Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf04.hostedemail.com (Postfix) with ESMTP id 435FA4000B for ; Fri, 24 Jan 2025 23:55:39 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=XLe18pnp; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf04.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737762939; a=rsa-sha256; cv=none; b=mJeUVIojo1frk8G3gi2yk2VWDad2gZauEGhzOqRFZ3vUiWdAgGGVT8dftXZGzhIxJcveVZ c3/9TYl31bnYnmCpUvyjBnb2akjCsuI4hnulqgJTZU7Xjq1j1pdDKVnchlir4bz1NavtMq v6pBecUmf+06Cu6BPb8Y3aZinjVkTQE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=XLe18pnp; dmarc=pass (policy=reject) header.from=oracle.com; spf=pass (imf04.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=anthony.yznaga@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737762939; 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=Gmt7QB3NcOmNhQjBszQbUI804S0rjvRagMuhEI7yvaU=; b=uHY0dlAgpHI5z3Mf9QHtpriZpaKQ0ZfkPNANVGai+cemtgHHbrWJcuQbd42afnY/OS0v2O e7raY6C5tctNUuVPzMmzW9SLiUYd+PyftjpxuL369k0aXU85jhK2D2egagRAj+4W7Qyq40 UdexN8Tw8Xy6qZAm9FnTDzH1+p5qQNg= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50OIeKEZ031124; Fri, 24 Jan 2025 23:55:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=corp-2023-11-20; bh=Gmt7Q B3NcOmNhQjBszQbUI804S0rjvRagMuhEI7yvaU=; b=XLe18pnpG/WvE0w7WwOXY y5bIblHn+FdWnW185Ykktr4sL6Xalmuzdvdq/qHYMpRSdi04j7yf3G2gLCAOwqeB fG2s3UJ9KB1t74mh62AMLQTe2v8989/wdSHUdojO0jsNTy50uFy027OHPa8QotEv R6Ri1dWaU2E006hYgPKoVSgJf67h/+Jhr1rH5KxT103ZQfoSo0rl3bJ/zsRQI4vh atf7VHTBh+aTE1GNhGUW3jDHJC2/4vgvLBi6Yp3S5ZgtPNJowCSCOF/ZfQknDTFq jC414yxxNtO9fER2M5ALcVKQZveFIoMWPpoENC9GIW3eYktUka4GcR5EX0S0/qs2 Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4485nsmvms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:55:26 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 50OMEpto036739; Fri, 24 Jan 2025 23:55:25 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44917u4aav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:55:25 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 50ONsxPs018051; Fri, 24 Jan 2025 23:55:24 GMT Received: from localhost.us.oracle.com (dhcp-10-65-130-174.vpn.oracle.com [10.65.130.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 44917u49ww-7; Fri, 24 Jan 2025 23:55:24 +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, jthoughton@google.com, corbet@lwn.net, dave.hansen@intel.com, kirill@shutemov.name, luto@kernel.org, brauner@kernel.org, arnd@arndb.de, ebiederm@xmission.com, catalin.marinas@arm.com, mingo@redhat.com, peterz@infradead.org, liam.howlett@oracle.com, lorenzo.stoakes@oracle.com, vbabka@suse.cz, jannh@google.com, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, tglx@linutronix.de, cgroups@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, 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: [PATCH 06/20] mm/mshare: Add a vma flag to indicate an mshare region Date: Fri, 24 Jan 2025 15:54:40 -0800 Message-ID: <20250124235454.84587-7-anthony.yznaga@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250124235454.84587-1-anthony.yznaga@oracle.com> References: <20250124235454.84587-1-anthony.yznaga@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-24_10,2025-01-23_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=724 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501240162 X-Proofpoint-GUID: fAnTHbbqevGjh-8GbPtHZ8_gFx9Uqmua X-Proofpoint-ORIG-GUID: fAnTHbbqevGjh-8GbPtHZ8_gFx9Uqmua X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 435FA4000B X-Stat-Signature: ipsdh6p5at35h6jejyz75kr3886ombo9 X-Rspam-User: X-HE-Tag: 1737762939-913270 X-HE-Meta: U2FsdGVkX199N4zsATf/vy+o84Vk6/vb4tKFPh9Q6VG60Is3rRbBmewoFkAqo41pMEjeZpFLU+ciS12RzdLfy13zKS10KTXPEWjRMLmDIIMmTtqEveIEfCGrbUpTW4sKTZzxX4gT0D8szJBZvMW4rMdyJhVmlhJUYMqxpSJdmZsvPGiXdf/pPg/adaZUTxWCSfYgILFwnghq7idsX7Yc66/fhxPjkP+a+mPllOlAfEQ2ZNyhsSknkhBU2y9Gy9fjTKep3lJE60qM7Snoujkj24gwlX9mvgLleWW8PEkkGDLGHn4pilOat3MCRNrC9oWwV9lyvNFvmxGnZHiysSpIBzEBq45uCYeL4w4CqL47WztbzPwp8Nova14lB8opt2jZ2mAq+6q2TqMLXwK1M7Iz6oeAx/u8YOrQmjPeOD4Yd32tWn7Q+yg4n5QYbl+yRSiROMXg4EDIGsLjT1KGE7KGNdu7aleTVxuq5qY4aJIWBrwUnGLDkW0swv9taReizzNUJFoSH45X9ozXfW8Wu4HnMm9i4URMywb6snsJD3vQA5iKv3XbDAvsjg+VAx6QFaGmIlmv/8OAXsXILfXBmRjyHqmBA/N3n4+qPUo5TL/kBg+dYjBU3ylf7hX1iItCe3QaGlXBEdwPR2IkZgfInZOYyB8+TUqWGa7bed3uo77mPT85J3+/AVEtL2q0FfIXus8TtcwvIgaMydE5CPEEH42h+b1SQD9MgizTUpoh6QfMvBr8rXGsQBY3SdNvT+BC9vrUAvju2wI7P/+Kmvw8vBKiSMpde/IiGf9TWrV0h5yDuviq4gVnkhArywMNK4P6CofBoX/g+/sBgoonDsSKJJRdQlywfOeRmlUzGXeXS4Cqq9YYKtTmo35TQWPWx3pv3WbVPvydvUrCUSzSwo04frFMCRm0AvQSTBE4kQusPn4r7qJ33nvOglKAs9fRzKQQ6xrnq9JV9NQcsJrs8AOfiLv H/9A/mkV CnDx1YMlkeJUe5bhzG0He4UMEScnwjqrTIqsSxE/o/lshbXFvjStJtgzws3aNkFmxa2AdJjGG0by1xAjBH18tx0wa+l6suOEN0oPzdoMkNgbrR0JvlXE1/08sffppGRcSq2n/avOoGhQFxd7YcDcIPekZRUlx7guy83hcMFBhTGcs8psy0VN+nqdZgxG4VABUTAOT7H748Ogm1/gWYyyQaFJH28TDBTzAKzSyO3Y5mQt1T6F1UjLlYQ5nuczTLNIHGSt3dhtl4I3h74zkclk+vP/p1MSVGH86pN9n3rQh8JFq4RHw1YMonG2AGxo39wRbRQSO 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 An mshare region contains zero or more actual vmas that map objects in the mshare range with shared page tables. Signed-off-by: Khalid Aziz Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Anthony Yznaga --- include/linux/mm.h | 19 +++++++++++++++++++ include/trace/events/mmflags.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 8483e09aeb2c..bca7aee40f4d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -440,6 +440,13 @@ extern unsigned int kobjsize(const void *objp); #define VM_DROPPABLE VM_NONE #endif +#ifdef CONFIG_MSHARE +#define VM_MSHARE_BIT 41 +#define VM_MSHARE BIT(VM_MSHARE_BIT) +#else +#define VM_MSHARE VM_NONE +#endif + #ifdef CONFIG_64BIT /* VM is sealed, in vm_flags */ #define VM_SEALED _BITUL(63) @@ -1092,6 +1099,18 @@ static inline bool vma_is_anon_shmem(struct vm_area_struct *vma) { return false; int vma_is_stack_for_current(struct vm_area_struct *vma); +#ifdef CONFIG_MSHARE +static inline bool vma_is_mshare(const struct vm_area_struct *vma) +{ + return vma->vm_flags & VM_MSHARE; +} +#else +static inline bool vma_is_mshare(const struct vm_area_struct *vma) +{ + return false; +} +#endif + /* flush_tlb_range() takes a vma, not a mm, and can care about flags */ #define TLB_FLUSH_VMA(mm,flags) { .vm_mm = (mm), .vm_flags = (flags) } diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflags.h index 3bc8656c8359..0c7d50ab56cd 100644 --- a/include/trace/events/mmflags.h +++ b/include/trace/events/mmflags.h @@ -160,6 +160,12 @@ IF_HAVE_PG_ARCH_3(arch_3) # define IF_HAVE_VM_DROPPABLE(flag, name) #endif +#ifdef CONFIG_MSHARE +# define IF_HAVE_VM_MSHARE(flag, name) {flag, name}, +#else +# define IF_HAVE_VM_MSHARE(flag, name) +#endif + #define __def_vmaflag_names \ {VM_READ, "read" }, \ {VM_WRITE, "write" }, \ @@ -193,6 +199,7 @@ IF_HAVE_VM_SOFTDIRTY(VM_SOFTDIRTY, "softdirty" ) \ {VM_HUGEPAGE, "hugepage" }, \ {VM_NOHUGEPAGE, "nohugepage" }, \ IF_HAVE_VM_DROPPABLE(VM_DROPPABLE, "droppable" ) \ +IF_HAVE_VM_MSHARE(VM_MSHARE, "mshare" ) \ {VM_MERGEABLE, "mergeable" } \ #define show_vma_flags(flags) \