From 2c330d7143d786edcfd0eecc96a44aab2a737b3b Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 19 Jun 2017 14:44:52 -0600 Subject: [PATCH] proc: sparc64 Export ADI-enabled memory Add a maps entry to /proc/pid/adi to show memory map information about SPARC ADI enabled memory. Orabug: 26052545 Signed-off-by: Eric Snowberg Signed-off-by: Allen Pais Reviewed-by: chris hyser --- fs/proc/adi.c | 1 + fs/proc/internal.h | 1 + fs/proc/task_mmu.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/fs/proc/adi.c b/fs/proc/adi.c index 023edc2e7bd2..ca14a8e1dd14 100644 --- a/fs/proc/adi.c +++ b/fs/proc/adi.c @@ -222,6 +222,7 @@ static const struct file_operations proc_tag_operations = { static const struct pid_entry adi_dir_stuff[] = { REG("tags", S_IRUSR | S_IWUSR, proc_tag_operations), + REG("maps", S_IRUGO, proc_adi_maps_operations), }; static int proc_adi_readdir(struct file *file, struct dir_context *ctx) diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 77010bda9dc2..65660d2a7e21 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -334,6 +334,7 @@ extern const struct file_operations proc_pid_smaps_operations; extern const struct file_operations proc_tid_smaps_operations; extern const struct file_operations proc_clear_refs_operations; extern const struct file_operations proc_pagemap_operations; +extern const struct file_operations proc_adi_maps_operations; extern unsigned long task_vsize(struct mm_struct *); extern unsigned long task_statm(struct mm_struct *, diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index d0930d112b25..7b22fa650450 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1620,4 +1620,39 @@ const struct file_operations proc_tid_numa_maps_operations = { .llseek = seq_lseek, .release = proc_map_release, }; + +#ifdef CONFIG_SPARC64 +static int show_adi_map(struct seq_file *m, struct vm_area_struct *vma) +{ + if (vma->vm_flags & VM_SPARC_ADI) + return show_map(m, vma, 1); + + return 0; +} + +static int show_pid_adi_map(struct seq_file *m, void *v) +{ + return show_adi_map(m, v); +} + +static const struct seq_operations proc_pid_adi_maps_op = { + .start = m_start, + .next = m_next, + .stop = m_stop, + .show = show_pid_adi_map, +}; + +static int pid_adi_maps_open(struct inode *inode, struct file *file) +{ + return do_maps_open(inode, file, &proc_pid_adi_maps_op); +} + +const struct file_operations proc_adi_maps_operations = { + .open = pid_adi_maps_open, + .read = seq_read, + .llseek = seq_lseek, + .release = proc_map_release, +}; + +#endif #endif /* CONFIG_NUMA */ -- 2.50.1