mm: slab/slub: use page->list consistently instead of page->lru
Subsystems (3)
PATCH 1/2 mm: slab/slub: use page->list consistently instead of page->lru
From: Dave Hansen <[email protected]>
'struct page' has two list_head fields: 'lru' and 'list'. Conveniently, they are unioned together. This means that code can use them interchangably, which gets horribly confusing like with this nugget from slab.c:
Quoted 3 lines
list_del(&page->lru); if (page->active == cachep->num) list_add(&page->list, &n->slabs_full);
This patch makes the slab and slub code use page->list universally instead of mixing ->list and ->lru.
It also adds some comments to attempt to keep new users from picking up uses of ->list.
So, the new rule is: page->list is what the slabs use. page->lru is for everybody else. This is a pretty arbitrary rule, but we need _something_. Maybe we should just axe the ->list one and make the sl?bs use ->lru.
---
linux.git-davehans/include/linux/mm_types.h | 5 ++ linux.git-davehans/mm/slab.c | 50 ++++++++++++++-------------- 2 files changed, 29 insertions(+), 26 deletions(-)
include/linux/mm_types.h renamed from include/linux/mm_types.h~make-slab-use-page-lru-vs-list-consistently +4 -1
@@ -123,6 +123,8 @@ struct page {union {struct list_head lru;/* Pageout list, eg. active_list * protected by zone->lru_lock ! +* Can be used as a generic list +* by the page owner. */ struct {/* slub per cpu partial pages */ struct page *next;/* Next partial slab */
@@ -135,7 +137,8 @@ struct page {#endif }; -struct list_head list;/* slobs list of pages */ +struct list_head list;/* sl[aou]bs list of pages. +* do not use outside of slabs */ struct slab *slab_page;/* slab fields */ struct rcu_head rcu_head;/* Used by SLAB * when destroying via RCU
mm/slab.c renamed from mm/slab.c~make-slab-use-page-lru-vs-list-consistently +25 -25
170 lines not on this page · raw message
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/2 mm: blk-mq: uses page->list incorrectly
From: Dave Hansen <[email protected]>
'struct page' has two list_head fields: 'lru' and 'list'. Conveniently, they are unioned together. This means that code can use them interchangably, which gets horribly confusing.
The blk-mq made the logical decision to try to use page->list. But, that field was actually introduced just for the slub code. ->lru is the right field to use outside of slab/slub.
---
linux.git-davehans/block/blk-mq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
block/blk-mq.c renamed from block/blk-mq.c~blk-mq-uses-page-list-incorrectly +3 -3
@@ -1087,8 +1087,8 @@ static void blk_mq_free_rq_map(struct blstruct page *page;while (!list_empty (&hctx->page_list)) { - page = list_first_entry(&hctx->page_list, struct page, list); -list_del_init (&page->list); + page = list_first_entry(&hctx->page_list, struct page, lru); +list_del_init (&page->lru);__free_pages (page, page->private); }
@@ -1152,7 +1152,7 @@ static int blk_mq_init_rq_map(struct blkbreak ; page->private = this_order; -list_add_tail (&page->list, &hctx->page_list); +list_add_tail (&page->lru, &hctx->page_list); p =page_address (page); entries_per_page =order_to_size (this_order) / rq_size;
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 2/2] mm: blk-mq: uses page->list incorrectly
Quoted 7 lines · Dave Hansen
From: Dave Hansen <[email protected]>
'struct page' has two
list_headfields: 'lru' and 'list'. Conveniently, they are unioned together. This means that code can use them interchangably, which gets horribly confusing.
Quoted 5 lines
The blk-mq made the logical decision to try to use
page->list. But, that field was actually introduced just for the slub code. ->lru is the right field to use outside of slab/slub.Signed-off-by Dave Hansen <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
RE: [PATCH 2/2] mm: blk-mq: uses page->list incorrectly
In reply to Dave HansenQuoted 7 lines · Dave Hansen
From: Dave Hansen <[email protected]>
'struct page' has two
list_headfields: 'lru' and 'list'. Conveniently, they are unioned together. This means that code can use them interchangably, which gets horribly confusing.
Quoted 5 lines
The blk-mq made the logical decision to try to use
page->list. But, that field was actually introduced just for the slub code. ->lru is the right field to use outside of slab/slub.Signed-off-by Dave Hansen <[email protected]>
Looks good to me.
for both.
Signature · 1 line
Kirill A. Shutemov
Quoted 14 lines · Dave Hansen
From: Dave Hansen <[email protected]>
'struct page' has two
list_headfields: 'lru' and 'list'. Conveniently, they are unioned together. This means that code can use them interchangably, which gets horribly confusing like with this nugget fromslab.c:Quoted 3 lines
list_del(&page->lru); if (page->active == cachep->num) list_add(&page->list, &n->slabs_full);This patch makes the slab and slub code use
page->listuniversally instead of mixing ->list and ->lru.
Quoted 8 lines
It also adds some comments to attempt to keep new users from picking up uses of ->list.
So, the new rule is:
page->listis what the slabs use.page->lruis for everybody else. This is a pretty arbitrary rule, but we need _something_. Maybe we should just axe the ->list one and make the sl?bs use ->lru.
I'd recommend this suggestion, I don't see why the slab allocators can't use a page->lru field to maintain their lists of slab pages and it makes the code much cleaner. Anybody hacking thise code will know it's not really a lru and we're just reusing a field from struct page without adding unnecessary complexity.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Dave Hansen
'struct page' has two
list_headfields: 'lru' and 'list'. Conveniently, they are unioned together. This means that code can use them interchangably, which gets horribly confusing like with this nugget fromslab.c:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>