Skip to content

Commit f7d3043

Browse files
kirylhansendc
authored andcommitted
mm: Expose untagging mask in /proc/$PID/status
Add a line in /proc/$PID/status to report untag_mask. It can be used to find out LAM status of the process from the outside. It is useful for debuggers. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Alexander Potapenko <glider@google.com> Link: https://lore.kernel.org/all/20230312112612.31869-10-kirill.shutemov%40linux.intel.com
1 parent 2f8794b commit f7d3043

5 files changed

Lines changed: 32 additions & 0 deletions

File tree

arch/arm64/include/asm/mmu_context.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ void post_ttbr_update_workaround(void);
288288
unsigned long arm64_mm_context_get(struct mm_struct *mm);
289289
void arm64_mm_context_put(struct mm_struct *mm);
290290

291+
#define mm_untag_mask mm_untag_mask
292+
static inline unsigned long mm_untag_mask(struct mm_struct *mm)
293+
{
294+
return -1UL >> 8;
295+
}
296+
291297
#include <asm-generic/mmu_context.h>
292298

293299
#endif /* !__ASSEMBLY__ */

arch/sparc/include/asm/mmu_context_64.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ static inline void finish_arch_post_lock_switch(void)
185185
}
186186
}
187187

188+
#define mm_untag_mask mm_untag_mask
189+
static inline unsigned long mm_untag_mask(struct mm_struct *mm)
190+
{
191+
return -1UL >> adi_nbits();
192+
}
193+
188194
#include <asm-generic/mmu_context.h>
189195

190196
#endif /* !(__ASSEMBLY__) */

arch/x86/include/asm/mmu_context.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ static inline void dup_lam(struct mm_struct *oldmm, struct mm_struct *mm)
104104
mm->context.untag_mask = oldmm->context.untag_mask;
105105
}
106106

107+
#define mm_untag_mask mm_untag_mask
108+
static inline unsigned long mm_untag_mask(struct mm_struct *mm)
109+
{
110+
return mm->context.untag_mask;
111+
}
112+
107113
static inline void mm_reset_untag_mask(struct mm_struct *mm)
108114
{
109115
mm->context.untag_mask = -1UL;

fs/proc/array.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include <linux/user_namespace.h>
9292
#include <linux/fs_struct.h>
9393
#include <linux/kthread.h>
94+
#include <linux/mmu_context.h>
9495

9596
#include <asm/processor.h>
9697
#include "internal.h"
@@ -423,6 +424,11 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)
423424
seq_printf(m, "THP_enabled:\t%d\n", thp_enabled);
424425
}
425426

427+
static inline void task_untag_mask(struct seq_file *m, struct mm_struct *mm)
428+
{
429+
seq_printf(m, "untag_mask:\t%#lx\n", mm_untag_mask(mm));
430+
}
431+
426432
int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
427433
struct pid *pid, struct task_struct *task)
428434
{
@@ -438,6 +444,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
438444
task_mem(m, mm);
439445
task_core_dumping(m, task);
440446
task_thp_status(m, mm);
447+
task_untag_mask(m, mm);
441448
mmput(mm);
442449
}
443450
task_sig(m, task);

include/linux/mmu_context.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ static inline void leave_mm(int cpu) { }
2828
# define task_cpu_possible(cpu, p) cpumask_test_cpu((cpu), task_cpu_possible_mask(p))
2929
#endif
3030

31+
#ifndef mm_untag_mask
32+
static inline unsigned long mm_untag_mask(struct mm_struct *mm)
33+
{
34+
return -1UL;
35+
}
36+
#endif
37+
3138
#endif

0 commit comments

Comments
 (0)