Re: [PATCH -v12 02/15] resources: Add probe_resource()

From: Bjorn Helgaas
Date: Thu Aug 30 2012 - 20:41:45 EST


On Wed, Aug 29, 2012 at 10:36 AM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
> On Wed, Aug 29, 2012 at 8:57 AM, Yinghai Lu <yinghai@xxxxxxxxxx> wrote:
>> also have another version for probe_resource, please check attached version -v8.
>>
>
> sorry, v8 forget removing two lines.
>
> please -v9 instead.
>
> -v8: Linus said: allocation/return is not right, and -1 step tricks make it
> not work as generic resource probe.
> So try to remove the needed_size tricks, and also use __adjust_resource
> for probing instead.
> -v9: remove two lines that is supposed to be removed after converting to use
> __adjust_resource

These tweaks might be slight improvements, but they completely miss
the point of my objection. I just don't think the probe_resource()
interface is a reasonable addition to kernel/resource.c. I think it's
too hard to describe what it does, and it seems like it's too specific
to what PCI needs in this particular case. We should be able to look
at the prototype and get a pretty good idea of what the function does,
but I can't do that with this:

+int probe_resource(struct resource *b_res,
+ struct resource *busn_res,
+ resource_size_t needed_size, struct resource **p,
+ int skip_nr, int limit, int stop_flags)

We already have adjust_resource(), which grows or shrinks a resource
while maintaining the invariants that the adjusted resource (1)
doesn't overlap any of its siblings and (2) still contains all its
children.

adjust_resource() seems like a fairly generic, generally useful
interface. What you're trying to do with probe_resource() is quite
similar, except that probe_resource() adds the idea of walking up the
tree.

I think you should consider something like an "expand_resource()" that
just balloons a resource at both ends until it abuts its siblings,
i.e., it grows the resource as much as possible. Then you know the
largest possible size, and you can use adjust_resource() to shrink it
again if you don't need that much. You can walk up the tree in the
caller when you need to.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/