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=-24.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, 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,USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL 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 DEA8FC433E0 for ; Tue, 2 Mar 2021 06:03:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A4C8614A7 for ; Tue, 2 Mar 2021 06:03:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A4C8614A7 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E7CB78D00E0; Tue, 2 Mar 2021 01:03:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E2D528D0063; Tue, 2 Mar 2021 01:03:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D43FE8D00E0; Tue, 2 Mar 2021 01:03:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0162.hostedemail.com [216.40.44.162]) by kanga.kvack.org (Postfix) with ESMTP id BE3B68D0063 for ; Tue, 2 Mar 2021 01:03:43 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 78717180AD83A for ; Tue, 2 Mar 2021 06:03:43 +0000 (UTC) X-FDA: 77873892726.14.D74C4C1 Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by imf06.hostedemail.com (Postfix) with ESMTP id 1F3DCC0007C5 for ; Tue, 2 Mar 2021 06:03:42 +0000 (UTC) Received: by mail-ot1-f45.google.com with SMTP id v12so17859580ott.10 for ; Mon, 01 Mar 2021 22:03:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=tBhpCAA1jPbTnLiEd7jXA8BiYncum4qnQ5XpzF97iQg=; b=ms0IMW24z3+h8/kEwL2uJqzBZnp9BvI/flyVqA+bL8lBcGyDtGnMX7yYiW8WrQjevj BOSIm4v30W774hCRni3r02ZTRBocJsycPL8rTdiRo1NgUboqrnAcg1Ts2YzX60YEjdMy Hq7+b4v0aZtv1Dm9dGcwtr1E4ql3QRJ9DU7BchDd5xHVdCyUH8poiWf+u3F516mnr+1Z U73l1siBOEfhEQ885ZXc8949NNkYX8o4zmBIjELuN87owYx0fhM7w/JwI+nzDDwAMsr1 kJMn5nQusZ0DhCD3KPUnt93iXhUvFcgLfR52qNCHM1bxTKK3nIkp+kf2o3WwIbLjKk7p fMNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=tBhpCAA1jPbTnLiEd7jXA8BiYncum4qnQ5XpzF97iQg=; b=IGnQvQ9pHHaqrF83nkZ/GLIrkl3TNjzkLCpntzgHe0xwRunVQdrjIfcIHkDXg5T1s9 yU61UmBi/vBc0udnhL5lbJgrAFeNqx27hxfxhCTdCqKjU/RDRhs3fam1rNMOIrgZElMZ 5SFzUXdpnrmB/pEp0q9Rf2tVIbFUQFQyy1YtsdXUh3JkytS3ycmO/KEQX76Ab1b9bC1a gL9CshZKj+NuYuw5yzrrfbeAHAP12NTozqy/ezLrVRshflTrs8zYCHTOBxSNGAjZNgjL hFozPPN6YLxcaWP1HFkKhEWoW+LXZrRXhXofHfKNigj70JB78g1lLumQyNOr0i/1jqNq qadA== X-Gm-Message-State: AOAM531mOXXXaLCXuLmj8ob2jwqAKm+CBTqxAqUP+HxhQxzWM6iD0+Ig i2CkXe5awISkk+YRfYYQaaT0EQ== X-Google-Smtp-Source: ABdhPJzGl9CU/c+ASlckrwohDeSS2vlX3mr80dlrxGTph/s+yDJ0I9fXJJpkpBpIojX+HmctCZy9Hg== X-Received: by 2002:a05:6830:239a:: with SMTP id l26mr6541916ots.280.1614665022032; Mon, 01 Mar 2021 22:03:42 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id x126sm3854510oix.5.2021.03.01.22.03.40 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Mon, 01 Mar 2021 22:03:41 -0800 (PST) Date: Mon, 1 Mar 2021 22:03:26 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Roman Gushchin , Hugh Dickins , Johannes Weiner , Michal Hocko , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/4] mm: /proc/sys/vm/stat_refresh skip checking known negative stats In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Stat-Signature: em4dgc4nou94ro5srbz5ny1fgrmsarzt X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1F3DCC0007C5 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=mail-ot1-f45.google.com; client-ip=209.85.210.45 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614665022-626300 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: vmstat_refresh() can occasionally catch nr_zone_write_pending and nr_writeback when they are transiently negative. The reason is partly that the interrupt which decrements them in test_clear_page_writeback() can come in before __test_set_page_writeback() got to increment them; but transient negatives are still seen even when that is prevented, and I am not yet certain why (but see Roman's note below). Those stats are not buggy, they have never been seen to drift away from 0 permanently: so just avoid the annoyance of showing a warning on them. Similarly avoid showing a warning on nr_free_cma: CMA users have seen that one reported negative from /proc/sys/vm/stat_refresh too, but it does drift away permanently: I believe that's because its incrementation and decrementation are decided by page migratetype, but the migratetype of a pageblock is not guaranteed to be constant. Roman Gushchin points out: For performance reasons, vmstat counters are incremented and decremented using per-cpu batches. vmstat_refresh() flushes the per-cpu batches on all CPUs, to get values as accurate as possible; but this method is not atomic, so the resulting value is not always precise. As a consequence, for those counters whose actual value is close to 0, a small negative value may occasionally be reported. If the value is small and the state is transient, it is not an indication of an error. Link: https://lore.kernel.org/linux-mm/20200714173747.3315771-1-guro@fb.com/ Reported-by: Roman Gushchin Signed-off-by: Hugh Dickins --- mm/vmstat.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- vmstat2/mm/vmstat.c 2021-02-25 11:56:18.000000000 -0800 +++ vmstat3/mm/vmstat.c 2021-02-25 12:42:15.000000000 -0800 @@ -1840,6 +1840,14 @@ int vmstat_refresh(struct ctl_table *tab if (err) return err; for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) { + /* + * Skip checking stats known to go negative occasionally. + */ + switch (i) { + case NR_ZONE_WRITE_PENDING: + case NR_FREE_CMA_PAGES: + continue; + } val = atomic_long_read(&vm_zone_stat[i]); if (val < 0) { pr_warn("%s: %s %ld\n", @@ -1856,6 +1864,13 @@ int vmstat_refresh(struct ctl_table *tab } #endif for (i = 0; i < NR_VM_NODE_STAT_ITEMS; i++) { + /* + * Skip checking stats known to go negative occasionally. + */ + switch (i) { + case NR_WRITEBACK: + continue; + } val = atomic_long_read(&vm_node_stat[i]); if (val < 0) { pr_warn("%s: %s %ld\n",