From patchwork Sun Dec 6 08:23:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 11953751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC39BC4361B for ; Sun, 6 Dec 2020 08:26:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 797CD23108 for ; Sun, 6 Dec 2020 08:26:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 797CD23108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1AD716B0072; Sun, 6 Dec 2020 03:26:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 185698D0003; Sun, 6 Dec 2020 03:26:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 074488D0002; Sun, 6 Dec 2020 03:26:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id E664B6B0072 for ; Sun, 6 Dec 2020 03:26:18 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AF3641EE6 for ; Sun, 6 Dec 2020 08:26:18 +0000 (UTC) X-FDA: 77562175236.14.quiet52_5c135e0273d4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 9757118229837 for ; Sun, 6 Dec 2020 08:26:18 +0000 (UTC) X-HE-Tag: quiet52_5c135e0273d4 X-Filterd-Recvd-Size: 8298 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Sun, 6 Dec 2020 08:26:18 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id j1so5526866pld.3 for ; Sun, 06 Dec 2020 00:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ibu+HPexsNJ6GCHgTCs1EnvihRdwIFloguIfEoBcFm0=; b=0KIdxuQCRm1tphbYacq9bX4Sb+TggrItu57ArKUaQQCoBwXHVcwX/Gwuv524IG7RZD IW1KI60Yad/FyRbVdczIJW0sLeWj5gELykG2wY8CQlDTorYmdkrUWAmRKbkHpHE59BEb +EH1FxqnpqL/WRaC7sjo+fRRNsF+URl0JgoJ166gWgGczQ2sIx38NeTBgjPmR+/WvHcl lXD0igovt2OFRjP9k0WXUnOInptBFTXsD9fR2CZ0UuXKJaI8Y43Ruj2CLaoXCBiWOzsv BWz1sOSryCfYCcK4psndLWYxqJn7YuoYVvT+CZoCRQNdV2KH4ixS71fk898ew25yiW5v gX0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ibu+HPexsNJ6GCHgTCs1EnvihRdwIFloguIfEoBcFm0=; b=XrHoLj3l8GimJCKVsQpkfHVraZlpzlp9YRZUmcaOoCU0eiDZB9vIqx6/t76fAOYkDz oH1FQsn7/OUK/H0eGaeuSwIzni0eZ1PYYL7303NoSe1HcSzpnl65f6LolOnO0v8bt8c0 WeDJ+eS+15OWamelwWwMiAN1j5CYuAkv9nzxG5IrQNipWkD0MhoLOyJiJ79+etjkDH/y bf8PimzFbdyyhJITQco5bydPDW034W76z3Pc8+VWophgQ2hP3gQzSVe3D6MPFhVAmiZI e4n394Mw02+69ABDNJpNL/AJVUMF7lqE7VbfJDHIA31bzzAOg8tNLLw6CyrmyVGKJrUM /Sbw== X-Gm-Message-State: AOAM5313BBzpTorWSbYGBlOPRTmXcggJ3nR5WZDlETpSE0MWK8MjVYIS 7GdB+fiBqpggxiZaHBbIO6SSWA== X-Google-Smtp-Source: ABdhPJxkn4xNXd8n2rBmwMbQZBjsprGIlYk6gl8R9Qy0Pg3h+GKmsg0om9+NPc4j2H+hw0dSFDiPaA== X-Received: by 2002:a17:90a:9516:: with SMTP id t22mr11426018pjo.182.1607243177099; Sun, 06 Dec 2020 00:26:17 -0800 (PST) Received: from localhost.localdomain ([103.136.221.70]) by smtp.gmail.com with ESMTPSA id iq3sm6884104pjb.57.2020.12.06.00.26.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Dec 2020 00:26:16 -0800 (PST) From: Muchun Song 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 Subject: [PATCH 3/9] mm: memcontrol: convert kernel stack account to byte-sized Date: Sun, 6 Dec 2020 16:23:03 +0800 Message-Id: <20201206082318.11532-7-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) In-Reply-To: <20201206082318.11532-1-songmuchun@bytedance.com> References: <20201206082318.11532-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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);