Message ID | 20250404021902.48863-9-anthony.yznaga@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 BB978C3601B for <linux-mm@archiver.kernel.org>; Fri, 4 Apr 2025 02:19:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 116D8280009; Thu, 3 Apr 2025 22:19:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C2C0280005; Thu, 3 Apr 2025 22:19:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E81A0280008; Thu, 3 Apr 2025 22:19:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B1365280005 for <linux-mm@kvack.org>; Thu, 3 Apr 2025 22:19:43 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 3306CBB739 for <linux-mm@kvack.org>; Fri, 4 Apr 2025 02:19:45 +0000 (UTC) X-FDA: 83294755530.15.E16FCA9 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf06.hostedemail.com (Postfix) with ESMTP id 0BFA1180002 for <linux-mm@kvack.org>; Fri, 4 Apr 2025 02:19:42 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=EEveCq6A; spf=pass (imf06.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=1743733183; 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=P2XFHgeO4VsoVgQxIbbUAqjLop0i7SOFEtZvQx9+un4=; b=F7W8cj9zWZY2yL7fH9yjcX1McnpY8wFyuNGfwk+Jax0/HmqI2QrtRt9/vwJH+UIami+68k n6Ve+fwde80K/+b7pnR7NdVmTK9mPQ2OZ01CGULsNwcWtqYLhSWf/nZq9TS+nGZeFm5lhV zNsR90R+tNUPfiBdXjrey/qYoN0fMwE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=EEveCq6A; spf=pass (imf06.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=1743733183; a=rsa-sha256; cv=none; b=fjG2Y2ik9yIfOzzHXMonJEH0gzw1blpcB9l6ROaqLgzQuuErN67cNF/Q0MsREcq6syh2EJ kwlBAiXXDKwu+xZ1WhYZ0VUL/OGM4Wxap6AB/0H1sd3S2lqw6MRH4vJrxKTXqqnU9EH7z1 mtiGEpUfZZDBIW8l4EYTKLn2E4t16g8= 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 5341N2YB018250; Fri, 4 Apr 2025 02:19:28 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=P2XFH geO4VsoVgQxIbbUAqjLop0i7SOFEtZvQx9+un4=; b=EEveCq6AMr+euQTlVS1HT YDUUD4VMHH7ZeJOrwBHdW1ZNljHVeLPDfiMlRcTMCD3h+Wq3cHHFSUTwHX6TsH7V ne6t8CIVI25Jx9uUQh1dQ1x5cV55hbzK1NnylKABXIXWwTFf21w+9/ej2OEDTScR sVpqS8Uri8pFmytEG1l9dw/VzxFqLk/tUgeHHAARRLs5uSZXH4OmTkYmQVJz1FTz bqXKxUjGrsTIfNYV2183lwK4TcTTGkG8lsIxPWPCyQxD/7TsRmeK0EFeJt3pnmhm Yzs5LFhxV/GDwHfUTgnBkOgddmapHWzHTEaYX+RNX6NtKjcS32bAnfqeENJbUqcJ g== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 45p9dtp4n4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Apr 2025 02:19:27 +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 5340dfDs017355; Fri, 4 Apr 2025 02:19:26 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 45t2pspjc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 04 Apr 2025 02:19:26 +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 5342H8gq030074; Fri, 4 Apr 2025 02:19:25 GMT Received: from localhost.localdomain (ca-dev60.us.oracle.com [10.129.136.27]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 45t2pspj73-9; Fri, 04 Apr 2025 02:19:25 +0000 From: Anthony Yznaga <anthony.yznaga@oracle.com> 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: [PATCH v2 08/20] mm/mshare: flush all TLBs when updating PTEs in an mshare range Date: Thu, 3 Apr 2025 19:18:50 -0700 Message-ID: <20250404021902.48863-9-anthony.yznaga@oracle.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250404021902.48863-1-anthony.yznaga@oracle.com> References: <20250404021902.48863-1-anthony.yznaga@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-04_01,2025-04-03_03,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2502280000 definitions=main-2504040014 X-Proofpoint-ORIG-GUID: x_lMRsGn6qiH95awEN80uSxpY_3-EKKe X-Proofpoint-GUID: x_lMRsGn6qiH95awEN80uSxpY_3-EKKe X-Rspamd-Queue-Id: 0BFA1180002 X-Stat-Signature: t3rj1m9zczbjupzsyho9ooc3ib8ufqhj X-Rspam-User: X-Rspamd-Server: rspam12 X-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1H/mJUPrcmOtA7rM13YRv7xr0kfAxJiizI54spPLLjdkHsWKMaWiSX1brmMiCjiaQW0E7cSDuSNWG1E2JdcDf6kJC9S6Ma0qdzLM53PLcm/A577WgvjAdPOcWg9PK4EpQyONyZaIvjeASNTuu8SYUe2f8RYUf93hyWVyxYgVQG5pafL9h3Pk29B+U6KXR8pABVzz9ZQgQ== 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Add support for shared PTEs across processes
|
expand
|
diff --git a/mm/mshare.c b/mm/mshare.c index 6bdbcfa8deea..792d86c61042 100644 --- a/mm/mshare.c +++ b/mm/mshare.c @@ -16,8 +16,10 @@ #include <linux/fs.h> #include <linux/fs_context.h> #include <linux/mman.h> +#include <linux/mmu_notifier.h> #include <uapi/linux/magic.h> #include <linux/falloc.h> +#include <asm/tlbflush.h> const unsigned long mshare_align = P4D_SIZE; const unsigned long mshare_base = mshare_align; @@ -29,6 +31,17 @@ struct mshare_data { unsigned long start; unsigned long size; unsigned long flags; + struct mmu_notifier mn; +}; + +static void mshare_invalidate_tlbs(struct mmu_notifier *mn, struct mm_struct *mm, + unsigned long start, unsigned long end) +{ + flush_tlb_all(); +} + +static const struct mmu_notifier_ops mshare_mmu_ops = { + .arch_invalidate_secondary_tlbs = mshare_invalidate_tlbs, }; static int mshare_vm_op_split(struct vm_area_struct *vma, unsigned long addr) @@ -237,6 +250,10 @@ msharefs_fill_mm(struct inode *inode) m_data->mm = mm; m_data->start = mshare_base; inode->i_private = m_data; + m_data->mn.ops = &mshare_mmu_ops; + ret = mmu_notifier_register(&m_data->mn, mm); + if (ret) + goto err_free; return 0;
Unlike the mm of a task, an mshare host mm is not updated on context switch. In particular this means that mm_cpumask is never updated which results in TLB flushes for updates to mshare PTEs only being done on the local CPU. To ensure entries are flushed for non-local TLBs, set up an mmu notifier on the mshare mm and use the .arch_invalidate_secondary_tlbs callback to flush all TLBs. arch_invalidate_secondary_tlbs guarantees that TLB entries will be flushed before pages are freed when unmapping pages in an mshare region. Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com> --- mm/mshare.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)