linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] proc: inline vma_stop into m_stop
@ 2020-03-17 19:31 Alexey Dobriyan
  2020-03-17 19:31 ` [PATCH 2/5] proc: remove m_cache_vma Alexey Dobriyan
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Alexey Dobriyan @ 2020-03-17 19:31 UTC (permalink / raw)
  To: akpm; +Cc: willy, linux-kernel, linux-fsdevel, viro, adobriyan

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

Instead of calling vma_stop() from m_start() and m_next(), do its work
in m_stop().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/proc/task_mmu.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 9442631fd4af..41f63df4789d 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -123,15 +123,6 @@ static void release_task_mempolicy(struct proc_maps_private *priv)
 }
 #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 *
 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)
 		return ERR_PTR(-ESRCH);
 
 	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;
+	}
 
 	if (down_read_killable(&mm->mmap_sem)) {
 		mmput(mm);
+		put_task_struct(priv->task);
+		priv->task = NULL;
 		return ERR_PTR(-EINTR);
 	}
 
@@ -195,7 +191,6 @@ static void *m_start(struct seq_file *m, loff_t *ppos)
 	if (pos == mm->map_count && priv->tail_vma)
 		return priv->tail_vma;
 
-	vma_stop(priv);
 	return NULL;
 }
 
@@ -206,21 +201,22 @@ static void *m_next(struct seq_file *m, void *v, loff_t *pos)
 
 	(*pos)++;
 	next = m_next_vma(priv, v);
-	if (!next)
-		vma_stop(priv);
 	return next;
 }
 
 static void m_stop(struct seq_file *m, void *v)
 {
 	struct proc_maps_private *priv = m->private;
+	struct mm_struct *mm = priv->mm;
 
-	if (!IS_ERR_OR_NULL(v))
-		vma_stop(priv);
-	if (priv->task) {
-		put_task_struct(priv->task);
-		priv->task = NULL;
-	}
+	if (!priv->task)
+		return;
+
+	release_task_mempolicy(priv);
+	up_read(&mm->mmap_sem);
+	mmput(mm);
+	put_task_struct(priv->task);
+	priv->task = NULL;
 }
 
 static int proc_maps_open(struct inode *inode, struct file *file,
-- 
2.25.0


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH 0/5] Simplify /proc/$pid/maps implementation
@ 2020-02-29 16:59 Matthew Wilcox
  2020-02-29 16:59 ` [PATCH 3/5] proc: Use ppos instead of m->version Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox @ 2020-02-29 16:59 UTC (permalink / raw)
  To: linux-fsdevel, Alexey Dobriyan; +Cc: Matthew Wilcox (Oracle), linux-kernel

From: "Matthew Wilcox (Oracle)" <willy@infradead.org>

Back in 2005, we merged a patch from Akamai that sped up /proc/$pid/maps
by using f_version to stash the user virtual address that we'd just
displayed.  That wasn't necessary; we can just use the private *ppos for
the same purpose.  There have also been some other odd choices made over
the years that use the seq_file infrastructure in some non-idiomatic ways.

Tested by using 'dd' with various different 'bs=' parameters to check that
calling ->start, ->stop and ->next at various offsets work as expected.

Matthew Wilcox (Oracle) (5):
  proc: Inline vma_stop into m_stop
  proc: remove m_cache_vma
  proc: Use ppos instead of m->version
  seq_file: Remove m->version
  proc: Inline m_next_vma into m_next

 fs/proc/task_mmu.c       | 95 +++++++++++++---------------------------
 fs/seq_file.c            | 28 ------------
 include/linux/seq_file.h |  1 -
 3 files changed, 31 insertions(+), 93 deletions(-)

base-commit: d5226fa6dbae0569ee43ecfc08bdcd6770fc4755
-- 
2.25.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-03-17 19:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17 19:31 [PATCH 1/5] proc: inline vma_stop into m_stop Alexey Dobriyan
2020-03-17 19:31 ` [PATCH 2/5] proc: remove m_cache_vma Alexey Dobriyan
2020-03-17 19:31 ` [PATCH 3/5] proc: use ppos instead of m->version Alexey Dobriyan
2020-03-17 19:32 ` [PATCH 4/5] seq_file: remove m->version Alexey Dobriyan
2020-03-17 19:32 ` [PATCH 5/5] proc: inline m_next_vma into m_next Alexey Dobriyan
  -- strict thread matches above, loose matches on Subject: below --
2020-02-29 16:59 [PATCH 0/5] Simplify /proc/$pid/maps implementation Matthew Wilcox
2020-02-29 16:59 ` [PATCH 3/5] proc: Use ppos instead of m->version Matthew Wilcox
2020-03-03 19:55   ` Alexey Dobriyan
2020-03-03 20:29     ` Matthew Wilcox
2020-03-03 20:53       ` Alexey Dobriyan
2020-03-03 21:05         ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).