[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250820010415.699353-23-anthony.yznaga@oracle.com>
Date: Tue, 19 Aug 2025 18:04:15 -0700
From: Anthony Yznaga <anthony.yznaga@...cle.com>
To: linux-mm@...ck.org
Cc: akpm@...ux-foundation.org, andreyknvl@...il.com, arnd@...db.de,
bp@...en8.de, brauner@...nel.org, bsegall@...gle.com, corbet@....net,
dave.hansen@...ux.intel.com, david@...hat.com,
dietmar.eggemann@....com, ebiederm@...ssion.com, hpa@...or.com,
jakub.wartak@...lbox.org, jannh@...gle.com, juri.lelli@...hat.com,
khalid@...nel.org, liam.howlett@...cle.com, linyongting@...edance.com,
lorenzo.stoakes@...cle.com, luto@...nel.org, markhemm@...glemail.com,
maz@...nel.org, mhiramat@...nel.org, mgorman@...e.de, mhocko@...e.com,
mingo@...hat.com, muchun.song@...ux.dev, neilb@...e.de,
osalvador@...e.de, pcc@...gle.com, peterz@...radead.org,
pfalcato@...e.de, rostedt@...dmis.org, rppt@...nel.org,
shakeel.butt@...ux.dev, surenb@...gle.com, tglx@...utronix.de,
vasily.averin@...ux.dev, vbabka@...e.cz, vincent.guittot@...aro.org,
viro@...iv.linux.org.uk, vschneid@...hat.com, willy@...radead.org,
x86@...nel.org, xhao@...ux.alibaba.com, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org
Subject: [PATCH v3 22/22] mm/mshare: charge fault handling allocations to the mshare owner
When handling a fault in an mshare range, redirect charges for page
tables and other allocations to the mshare owner rather than the
current task.
Signed-off-by: Anthony Yznaga <anthony.yznaga@...cle.com>
---
mm/memory.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mm/memory.c b/mm/memory.c
index 177eb53475cb..127db0b9932c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -6468,9 +6468,17 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
struct mm_struct *mm = vma->vm_mm;
vm_fault_t ret;
bool is_droppable;
+ bool is_mshare = mm_flags_test(MMF_MSHARE, mm);
+ struct mem_cgroup *mshare_memcg;
+ struct mem_cgroup *memcg;
__set_current_state(TASK_RUNNING);
+ if (unlikely(is_mshare)) {
+ mshare_memcg = get_mem_cgroup_from_mm(vma->vm_mm);
+ memcg = set_active_memcg(mshare_memcg);
+ }
+
ret = sanitize_fault_flags(vma, &flags);
if (ret)
goto out;
@@ -6530,6 +6538,11 @@ vm_fault_t handle_mm_fault(struct vm_area_struct *vma, unsigned long address,
out:
mm_account_fault(mm, regs, address, flags, ret);
+ if (unlikely(is_mshare)) {
+ set_active_memcg(memcg);
+ mem_cgroup_put(mshare_memcg);
+ }
+
return ret;
}
EXPORT_SYMBOL_GPL(handle_mm_fault);
--
2.47.1
Powered by blists - more mailing lists