Commit d07ded61 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Linus Torvalds

proc: inline vma_stop into m_stop

Instead of calling vma_stop() from m_start() and m_next(), do its work
in m_stop().
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20200317193201.9924-1-adobriyan@gmail.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5c5ab971
...@@ -123,15 +123,6 @@ static void release_task_mempolicy(struct proc_maps_private *priv) ...@@ -123,15 +123,6 @@ static void release_task_mempolicy(struct proc_maps_private *priv)
} }
#endif #endif
static void vma_stop(struct proc_maps_private *priv)
{
struct mm_struct *mm = priv->mm;
release_task_mempolicy(priv);
up_read(&mm->mmap_sem);
mmput(mm);
}
static struct vm_area_struct * static struct vm_area_struct *
m_next_vma(struct proc_maps_private *priv, struct vm_area_struct *vma) m_next_vma(struct proc_maps_private *priv, struct vm_area_struct *vma)
{ {
...@@ -163,11 +154,16 @@ static void *m_start(struct seq_file *m, loff_t *ppos) ...@@ -163,11 +154,16 @@ static void *m_start(struct seq_file *m, loff_t *ppos)
return ERR_PTR(-ESRCH); return ERR_PTR(-ESRCH);
mm = priv->mm; mm = priv->mm;
if (!mm || !mmget_not_zero(mm)) if (!mm || !mmget_not_zero(mm)) {
put_task_struct(priv->task);
priv->task = NULL;
return NULL; return NULL;
}
if (down_read_killable(&mm->mmap_sem)) { if (down_read_killable(&mm->mmap_sem)) {
mmput(mm); mmput(mm);
put_task_struct(priv->task);
priv->task = NULL;
return ERR_PTR(-EINTR); return ERR_PTR(-EINTR);
} }
...@@ -195,7 +191,6 @@ static void *m_start(struct seq_file *m, loff_t *ppos) ...@@ -195,7 +191,6 @@ static void *m_start(struct seq_file *m, loff_t *ppos)
if (pos == mm->map_count && priv->tail_vma) if (pos == mm->map_count && priv->tail_vma)
return priv->tail_vma; return priv->tail_vma;
vma_stop(priv);
return NULL; return NULL;
} }
...@@ -206,21 +201,22 @@ static void *m_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -206,21 +201,22 @@ static void *m_next(struct seq_file *m, void *v, loff_t *pos)
(*pos)++; (*pos)++;
next = m_next_vma(priv, v); next = m_next_vma(priv, v);
if (!next)
vma_stop(priv);
return next; return next;
} }
static void m_stop(struct seq_file *m, void *v) static void m_stop(struct seq_file *m, void *v)
{ {
struct proc_maps_private *priv = m->private; struct proc_maps_private *priv = m->private;
struct mm_struct *mm = priv->mm;
if (!IS_ERR_OR_NULL(v)) if (!priv->task)
vma_stop(priv); return;
if (priv->task) {
release_task_mempolicy(priv);
up_read(&mm->mmap_sem);
mmput(mm);
put_task_struct(priv->task); put_task_struct(priv->task);
priv->task = NULL; priv->task = NULL;
}
} }
static int proc_maps_open(struct inode *inode, struct file *file, static int proc_maps_open(struct inode *inode, struct file *file,
......
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