From patchwork Tue May 30 14:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13260306 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 8BFE7C7EE2F for ; Tue, 30 May 2023 14:56:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 184CD6B0075; Tue, 30 May 2023 10:56:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16B526B007D; Tue, 30 May 2023 10:56:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAD7C6B007B; Tue, 30 May 2023 10:56:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DCE0D6B0075 for ; Tue, 30 May 2023 10:56:58 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6EC65ADFEB for ; Tue, 30 May 2023 14:56:58 +0000 (UTC) X-FDA: 80847223716.22.DFE4883 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id AB909C001E for ; Tue, 30 May 2023 14:56:56 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KK44kWQt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.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=1685458616; 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=Zp+6wKN5pw6h0b4P0Mp9cZhOYKe0APjLNDcaJDBGqc0=; b=YK0oC+fQigN0XoXwMqn/RyAQjtIL+e4CzHeF0b6OZ4093GzSkMmbvamJfFt4lIfIzU8/Kh npIRvqM1Z1PpAaEsvhJT2q1KgB4VW0cLWCKCJOaFMYJN6a0O3Sj8VmNRLB73I0Zcu6F9gG bnCDZhcfGzJ21ItP1pAbpeFUY+perPU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KK44kWQt; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685458616; a=rsa-sha256; cv=none; b=X6stKSvuKS0DfNKigelyheOGDBdvzLAmkyQCBt3pU/UUnZdmJu8C856cnViC2gM6+5QVqX CZQ+6PeVBDvlWOVEmMBgAtc9DVY79JFoByhEGMztO10ozANMiz6kQaVKQfd68XTKxISBIY VG1Cj9S69EbQ6Y1Y5FfoyMUQ3q8/+pk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685458615; 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=Zp+6wKN5pw6h0b4P0Mp9cZhOYKe0APjLNDcaJDBGqc0=; b=KK44kWQtOd6KwlTRTlwFn57e9430/h84pRMj/h5h7i0+uMBUrpwtXlPyGAdQ4hm25IcuAv Un3PZnuk0CFwM9N9we09QX5zwLIeX7J9m7kwueECKzJti3fcQnYUxSaCHEBKSUP9tyRdi5 nIL+wIuvLNGKaySrXBa4qS5jzvxFqnE= 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-609-WcYEjc5XOeSOkwHfXbc04Q-1; Tue, 30 May 2023 10:56:53 -0400 X-MC-Unique: WcYEjc5XOeSOkwHfXbc04Q-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 241BB101A53B; 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 E742BC154D2; Tue, 30 May 2023 14:56:50 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 5C58B401E1522; Tue, 30 May 2023 11:56:33 -0300 (-03) Message-ID: <20230530145336.155097348@redhat.com> User-Agent: quilt/0.67 Date: Tue, 30 May 2023 11:52:38 -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 4/4] mm/vmstat: do not refresh stats for nohz_full CPUs References: <20230530145234.968927611@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: AB909C001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: to6i7t3s8s7uxkg9ge5a1yswsfrsoh5r X-HE-Tag: 1685458616-663774 X-HE-Meta: U2FsdGVkX1/EUAT4VLsENvTBb1yQnHt3pvheCGZRJpg9exeLalUGbLV+JPHvUce33frJnJ4ss4qC1xz2jFL23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VwblqCgc7aqxX103Y4FyafQ0krlh0NFgw+POmczS5VFZQXL2hohefx 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 queueing work on nohz_full CPUs is undesirable for certain aplications. Fix by not refreshing per-CPU stats of nohz_full CPUs. 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 @@ -1877,12 +1877,31 @@ static void refresh_vm_stats(struct work refresh_cpu_vm_stats(true); } +#ifdef CONFIG_NO_HZ_FULL +static inline const cpumask_t *tickless_cpumask(void) +{ + return tick_nohz_full_mask; +} +#else +static cpumask_t empty_cpumask; +static inline const cpumask_t *tickless_cpumask(void) +{ + return &empty_cpumask; +} +#endif + int vmstat_refresh(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { long val; int err; int i; + cpumask_var_t dstmask; + + if (!alloc_cpumask_var(&dstmask, GFP_KERNEL)) + return -ENOMEM; + + cpumask_andnot(dstmask, cpu_possible_mask, tickless_cpumask()); /* * The regular update, every sysctl_stat_interval, may come later @@ -1896,7 +1915,9 @@ int vmstat_refresh(struct ctl_table *tab * transiently negative values, report an error here if any of * the stats is negative, so we know to go looking for imbalance. */ - err = schedule_on_each_cpu(refresh_vm_stats); + err = schedule_on_each_cpumask(refresh_vm_stats, dstmask); + free_cpumask_var(dstmask); + if (err) return err; for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) {