From patchwork Thu Feb 9 15:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13134759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28482C61DA4 for ; Thu, 9 Feb 2023 15:33:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED44B6B0074; Thu, 9 Feb 2023 10:33:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A880F6B0087; Thu, 9 Feb 2023 10:33:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77D6B6B0081; Thu, 9 Feb 2023 10:33:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4AFDE6B0085 for ; Thu, 9 Feb 2023 10:33:25 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 13080A0F36 for ; Thu, 9 Feb 2023 15:33:25 +0000 (UTC) X-FDA: 80448147570.09.3F9DF5A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 676578001E for ; Thu, 9 Feb 2023 15:33:23 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J0c7vGyu; spf=pass (imf30.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675956803; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references:dkim-signature; bh=vcrcLyyXGvx1agmSjax9RNBo44/wgLryjaESGOqOIAs=; b=P9wZALa3M20xe0p+AGlY1ci+lxkQPYQr63HT7Nqm981xaldkgChmhyW1n7XbA0Fpy/Ez9V JegbhCreqLrN082GkJNMYqJYJQATqW2P4hmrWmTg7xXKqSkSU2szbUZsXKfzcp103Vlvzw RtW17kdKuD2P+YXsRUjIIJrxe75zhOw= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=J0c7vGyu; spf=pass (imf30.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675956803; a=rsa-sha256; cv=none; b=5CbSRLiwsssR/GJqqNXOyfPqBPgLVrG6AD+U48WN8VJX16XGNeNz5QnNLCDj+Nmm+K9a8e B1BQWA9bmwct66w+vHWWo0Fu5EgnOtJpGlxFJNz2SS7JDWs7gsB4mxdDSoJCBg3m0MWJi8 EcxXdm3q8a4T5+D5Dsml6Bc94F9JMoo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675956802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=vcrcLyyXGvx1agmSjax9RNBo44/wgLryjaESGOqOIAs=; b=J0c7vGyuNEmkfw8qDF50X+gztvsL/QgoVYue7mKDVRElsbelW6IN4DMoXpHokydv3pZSVp komTYnUo+4NlBreI1aKdlZPA7VYc+zthWDAR5vKsmKzRjJ3xUNwtwLImoIxG3c6c9EvxKZ S5iOpLRJ9fPq4TxMk37YJwk5jSv9FhU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-19-QmJbcTqeOtaOCHDJgUQZlw-1; Thu, 09 Feb 2023 10:33:19 -0500 X-MC-Unique: QmJbcTqeOtaOCHDJgUQZlw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C95FD3C10ED4; Thu, 9 Feb 2023 15:33:14 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-3.gru2.redhat.com [10.97.112.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A00D4C16022; Thu, 9 Feb 2023 15:33:14 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 60375403CC068; Thu, 9 Feb 2023 12:32:51 -0300 (-03) Message-ID: <20230209150150.380060673@redhat.com> User-Agent: quilt/0.67 Date: Thu, 09 Feb 2023 12:01:50 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 00/11] fold per-CPU vmstats remotely X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: qebe64afrzt4t38z9cn8nadr38sw7bgj X-Rspamd-Queue-Id: 676578001E X-HE-Tag: 1675956803-416378 X-HE-Meta: U2FsdGVkX19FgrDkMQt+hG7IXxUPAm/JVyQmXa/t3DqqsTw7He69mmEZjO6kwp8oqLWcdTz/8W51PAKkK42VguxQa5oXVIttPEyhBDRDyqeZ4zL+3oapvsM8BiJU5pjLfUtKZsqfJAjYHfcwRXyMVaQ6zBpN23okSpBJB/v3xKasA64xcjUGvrZ5G6teer4lIqxW7K+fI0jzvezIyS8BscRVSH06GS9Bu24yKVT9808C7cvmvcI3l0qXyPMe1FQS/rZRRi/QdZDuDVMjVCPkDqvHByY3gq3mCu9fkAr+sqpNc2imArRM4xrlLwXMxyEtPcGH/A/6cBqUlRqzVptXuZxYvaqSbqnvWU0Hx7+7+3uOi6+M7tt/2zDm1coqp27Hch2OiwGGo7E/8oIukPh2cZPlwN1req72IibnSplN8hDVvzVw1fNoukLvFEWdJio4D/zbc7wI4Qt5aMMHYtNHKxxqrQT+0KWEmv2S41D7HiO4RxSTw8RiF2H6YA2UCP8G7xkeBrw0Ms0sFgcjd9X6q9kic0M48vZ+lu/IyGjva0lcsFlQo2yn8rKc18vFuKLgBRFvWaY1V8FTogJCI/uGzGGKAKCMgSEB6bp2QrcTYKHD1UR/9klNgqJ5NTAzOUA7yPhF3ZlMscrG7TpUa2zIVJY8kt+kaGpw+lR/PuE3pDXDUlgC+XYVr91XgK4rgf5e5/xEtRkYugu2PDlYseu33CqtmF6wbLpwvUV91MSLcJtHC4YHDsQqbh1Am8rY5EXKEO1M4z99cjKZc2TYVcb9HR76s8EW3jnpx1Ms7DHTSyn6B5t407jeQT8M0F7bj5SanUSR6EuOTrk8P059/yP5IT732B3H3B/7hYnsKsf81clp7WhfBnI6RoIgAIZXHeupStyRjWZV1hnWQ9MFAdsTeNDmOkM8IgajuFkQhFZ98VSFmX6Vg0xxyyEzb0EnU3FfgO0pgZH28kQmTmOFLXH S84mQrLA FqgMNs3Ah++CntxwcTdO+D387QvsBA/eOGu1VlSXDep9YI5qVRDOkRKqz28Pi61o0raWyrRDbQ/+e0Wb7nynjqVtQTHlcLpKErXULpu/5vrT7GeB+zIi7TwZUjQ== 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: This patch series addresses the following two problems: 1. A customer provided some evidence which indicates that the idle tick was stopped; albeit, CPU-specific vmstat counters still remained populated. Thus one can only assume quiet_vmstat() was not invoked on return to the idle loop. If I understand correctly, I suspect this divergence might erroneously prevent a reclaim attempt by kswapd. If the number of zone specific free pages are below their per-cpu drift value then zone_page_state_snapshot() is used to compute a more accurate view of the aforementioned statistic. Thus any task blocked on the NUMA node specific pfmemalloc_wait queue will be unable to make significant progress via direct reclaim unless it is killed after being woken up by kswapd (see throttle_direct_reclaim()) 2. With a SCHED_FIFO task that busy loops on a given CPU, and kworker for that CPU at SCHED_OTHER priority, queuing work to sync per-vmstats will either cause that work to never execute, or stalld (i.e. stall daemon) boosts kworker priority which causes a latency violation By having vmstat_shepherd flush the per-CPU counters to the global counters from remote CPUs. This is done using cmpxchg to manipulate the counters, both CPU locally (via the account functions), and remotely (via cpu_vm_stats_fold). Thanks to Aaron Tomlin for diagnosing issue 1 and writing the initial patch series. v2: - actually use LOCK CMPXCHG on counter mod/inc/dec functions (Christoph Lameter) - use try_cmpxchg for cmpxchg loops (Uros Bizjak / Matthew Wilcox) arch/arm64/include/asm/percpu.h | 16 ++- arch/loongarch/include/asm/percpu.h | 23 ++++ arch/s390/include/asm/percpu.h | 5 + arch/x86/include/asm/percpu.h | 39 ++++---- include/asm-generic/percpu.h | 17 +++ include/linux/mmzone.h | 3 kernel/fork.c | 2 kernel/scs.c | 2 mm/vmstat.c | 424 ++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------ 9 files changed, 308 insertions(+), 223 deletions(-)