From: Muchun Song <songmuchun@bytedance.com>
To: gregkh@linuxfoundation.org, rafael@kernel.org,
adobriyan@gmail.com, akpm@linux-foundation.org,
hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com,
hughd@google.com, will@kernel.org, guro@fb.com, rppt@kernel.org,
tglx@linutronix.de, esyr@redhat.com, peterx@redhat.com,
krisman@collabora.com, surenb@google.com, avagin@openvz.org,
elver@google.com, rdunlap@infradead.org, iamjoonsoo.kim@lge.com
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org, cgroups@vger.kernel.org,
Muchun Song <songmuchun@bytedance.com>
Subject: [PATCH 3/9] mm: memcontrol: convert kernel stack account to byte-sized
Date: Sun, 6 Dec 2020 16:23:03 +0800 [thread overview]
Message-ID: <20201206082318.11532-7-songmuchun@bytedance.com> (raw)
In-Reply-To: <20201206082318.11532-1-songmuchun@bytedance.com>
The kernel stack account is the only one that counts in KiB.
This patch convert it from KiB to byte.
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
drivers/base/node.c | 2 +-
fs/proc/meminfo.c | 2 +-
include/linux/mmzone.h | 2 +-
kernel/fork.c | 8 ++++----
mm/memcontrol.c | 2 +-
mm/page_alloc.c | 2 +-
mm/vmstat.c | 4 ++--
7 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/base/node.c b/drivers/base/node.c
index 6ffa470e2984..855886a6ba0e 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -446,7 +446,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, node_page_state(pgdat, NR_KERNEL_STACK_KB),
+ nid, node_page_state(pgdat, NR_KERNEL_STACK_B) / 1024,
#ifdef CONFIG_SHADOW_CALL_STACK
nid, node_page_state(pgdat, NR_KERNEL_SCS_KB),
#endif
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 887a5532e449..c396b6cfba82 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -101,7 +101,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
show_val_kb(m, "SReclaimable: ", sreclaimable);
show_val_kb(m, "SUnreclaim: ", sunreclaim);
seq_printf(m, "KernelStack: %8lu kB\n",
- global_node_page_state(NR_KERNEL_STACK_KB));
+ global_node_page_state(NR_KERNEL_STACK_B) / 1024);
#ifdef CONFIG_SHADOW_CALL_STACK
seq_printf(m, "ShadowCallStack:%8lu kB\n",
global_node_page_state(NR_KERNEL_SCS_KB));
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 15132adaa233..bd34416293ec 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -202,7 +202,7 @@ enum node_stat_item {
NR_KERNEL_MISC_RECLAIMABLE, /* reclaimable non-slab kernel pages */
NR_FOLL_PIN_ACQUIRED, /* via: pin_user_page(), gup flag: FOLL_PIN */
NR_FOLL_PIN_RELEASED, /* pages returned via unpin_user_page() */
- NR_KERNEL_STACK_KB, /* measured in KiB */
+ NR_KERNEL_STACK_B, /* measured in byte */
#if IS_ENABLED(CONFIG_SHADOW_CALL_STACK)
NR_KERNEL_SCS_KB, /* measured in KiB */
#endif
diff --git a/kernel/fork.c b/kernel/fork.c
index 345f378e104d..2913d7c43dcb 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -382,11 +382,11 @@ static void account_kernel_stack(struct task_struct *tsk, int account)
/* All stack pages are in the same node. */
if (vm)
- mod_lruvec_page_state(vm->pages[0], NR_KERNEL_STACK_KB,
- account * (THREAD_SIZE / 1024));
+ mod_lruvec_page_state(vm->pages[0], NR_KERNEL_STACK_B,
+ account * THREAD_SIZE);
else
- mod_lruvec_kmem_state(stack, NR_KERNEL_STACK_KB,
- account * (THREAD_SIZE / 1024));
+ mod_lruvec_kmem_state(stack, NR_KERNEL_STACK_B,
+ account * THREAD_SIZE);
}
static int memcg_charge_kernel_stack(struct task_struct *tsk)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 695dedf8687a..a7ec79dcb7dc 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1500,7 +1500,7 @@ struct memory_stat {
static struct memory_stat memory_stats[] = {
{ "anon", PAGE_SIZE, NR_ANON_MAPPED },
{ "file", PAGE_SIZE, NR_FILE_PAGES },
- { "kernel_stack", 1024, NR_KERNEL_STACK_KB },
+ { "kernel_stack", 1, NR_KERNEL_STACK_B },
{ "percpu", 1, MEMCG_PERCPU_B },
{ "sock", PAGE_SIZE, MEMCG_SOCK },
{ "shmem", PAGE_SIZE, NR_SHMEM },
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 56e603eea1dd..c28f8e1f1ef6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5573,7 +5573,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
K(node_page_state(pgdat, NR_ANON_THPS) * HPAGE_PMD_NR),
#endif
K(node_page_state(pgdat, NR_WRITEBACK_TEMP)),
- node_page_state(pgdat, NR_KERNEL_STACK_KB),
+ node_page_state(pgdat, NR_KERNEL_STACK_B) / 1024,
#ifdef CONFIG_SHADOW_CALL_STACK
node_page_state(pgdat, NR_KERNEL_SCS_KB),
#endif
diff --git a/mm/vmstat.c b/mm/vmstat.c
index f7857a7052e4..3e3bcaf7ba7e 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -353,7 +353,7 @@ void __mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item,
x = delta + __this_cpu_read(*p);
t = __this_cpu_read(pcp->stat_threshold);
- if (unlikely(item == NR_KERNEL_STACK_KB))
+ if (unlikely(item == NR_KERNEL_STACK_B))
t <<= PAGE_SHIFT;
if (unlikely(abs(x) > t)) {
@@ -575,7 +575,7 @@ static inline void mod_node_state(struct pglist_data *pgdat,
* for all cpus in a node.
*/
t = this_cpu_read(pcp->stat_threshold);
- if (unlikely(item == NR_KERNEL_STACK_KB))
+ if (unlikely(item == NR_KERNEL_STACK_B))
t <<= PAGE_SHIFT;
o = this_cpu_read(*p);
--
2.11.0
next prev parent reply other threads:[~2020-12-06 8:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-06 8:22 [PATCH v2 00/12] Convert all vmstat counters to pages or bytes Muchun Song
2020-12-06 8:22 ` [PATCH v2 01/12] mm: memcontrol: fix NR_ANON_THPS account Muchun Song
2020-12-06 8:22 ` [PATCH 1/9] mm: vmstat: fix stat_threshold for NR_KERNEL_STACK_KB Muchun Song
2020-12-06 8:23 ` [PATCH v2 02/12] mm: memcontrol: convert NR_ANON_THPS account to pages Muchun Song
2020-12-06 8:23 ` [PATCH 2/9] mm: memcontrol: fix NR_ANON_THPS account Muchun Song
2020-12-06 8:23 ` [PATCH v2 03/12] mm: memcontrol: convert NR_FILE_THPS account to pages Muchun Song
2020-12-06 8:23 ` Muchun Song [this message]
2020-12-06 8:23 ` [PATCH 4/9] mm: memcontrol: convert NR_ANON_THPS " Muchun Song
2020-12-06 8:23 ` [PATCH v2 04/12] mm: memcontrol: convert NR_SHMEM_THPS " Muchun Song
2020-12-06 8:23 ` [PATCH 5/9] mm: memcontrol: convert NR_FILE_THPS " Muchun Song
2020-12-06 8:23 ` [PATCH v2 05/12] mm: memcontrol: convert NR_SHMEM_PMDMAPPED " Muchun Song
2020-12-06 8:23 ` [PATCH v2 06/12] mm: memcontrol: convert NR_FILE_PMDMAPPED " Muchun Song
2020-12-06 8:23 ` [PATCH 6/9] mm: memcontrol: convert NR_SHMEM_THPS " Muchun Song
2020-12-06 8:23 ` [PATCH 7/9] mm: memcontrol: convert NR_SHMEM_PMDMAPPED " Muchun Song
2020-12-06 10:02 ` [PATCH v2 00/12] Convert all vmstat counters to pages or bytes Muchun Song
-- strict thread matches above, loose matches on Subject: below --
2020-12-05 13:02 [PATCH 0/9] Convert all THP vmstat counters to pages Muchun Song
2020-12-05 13:02 ` [PATCH 3/9] mm: memcontrol: convert kernel stack account to byte-sized Muchun Song
2020-12-05 14:10 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201206082318.11532-7-songmuchun@bytedance.com \
--to=songmuchun@bytedance.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@openvz.org \
--cc=cgroups@vger.kernel.org \
--cc=elver@google.com \
--cc=esyr@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=krisman@collabora.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=peterx@redhat.com \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=vdavydov.dev@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).