Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F6F5C433F5 for ; Thu, 13 Jan 2022 13:40:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235465AbiAMNje (ORCPT ); Thu, 13 Jan 2022 08:39:34 -0500 Received: from mx2.didiglobal.com ([111.202.154.82]:25446 "HELO mailgate02.didichuxing.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S229915AbiAMNjc (ORCPT ); Thu, 13 Jan 2022 08:39:32 -0500 Received: from mail.didiglobal.com (unknown [172.20.36.211]) by mailgate02.didichuxing.com (Maildata Gateway V2.8) with ESMTP id 3E3BD6005E800; Thu, 13 Jan 2022 21:39:28 +0800 (CST) Received: from localhost.localdomain (172.20.16.101) by BJSGEXMBX11.didichuxing.com (172.20.15.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 13 Jan 2022 21:39:27 +0800 X-MD-Sfrom: wanghonglei@didiglobal.com X-MD-SrcIP: 172.20.36.211 From: Honglei Wang To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , CC: Honglei Wang Subject: [PATCH] sched/numa: initialize numa statistics when forking new task Date: Thu, 13 Jan 2022 21:39:20 +0800 Message-ID: <20220113133920.49900-1-wanghonglei@didichuxing.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [172.20.16.101] X-ClientProxiedBy: BJEXCAS02.didichuxing.com (172.20.36.211) To BJSGEXMBX11.didichuxing.com (172.20.15.141) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The child processes will inherit numa_pages_migrated and total_numa_faults from the parent. It means even if there is no numa fault happen on the child, the statistics in /proc/$pid of the child process might show huge amount. This is a bit weird. Let's initialize them when do fork. Signed-off-by: Honglei Wang --- kernel/sched/fair.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6e476f6d9435..1aa0ec123a4b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -2826,6 +2826,8 @@ void init_numa_balancing(unsigned long clone_flags, struct task_struct *p) /* Protect against double add, see task_tick_numa and task_numa_work */ p->numa_work.next = &p->numa_work; p->numa_faults = NULL; + p->numa_pages_migrated = 0; + p->total_numa_faults = 0; RCU_INIT_POINTER(p->numa_group, NULL); p->last_task_numa_placement = 0; p->last_sum_exec_runtime = 0; -- 2.14.1