diff mbox series

procfs: fix the output format in /proc/PID/wchan

Message ID 1542626272-29129-1-git-send-email-laoar.shao@gmail.com (mailing list archive)
State New, archived
Headers show
Series procfs: fix the output format in /proc/PID/wchan | expand

Commit Message

Yafang Shao Nov. 19, 2018, 11:17 a.m. UTC
Just add the missing newline.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 fs/proc/base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrew Morton Nov. 22, 2018, 3:28 a.m. UTC | #1
On Mon, 19 Nov 2018 19:17:52 +0800 Yafang Shao <laoar.shao@gmail.com> wrote:

> Just add the missing newline.
> 
> ...
>
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -370,11 +370,12 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
>  	wchan = get_wchan(task);
>  	if (wchan && !lookup_symbol_name(wchan, symname)) {
>  		seq_puts(m, symname);
> +		seq_putc(m, '\n');
>  		return 0;
>  	}
>  
>  print0:
> -	seq_putc(m, '0');
> +	seq_puts(m, "0\n");
>  	return 0;
>  }
>  #endif /* CONFIG_KALLSYMS */

What is presently wrong with the wchan output?  The changelog
should explain such things, please.

Providing example output with the patch unapplied and then with the
patch applied would help us to understand the patch's effect.

Thanks.
Alexey Dobriyan Nov. 22, 2018, 11:40 a.m. UTC | #2
On Wed, Nov 21, 2018 at 07:28:44PM -0800, Andrew Morton wrote:
> On Mon, 19 Nov 2018 19:17:52 +0800 Yafang Shao <laoar.shao@gmail.com> wrote:
>
> > Just add the missing newline.
> >
> > ...
> >
> > --- a/fs/proc/base.c
> > +++ b/fs/proc/base.c
> > @@ -370,11 +370,12 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
> >  	wchan = get_wchan(task);
> >  	if (wchan && !lookup_symbol_name(wchan, symname)) {
> >  		seq_puts(m, symname);
> > +		seq_putc(m, '\n');
> >  		return 0;
> >  	}
> >
> >  print0:
> > -	seq_putc(m, '0');
> > +	seq_puts(m, "0\n");
> >  	return 0;
> >  }
> >  #endif /* CONFIG_KALLSYMS */
>
> What is presently wrong with the wchan output?  The changelog
> should explain such things, please.

It is just newline to make "cat /proc/*/wchan" output look cool.
But newline can break something.
Yafang Shao Nov. 22, 2018, 1:29 p.m. UTC | #3
On Thu, Nov 22, 2018 at 7:40 PM Alexey Dobriyan <adobriyan@gmail.com> wrote:
>
> On Wed, Nov 21, 2018 at 07:28:44PM -0800, Andrew Morton wrote:
> > On Mon, 19 Nov 2018 19:17:52 +0800 Yafang Shao <laoar.shao@gmail.com> wrote:
> >
> > > Just add the missing newline.
> > >
> > > ...
> > >
> > > --- a/fs/proc/base.c
> > > +++ b/fs/proc/base.c
> > > @@ -370,11 +370,12 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
> > >     wchan = get_wchan(task);
> > >     if (wchan && !lookup_symbol_name(wchan, symname)) {
> > >             seq_puts(m, symname);
> > > +           seq_putc(m, '\n');
> > >             return 0;
> > >     }
> > >
> > >  print0:
> > > -   seq_putc(m, '0');
> > > +   seq_puts(m, "0\n");
> > >     return 0;
> > >  }
> > >  #endif /* CONFIG_KALLSYMS */
> >
> > What is presently wrong with the wchan output?  The changelog
> > should explain such things, please.
>
> It is just newline to make "cat /proc/*/wchan" output look cool.
> But newline can break something.

Could you pls. show some examples for what the newline may break ?

