[PATCH] ARM: fix unwinding for XIP kernels

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Mon Nov 28 05:02:19 EST 2011


On Mon, Nov 28, 2011 at 09:45:03AM +0000, Catalin Marinas wrote:
> On Mon, Nov 28, 2011 at 09:22:17AM +0000, Uwe Kleine-König wrote:
> > Hello,
> > 
> > On Mon, Nov 21, 2011 at 06:35:45PM +0000, Catalin Marinas wrote:
> > > On Sun, Nov 20, 2011 at 11:28:09AM +0000, Uwe Kleine-König wrote:
> > > > On Thu, Nov 17, 2011 at 02:17:06PM +0000, Catalin Marinas wrote:
> > > > > On Thu, Nov 17, 2011 at 01:40:00PM +0000, Uwe Kleine-König wrote:
> > > > > > The linker places the unwind tables in readonly sections. So when using
> > > > > > an XIP kernel these are located in ROM and cannot be modified.
> > > > > > 
> > > > > > For that reason don't convert the symbol addresses during boot (or
> > > > > > module loading) but only when interpreting them in search_index().
> > > > > > Moreover several consts are added to catch future writes and rename the
> > > > > > member "addr" of struct unwind_idx to "addr_offset" to better match the
> > > > > > new semantic.
> > > > > > 
> > > > > > This fixes unwinding on XIP which compared prel31 offsets to absolute
> > > > > > addresses because the initial conversion from prel31 to absolute failed.
> > > > > 
> > > > > My only worry - does this increase the index search by doing the prel31
> > > > > conversion every time? It could affect tools like lockdep that need to
> > > > > get the backtrace regularly at run-time.
> > > > I did a first test now using 
> > > > 
> > > > 	static int __init unwind_test(void)
> > > 
> > > With your latest patch, have you tried dropping __init from this
> > > function? Since the .init.text section goes after the unwind_idx tables,
> > > all the prel31 offsets are positive and the number of init functions is
> > > smaller than the run-time ones.
> > Yeah, it works fine. In fact unwinding unwind_test yields:
> > 
> > 	do_one_initcall+0x50/0x158
> > 	kernel_init+0x78/0x120
> > 	kernel_thread_exit+0x0/0x8
> > 
> > where kernel_thread_exit is not in .init.text, too.
> > 
> > I don't know why you asked? Did you see a bug? Or is it just to let me
> > do enough testing before you start reviewing my patches?
> 
> It's not a bug, just a wondering about the performance figures you got
> with your latest patch. When you have __init to unwind_test, the
> .init.text functions are placed by the linker after the unwinding table,
> with having a positive prel31 address. All the non-init functions are
> placed before the table with a negative prel31. With your latest patch,
> you split the set of functions in two ranges - the non-init one with a
> negative prel31 and the init functions with a positive prel31 and the
> binary search only happens on one of these ranges. The problem is that
> the init range is much smaller than the non-init one, so your benchmark
> figures may not be realistic.
> 
> Could you run the simple benchmark on a non-init function?
Without __init I get with the original implementation:

	34139, 34127, 34100

and with my patch I get

	33456, 33425, 33407

So the speedup here is smaller here, but still OK. Anyhow, I don't care
much about the speedup compared to the current implementation. I like my
patch because it's more correct as it doesn't need to modify the unwind
tables and is searched in a nice way that doesn't look to be less
effective by an order.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the linux-arm-kernel mailing list