Commit 78d683e8 authored by Andy Lutomirski's avatar Andy Lutomirski Committed by H. Peter Anvin

mm, fs: Add vm_ops->name as an alternative to arch_vma_name

arch_vma_name sucks.  It's a silly hack, and it's annoying to
implement correctly.  In fact, AFAICS, even the straightforward x86
implementation is incorrect (I suspect that it breaks if the vdso
mapping is split or gets remapped).

This adds a new vm_ops->name operation that can replace it.  The
followup patches will remove all uses of arch_vma_name on x86,
fixing a couple of annoyances in the process.
Signed-off-by: default avatarAndy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/2eee21791bb36a0a408c5c2bdb382a9e6a41ca4a.1400538962.git.luto@amacapital.netSigned-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 1e844fb4
...@@ -1108,6 +1108,14 @@ static bool always_dump_vma(struct vm_area_struct *vma) ...@@ -1108,6 +1108,14 @@ static bool always_dump_vma(struct vm_area_struct *vma)
/* Any vsyscall mappings? */ /* Any vsyscall mappings? */
if (vma == get_gate_vma(vma->vm_mm)) if (vma == get_gate_vma(vma->vm_mm))
return true; return true;
/*
* Assume that all vmas with a .name op should always be dumped.
* If this changes, a new vm_ops field can easily be added.
*/
if (vma->vm_ops && vma->vm_ops->name && vma->vm_ops->name(vma))
return true;
/* /*
* arch_vma_name() returns non-NULL for special architecture mappings, * arch_vma_name() returns non-NULL for special architecture mappings,
* such as vDSO sections. * such as vDSO sections.
......
...@@ -300,6 +300,12 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) ...@@ -300,6 +300,12 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
goto done; goto done;
} }
if (vma->vm_ops && vma->vm_ops->name) {
name = vma->vm_ops->name(vma);
if (name)
goto done;
}
name = arch_vma_name(vma); name = arch_vma_name(vma);
if (!name) { if (!name) {
pid_t tid; pid_t tid;
......
...@@ -239,6 +239,12 @@ struct vm_operations_struct { ...@@ -239,6 +239,12 @@ struct vm_operations_struct {
*/ */
int (*access)(struct vm_area_struct *vma, unsigned long addr, int (*access)(struct vm_area_struct *vma, unsigned long addr,
void *buf, int len, int write); void *buf, int len, int write);
/* Called by the /proc/PID/maps code to ask the vma whether it
* has a special name. Returning non-NULL will also cause this
* vma to be dumped unconditionally. */
const char *(*name)(struct vm_area_struct *vma);
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
/* /*
* set_policy() op must add a reference to any non-NULL @new mempolicy * set_policy() op must add a reference to any non-NULL @new mempolicy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment