slub: Fix calculation of cpu slabs
Subsystems (2)
PATCH 1/1 slub: Fix calculation of cpu slabs
/sys/kernel/slab/:t-0000048 # cat cpu_slabs
231 N0=16 N1=215
/sys/kernel/slab/:t-0000048 # cat slabs
145 N0=36 N1=109
See, the number of slabs is smaller than that of cpu slabs.
The bug was introduced by commit 49e2258586b423684f03c278149ab46d8f8b6700 ("slub: per cpu cache for partial pages").
We should use page->pages instead of page->pobjects when calculating the number of cpu partial slabs. This also fixes the mapping of slabs and nodes.
As there's no variable storing the number of total/active objects in cpu partial slabs, and we don't have user interfaces requiring those statistics, I just add WARN_ON for those cases.
--- mm/slub.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
mm/slub.c +7 -1
@@ -4300,7 +4300,13 @@ static ssize_t show_slab_objects(struct kmem_cache *s, page =ACCESS_ONCE (c->partial);if (page) { - x = page->pobjects; + node =page_to_nid (page); +if (flags &SO_TOTAL ) +WARN_ON_ONCE (1 ); +else if (flags &SO_OBJECTS ) +WARN_ON_ONCE (1 ); +else + x = page->pages; total += x; nodes[node] += x; }
Signature · 7 lines
1.8.0.2 -- 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 3 lines · Li Zefan
We should use
page->pagesinstead ofpage->pobjectswhen calculating the number of cpu partial slabs. This also fixes the mapping of slabs and nodes.
True.
Quoted 3 lines
As there's no variable storing the number of total/active objects in cpu partial slabs, and we don't have user interfaces requiring those statistics, I just add
WARN_ONfor those cases.
Well that is not strictly required but it does not hurt either.
--
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 14 lines · Li Zefan
/sys/kernel/slab/:t-0000048 # cat
cpu_slabs
231 N0=16 N1=215
/sys/kernel/slab/:t-0000048 # cat slabs
145 N0=36 N1=109See, the number of slabs is smaller than that of cpu slabs.
The bug was introduced by commit
49e2258586b423684f03c278149ab46d8f8b6700("slub: per cpu cache for partial pages").We should use
page->pagesinstead ofpage->pobjectswhen calculating the number of cpu partial slabs. This also fixes the mapping of slabs and nodes.
Quoted 6 lines
As there's no variable storing the number of total/active objects in cpu partial slabs, and we don't have user interfaces requiring those statistics, I just add
WARN_ONfor those cases.Cc <[email protected]> # 3.2+Signed-off-by Li Zefan <[email protected]>
Quoted 31 lines
---
mm/slub.c| 8 +++++++-1 file changed, 7 insertions(+), 1 deletion(-)mm/slub.c +7
-1@@ -4300,7 +4300,13 @@ static ssize_t show_slab_objects(struct kmem_cache *s, page =ACCESS_ONCE (c->partial);if (page) { - x = page->pobjects; + node =page_to_nid (page); +if (flags &SO_TOTAL ) +WARN_ON_ONCE (1 ); +else if (flags &SO_OBJECTS ) +WARN_ON_ONCE (1 ); +else + x = page->pages; total += x; nodes[node] += x; }Signature · 7 lines
1.8.0.2 -- 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>
--
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>
Hi Pekka,
could you pick up this patch?
Quoted 8 lines · Christoph Lameter
Quoted 3 lines · Li Zefan
We should use
page->pagesinstead ofpage->pobjectswhen calculating the number of cpu partial slabs. This also fixes the mapping of slabs and nodes.True.
Quoted 9 lines
Quoted 3 lines
As there's no variable storing the number of total/active objects in cpu partial slabs, and we don't have user interfaces requiring those statistics, I just add
WARN_ONfor those cases.Well that is not strictly required but it does not hurt either.
--
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 15 lines · Wanpeng Li
Quoted 14 lines · Li Zefan
/sys/kernel/slab/:t-0000048 # cat
cpu_slabs
231 N0=16 N1=215
/sys/kernel/slab/:t-0000048 # cat slabs
145 N0=36 N1=109See, the number of slabs is smaller than that of cpu slabs.
The bug was introduced by commit
49e2258586b423684f03c278149ab46d8f8b6700("slub: per cpu cache for partial pages").We should use
page->pagesinstead ofpage->pobjectswhen calculating the number of cpu partial slabs. This also fixes the mapping of slabs and nodes.
Quoted 8 lines
Quoted 6 lines
As there's no variable storing the number of total/active objects in cpu partial slabs, and we don't have user interfaces requiring those statistics, I just add
WARN_ONfor those cases.Cc <[email protected]> # 3.2+Signed-off-by Li Zefan <[email protected]>Reviewed-by Wanpeng Li <[email protected]>
Applied and sorry for the slow response!
--
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>