From patchwork Tue Feb 2 18:43:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12062621 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.5 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,URIBL_BLOCKED,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 0F524C433DB for ; Tue, 2 Feb 2021 18:43:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5051464E34 for ; Tue, 2 Feb 2021 18:43:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5051464E34 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D7C596B0006; Tue, 2 Feb 2021 13:43:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D52456B006C; Tue, 2 Feb 2021 13:43:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C693B6B0070; Tue, 2 Feb 2021 13:43:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id B17EE6B0006 for ; Tue, 2 Feb 2021 13:43:46 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6F9761EFD for ; Tue, 2 Feb 2021 18:43:46 +0000 (UTC) X-FDA: 77774201652.29.skin84_4114a03275cd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id CCB82180868D3 for ; Tue, 2 Feb 2021 18:43:45 +0000 (UTC) X-HE-Tag: skin84_4114a03275cd X-Filterd-Recvd-Size: 5097 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 18:43:45 +0000 (UTC) Received: by mail-qk1-f172.google.com with SMTP id l27so20829768qki.9 for ; Tue, 02 Feb 2021 10:43:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Y/EUDZtKaiSyDKXvfLIwZ1X17LExjz/BTXp+Qswz/80=; b=Iz+nS5wB18XhzRHXXjLAFP2+rBMbj2fQKW9W5Q44tL57OvvIC6Cojk6ZN4/AsU+AGv 9qsWNiQ29WnyFcNAolBh8/jA2621OTXLX0rFhktZrQ/TpGJNwbimKjZuuRBB7zEJTTsa B7JRNSsSRwHpSz/vifIONK8yfhvdlKSe8oem48/EzZe8h40a0fY1+00QhhyXUB2wprJ5 ftVQpVLH1QOCvywbBVPj9jOh2qaXRUXeplvi/c0IyMx0jpxRAoqadgz/TXyF1MwsnXdD DN91xV/99jLXys7egtWY9i/OcXJk5Fc/bn3c+QT1GPWEGd3EiENaTWXhaUUF3/3NYt94 jlmw== 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:mime-version :content-transfer-encoding; bh=Y/EUDZtKaiSyDKXvfLIwZ1X17LExjz/BTXp+Qswz/80=; b=oldZ7c1e6UGUWydzfAJDgvf6lzJRsFCooeW6G0Pm87aeg5pVMoeLt8xT1w0GCJXmit si774HOiwdji7fJ9y4/mn9Y/ryZVjlxOANZzATGTGf2hAn1fn/1+o6McosKJNs8GemPD lby5w/9OorcJkldyYuoleYTNK6+1aR0SAVgHLMf3TWKxX+OMKQgyKPpsMOa+lbST3R+W F/DakZ420LCRH2zaWncPqfX+v9VK8CRGrNPjEzphaIDXzmo/lnB1MHbTndDGuds82NB5 iJjbCWhiST+/W1RwJkJkshnECv2cZvRPwqlGrlE93mEkZjcZ7SzpWL4/lwnD1yvPp94d kcMA== X-Gm-Message-State: AOAM533HsUjOjhH/38uuOOJvbZ3tL2vLWjL4pJogwtxWUyJRKylRPY1F fX7n/v9Vrf0ezJhm4EdUnDjIFA== X-Google-Smtp-Source: ABdhPJwit/eqC47k4f+5oaw7MilN7SBc0rePovCbW+aVM/dLH44ek4q1m6tXMzBR4h7juI2aL+zwUQ== X-Received: by 2002:a05:620a:ce8:: with SMTP id c8mr22564722qkj.282.1612291424480; Tue, 02 Feb 2021 10:43:44 -0800 (PST) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id t71sm17028805qka.86.2021.02.02.10.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 10:43:43 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH] mm: vmstat: fix NOHZ wakeups for node stat changes Date: Tue, 2 Feb 2021 13:43:42 -0500 Message-Id: <20210202184342.118513-1-hannes@cmpxchg.org> X-Mailer: git-send-email 2.30.0 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: On NOHZ, the periodic vmstat flushers on each CPU can go to sleep and won't wake up until stat changes are detected in the per-cpu deltas of the zone vmstat counters. In commit 75ef71840539 ("mm, vmstat: add infrastructure for per-node vmstats") per-node counters were introduced, and subsequently most stats were moved from the zone to the node level. However, the node counters weren't added to the NOHZ wakeup detection. In theory this can cause per-cpu errors to remain in the user-reported stats indefinitely. In practice this only affects a handful of sub counters (file_mapped, dirty and writeback e.g.) because other page state changes at the node level likely involve a change at the zone level as well (alloc and free, lru ops). Also, nobody has complained. Fix it up for completeness: wake up vmstat refreshing on node changes. Also remove the BUILD_BUG_ONs that assert counter size; we haven't relied on it since we added sizeof() to the range calculation in commit 13c9aaf7fa01 ("mm/vmstat.c: fix NUMA statistics updates"). Signed-off-by: Johannes Weiner --- mm/vmstat.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 97fc32a53320..1cf549dd703e 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1904,16 +1904,12 @@ static void vmstat_update(struct work_struct *w) */ static bool need_update(int cpu) { + pg_data_t *last_pgdat = NULL; struct zone *zone; for_each_populated_zone(zone) { struct per_cpu_pageset *p = per_cpu_ptr(zone->pageset, cpu); - - BUILD_BUG_ON(sizeof(p->vm_stat_diff[0]) != 1); -#ifdef CONFIG_NUMA - BUILD_BUG_ON(sizeof(p->vm_numa_stat_diff[0]) != 2); -#endif - + struct per_cpu_nodestat *n; /* * The fast way of checking if there are any vmstat diffs. */ @@ -1925,6 +1921,13 @@ static bool need_update(int cpu) sizeof(p->vm_numa_stat_diff[0]))) return true; #endif + if (last_pgdat == zone->zone_pgdat) + continue; + last_pgdat = zone->zone_pgdat; + n = per_cpu_ptr(zone->zone_pgdat->per_cpu_nodestats, cpu); + if (memchr_inv(n->vm_node_stat_diff, 0, NR_VM_NODE_STAT_ITEMS * + sizeof(n->vm_node_stat_diff[0]))) + return true; } return false; }