Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp781818pxb; Thu, 25 Feb 2021 15:15:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS8juc75S+ehfAdA5zFzUeirMS13YqD8OI1mbbZmlT20yXdd2X+SEAU9XjIgWccuntr51i X-Received: by 2002:a17:906:af91:: with SMTP id mj17mr14111ejb.230.1614294946143; Thu, 25 Feb 2021 15:15:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614294946; cv=none; d=google.com; s=arc-20160816; b=lz6kMiuiQlltAI57ODAenj5bxIzlNCjhoSnv7GpWwHffDhgv8lWRbpbG9Xsq5u7fwJ y5Y3Tpfjqo62oZSWUwly1zNG/0Yq4AO5BvyD8PpPz3/hht6nyD1BHIHjegbWSLxIi4Gl imaIhQ32/7AB81wqUjjMg64ZckwkK6tnWZlUIDX1uNaz0lsXEgp2aTfSiHIFC7NUtD+4 EPphjYguFmIoLF4ShpyIvi5XwEs/a57/DWU3bubDjHAXTjnoipaD2osQznUoMWcnCti5 Evow+I3GAdw7mw5fhTWcVZp1boDwx6y54FkRh0LJkJeIK8nOhwz3K0wRXwKc5M+JdO0C iIPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=8+F1D1lXhzkAPi6K9Z/dpHmXeEnlD5O2kNPvAi2nZ4Q=; b=RjzqCyjIfg4mDPlgv6LeWs0KP2fSfRlJSCr3p5i63bR5MMADvbf7htaFEr05VnKBTX vAQDhNds7c/wet5iGZbxjcGP5ac1SDxHjD35767XVQMjkQ9hdbxD2t+Q0hXb/eKWqKPB R4XRqX+fbUWsxwmrUxXo+npaVWA/21EaTmU6ClBxh61yLKfP0GqAMBgPmordz5DvXUyg MAfvaewtaK2iaQMm5bMq9W5OM0/P4EDzkPZmIBJ7TDDIz1mrYnZcLeD3fZXrIfVD/C7X msRyGreszb0aDstvHhx4qUjPLSaKeaW4TqvQyDnN0WAVLM2BiDc8T9A6a+9EsoiVYfY3 O/nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=taz4RTC0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b7si3971072ejv.268.2021.02.25.15.15.23; Thu, 25 Feb 2021 15:15:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=taz4RTC0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbhBYXOr (ORCPT + 99 others); Thu, 25 Feb 2021 18:14:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbhBYXOr (ORCPT ); Thu, 25 Feb 2021 18:14:47 -0500 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 062A8C061574 for ; Thu, 25 Feb 2021 15:14:07 -0800 (PST) Received: by mail-ot1-x32d.google.com with SMTP id e45so7381983ote.9 for ; Thu, 25 Feb 2021 15:14:06 -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=8+F1D1lXhzkAPi6K9Z/dpHmXeEnlD5O2kNPvAi2nZ4Q=; b=taz4RTC0+G8PvM1uwoOpuyhIsFuQGdRvf50tuJsYOFiiNSaCi7rH+jPsSMS08o7ric bsoj0G8BsyU2k/m14j5nHD0JpfC+lHG4l916bancc93Q0d2eOK2selxVKx14Jc3u6jYF t02UXofC8ofRkPG2NlqBOELORdM0pE9BwaH+HalgvvO1H4MMOwHXz7NmFozZXpETZTd8 fLczgVmcWQ0838PjYA+eAjYKNUknp8SOvgFRH8jkCbXj2qpethyUyuEnVb3cQwS3nO7o v7kH1INCxd26bDL+jkucY1HQaqOYon3GasY2S3h+PTTMnC+TMeN+5UhdHt3kL6b97xlr O/Ww== 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=8+F1D1lXhzkAPi6K9Z/dpHmXeEnlD5O2kNPvAi2nZ4Q=; b=hWvjmZxad/YT6dRQ/5HTZnEsHgqSmgXbL916J5Y+I1TUBKNwlK9T64RDW9y+Bsspk6 cNoopXxElYkIadY3wBa000roAlRXTmHWtuTQrImgYrD+Rbir9Fg1sf6P76BI2u0CtnhJ BLM5r3tUFn1h9MC63t0xYXJS4EjYkhSVm24WLDBombLw9mMXcCYpnCpCyhslFT65ahX9 JZ5Mtf81CErGBsg3uBUPtjKrq2OVGxBTJJSge0PNaDa7FBq/4pJXTeY+AzAS3wQFxpFT Xw4pJ7ZgAJbPHD1kB9WpfUm9CwRBg3LO7IsxGSFwmnLipaeG+C3HUJKdGPndBce35pXE RybQ== X-Gm-Message-State: AOAM533FDc2AwGKY9z8ss6WhNkR8is/vErC0SAt/0q++wf1pU/1BiLSs HU5Cok/yWWXK6lBDgKLpH9iIjg== X-Received: by 2002:a05:6830:1416:: with SMTP id v22mr45280otp.239.1614294846254; Thu, 25 Feb 2021 15:14:06 -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 h11sm1418826ooj.36.2021.02.25.15.14.05 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Thu, 25 Feb 2021 15:14:05 -0800 (PST) Date: Thu, 25 Feb 2021 15:14:03 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Roman Gushchin , Johannes Weiner , Michal Hocko , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 we have not yet resolved why (Roman believes that it is an unavoidable consequence of the refresh scheduled on each cpu). But 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. Use switch statements so we can most easily add or remove cases later. 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",