Message ID | 20250124235454.84587-20-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 45153C02181 for <linux-mm@archiver.kernel.org>; Fri, 24 Jan 2025 23:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE72C2800C1; Fri, 24 Jan 2025 18:57:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6DD62800B0; Fri, 24 Jan 2025 18:57:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC0532800C1; Fri, 24 Jan 2025 18:57:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8739A2800B0 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 18:57:48 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 36507B110F for <linux-mm@kvack.org>; Fri, 24 Jan 2025 23:57:48 +0000 (UTC) X-FDA: 83044010616.19.4D7A38F Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf04.hostedemail.com (Postfix) with ESMTP id EE2D840008 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 23:57:45 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=B3fjZHZb; spf=pass (imf04.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=1737763066; 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=SM5Ww7fWlIZajv0rUMSJsMcTKUFDtvzpjq2xibJD7zc=; b=bc9HTNjvcmEddqTBiiufg09HxvgdMYu9MQQz2IHnrlciBofMKtVbNgAs+N0WGC5BF/QCeC Je8PeUiZ2mhChYTULeWjp6nYWNiK7bvAX1QUA4NZvE1xqEJKngiFr0jhwqBwCGiB6rwseb w7rl6GDvBKz28PqiJan3rssSyArqoIQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737763066; a=rsa-sha256; cv=none; b=N9rB0ubYXIeQNcYA0uB2b5VkKhswpgOm/fdmUIdUa06gluL8aJAaO6nonXenW1JY+2yB8o XMahlGogTXEgDzKR0jp3gBPplyHuGQpVkTYR862DzgFjVIT1nXS2sWNq5dWYRbnQZVRRqz cLTqoIs9zi4O5C7LJnE9Q0zhHJ+fcCU= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-11-20 header.b=B3fjZHZb; spf=pass (imf04.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 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50OIBhnG000613; Fri, 24 Jan 2025 23:56:10 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=SM5Ww 7fWlIZajv0rUMSJsMcTKUFDtvzpjq2xibJD7zc=; b=B3fjZHZbj/1OatG3T8blh RsVs7af8iubXIbp5pCA/LmBolWeub9ZWDjgfFw/eUeRi9kdXt4spr34dzUUkjVYH 8YFGdxJ4Z5/RpbERJYmTWBrzS9ds8FNE2A0kyKEfgzObXPdQl7S+wid3oS7YndzN RZR9201pZ9PZfSijDDQmyNa/mBgI2y7nL9PF9mqYFcwu3MYFtqG6NtUY/EBfUsRO 9kYqDw1UwZamvlgb0Lzhzui1+zNUkKTJbSnBNmyZJxKmd7jmxIsBEVT1go/vz6CP ybAZTHMbWjqjXO8Y8QBEbLr+RzKlZtiw3vGENMpoLhyb+Mkvr3LTEbk1ar79lSPf 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 44awyh5rkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:56:10 +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 50OMPchS036590; Fri, 24 Jan 2025 23:56:09 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 44917u4aq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Jan 2025 23:56:09 +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 50ONsxQK018051; Fri, 24 Jan 2025 23:56:08 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-20; Fri, 24 Jan 2025 23:56:08 +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 19/20] mm/mshare: get memcg from current->mm instead of mshare mm Date: Fri, 24 Jan 2025 15:54:53 -0800 Message-ID: <20250124235454.84587-20-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=912 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501240162 X-Proofpoint-ORIG-GUID: mhtNEYRHB3aSsRiiq5ZgkAR2eaM2NkII X-Proofpoint-GUID: mhtNEYRHB3aSsRiiq5ZgkAR2eaM2NkII X-Rspamd-Queue-Id: EE2D840008 X-Stat-Signature: gia46f4mhrii3ta6k8ajyp153rt6gkk7 X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1737763065-644189 X-HE-Meta: U2FsdGVkX19mTuZTvXoU4YuSNmbgg4F5my1YBWU8CRWDiXajTSWcJ7jgxTMYQSHj7pXVqbSeFI9fiuzoiRjikcAUiFYvYKYXeIARSmvGouyUs4tJXE3NGVpxl8AM5G3FZT0rihuITkIZczWl2CfXnLXw43eesX7+iAkdPTKh7m7+kl8+cu9h8AFfTles2kJ97Sr2s/Y0BJdoiATCqhEGkAxJJLHlRXRzg1PD6OgX1WHLIIvCmDMsV/CrW8W8ru1vY8UaNuNXn19xp5UnsK8NDxA9LYduUhaVSFKKv02Q4wGAlroZ2vhUQz85PmIY97q4SJw3jKLcMFaEekPAGggCZz9aMGO9SotHcJe5pnQv1cv9UIWpdWywErPa6c/pGjcJ/+6KuqAb93XEs5J3FmS6wYUt6jkfK4Pmtn0kkmMWj7mcun+/lV/eAC86Xmokw6SWsT/Vhwmu4jocPBFIdtVCnQw+bCSd0ZEpQWWzYbD/r23hcaWV1W5YvS6m/2iBtR2LKl/vW8lq8QzH24pYxPhVtlXQctHgxMEM3muzPN/T1mWuYZHw/6bzWKZ5DoYlLONOITxg8B1MdnYyPoquH/vjpYROSLiFeB8ru3NydL2i2uKSqWaJgd2RAWSnFLhCk/fxDJPm6KSjsd3iKua+LTtjit4OMLJWKVxOQp1hIM6n2PkcvfIIeeqRiO3Hnm2+IUdPL0nEfel4qJCOBIy73GFUC0vwBqXeg4ZrVp5LB1kjdXPCiKQDp8WHGNhDGrSDNO31EHlH76yd8zsXmmWIYcx6dKcV1a5SoEJWzCXvqqI848fMDJA1eIkydpRLqhJnhg5/tjTuIYVum83VIfkIuSQIdhwsVKJ4852M4TybGTHqY5r6DZwpaLZtELqp5OZENwA3aVAV/9ZeAhh4HZByx762Gck4rwLzOfeAW7OlbtIgL/O+9cPzKWzzEJDO8b2WBCbUpiXq3jCrrcMhgDWpEsj PzZp5VLh v77jdetfz32rZABY4Z28bZ2gyBbS1bI29mKfV1uKW1nel+tL1vh7RXIyjA7n323KvSTsMmyvciZsctDohHWuIo8yNS1l5UOHVgjb4csP1uWImWtFzhHR1AlaXNDJMdSpnMqCInPXVK+tTwL/15dSDca2JYzeezA7tqpv797kk53m8a6luMuKBfev48Zs+2xddnWaX2oBFFOnhY45wNTxb6oJY5YPTGOnBsSm4mMzZmcEB9cU= 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/include/linux/memcontrol.h b/include/linux/memcontrol.h index 6e74b8254d9b..e458ca80e833 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -987,6 +987,9 @@ static inline void count_memcg_events_mm(struct mm_struct *mm, if (mem_cgroup_disabled()) return; + if (test_bit(MMF_MSHARE, &mm->flags)) + mm = current->mm; + rcu_read_lock(); memcg = mem_cgroup_from_task(rcu_dereference(mm->owner)); if (likely(memcg)) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 46f8b372d212..ba6267615ee6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -938,7 +938,8 @@ struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm) mm = current->mm; if (unlikely(!mm)) return root_mem_cgroup; - } + } else if (test_bit(MMF_MSHARE, &mm->flags)) + mm = current->mm; rcu_read_lock(); do { diff --git a/mm/mshare.c b/mm/mshare.c index 4c3f6c2410d6..5cc416cfd78c 100644 --- a/mm/mshare.c +++ b/mm/mshare.c @@ -381,6 +381,9 @@ msharefs_fill_mm(struct inode *inode) if (ret) goto err_free; +#ifdef CONFIG_MEMCG + mm->owner = NULL; +#endif return 0; err_free:
Because handle_mm_fault() may operate on a vma from an mshare host mm, the mm passed to cgroup functions count_memcg_event_mm() and get_mem_cgroup_from_mm() may be an mshare host mm. These functions find a memcg by dereferencing mm->owner which is set when an mm is allocated. Since the task that created an mshare file may exit before the file is deleted, use current->mm instead to find the memcg to update or charge to. This may not be the right solution but is hopefully a good starting point. If charging should always go to a single memcg associated with the mshare file, perhaps active_memcg could be used. Signed-off-by: Anthony Yznaga <anthony.yznaga@oracle.com> --- include/linux/memcontrol.h | 3 +++ mm/memcontrol.c | 3 ++- mm/mshare.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-)