From patchwork Tue May 30 14:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13260305 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 6921CC77B73 for ; Tue, 30 May 2023 14:56:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2D576B0074; Tue, 30 May 2023 10:56:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC0E36B0075; Tue, 30 May 2023 10:56:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 955F8900002; Tue, 30 May 2023 10:56:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 824016B0074 for ; Tue, 30 May 2023 10:56:56 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3135A140227 for ; Tue, 30 May 2023 14:56:56 +0000 (UTC) X-FDA: 80847223632.14.5D94F0F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 160BE40006 for ; Tue, 30 May 2023 14:56:53 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I+am0RZN; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685458614; 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:in-reply-to: references:references:dkim-signature; bh=B/GSKf6UEn0c42XXKcBB/6CIce6RG7UgO/Nmikr6pJA=; b=myATcJ4wHrpm41msnXfEY87/aS3ML2/3F58sNH35MuCSiUhUu1lpADrqfJJdtIwA+Av+Dd PV2LNk+0QBeUqgSql6DgaG+HYIebme3NVRCdF8QihfVRzULNKLXItL78yogQ97loRb5IT9 qA+rebbF7vv38yyFqGRSgk2zd4M+8do= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I+am0RZN; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685458614; a=rsa-sha256; cv=none; b=445W4ZJZ538GlN4xzVxX87bwpaINF9GBHAjzlCSri5v6OxM4LICLfVPxwcw+BQHM4sfvK4 8oqGNQlAOa7lYgcMtlZ/WimF08rqiyAcxUQuZVO2wS1bFgJ426yQP1nZddTRwfvo6Wwu7K WKEQf2lNgkcx3GOGC0W77oQ/BE+kK1Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685458613; 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: references:references; bh=B/GSKf6UEn0c42XXKcBB/6CIce6RG7UgO/Nmikr6pJA=; b=I+am0RZNTTd+4SZTHjd0uxpBOau02f2Y/oDeEpOC1YGJqPr7QDe8mjHymkHHEdytoQytGf u4ImP301WtV+oexy4+n/0GsISrinafw5Xj9HGAhl3rlusMzxx33NIMqUy65zAMunhF7XkF beRWUfg0kBsVQAkp0F2PCHg/i9YKROI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-qhAbuYgmMEKTml1kAmu7gA-1; Tue, 30 May 2023 10:56:51 -0400 X-MC-Unique: qhAbuYgmMEKTml1kAmu7gA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 28452185A792; Tue, 30 May 2023 14:56:51 +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 E7445420A8; Tue, 30 May 2023 14:56:50 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 4E9DA401CFE3F; Tue, 30 May 2023 11:56:33 -0300 (-03) Message-ID: <20230530145335.828634764@redhat.com> User-Agent: quilt/0.67 Date: Tue, 30 May 2023 11:52:36 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vlastimil Babka , Michal Hocko , Marcelo Tosatti Subject: [PATCH 2/4] vmstat: skip periodic vmstat update for nohz full CPUs References: <20230530145234.968927611@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 160BE40006 X-Stat-Signature: 46sfo8noz1afzc9r4twr7smuzqned8hd X-Rspam-User: X-HE-Tag: 1685458613-30625 X-HE-Meta: U2FsdGVkX1/7/ZV2HytVpdZ4MLtO8x/HqNuDtlFCpnxQrq2LvBCBp2ZThepON/a5kbtc1+sA1YWBmeCRK5BR/hIMeRl0Xu53uAWgqwSLlkGWPQzE4vrE7VX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+wMpQrhB7Rbnu1nsYO9SoQUBL4SpFSJlqU+Q== 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: The interruption caused by vmstat_update is undesirable for certain aplications: oslat 1094.456862: sys_mlock(start: 7f7ed0000b60, len: 1000) oslat 1094.456971: workqueue_queue_work: ... function=vmstat_update ... oslat 1094.456974: sched_switch: prev_comm=oslat ... ==> next_comm=kworker/5:1 ... kworker 1094.456978: sched_switch: prev_comm=kworker/5:1 ==> next_comm=oslat ... The example above shows an additional 7us for the oslat -> kworker -> oslat switches. In the case of a virtualized CPU, and the vmstat_update interruption in the host (of a qemu-kvm vcpu), the latency penalty observed in the guest is higher than 50us, violating the acceptable latency threshold. Skip periodic updates for nohz full CPUs. Any callers who need precise values should use a snapshot of the per-CPU counters, or use the global counters with measures to handle errors up to thresholds (see calculate_normal_threshold). Suggested by Michal Hocko. Signed-off-by: Marcelo Tosatti Index: linux-vmstat-remote/mm/vmstat.c =================================================================== --- linux-vmstat-remote.orig/mm/vmstat.c +++ linux-vmstat-remote/mm/vmstat.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "internal.h" @@ -2022,6 +2023,16 @@ static void vmstat_shepherd(struct work_ for_each_online_cpu(cpu) { struct delayed_work *dw = &per_cpu(vmstat_work, cpu); + /* + * Skip periodic updates for nohz full CPUs. + * Any callers who need precise values should use + * a snapshot of the per-CPU counters, or use the global + * counters with measures to handle errors up to + * thresholds (see calculate_normal_threshold). + */ + if (tick_nohz_full_cpu(cpu)) + continue; + if (!delayed_work_pending(dw) && need_update(cpu)) queue_delayed_work_on(cpu, mm_percpu_wq, dw, 0);