From patchwork Mon May 4 07:03:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandipan Das X-Patchwork-Id: 11525131 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5BC0913 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 A978120757 for ; Mon, 4 May 2020 07:03:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A978120757 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DFC5D8E0001; Mon, 4 May 2020 03:03:14 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 2,0,0,db9f9124323cbe81,d41d8cd98f00b204,sandipan@linux.ibm.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1261:1345:1437:1534:1542:1711:1730:1747:1777:1792:1801:2194:2196:2199:2200:2393:2559:2562:2898:3138:3139:3140:3141:3142:3353:3369:3865:3866:3867:3874:4250:4385:4605:5007:6261:7904:8603:9121:10004:11026:11658:11914:12043:12296:12297:12438:12555:12679:12895:14181:14394:14721:14819:21080:21451:21617:21990:30054:30070,0,RBL:148.163.158.5:@linux.ibm.com:.lbl8.mailshell.net-62.14.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none 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];