LWN.net Logo

Advertisement

E-Commerce & credit card processing - the Open Source way!

Advertise here

Why struct meta_page?

Why struct meta_page?

Posted Aug 4, 2007 9:30 UTC (Sat) by balbir_singh (subscriber, #34142)
In reply to: Why struct meta_page? by i3839
Parent article: Controlling memory use in containers

Your calculation seems accurate, but remember not everyone wants to use the memory controller. For non-users of the feature, we could later add a boot option and the overhead would be (with config enabled)

nr_pages * sizeof(pointer)

without this, the overhead would clearly be

3 * nr_pages * sizeof(pointer)

I need to double check this, but the sizeof struct page is currently close to being aligned in one cacheline, continuous and uncontrolled extensions can hurt in the long run (may be even now).


(Log in to post comments)

Why struct meta_page?

Posted Aug 4, 2007 13:20 UTC (Sat) by i3839 (subscriber, #31386) [Link]

Currently it's 56 bytes for 64 bit systems and 32 bytes for 32 bit ones, so you're right that adding pointers is bad, but that's also true for the one pointer you add (less so for 64 bit systems though).

Can't you reuse the struct list_head lru in struct page for the container instead of using two lists? That would save two pointers. If you need to do global reclaim you can do it per container, ordered on how "full" they are.

Also, is the struct mem_container* pointer really needed? Don't you know which container is involved from the context it's used? And the few times you really need it, can't you walk the lru list to find it out? (E.g. add struct mem_container to the lru list and distinguish it by setting a bit in the lru pointer or some other trick).

Just throwing ideas at you.

Why struct meta_page?

Posted Aug 6, 2007 17:26 UTC (Mon) by i3839 (subscriber, #31386) [Link]

If the above method of reusing the current lru isn't possible, an alternative would be to keep around a shadow array of struct meta_page, assuming currently an array of struct pages is used starting at a known location. Then you can calculate the index of the other structure from the memory address of either structure, also making those two pointers redundant, with the added benefit that struct page size isn't increased and the memory is only allocated when containers are used.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds