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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 82278C3A5A9 for ; Mon, 4 May 2020 07:03:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 506C120757 for ; Mon, 4 May 2020 07:03:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 506C120757 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E4C288E0006; Mon, 4 May 2020 03:03:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DFC5D8E0001; Mon, 4 May 2020 03:03:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D124C8E0006; Mon, 4 May 2020 03:03:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id BA3678E0001 for ; Mon, 4 May 2020 03:03:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 68ABE4995E8 for ; Mon, 4 May 2020 07:03:14 +0000 (UTC) X-FDA: 76778145108.30.print19_738e810f96462 X-HE-Tag: print19_738e810f96462 X-Filterd-Recvd-Size: 4956 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 May 2020 07:03:13 +0000 (UTC) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0446Y5Yu120298; Mon, 4 May 2020 03:03:12 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 30sp8hbfhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2020 03:03:12 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 0446txrV027115; Mon, 4 May 2020 07:03:10 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 30s0g61nxs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 04 May 2020 07:03:10 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0447376B10551636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 May 2020 07:03:07 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BBFAD4C052; Mon, 4 May 2020 07:03:06 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A58C4C059; Mon, 4 May 2020 07:03:05 +0000 (GMT) Received: from fir03.in.ibm.com (unknown [9.121.59.65]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 4 May 2020 07:03:05 +0000 (GMT) From: Sandipan Das To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, khlebnikov@yandex-team.ru, mhocko@kernel.org, kirill@shutemov.name, aneesh.kumar@linux.ibm.com, srikar@linux.vnet.ibm.com Subject: [PATCH] mm: vmstat: Use zeroed stats for unpopulated zones Date: Mon, 4 May 2020 12:33:04 +0530 Message-Id: <20200504070304.127361-1-sandipan@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-05-04_02:2020-05-01,2020-05-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=3 priorityscore=1501 spamscore=0 clxscore=1011 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005040053 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: For unpopulated zones, the pagesets point to the common boot_pageset which can have non-zero vm_numa_stat counts. Because of this memory-less nodes end up having non-zero NUMA statistics. This can be observed on any architecture that supports memory-less NUMA nodes. E.g. $ numactl -H available: 2 nodes (0-1) node 0 cpus: 0 1 2 3 node 0 size: 0 MB node 0 free: 0 MB node 1 cpus: 4 5 6 7 node 1 size: 8131 MB node 1 free: 6980 MB node distances: node 0 1 0: 10 40 1: 40 10 $ numastat node0 node1 numa_hit 108 56495 numa_miss 0 0 numa_foreign 0 0 interleave_hit 0 4537 local_node 108 31547 other_node 0 24948 Hence, return zero explicitly for all the stats of an unpopulated zone. Signed-off-by: Sandipan Das --- include/linux/vmstat.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 292485f3d24d..55a68b379a2c 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -159,6 +159,21 @@ static inline unsigned long zone_numa_state_snapshot(struct zone *zone, long x = atomic_long_read(&zone->vm_numa_stat[item]); int cpu; + /* + * Initially, the pageset of all zones are set to point to the + * boot_pageset. The real pagesets are allocated later but only + * for the populated zones. Unpopulated zones still continue + * using the boot_pageset. + * + * Before the real pagesets are allocated, the boot_pageset's + * vm_numa_stat counters can get incremented. This affects the + * unpopulated zones which end up with non-zero stats despite + * having no memory associated with them. For such cases, + * return zero explicitly. + */ + if (!populated_zone(zone)) + return 0; + for_each_online_cpu(cpu) x += per_cpu_ptr(zone->pageset, cpu)->vm_numa_stat_diff[item]; -- 2.17.1