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  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]
Date:	Tue, 10 Nov 2009 07:57:47 -0800 (PST)
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Yinghai Lu <yhlu.kernel@...il.com>
cc:	Jesse Barnes <jbarnes@...tuousgeek.org>,
	Ivan Kokshaysky <ink@...assic.park.msu.ru>,
	Ingo Molnar <mingo@...e.hu>, Matthew Wilcox <matthew@....cx>,
	"linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: pci_find_parent_resource patch



On Tue, 10 Nov 2009, Yinghai Lu wrote:

> On Tue, Nov 10, 2009 at 12:23 AM, Jesse Barnes <jbarnes@...tuousgeek.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
--
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