Message ID | 20250124235454.84587-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 9D28FC0218B for <linux-mm@archiver.kernel.org>; Fri, 24 Jan 2025 23:55:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 73D102800B5; Fri, 24 Jan 2025 18:55:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EF362800B0; Fri, 24 Jan 2025 18:55:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F3E52800B5; Fri, 24 Jan 2025 18:55:47 -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 3076A2800B0 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 18:55:47 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E7E44C19F5 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 23:55:46 +0000 (UTC) X-FDA: 83044005492.07.872F3B7 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf22.hostedemail.com (Postfix) with ESMTP id F1C7AC0006 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 23:55:44 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=dkhH1ABN; spf=pass (imf22.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.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=1737762945; 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=rU9rPudGLwBZN+ul8ATDIQZHL+5JLK1AK68Xl6t+yJk=; b=STSQR1WQd2L8J596Np0UDVqCo0CYczl0XLQFTfeLxQ5mRsFVFXCmwl9vPC2ifQNnnReCzV a+IkDZ3wcgDiRU4sMlhxTD22GZGyfs7z9oCVeU2mo6qoeSIPGRjEzTUPspTXD2O+LUx/5Q d7nBvtT4S03Gz+1asOIbHcaAfEUsQl4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=dkhH1ABN; spf=pass (imf22.hostedemail.com: domain of anthony.yznaga@oracle.com designates 205.220.177.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=1737762945; a=rsa-sha256; cv=none; b=W5grUOxVDNU8Eo0Rk6+UWHVcDNQZupJU1tfUYPWjq/Wuug2dgLAF7YhGTplBILPMjdTaPY KTsJ3lxiJ4YR2NHq4UigktLW7mztGx6yA7kbNGdzLW3cz80UhUesyaCiUsT0YuqgnVJRYm +azq9qZkQJMvEzUEWxqEqWFymN66eok= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50OIHwxb022439; Fri, 24 Jan 2025 23:55:33 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=rU9rP udGLwBZN+ul8ATDIQZHL+5JLK1AK68Xl6t+yJk=; b=dkhH1ABNUHDgkMbcNjOVe HLOlO3zpfZ6/zcXgH1MWSMApJp53Zwemc5AMBv8VgZ8H72pMejt0H3iho7yOmvzF H9xMiQUdAlws7OQLQt3lEzupvIdFAz9lcZVHNY52vnuTO1jN4+4NOIRkaG0aXtrA L01uc+qtH7o9rswF60olv2Vbr/OTaxT5KAyuoPLHYUCrd1ijEpIlZlcF0e0FXYcT iEBP96177UVbNmeouIy0f2vKY7Z3tP7ni1ruGvCXQ6tLrF4NkSSbvbYlOZXQNQuo FddCVtbP+byHiQ2Hg2u0Y9K411peP9nCUuiZ90jxeGRg+PLZXMcNjZr1ChereVuS g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 4485qm4y4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:55:33 +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 50OMEElh036463; Fri, 24 Jan 2025 23:55:32 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44917u4acw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:55:32 +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 50ONsxPw018051; Fri, 24 Jan 2025 23:55:31 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-9; Fri, 24 Jan 2025 23:55:31 +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, 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 08/20] mm/mshare: flush all TLBs when updating PTEs in an mshare range Date: Fri, 24 Jan 2025 15:54:42 -0800 Message-ID: <20250124235454.84587-9-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 Content-Transfer-Encoding: 8bit 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=999 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: G0_gkNzHGYYH-z86dDhJuuCCuwBORxu- X-Proofpoint-ORIG-GUID: G0_gkNzHGYYH-z86dDhJuuCCuwBORxu- X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: F1C7AC0006 X-Stat-Signature: 5donmjkehiyiicpyajz37nj4u6qpxwqa X-HE-Tag: 1737762944-7108 X-HE-Meta: U2FsdGVkX1/+CZ+JTpvWAw8Car+89tD6FNyAzscEZmIMb8O58IXtjZojPZLQKQgCuaQHe1PsNnGDXK1XiuLu2tP9BVe9t4qMT+WXwmmf6eBIU9hLJluSIL1wyH12s3AP5h84yHW5Hy95Req92vlg8V383LAI5mSbFx/tJosxUCPJ6UODDoDAlD7s/gtu9vb4225boAS7B4/n3MfpMOPy/WrNgdSvOBD93iF4lGcJsPExgwUGN6dlc3fxeGBbrul163czZfOyrWZ9rt0iCLZwPbjHLyx0g40s1eJsLC5+r1q0io6lCO7mo+wyQu9xNWJssNry3/CWUfYzrE7vxv0zna4jVoHe9WUK34EybkLlanqDHk1YcPRflmRNDdTTgfNvr3v3Riy9HDTPdtahiIMuroervNeTTzTtN4+h6W2RO5QVgtVVln3Gmwp0ctNVCVcIB4Vd3wb70gd1ZXOkpSZwxSFQqvUiNRENwtTkEugfJTyNrlbcSRLnYqhWmHxqU0/qDI6snoaCynA/djsxF7vuvu4cZKuRuNzB5N6p9TLNkMgY7jtKPtaTjgAiRRkZ3A3neW+eeoY8YBqDnGQFMZB0EG4/FSGtp8oaDTp0KxeCviXTUoDIGcGiU/PLuw5o6xby1r65qPuIAbaKe9EcqiewDifZIZGBJeBt+m4bCOFgcUIhYmctDk0j/+4j6dz0EC26Q0K1gZYFhSPYbBqHqck8EbfxUtmU9KosKKpB/EhhlVmBPSNnqGmRwAlE6xkhreopWai6zDpjQPvN1AxkqwRFygrNUtfirp8Ypcv/MSdJbIsOheXvKnle3bwp480gxNCrKVFt6ZuULykHe2+g6uCtPePvqj6wQSduqKQ1r+vgU7O/vzifzhcYW+DuBoiagjCEcU7NsWsREhrM4TbW9XfyUfRcTGPLfL4StsJR8X+r3oEkZawN1Y8ehSWv8KrNontWAmJElOl9SqGGf3XfvJc YFval9tT 9/TouoNY3m5+AKymJ2rAKaQz8T4vrr3gVe39x1I5bzGMTDlDzdIsGoy3O7Ctu3PaFt3UnA1x+xvrr4Ckt/u1ZYJcmSrVXEl93hZldCkPtLdWW4Eho0QiSfxYunBMPGH7FYpk+emZ4zFwTkyGKx51qtUueGFiAUUenimDAG98DcO+Wq+S/edINjk2uvabYwiVZkBMSFDCmBanDl8m7zW0iO/MWvGnN56+XV4P8TESfGMGT+gKhEEtu8AuYdLzuaV9iM7LjGRvpKXVx+Ho= 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 529a90fe1602..8dca4199dd01 100644 --- a/mm/mshare.c +++ b/mm/mshare.c @@ -17,9 +17,11 @@ #include <linux/fs.h> #include <linux/fs_context.h> #include <linux/mman.h> +#include <linux/mmu_notifier.h> #include <linux/spinlock_types.h> #include <uapi/linux/magic.h> #include <uapi/linux/msharefs.h> +#include <asm/tlbflush.h> const unsigned long mshare_align = P4D_SIZE; @@ -27,6 +29,17 @@ struct mshare_data { struct mm_struct *mm; spinlock_t m_lock; struct mshare_info minfo; + 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) @@ -191,6 +204,10 @@ msharefs_fill_mm(struct inode *inode) m_data->mm = mm; spin_lock_init(&m_data->m_lock); 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(+)