From patchwork Fri Mar 3 19:58:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13159444 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 380B7C64EC4 for ; Fri, 3 Mar 2023 20:00:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 44FAB6B0075; Fri, 3 Mar 2023 15:00:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FD506B007B; Fri, 3 Mar 2023 15:00:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 232FA6B0075; Fri, 3 Mar 2023 15:00:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0DE4C6B0072 for ; Fri, 3 Mar 2023 15:00:39 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CF6831211B4 for ; Fri, 3 Mar 2023 20:00:38 +0000 (UTC) X-FDA: 80528654556.05.D75FC18 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 29DCE10001E for ; Fri, 3 Mar 2023 20:00:35 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WbAfdDGZ; spf=pass (imf05.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=1677873637; a=rsa-sha256; cv=none; b=UC01xCZrJDUgzFZHh6IXSzvwg2wiittMKueKgsgO7aCWI9uaenO1jkSvCMNVt3EbJ9U7+l KbWy/sJclPgyumAXaLy4tf1mbVUDBFLCah18f4sGJ3CcUvxcomv0mtQaWUiA+q9IjMXBdO lXod/5xNk7xVyCZqFYECF+lUWYn5Pts= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WbAfdDGZ; spf=pass (imf05.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=1677873637; 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=y7Yi1l52AyC6VYyAHckMD0UPWhdM1o7McEseCbmGWHM=; b=2K2tLCe/Au3FRRU0i+thLAu6DyPLvGJsSN9O2de8/xaGpwiN+teFeh1105wa0FYrQ2uTp5 ZL7VJKo4x8KH6/VOfiUKNjIFckRsvUeyysZvJWufxg5lCG0wZTODsETF7aUk5d/QRKQTjD nB5YbAyz++kyFQRoTcJMa59mMSvVdm0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677873635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=y7Yi1l52AyC6VYyAHckMD0UPWhdM1o7McEseCbmGWHM=; b=WbAfdDGZr14HGUjfsC7ArECY+98LxVjc+MwzPtdtMV0qdVQXbuVuUUAJq2j33u0EFQZL3h faPDBHECtRul5J0VPWVAqmx65oC9Rz+uTVZD4Iigstf2kgrE00GKU3fToMNXOazIgLQeia r8yttN8KGSDVBe3mN7Ag1nsh6OdJFko= 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-435-LoKFVJqMNxqE4wuiHRGJuQ-1; Fri, 03 Mar 2023 15:00:31 -0500 X-MC-Unique: LoKFVJqMNxqE4wuiHRGJuQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 911461C05AAD; Fri, 3 Mar 2023 20:00:30 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CD802026D4B; Fri, 3 Mar 2023 20:00:30 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 85CF4403EA219; Fri, 3 Mar 2023 17:00:12 -0300 (-03) Message-ID: <20230303195841.310844446@redhat.com> User-Agent: quilt/0.67 Date: Fri, 03 Mar 2023 16:58:41 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Russell King , Huacai Chen , Heiko Carstens , x86@kernel.org Subject: [PATCH v3 00/11] fold per-CPU vmstats remotely X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspam-User: X-Rspamd-Queue-Id: 29DCE10001E X-Rspamd-Server: rspam01 X-Stat-Signature: znpuyhriw1cg38wu4u1y39g6jr7boi6y X-HE-Tag: 1677873635-635223 X-HE-Meta: U2FsdGVkX1/XQmEW85KpJ9NZIQV3KeLHDu4CWsj563sDOwg8DDPIz9c8roud2iIvxJBD68LfayLT4Vn8LGH/PIMZVV+sMtTwLkwetm9wIXb8jtVqRhZfrmfO68Ca70LHwT6knxQOi9RSAIRFZLT3pjWIOMIA3ZCQHC/WmhqBFb0jeB2GsPp0YFrQk09Trn1CJOH7FPzO1AJXqR5NSjbf/604D1WwEuej4ktZIc6RrfNtXr9HVlH8KOqD5Uh+1geQyDHrwAvQLIzkXddmPYifHdNI00gmLC0TnRM9JshXQg5NYMR/+C57xdBD+R/6g2SH2yknryWwjiqZtKV4B5Qc36yMuaUhIq0Y5FPnzLEgTKHAusu+HITl9VouP+oWm0x53yHyyumKdobNLGC5CU6ud7+b5v5uQmAJppU0Y2cSxfMyjbKa+zJz4fMFnuMiwMWdoMcgkg+6lr/oLqRgF801pD0QKmY0lumVObVYu1v0JMHsndwOWUe5cZBmD56jVU7b6W2jaG4BsuXSlYDVBUi1I2w35Df/VTfdW1w7FJcSlI9p3KJdiiBzmlfVva/qb1H/i26n9JIflXI9IdzdeUduvPD+3/61Wi40m0oJyVadex2jmCHEHEnk1wMyOj+VhS9jJ82KJpNmnzNuo5JHz9iSY2FUFPZoPGrgTk3IvBr2vvpf0bMroc8Puvt1a+sTZm8uxBgd+wRbxDoGRTV0lULWCfY3xLSxLHp9UQUxzmWEmPLlEbapv4P4WcCHx2DdBxfx5Oxdf08brBJIicFONPtdKDLDDHijNl76g92qa9CUt/LnTV7QHEVWgxPUFD9GuutkzulekEe0TdmMq4G9LVEDkUWceuZrXUO2FlWF+cCIEwhoxIjrIXTgFIVh7qohC9w0nWI33hO3MP578JnGGlVDTu6FY6WhX+s4osm9OtZZNYFi2Vq0iJp9uU5ALK59Y5nKw1cuGjuE6vVVq8e9HZs mVGQ2/h+ off+FsFL9d5njBdDg7d/AO/0/7wE8oYhRgCwo90A4doyDkNqxtzd1SmarppiQ7hhGrjrCsftaCwNYPQzz/dLFVT7qbbaUCJxMH5JpAq6kfm6jq9soOgryfpaZAS8UYGEgO/+w 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. v3: - Removed unused drain_zone_pages and changes variable (David Hildenbrand) - Use xchg instead of cmpxchg in refresh_cpu_vm_stats (Peter Xu) - Add drain_all_pages to vmstat_refresh to make stats more accurate (Peter Xu) - Improve changelog of "mm/vmstat: switch counter modification to cmpxchg" (Peter Xu / David) - Improve changelog of "mm/vmstat: remove remote node draining" (David Hildenbrand) 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 include/linux/percpu-defs.h | 2 kernel/fork.c | 2 kernel/scs.c | 2 mm/page_alloc.c | 23 ---- mm/vmstat.c | 424 +++++++++++++++++++++++++++++++++++++++++------------------------------------ 11 files changed, 307 insertions(+), 249 deletions(-)