Use linked lists for resources instead of fixed arrays.
resources.diff - changes the definitions resource_usage.diff - changes the functions where resources are used sconfig.diff - changes the device tree
From the qemu boot log:
before: malloc Enter, size 1092, free_mem_ptr 00118444 malloc 00118444
after: malloc Enter, size 228, free_mem_ptr 001180e4 malloc 001180e4
I allocate resources in blocks of 64. It could be smaller to decrease memory usage, but I think it's plenty large (2560 bytes)
Signed-off-by: Myles Watson mylesgw@gmail.com
Thanks, Myles
On Thu, May 20, 2010 at 1:16 PM, Myles Watson mylesgw@gmail.com wrote:
Use linked lists for resources instead of fixed arrays.
resource_usage.diff - changes the functions where resources are used
Here's an updated patch that doesn't hang :) I was in too much of a hurry. We could add the resources to the end of the list to maintain the old order if anyone cares. Since we're using a list, the resources are in reverse order.
Signed-off-by: Myles Watson mylesgw@gmail.com
Thanks, Myles
We could add the resources to the end of the list to maintain the old order if anyone cares. Since we're using a list, the resources are in reverse order.
Since it makes it easier to debug in case there's a problem, here it is.
Signed-off-by: Myles Watson mylesgw@gmail.com
Thanks, Myles
Am 21.05.2010 01:08, schrieb Myles Watson:
static void free_resource(device_t dev, struct resource *res, struct
resource *prev)
...
- res->next = free_resources;
- free_resources = res->next;
Shouldn't that be + res->next = free_resources; + free_resources = res; to add res to the free_resources?
Other than that, this is great! Smaller, cleaner, faster code, that uses less memory to achieve the same result - wonderful!
With the above thing cleared up, this is Acked-by: Patrick Georgi patrick.georgi@coresystems.de
On Fri, May 21, 2010 at 8:03 AM, Patrick Georgi patrick@georgi-clan.de wrote:
Am 21.05.2010 01:08, schrieb Myles Watson:
static void free_resource(device_t dev, struct resource *res, struct
resource *prev)
...
- res->next = free_resources;
- free_resources = res->next;
Shouldn't that be
- res->next = free_resources;
- free_resources = res;
to add res to the free_resources?
Yes. Thanks for catching it. It's too bad to leak the memory you're saving :) Fixed.
Other than that, this is great! Smaller, cleaner, faster code, that uses less memory to achieve the same result - wonderful!
Thanks. If we do the same thing with links we could save another ~150 bytes per device. There are 8 links per device when few of them have any at all.
With the above thing cleared up, this is Acked-by: Patrick Georgi patrick.georgi@coresystems.de
Rev 5576.
Thanks, Myles
Am 20.05.2010 21:16, schrieb Myles Watson:
Signed-off-by: Myles Watson mylesgw@gmail.com
resources.diff and sconfig.diff are Acked-by: Patrick Georgi patrick.georgi@coresystems.de