From patchwork Mon Aug 8 19:48:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Tomlin X-Patchwork-Id: 12939098 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 8EF2BC00140 for ; Mon, 8 Aug 2022 19:48:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2167E6B0071; Mon, 8 Aug 2022 15:48:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A02B8E0002; Mon, 8 Aug 2022 15:48:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03FD18E0001; Mon, 8 Aug 2022 15:48:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E2EEA6B0071 for ; Mon, 8 Aug 2022 15:48:25 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B2EA1C0C87 for ; Mon, 8 Aug 2022 19:48:25 +0000 (UTC) X-FDA: 79777462170.27.05716A0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 404661C0067 for ; Mon, 8 Aug 2022 19:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659988104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/GndbpOdEsWW3Ey1GFStHOY4x2/TccVmhX9gHCE2e40=; b=dK9JGlQcPDMAn5HdmhZi3PJRtZ00vpgUYKm/CBkGy1wKhjCP9anx6rH7vCN+p3L6VOQOT4 /6+EenPSMv6Rm3FJyAKbAPosHnftGvJfuXsp60F1Rsj7VfSCOfGetnag5kIIdlrgif3XqW 2nqLn1XqFhGBUYFEJSWOgWB1CiqYfiI= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-459-WYa1eoYYORS7uJ0SRMCIzw-1; Mon, 08 Aug 2022 15:48:23 -0400 X-MC-Unique: WYa1eoYYORS7uJ0SRMCIzw-1 Received: by mail-wm1-f69.google.com with SMTP id r5-20020a1c4405000000b003a534ec2570so1931900wma.7 for ; Mon, 08 Aug 2022 12:48:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=/GndbpOdEsWW3Ey1GFStHOY4x2/TccVmhX9gHCE2e40=; b=Rrqh8jzYN3tu/P7v6ea0CUTH+QLMDuOpaHRKwwcLykUOoaAopD/ZffoJT1pcSbKaxr FLxDRdn05+jrp6LPTCVZqxuADUw5CoeW+OCI8Kh40s5F9SPwjyKvoU75tPyBbgLBt5QA 74jHVFMJOkhyoZMu6sBKm/jtZKkCPZaAx/SZYUAhMpjjjr06INr/P6WZNb/Hu/ZCsFb9 lNgr6SmQR03NdvY3b1dvSzalzzCCNK3RH8pCVv15tt+41aUYlQAW9Exq8tLI1L9WJW2U soJG9Jt1LXLGt1o7gfOIbCyWUChJ7w9KjFMnTcSZaHDZpgq8yYGx2auFeIe86F50d3eE tE2Q== X-Gm-Message-State: ACgBeo3AoroWiUIX7F6wxWbUu/owJBbfJ4r8P3N+nwNz7cU5zetMNDbi 11K5Xs2XIo79m1Zwvj4btOQ+krYg6drkgcXYfNv/MytYHwcurhkDP4bXEdjReeJFqHPRyRnLcIN BqUiCULmeag== X-Received: by 2002:a05:6000:178c:b0:222:f8ec:9977 with SMTP id e12-20020a056000178c00b00222f8ec9977mr2529261wrg.509.1659988102520; Mon, 08 Aug 2022 12:48:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wJ7LojV6ap4KmTRyk0CU1xjQumbUrwh2+AS35G9oakKYiRb2GBRHD9y266OQuShj0T3ykkw== X-Received: by 2002:a05:6000:178c:b0:222:f8ec:9977 with SMTP id e12-20020a056000178c00b00222f8ec9977mr2529246wrg.509.1659988102279; Mon, 08 Aug 2022 12:48:22 -0700 (PDT) Received: from localhost (cpc111743-lutn13-2-0-cust979.9-3.cable.virginm.net. [82.17.115.212]) by smtp.gmail.com with ESMTPSA id t5-20020adff605000000b0021e5f32ade7sm11911544wrp.68.2022.08.08.12.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Aug 2022 12:48:21 -0700 (PDT) From: Aaron Tomlin To: frederic@kernel.org, mtosatti@redhat.com Cc: cl@linux.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, pauld@redhat.com, neelx@redhat.com, oleksandr@natalenko.name, atomlin@atomlin.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v6 0/2] tick/sched: Ensure quiet_vmstat() is called when the idle tick was stopped too Date: Mon, 8 Aug 2022 20:48:18 +0100 Message-Id: <20220808194820.676246-1-atomlin@redhat.com> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659988105; a=rsa-sha256; cv=none; b=UJNXjcYTyiooJFM8kOTOnQKKHylJppz8fxPSM3tSVa5rP9+YRomaxstpYNf0Bv8BFpKLnI 3ctzICgrazpgsiMawNIgsdJaiw/kVdpPJ/qSQIzXnLXr5ArUTFMrfBJIbfHgtUXjHvswmu LOiPfzuLftFF00AclJRaSzM6dxDbc4Q= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dK9JGlQc; spf=pass (imf18.hostedemail.com: domain of atomlin@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=atomlin@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=1659988105; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=/GndbpOdEsWW3Ey1GFStHOY4x2/TccVmhX9gHCE2e40=; b=8NblIdKdB2p4w56mafxlaDp0xZtbVDBVPl80js/sI7LDJIepguDE3SWTr7exAlmzk5rCcv NeKkKb4zlViCyJZc4+W5WHpu18TW6wG8o+Ub9oJONREBIE3in7u1kPgPRfGWzrAJu2u79i BSIKvkkfUeaUn8qKmT0CAYyyNbYuASI= X-Rspamd-Queue-Id: 404661C0067 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dK9JGlQc; spf=pass (imf18.hostedemail.com: domain of atomlin@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=atomlin@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: hsptkrs5fmjpdch36ii9j8emptoe9wut X-HE-Tag: 1659988105-946198 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: Hi Frederic and Marcelo, I have incorporated an idea from Marcelo's patch [1] where a CPU-specific variable is used to indicate if a vmstat differential/or imbalance is present for a given CPU. So, at the appropriate time, vmstat processing can be initiated. The hope is that this particular approach is "cheaper" when compared to need_update() - used currently; in the context of nohz_full and the scheduling-clock tick being stopped, we would now with this patch, check if a CPU-specific vmstat imbalance is present before exiting user-mode (see tick_nohz_user_enter_prepare()). This trivial test program [2] was used to determine the somewhat impact under vanilla and with the proposed changes; mlock(2) and munlock(2) was used solely to modify vmstat item 'NR_MLOCK'. The following is an average count of CPU-cycles across the aforementioned system calls and the idle loop, respectively. I believe these results are negligible: Modified | Vanilla | cycles per syscall: 7399 | cycles per syscall: 4150 cycles per idle loop: 141048 | cycles per idle loop: 144730 | Any feedback would be appreciated. Thanks. Changes since v5 [3]: - Introduced __tick_nohz_user_enter_prepare() - Switched to EXPORT_SYMBOL_GPL() Changes since v4 [4]: - Moved vmstat_dirty specific changes into a separate patch (Marcelo Tosatti) Changes since v3 [5]: - Used EXPORT_SYMBOL() on tick_nohz_user_enter_prepare() - Replaced need_update() - Introduced CPU-specific variable namely vmstat_dirty and mark_vmstat_dirty() [1]: https://lore.kernel.org/lkml/20220204173554.763888172@fedora.localdomain/ [2]: https://pastebin.com/8AtzSAuK [3]: https://lore.kernel.org/lkml/20220801234258.134609-1-atomlin@redhat.com/ [4]: https://lore.kernel.org/lkml/20220621172207.1501641-1-atomlin@redhat.com/ [5]: https://lore.kernel.org/lkml/20220422193647.3808657-1-atomlin@redhat.com/ Aaron Tomlin (2): mm/vmstat: Use per cpu variable to track a vmstat discrepancy tick/sched: Ensure quiet_vmstat() is called when the idle tick was stopped too include/linux/tick.h | 5 +++-- kernel/time/tick-sched.c | 19 ++++++++++++++++- mm/vmstat.c | 46 +++++++++++++--------------------------- 3 files changed, 36 insertions(+), 34 deletions(-)