From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 4D7CBC433DB for ; Tue, 2 Mar 2021 08:44:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A739E64DE4 for ; Tue, 2 Mar 2021 08:44:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A739E64DE4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CD4718D00E8; Tue, 2 Mar 2021 03:44:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C5DB48D0063; Tue, 2 Mar 2021 03:44:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFD228D00E8; Tue, 2 Mar 2021 03:44:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id 946D78D0063 for ; Tue, 2 Mar 2021 03:44:45 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 59E04181AF5CC for ; Tue, 2 Mar 2021 08:44:45 +0000 (UTC) X-FDA: 77874298530.28.825680D Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf25.hostedemail.com (Postfix) with ESMTP id D4E8E60024A3 for ; Tue, 2 Mar 2021 08:44:43 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614674683; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZBnLGSe1gH0StLLOp+vkB66rJ3ZeBVTb8pfylvStG8Y=; b=U21HVWtfzGlmYBEkQ0M5CXhpoSfBCOeIsn4zdzi9ieIOlJ9hKZ5AO1iKjkv/dnGoCWGINE XLpR/Y8WhZ/iYDJiP71+kEkLhgUNyj8gUcUM0gt9Czm/kdQV4JZiq0zixQN4u5in+R8K3i KcX0zMsZU/tSkbxoKBwLeDuBQyR9RiQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 65777ABF4; Tue, 2 Mar 2021 08:44:43 +0000 (UTC) Date: Tue, 2 Mar 2021 09:44:42 +0100 From: Michal Hocko To: Muchun Song Cc: guro@fb.com, hannes@cmpxchg.org, akpm@linux-foundation.org, shakeelb@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: memcontrol: fix kernel stack account Message-ID: References: <20210302073733.8928-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210302073733.8928-1-songmuchun@bytedance.com> X-Stat-Signature: z4m4mrxqtxdistso41m637ysen6839jb X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D4E8E60024A3 Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614674683-425235 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: On Tue 02-03-21 15:37:33, Muchun Song wrote: > The alloc_thread_stack_node() cannot guarantee that allocated stack pages > are in the same node when CONFIG_VMAP_STACK. Because we do not specify > __GFP_THISNODE to __vmalloc_node_range(). Fix it by caling > mod_lruvec_page_state() for each page one by one. What is the actual problem you are trying to address by this patch? 991e7673859e has deliberately dropped the per page accounting. Can you explain why that was incorrect? There surely is some imprecision involved but does it matter and is it even observable? > Fixes: 991e7673859e ("mm: memcontrol: account kernel stack per node") > Signed-off-by: Muchun Song > --- > kernel/fork.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/kernel/fork.c b/kernel/fork.c > index d66cd1014211..6e2201feb524 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -379,14 +379,19 @@ static void account_kernel_stack(struct task_struct *tsk, int account) > void *stack = task_stack_page(tsk); > struct vm_struct *vm = task_stack_vm_area(tsk); > > + if (vm) { > + int i; > > - /* 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)); > - else > + BUG_ON(vm->nr_pages != THREAD_SIZE / PAGE_SIZE); > + > + for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) > + mod_lruvec_page_state(vm->pages[i], NR_KERNEL_STACK_KB, > + account * (PAGE_SIZE / 1024)); > + } else { > + /* All stack pages are in the same node. */ > mod_lruvec_kmem_state(stack, NR_KERNEL_STACK_KB, > account * (THREAD_SIZE / 1024)); > + } > } > > static int memcg_charge_kernel_stack(struct task_struct *tsk) > -- > 2.11.0 -- Michal Hocko SUSE Labs