* [PATCH v2 01/13] x86/mm/hotplug: Don't remove PGD entries in remove_pagetable()
[not found] <cover.1466192946.git.luto@kernel.org>
@ 2016-06-17 20:00 ` Andy Lutomirski
2016-06-17 20:00 ` [PATCH v2 04/13] mm: Track NR_KERNEL_STACK in KiB instead of number of stacks Andy Lutomirski
2016-06-17 20:00 ` [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack Andy Lutomirski
2 siblings, 0 replies; 8+ messages in thread
From: Andy Lutomirski @ 2016-06-17 20:00 UTC (permalink / raw)
To: x86, linux-kernel
Cc: linux-arch, Borislav Petkov, Nadav Amit, Kees Cook, Brian Gerst,
kernel-hardening@lists.openwall.com, Linus Torvalds,
Josh Poimboeuf, Jann Horn, Heiko Carstens, Ingo Molnar,
Andrew Morton, Andy Lutomirski, Denys Vlasenko, H. Peter Anvin,
Oleg Nesterov, Peter Zijlstra, Rik van Riel, Thomas Gleixner,
Waiman Long, linux-mm
From: Ingo Molnar <mingo@kernel.org>
So when memory hotplug removes a piece of physical memory from pagetable
mappings, it also frees the underlying PGD entry.
This complicates PGD management, so don't do this. We can keep the
PGD mapped and the PUD table all clear - it's only a single 4K page
per 512 GB of memory hotplugged.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Waiman Long <Waiman.Long@hp.com>
Cc: linux-mm@kvack.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Message-Id: <1442903021-3893-4-git-send-email-mingo@kernel.org>
---
arch/x86/mm/init_64.c | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index bce2e5d9edd4..c7465453d64e 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -702,27 +702,6 @@ static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud)
spin_unlock(&init_mm.page_table_lock);
}
-/* Return true if pgd is changed, otherwise return false. */
-static bool __meminit free_pud_table(pud_t *pud_start, pgd_t *pgd)
-{
- pud_t *pud;
- int i;
-
- for (i = 0; i < PTRS_PER_PUD; i++) {
- pud = pud_start + i;
- if (pud_val(*pud))
- return false;
- }
-
- /* free a pud table */
- free_pagetable(pgd_page(*pgd), 0);
- spin_lock(&init_mm.page_table_lock);
- pgd_clear(pgd);
- spin_unlock(&init_mm.page_table_lock);
-
- return true;
-}
-
static void __meminit
remove_pte_table(pte_t *pte_start, unsigned long addr, unsigned long end,
bool direct)
@@ -913,7 +892,6 @@ remove_pagetable(unsigned long start, unsigned long end, bool direct)
unsigned long addr;
pgd_t *pgd;
pud_t *pud;
- bool pgd_changed = false;
for (addr = start; addr < end; addr = next) {
next = pgd_addr_end(addr, end);
@@ -924,13 +902,8 @@ remove_pagetable(unsigned long start, unsigned long end, bool direct)
pud = (pud_t *)pgd_page_vaddr(*pgd);
remove_pud_table(pud, addr, next, direct);
- if (free_pud_table(pud, pgd))
- pgd_changed = true;
}
- if (pgd_changed)
- sync_global_pgds(start, end - 1, 1);
-
flush_tlb_all();
}
--
2.5.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 04/13] mm: Track NR_KERNEL_STACK in KiB instead of number of stacks
[not found] <cover.1466192946.git.luto@kernel.org>
2016-06-17 20:00 ` [PATCH v2 01/13] x86/mm/hotplug: Don't remove PGD entries in remove_pagetable() Andy Lutomirski
@ 2016-06-17 20:00 ` Andy Lutomirski
2016-06-20 13:16 ` Michal Hocko
2016-06-17 20:00 ` [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack Andy Lutomirski
2 siblings, 1 reply; 8+ messages in thread
From: Andy Lutomirski @ 2016-06-17 20:00 UTC (permalink / raw)
To: x86, linux-kernel
Cc: linux-arch, Borislav Petkov, Nadav Amit, Kees Cook, Brian Gerst,
kernel-hardening@lists.openwall.com, Linus Torvalds,
Josh Poimboeuf, Jann Horn, Heiko Carstens, Andy Lutomirski,
Vladimir Davydov, Johannes Weiner, Michal Hocko, linux-mm
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.
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: linux-mm@kvack.org
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
drivers/base/node.c | 3 +--
fs/proc/meminfo.c | 2 +-
include/linux/mmzone.h | 2 +-
kernel/fork.c | 3 ++-
mm/page_alloc.c | 3 +--
5 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 560751bad294..27dc68a0ed2d 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -121,8 +121,7 @@ static ssize_t node_read_meminfo(struct device *dev,
nid, K(node_page_state(nid, NR_FILE_MAPPED)),
nid, K(node_page_state(nid, NR_ANON_PAGES)),
nid, K(i.sharedram),
- nid, node_page_state(nid, NR_KERNEL_STACK) *
- THREAD_SIZE / 1024,
+ nid, node_page_state(nid, NR_KERNEL_STACK_KB),
nid, K(node_page_state(nid, NR_PAGETABLE)),
nid, K(node_page_state(nid, NR_UNSTABLE_NFS)),
nid, K(node_page_state(nid, NR_BOUNCE)),
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 83720460c5bc..239b5a06cee0 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -145,7 +145,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()),
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 02069c23486d..63f05a7efb54 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -127,7 +127,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_UNSTABLE_NFS, /* NFS unstable pages */
NR_BOUNCE,
diff --git a/kernel/fork.c b/kernel/fork.c
index 5c2c355aa97f..be7f006af727 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -225,7 +225,8 @@ static void account_kernel_stack(struct thread_info *ti, int account)
{
struct zone *zone = page_zone(virt_to_page(ti));
- 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)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6903b695ebae..a277dea926c9 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4457,8 +4457,7 @@ void show_free_areas(unsigned int filter)
K(zone_page_state(zone, NR_SHMEM)),
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_UNSTABLE_NFS)),
K(zone_page_state(zone, NR_BOUNCE)),
--
2.5.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack
[not found] <cover.1466192946.git.luto@kernel.org>
2016-06-17 20:00 ` [PATCH v2 01/13] x86/mm/hotplug: Don't remove PGD entries in remove_pagetable() Andy Lutomirski
2016-06-17 20:00 ` [PATCH v2 04/13] mm: Track NR_KERNEL_STACK in KiB instead of number of stacks Andy Lutomirski
@ 2016-06-17 20:00 ` Andy Lutomirski
2016-06-17 20:55 ` Josh Poimboeuf
2016-06-20 13:02 ` Michal Hocko
2 siblings, 2 replies; 8+ messages in thread
From: Andy Lutomirski @ 2016-06-17 20:00 UTC (permalink / raw)
To: x86, linux-kernel
Cc: linux-arch, Borislav Petkov, Nadav Amit, Kees Cook, Brian Gerst,
kernel-hardening@lists.openwall.com, Linus Torvalds,
Josh Poimboeuf, Jann Horn, Heiko Carstens, Andy Lutomirski,
Vladimir Davydov, Johannes Weiner, Michal Hocko, linux-mm
We should account for stacks regardless of stack size. Move it into
account_kernel_stack.
Fixes: 12580e4b54ba8 ("mm: memcontrol: report kernel stack usage in cgroup2 memory.stat")
Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: linux-mm@kvack.org
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
kernel/fork.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index be7f006af727..cd2abe6e4e41 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -165,20 +165,12 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
struct page *page = alloc_kmem_pages_node(node, THREADINFO_GFP,
THREAD_SIZE_ORDER);
- if (page)
- memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
- 1 << THREAD_SIZE_ORDER);
-
return page ? page_address(page) : NULL;
}
static inline void free_thread_info(struct thread_info *ti)
{
- struct page *page = virt_to_page(ti);
-
- memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
- -(1 << THREAD_SIZE_ORDER));
- __free_kmem_pages(page, THREAD_SIZE_ORDER);
+ free_kmem_pages((unsigned long)ti, THREAD_SIZE_ORDER);
}
# else
static struct kmem_cache *thread_info_cache;
@@ -227,6 +219,11 @@ static void account_kernel_stack(struct thread_info *ti, int account)
mod_zone_page_state(zone, NR_KERNEL_STACK_KB,
THREAD_SIZE / 1024 * account);
+
+ /* All stack pages belong to the same memcg. */
+ memcg_kmem_update_page_stat(
+ virt_to_page(ti), MEMCG_KERNEL_STACK,
+ account * (THREAD_SIZE / PAGE_SIZE));
}
void free_task(struct task_struct *tsk)
--
2.5.5
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack
2016-06-17 20:00 ` [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack Andy Lutomirski
@ 2016-06-17 20:55 ` Josh Poimboeuf
2016-06-17 22:18 ` Andy Lutomirski
2016-06-20 13:02 ` Michal Hocko
1 sibling, 1 reply; 8+ messages in thread
From: Josh Poimboeuf @ 2016-06-17 20:55 UTC (permalink / raw)
To: Andy Lutomirski
Cc: x86, linux-kernel, linux-arch, Borislav Petkov, Nadav Amit,
Kees Cook, Brian Gerst, kernel-hardening@lists.openwall.com,
Linus Torvalds, Jann Horn, Heiko Carstens, Vladimir Davydov,
Johannes Weiner, Michal Hocko, linux-mm
On Fri, Jun 17, 2016 at 01:00:41PM -0700, Andy Lutomirski wrote:
> We should account for stacks regardless of stack size. Move it into
> account_kernel_stack.
>
> Fixes: 12580e4b54ba8 ("mm: memcontrol: report kernel stack usage in cgroup2 memory.stat")
> Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: linux-mm@kvack.org
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
> kernel/fork.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index be7f006af727..cd2abe6e4e41 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -165,20 +165,12 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
> struct page *page = alloc_kmem_pages_node(node, THREADINFO_GFP,
> THREAD_SIZE_ORDER);
>
> - if (page)
> - memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
> - 1 << THREAD_SIZE_ORDER);
> -
> return page ? page_address(page) : NULL;
> }
>
> static inline void free_thread_info(struct thread_info *ti)
> {
> - struct page *page = virt_to_page(ti);
> -
> - memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
> - -(1 << THREAD_SIZE_ORDER));
> - __free_kmem_pages(page, THREAD_SIZE_ORDER);
> + free_kmem_pages((unsigned long)ti, THREAD_SIZE_ORDER);
> }
> # else
> static struct kmem_cache *thread_info_cache;
> @@ -227,6 +219,11 @@ static void account_kernel_stack(struct thread_info *ti, int account)
>
> mod_zone_page_state(zone, NR_KERNEL_STACK_KB,
> THREAD_SIZE / 1024 * account);
> +
> + /* All stack pages belong to the same memcg. */
> + memcg_kmem_update_page_stat(
> + virt_to_page(ti), MEMCG_KERNEL_STACK,
> + account * (THREAD_SIZE / PAGE_SIZE));
> }
Won't this be broken in the case where THREAD_SIZE < PAGE_SIZE?
--
Josh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack
2016-06-17 20:55 ` Josh Poimboeuf
@ 2016-06-17 22:18 ` Andy Lutomirski
0 siblings, 0 replies; 8+ messages in thread
From: Andy Lutomirski @ 2016-06-17 22:18 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: Andy Lutomirski, X86 ML, linux-kernel@vger.kernel.org, linux-arch,
Borislav Petkov, Nadav Amit, Kees Cook, Brian Gerst,
kernel-hardening@lists.openwall.com, Linus Torvalds, Jann Horn,
Heiko Carstens, Vladimir Davydov, Johannes Weiner, Michal Hocko,
linux-mm@kvack.org
On Fri, Jun 17, 2016 at 1:55 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Fri, Jun 17, 2016 at 01:00:41PM -0700, Andy Lutomirski wrote:
>> We should account for stacks regardless of stack size. Move it into
>> account_kernel_stack.
>>
>> Fixes: 12580e4b54ba8 ("mm: memcontrol: report kernel stack usage in cgroup2 memory.stat")
>> Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
>> Cc: Johannes Weiner <hannes@cmpxchg.org>
>> Cc: Michal Hocko <mhocko@kernel.org>
>> Cc: linux-mm@kvack.org
>> Signed-off-by: Andy Lutomirski <luto@kernel.org>
>> ---
>> kernel/fork.c | 15 ++++++---------
>> 1 file changed, 6 insertions(+), 9 deletions(-)
>>
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index be7f006af727..cd2abe6e4e41 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -165,20 +165,12 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
>> struct page *page = alloc_kmem_pages_node(node, THREADINFO_GFP,
>> THREAD_SIZE_ORDER);
>>
>> - if (page)
>> - memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
>> - 1 << THREAD_SIZE_ORDER);
>> -
>> return page ? page_address(page) : NULL;
>> }
>>
>> static inline void free_thread_info(struct thread_info *ti)
>> {
>> - struct page *page = virt_to_page(ti);
>> -
>> - memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
>> - -(1 << THREAD_SIZE_ORDER));
>> - __free_kmem_pages(page, THREAD_SIZE_ORDER);
>> + free_kmem_pages((unsigned long)ti, THREAD_SIZE_ORDER);
>> }
>> # else
>> static struct kmem_cache *thread_info_cache;
>> @@ -227,6 +219,11 @@ static void account_kernel_stack(struct thread_info *ti, int account)
>>
>> mod_zone_page_state(zone, NR_KERNEL_STACK_KB,
>> THREAD_SIZE / 1024 * account);
>> +
>> + /* All stack pages belong to the same memcg. */
>> + memcg_kmem_update_page_stat(
>> + virt_to_page(ti), MEMCG_KERNEL_STACK,
>> + account * (THREAD_SIZE / PAGE_SIZE));
>> }
>
> Won't this be broken in the case where THREAD_SIZE < PAGE_SIZE?
In my defense, it was broken before this change, too. Sigh. I'll
change this to count in KiB too.
As far as I can tell, this thing is used for display only.
--Andy
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack
2016-06-17 20:00 ` [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack Andy Lutomirski
2016-06-17 20:55 ` Josh Poimboeuf
@ 2016-06-20 13:02 ` Michal Hocko
2016-06-20 16:05 ` Andy Lutomirski
1 sibling, 1 reply; 8+ messages in thread
From: Michal Hocko @ 2016-06-20 13:02 UTC (permalink / raw)
To: Andy Lutomirski
Cc: x86, linux-kernel, linux-arch, Borislav Petkov, Nadav Amit,
Kees Cook, Brian Gerst, kernel-hardening@lists.openwall.com,
Linus Torvalds, Josh Poimboeuf, Jann Horn, Heiko Carstens,
Vladimir Davydov, Johannes Weiner, linux-mm
On Fri 17-06-16 13:00:41, Andy Lutomirski wrote:
> We should account for stacks regardless of stack size. Move it into
> account_kernel_stack.
>
> Fixes: 12580e4b54ba8 ("mm: memcontrol: report kernel stack usage in cgroup2 memory.stat")
> Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: linux-mm@kvack.org
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> kernel/fork.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index be7f006af727..cd2abe6e4e41 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -165,20 +165,12 @@ static struct thread_info *alloc_thread_info_node(struct task_struct *tsk,
> struct page *page = alloc_kmem_pages_node(node, THREADINFO_GFP,
> THREAD_SIZE_ORDER);
>
> - if (page)
> - memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
> - 1 << THREAD_SIZE_ORDER);
> -
> return page ? page_address(page) : NULL;
> }
>
> static inline void free_thread_info(struct thread_info *ti)
> {
> - struct page *page = virt_to_page(ti);
> -
> - memcg_kmem_update_page_stat(page, MEMCG_KERNEL_STACK,
> - -(1 << THREAD_SIZE_ORDER));
> - __free_kmem_pages(page, THREAD_SIZE_ORDER);
> + free_kmem_pages((unsigned long)ti, THREAD_SIZE_ORDER);
> }
> # else
> static struct kmem_cache *thread_info_cache;
> @@ -227,6 +219,11 @@ static void account_kernel_stack(struct thread_info *ti, int account)
>
> mod_zone_page_state(zone, NR_KERNEL_STACK_KB,
> THREAD_SIZE / 1024 * account);
> +
> + /* All stack pages belong to the same memcg. */
> + memcg_kmem_update_page_stat(
> + virt_to_page(ti), MEMCG_KERNEL_STACK,
> + account * (THREAD_SIZE / PAGE_SIZE));
> }
>
> void free_task(struct task_struct *tsk)
> --
> 2.5.5
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 04/13] mm: Track NR_KERNEL_STACK in KiB instead of number of stacks
2016-06-17 20:00 ` [PATCH v2 04/13] mm: Track NR_KERNEL_STACK in KiB instead of number of stacks Andy Lutomirski
@ 2016-06-20 13:16 ` Michal Hocko
0 siblings, 0 replies; 8+ messages in thread
From: Michal Hocko @ 2016-06-20 13:16 UTC (permalink / raw)
To: Andy Lutomirski
Cc: x86, linux-kernel, linux-arch, Borislav Petkov, Nadav Amit,
Kees Cook, Brian Gerst, kernel-hardening@lists.openwall.com,
Linus Torvalds, Josh Poimboeuf, Jann Horn, Heiko Carstens,
Vladimir Davydov, Johannes Weiner, linux-mm
On Fri 17-06-16 13:00:40, Andy Lutomirski wrote:
> 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.
>
> Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: linux-mm@kvack.org
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
Makes sense to me.
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> drivers/base/node.c | 3 +--
> fs/proc/meminfo.c | 2 +-
> include/linux/mmzone.h | 2 +-
> kernel/fork.c | 3 ++-
> mm/page_alloc.c | 3 +--
> 5 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/base/node.c b/drivers/base/node.c
> index 560751bad294..27dc68a0ed2d 100644
> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -121,8 +121,7 @@ static ssize_t node_read_meminfo(struct device *dev,
> nid, K(node_page_state(nid, NR_FILE_MAPPED)),
> nid, K(node_page_state(nid, NR_ANON_PAGES)),
> nid, K(i.sharedram),
> - nid, node_page_state(nid, NR_KERNEL_STACK) *
> - THREAD_SIZE / 1024,
> + nid, node_page_state(nid, NR_KERNEL_STACK_KB),
> nid, K(node_page_state(nid, NR_PAGETABLE)),
> nid, K(node_page_state(nid, NR_UNSTABLE_NFS)),
> nid, K(node_page_state(nid, NR_BOUNCE)),
> diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
> index 83720460c5bc..239b5a06cee0 100644
> --- a/fs/proc/meminfo.c
> +++ b/fs/proc/meminfo.c
> @@ -145,7 +145,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()),
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 02069c23486d..63f05a7efb54 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -127,7 +127,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_UNSTABLE_NFS, /* NFS unstable pages */
> NR_BOUNCE,
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 5c2c355aa97f..be7f006af727 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -225,7 +225,8 @@ static void account_kernel_stack(struct thread_info *ti, int account)
> {
> struct zone *zone = page_zone(virt_to_page(ti));
>
> - 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)
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 6903b695ebae..a277dea926c9 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -4457,8 +4457,7 @@ void show_free_areas(unsigned int filter)
> K(zone_page_state(zone, NR_SHMEM)),
> 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_UNSTABLE_NFS)),
> K(zone_page_state(zone, NR_BOUNCE)),
> --
> 2.5.5
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack
2016-06-20 13:02 ` Michal Hocko
@ 2016-06-20 16:05 ` Andy Lutomirski
0 siblings, 0 replies; 8+ messages in thread
From: Andy Lutomirski @ 2016-06-20 16:05 UTC (permalink / raw)
To: Michal Hocko
Cc: linux-arch, Josh Poimboeuf, Borislav Petkov, Heiko Carstens,
linux-mm@kvack.org, Brian Gerst, Johannes Weiner, Linus Torvalds,
Nadav Amit, Kees Cook, linux-kernel@vger.kernel.org, Jann Horn,
Vladimir Davydov, kernel-hardening@lists.openwall.com, X86 ML
On Jun 20, 2016 6:02 AM, "Michal Hocko" <mhocko@kernel.org> wrote:
>
> On Fri 17-06-16 13:00:41, Andy Lutomirski wrote:
> > We should account for stacks regardless of stack size. Move it into
> > account_kernel_stack.
> >
> > Fixes: 12580e4b54ba8 ("mm: memcontrol: report kernel stack usage in cgroup2 memory.stat")
> > Cc: Vladimir Davydov <vdavydov@virtuozzo.com>
> > Cc: Johannes Weiner <hannes@cmpxchg.org>
> > Cc: Michal Hocko <mhocko@kernel.org>
> > Cc: linux-mm@kvack.org
> > Signed-off-by: Andy Lutomirski <luto@kernel.org>
>
> Acked-by: Michal Hocko <mhocko@suse.com>
>
This needs the same kilobyte treatment as the other accounting patch,
so I'm going to send v3 without your ack.
--Andy
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-06-20 16:05 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1466192946.git.luto@kernel.org>
2016-06-17 20:00 ` [PATCH v2 01/13] x86/mm/hotplug: Don't remove PGD entries in remove_pagetable() Andy Lutomirski
2016-06-17 20:00 ` [PATCH v2 04/13] mm: Track NR_KERNEL_STACK in KiB instead of number of stacks Andy Lutomirski
2016-06-20 13:16 ` Michal Hocko
2016-06-17 20:00 ` [PATCH v2 05/13] mm: Move memcg stack accounting to account_kernel_stack Andy Lutomirski
2016-06-17 20:55 ` Josh Poimboeuf
2016-06-17 22:18 ` Andy Lutomirski
2016-06-20 13:02 ` Michal Hocko
2016-06-20 16:05 ` Andy Lutomirski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).