LWN.net Logo

Why struct meta_page?

Why struct meta_page?

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

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.


(Log in to post comments)

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