lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081107085352.GA27245@elte.hu>
Date:	Fri, 7 Nov 2008 09:53:52 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Ken Chen <kenchen@...gle.com>, linux-kernel@...r.kernel.org,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [patch] add /proc/pid/stack to dump task's stack trace


* Alexey Dobriyan <adobriyan@...il.com> wrote:

> On Fri, Nov 07, 2008 at 09:32:49AM +0100, Ingo Molnar wrote:
> > 
> > * Alexey Dobriyan <adobriyan@...il.com> wrote:
> > 
> > > On Fri, Nov 07, 2008 at 08:59:25AM +0100, Ingo Molnar wrote:
> > > > 
> > > > * Ingo Molnar <mingo@...e.hu> wrote:
> > > > 
> > > > > > > + * buffer size used for proc read.  See proc_info_read().
> > > > > > > + * 4K page size but our output routines use some slack for overruns
> > > > > > > + */
> > > > > > > +#define PROC_BLOCK_SIZE	(3*1024)
> > > > > 
> > > > > That sounds like a proper limit - the hard limit for this particular 
> > > > > printout function is 4096-170, so we are well within the 
> > > > > PROC_BLOCK_SIZE range.
> > > > 
> > > > ok, i've added Ken's patch to tip/core/stacktrace and started testing 
> > > > it.
> > > > 
> > > > Alexey, i've added your Acked-by because you appeared to like the 
> > > > patch - let me know if i should remove it.
> > > 
> > > Of course, I don't like it!
> > > 
> > > Switch to seqfiles, add entry in TID table as well.
> > >
> > > The idea is good, though.
> > 
> > oh well - Ken, could you please switch it to seqfiles?
> > 
> > It should be something like this to convert the currently sweet and 
> > trivial function into a much more complex seqfile iterator splitup:
> > 
> > - the ::start method does the kmalloc of a loop state structure like 
> >   this:
> > 
> >   {
> > 	struct stack_trace backtrace;
> > 	unsigned long entries[MAX_STACK_TRACE_DEPTH];
> > 
> > 	int iterator;
> >   }
> > 
> >   and saves the trace. (struct stack_trace trace can be on-stack, it's 
> >   only needed for the save_stack_trace() - and we keep the entries 
> >   after that.)
> > 
> > - the ::stop method does the kfree of the loop state.
> > 
> > - the ::show method prints a single line, based on ->entries[->iterator]
> > 
> > - the ::next method does ->iterator++, and returns NULL if iterator 
> >   reaches ->backtrace.nr_entries.
> > 
> > it will be more source code, larger kernel image, it will be more 
> > fragile and will be harder to review, and it wont actually matter in 
> > practice because 99.9999% of the backtraces we care about have a size 
> > smaller than 3K. (and where they get larger clipping them to the first 
> > 3K is perfectly fine)
> 
> Or you can do all of this in ->show(), without start/next/stop:
> 
> 	for (i = 0; i < N; i++)
> 		seq_printf(m, "[<%p>] %pS\n", x, x);

hm, is that preferred over the current fs/proc/base.c code?

If that's the preferred way of doing these things, why arent all the 
single-page procfs functions converted over to seq_file:

 #ifdef CONFIG_KALLSYMS
        INF("wchan",      S_IRUGO, pid_wchan),
 #endif
+#ifdef CONFIG_STACKTRACE
+       INF("stack",      S_IRUSR, pid_stack),
+#endif
 #ifdef CONFIG_SCHEDSTATS
        INF("schedstat",  S_IRUGO, pid_schedstat),
 #endif

?

Really, please realize what happened here. All this unnecessary work 
comes from Ken just having done the _natural_ thing when extending the 
existing upstream code: using the existing fs/proc/base.c methods as a 
template to write new code. If those templates use outdated APIs, then 
new code will be "outdated" too - and this confusion will go on 
forever.

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