Thanks
Yafang
Alexey Dobriyan Nov. 22, 2018, 1:38 p.m. UTC | #4
On Thu, Nov 22, 2018 at 09:29:52PM +0800, Yafang Shao wrote:
> On Thu, Nov 22, 2018 at 7:40 PM Alexey Dobriyan <adobriyan@gmail.com> wrote:
> >
> > On Wed, Nov 21, 2018 at 07:28:44PM -0800, Andrew Morton wrote:
> > > On Mon, 19 Nov 2018 19:17:52 +0800 Yafang Shao <laoar.shao@gmail.com> wrote:
> > >
> > > > Just add the missing newline.
> > > >
> > > > ...
> > > >
> > > > --- a/fs/proc/base.c
> > > > +++ b/fs/proc/base.c
> > > > @@ -370,11 +370,12 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
> > > >     wchan = get_wchan(task);
> > > >     if (wchan && !lookup_symbol_name(wchan, symname)) {
> > > >             seq_puts(m, symname);
> > > > +           seq_putc(m, '\n');
> > > >             return 0;
> > > >     }
> > > >
> > > >  print0:
> > > > -   seq_putc(m, '0');
> > > > +   seq_puts(m, "0\n");
> > > >     return 0;
> > > >  }
> > > >  #endif /* CONFIG_KALLSYMS */
> > >
> > > What is presently wrong with the wchan output?  The changelog
> > > should explain such things, please.
> >
> > It is just newline to make "cat /proc/*/wchan" output look cool.
> > But newline can break something.
> 
> Could you pls. show some examples for what the newline may break ?

	char buf[16];
	rv = read(fd, buf, sizeof(buf));
	assert(rv == 1);
Yafang Shao Nov. 23, 2018, 9:57 a.m. UTC | #5
On Thu, Nov 22, 2018 at 9:38 PM Alexey Dobriyan <adobriyan@gmail.com> wrote:
>
> On Thu, Nov 22, 2018 at 09:29:52PM +0800, Yafang Shao wrote:
> > On Thu, Nov 22, 2018 at 7:40 PM Alexey Dobriyan <adobriyan@gmail.com> wrote:
> > >
> > > On Wed, Nov 21, 2018 at 07:28:44PM -0800, Andrew Morton wrote:
> > > > On Mon, 19 Nov 2018 19:17:52 +0800 Yafang Shao <laoar.shao@gmail.com> wrote:
> > > >
> > > > > Just add the missing newline.
> > > > >
> > > > > ...
> > > > >
> > > > > --- a/fs/proc/base.c
> > > > > +++ b/fs/proc/base.c
> > > > > @@ -370,11 +370,12 @@ static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
> > > > >     wchan = get_wchan(task);
> > > > >     if (wchan && !lookup_symbol_name(wchan, symname)) {
> > > > >             seq_puts(m, symname);
> > > > > +           seq_putc(m, '\n');
> > > > >             return 0;
> > > > >     }
> > > > >
> > > > >  print0:
> > > > > -   seq_putc(m, '0');
> > > > > +   seq_puts(m, "0\n");
> > > > >     return 0;
> > > > >  }
> > > > >  #endif /* CONFIG_KALLSYMS */
> > > >
> > > > What is presently wrong with the wchan output?  The changelog
> > > > should explain such things, please.
> > >
> > > It is just newline to make "cat /proc/*/wchan" output look cool.
> > > But newline can break something.
> >
> > Could you pls. show some examples for what the newline may break ?
>
>         char buf[16];
>         rv = read(fd, buf, sizeof(buf));
>         assert(rv == 1);

That's really a break, so we can't apply this patch.

Hi Andrew,
I found that you have applied this patch to -mm tree, could you pls.
help revert it as it may break something ?

Thanks
Yafang
diff mbox series

Patch

diff --git a/fs/proc/base.c b/fs/proc/base.c
index ce34654..d7f49fb 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -370,11 +370,12 @@  static int proc_pid_wchan(struct seq_file *m, struct pid_namespace *ns,
 	wchan = get_wchan(task);
 	if (wchan && !lookup_symbol_name(wchan, symname)) {
 		seq_puts(m, symname);
+		seq_putc(m, '\n');
 		return 0;
 	}
 
 print0:
-	seq_putc(m, '0');
+	seq_puts(m, "0\n");
 	return 0;
 }
 #endif /* CONFIG_KALLSYMS */