lkml.org 
[lkml]   [2012]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] block: convert elevator to generic rb tree code
On Tue, May 29, 2012 at 08:17:17AM +0900, Tejun Heo wrote:
> On Fri, May 25, 2012 at 01:57:41PM -0700, Kent Overstreet wrote:
> > Change-Id: I676968e201f0de9a0d0a7813e2fcc6873343e8c3
> >
> > Signed-off-by: Kent Overstreet <koverstreet@google.com>
>
> You know what I was gonna complain about here, right? :)

Yep :P

> > struct request *elv_rb_find(struct rb_root *root, sector_t sector)
> > {
> > - struct rb_node *n = root->rb_node;
> > - struct request *rq;
> > -
> > - while (n) {
> > - rq = rb_entry(n, struct request, rb_node);
> > + struct request search = { .__sector = sector };
>
> This is dangerous. You can't put things like struct request on stack.
> It might look like it's working ok on the tested setup but archs
> differ in stack pressure and more importantly people may add
> arbitrarily sized fields, including debugging stuff, to struct
> request. So, no, please don't do that.

I was telling you about this exact issue before - and I looked at the
assembly to make sure that when the inlined version of rb_search() was
used the struct request on the stack was optimized away, and it was.

So in practice there's no extra stack usage. Whether this is an
optimization we want to depend I'm not going to say; I suspect it's
pretty safe w.r.t. the optimizer but it's definitely sketchy and if at
some point someone came along and switched it to the uninline version
we'd have problems.

So we might want to leave this one open coded. Which would make me sad,
but I can't think of a sane way of implementing generic rb_search() that
doesn't require passing it a type t to compare against.

I dunno.


\
 
 \ /
  Last update: 2012-05-29 05:41    [W:0.098 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site