linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Kent Overstreet <koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org,
	paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org
Subject: Re: [PATCH 3/3] block: convert elevator to generic rb tree code
Date: Tue, 29 May 2012 14:24:58 +0900	[thread overview]
Message-ID: <20120529052458.GA17366@google.com> (raw)
In-Reply-To: <20120529032502.GA10175-RcKxWJ4Cfj3IzGYXcIpNmNLIRw13R84JkQQo+JxHRPFibQn6LdNjmg@public.gmane.org>

Hello, Kent.

On Mon, May 28, 2012 at 11:25:02PM -0400, Kent Overstreet wrote:
> On Tue, May 29, 2012 at 08:17:17AM +0900, Tejun Heo wrote:
> > 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.

I don't think we can depend on that.  Note that compiler may as well
decide not to inline an inline function (e.g. if it sees many calling
instances).  Depending on such behavior is way too fragile.

> 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 don't know either.  Open coding isn't the end of the world but I
suspect a lot of data structures which go on rbtree wouldn't be stack
friendly, so having common helper which can't handle that might not be
too helpful.

Thanks.

--
tejun

  parent reply	other threads:[~2012-05-29  5:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25 20:57 [PATCH 0/3] Generic rb tree code Kent Overstreet
2012-05-25 20:57 ` [PATCH 1/3] rbtree: Add rb_insert(), rb_search(), etc Kent Overstreet
     [not found]   ` <1337979461-19654-2-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-05-28 23:35     ` Tejun Heo
2012-05-25 20:57 ` [PATCH 2/3] timerqueue: convert to generic rb tree code Kent Overstreet
2012-05-25 20:57 ` [PATCH 3/3] block: convert elevator " Kent Overstreet
     [not found]   ` <1337979461-19654-4-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-05-28 23:17     ` Tejun Heo
2012-05-29  3:25       ` Kent Overstreet
     [not found]         ` <20120529032502.GA10175-RcKxWJ4Cfj3IzGYXcIpNmNLIRw13R84JkQQo+JxHRPFibQn6LdNjmg@public.gmane.org>
2012-05-29  5:24           ` Tejun Heo [this message]
     [not found]             ` <20120529052458.GA17366-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-05-29  6:57               ` Kent Overstreet
     [not found] ` <1337979461-19654-1-git-send-email-koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2012-05-28 23:22   ` [PATCH 0/3] Generic " Tejun Heo
     [not found]     ` <20120528232246.GC20954-RcKxWJ4Cfj1J2suj2OqeGauc2jM2gXBXkQQo+JxHRPFibQn6LdNjmg@public.gmane.org>
2012-05-29  3:30       ` Kent Overstreet
     [not found]         ` <20120529033032.GB10175-RcKxWJ4Cfj3IzGYXcIpNmNLIRw13R84JkQQo+JxHRPFibQn6LdNjmg@public.gmane.org>
2012-05-29  5:28           ` Tejun Heo
2012-05-31 21:03   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120529052458.GA17366@google.com \
    --to=tj-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
    --cc=koverstreet-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=linux-bcache-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).