mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Yinghai Lu <yhlu.kernel@gmail.com>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Ingo Molnar <mingo@elte.hu>, Matthew Wilcox <matthew@wil.cx>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: pci_find_parent_resource patch
Date: Tue, 10 Nov 2009 07:57:47 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.2.01.0911100745580.31845@localhost.localdomain> (raw)
In-Reply-To: <86802c440911100205i14dcf69i99cb0ef6f76406d1@mail.gmail.com>



On Tue, 10 Nov 2009, Yinghai Lu wrote:

> On Tue, Nov 10, 2009 at 12:23 AM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
> > I don't remember seeing it, is it for 2.6.32?
> 
> http://lkml.org/lkml/2009/8/7/352

I'm not entirely sure it needs to go into 32, but it's probably the right 
thing to do. Another way of explaining the patch is:

 - we currently pick the _first_ exactly matching bus resource entry, but 
   the _last_ inexactly matching one. Normally first/last shouldn't 
   matter, but bus resource entries aren't actually all created equal: in 
   a transparent bus, the last resources will be the parent resources, 
   which we should generally try to avoid unless we have no choice. So 
   "first matching" is the thing we should always aim for.

 - the patch is a bit bigger than it needs to be, because I simplified the 
   logic at the same time. It used to be a fairly incomprehensible

	if ((res->flags & IORESOURCE_PREFETCH) && !(r->flags & IORESOURCE_PREFETCH))
		best = r;       /* Approximating prefetchable by non-prefetchable */

   and technically, all the patch did was to make that complex choice be 
   even more complex (it basically added a "&& !best" to say that if we 
   already gound a non-prefetchable window for the prefetchable resource, 
   then we won't override an earlier one with that later one: remember 
   "first matching").

 - So instead of that complex one with three separate conditionals in one, 
   I split it up a bit, and am taking advantage of the fact that we 
   already handled the exact case, so if 'res->flags' has the PREFETCH 
   bit, then we already know that 'r->flags' will _not_ have it. So the 
   simplified code drops the redundant test, and does the new '!best' test 
   separately. It also uses 'continue' as a way to ignore the bus 
   resource we know doesn't work (ie a prefetchable bus resource is _not_ 
   acceptable for anything but an exact match), so it turns into:


	/* We can't insert a non-prefetch resource inside a prefetchable parent .. */
	if (r->flags & IORESOURCE_PREFETCH)
		continue;
	/* .. but we can put a prefetchable resource inside a non-prefetchable one */
	if (!best)
		best = r;

   instead. With the comments, it's now six lines instead of two, but it's 
   conceptually simpler, and I _could_ have written it as two lines:

	if ((res->flags & IORESOURCE_PREFETCH) && !best)
		best = r;	/* Approximating prefetchable by non-prefetchable */

   but I thought that was too damn subtle.

Feel free to use this long explanation as a commit message if you want,

			Linus

  reply	other threads:[~2009-11-10 15:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-09 20:04 Yinghai Lu
2009-11-10  8:23 ` Jesse Barnes
2009-11-10 10:05   ` Yinghai Lu
2009-11-10 15:57     ` Linus Torvalds [this message]
2009-11-11  8:21       ` Jesse Barnes
2009-11-25  0:22 Yinghai Lu
2009-12-04 23:59 ` Jesse Barnes
2009-12-05  0:24   ` Linus Torvalds
2009-12-05  0:30     ` Jesse Barnes

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=alpine.LFD.2.01.0911100745580.31845@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=ink@jurassic.park.msu.ru \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=mingo@elte.hu \
    --cc=yhlu.kernel@gmail.com \
    /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

Powered by JetHome