mm: track NR_KERNEL_STACK in KiB instead of number of stacks
authorAndy Lutomirski <luto@kernel.org>
Thu, 28 Jul 2016 22:48:14 +0000 (15:48 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 28 Jul 2016 23:07:41 +0000 (16:07 -0700)
Currently, NR_KERNEL_STACK tracks the number of kernel stacks in a zone.
This only makes sense if each kernel stack exists entirely in one zone,
and allowing vmapped stacks could break this assumption.

Since frv has THREAD_SIZE < PAGE_SIZE, we need to track kernel stack
allocations in a unit that divides both THREAD_SIZE and PAGE_SIZE on all
architectures.  Keep it simple and use KiB.

Link: http://lkml.kernel.org/r/083c71e642c5fa5f1b6898902e1b2db7b48940d4.1468523549.git.luto@kernel.org
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/base/node.c
fs/proc/meminfo.c
include/linux/mmzone.h
kernel/fork.c
mm/page_alloc.c

index 264cc214c4df10eff29798f18150370f9928c25a..29cd96661b3077f5272c40e17fd5d5f1b9b9d952 100644 (file)
@@ -124,8 +124,7 @@ static ssize_t node_read_meminfo(struct device *dev,
                       nid, K(node_page_state(pgdat, NR_FILE_MAPPED)),
                       nid, K(node_page_state(pgdat, NR_ANON_MAPPED)),
                       nid, K(i.sharedram),
-                      nid, sum_zone_node_page_state(nid, NR_KERNEL_STACK) *
-                               THREAD_SIZE / 1024,
+                      nid, sum_zone_node_page_state(nid, NR_KERNEL_STACK_KB),
                       nid, K(sum_zone_node_page_state(nid, NR_PAGETABLE)),
                       nid, K(node_page_state(pgdat, NR_UNSTABLE_NFS)),
                       nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)),
index c1fdcc1a907ac96c98cc6fcd672ccb8725cf9364..09e18fdf61e5b48dd67234b19972a10dd5131662 100644 (file)
@@ -147,7 +147,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
                                global_page_state(NR_SLAB_UNRECLAIMABLE)),
                K(global_page_state(NR_SLAB_RECLAIMABLE)),
                K(global_page_state(NR_SLAB_UNRECLAIMABLE)),
-               global_page_state(NR_KERNEL_STACK) * THREAD_SIZE / 1024,
+               global_page_state(NR_KERNEL_STACK_KB),
                K(global_page_state(NR_PAGETABLE)),
 #ifdef CONFIG_QUICKLIST
                K(quicklist_total_size()),
index ca0fbc483441f81cfd9294c40209bdb9b5a05b68..f2e4e90621ec25c237703bc5b1ecba814d1afce9 100644 (file)
@@ -121,7 +121,7 @@ enum zone_stat_item {
        NR_SLAB_RECLAIMABLE,
        NR_SLAB_UNRECLAIMABLE,
        NR_PAGETABLE,           /* used for pagetables */
-       NR_KERNEL_STACK,
+       NR_KERNEL_STACK_KB,     /* measured in KiB */
        /* Second 128 byte cacheline */
        NR_BOUNCE,
 #if IS_ENABLED(CONFIG_ZSMALLOC)
index de21f25e0d2ce9755b80ecc653269b8b5f8e5415..af3637e0ee52dbd71e0a9075fbd5aaf47304f1f3 100644 (file)
@@ -225,7 +225,8 @@ static void account_kernel_stack(unsigned long *stack, int account)
 {
        struct zone *zone = page_zone(virt_to_page(stack));
 
-       mod_zone_page_state(zone, NR_KERNEL_STACK, account);
+       mod_zone_page_state(zone, NR_KERNEL_STACK_KB,
+                           THREAD_SIZE / 1024 * account);
 }
 
 void free_task(struct task_struct *tsk)
index dfdb608f7b3d54a72990ed582e911b0ff3405813..c281125b234980eccb1e8371314960105553dbe7 100644 (file)
@@ -4359,8 +4359,7 @@ void show_free_areas(unsigned int filter)
                        K(zone_page_state(zone, NR_MLOCK)),
                        K(zone_page_state(zone, NR_SLAB_RECLAIMABLE)),
                        K(zone_page_state(zone, NR_SLAB_UNRECLAIMABLE)),
-                       zone_page_state(zone, NR_KERNEL_STACK) *
-                               THREAD_SIZE / 1024,
+                       zone_page_state(zone, NR_KERNEL_STACK_KB),
                        K(zone_page_state(zone, NR_PAGETABLE)),
                        K(zone_page_state(zone, NR_BOUNCE)),
                        K(free_pcp),