From patchwork Mon May 15 18:00:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13242016 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 EBD96C77B7D for ; Mon, 15 May 2023 18:04:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6C7290000C; Mon, 15 May 2023 14:03:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A547C90000A; Mon, 15 May 2023 14:03:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A87190000C; Mon, 15 May 2023 14:03:54 -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 79D6390000A for ; Mon, 15 May 2023 14:03:54 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 17979813C6 for ; Mon, 15 May 2023 18:03:54 +0000 (UTC) X-FDA: 80793262788.04.9F9AE19 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id CE449120020 for ; Mon, 15 May 2023 18:03:47 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OnLt/hlo"; spf=pass (imf29.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=1684173827; 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=0t7wAXZL5USXQxpN4vCajFBy/hf1+LlNt2JScd0fQmU=; b=tp+KXl/Ro1Lo+d+lxW7mhP/AVQnC49wuRtjQvj4ij3OUsxjPiekj0ELtV87EilMCJEKoEr FSuKP127YldDufBKW24G24hRZoVut50XkhbpOx4HKCJFEAy64lsWVjFRywTOZ1azj9aCE8 +wxIGesoeB8HzRZngGDZKDHKAzxF+7g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684173827; a=rsa-sha256; cv=none; b=ck5kjB1EM+RturTwEsRrIWF4UGWix7sGlNDXADVBe2+81JxYBXP3lUBliw5qtJM5uQLFzd hguA0wyt4ktDo6P3DXtr0gIAnklhDOxwJAgjxVIi2If+Lo6YcVctQiSqy2ip1BxODhZ2uU BfkBAMThbxbCugZyOqqGtS6LhWGyOY0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OnLt/hlo"; spf=pass (imf29.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684173826; 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=0t7wAXZL5USXQxpN4vCajFBy/hf1+LlNt2JScd0fQmU=; b=OnLt/hloAQqN9/oh6gQ4tlV/lMNvm5vrUTemEnGhoaBvUASdWNTwFV8VD93TdbQekb1XJA q8ac+myzt3FPmV5dHjULMBytsYHQ5R80GsF56eTD4ecI6OOfB6sMKvlHSIH+F+ZjpvShNM FLuuW7BmSnP3B3jjiPyzRwq8e57pqnc= 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-411-S8EJZ_4aPK6en7Q5TLj-6A-1; Mon, 15 May 2023 14:03:43 -0400 X-MC-Unique: S8EJZ_4aPK6en7Q5TLj-6A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0C0671C0F2E3; Mon, 15 May 2023 18:03:43 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-4.gru2.redhat.com [10.97.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D41A42166B29; Mon, 15 May 2023 18:03:42 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 890914161E531; Mon, 15 May 2023 15:02:17 -0300 (-03) Message-ID: <20230515180138.717342763@redhat.com> User-Agent: quilt/0.67 Date: Mon, 15 May 2023 15:00:27 -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, Vlastimil Babka , Michal Hocko , Marcelo Tosatti Subject: [PATCH v8 12/13] mm/vmstat: refresh stats remotely instead of via work item References: <20230515180015.016409657@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Queue-Id: CE449120020 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: w8upo9686hafu35px6eontmit34m8kxs X-HE-Tag: 1684173827-77598 X-HE-Meta: U2FsdGVkX18jAVik6jFH+emgXP4RQ9RH3ZZYa7LZyPPs7ENthRdrofQiFzhQbC4KyEr3ZgFiabbyvCvmV0onl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FR8v/QM6eUFD6w5UlmQ== 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: Refresh per-CPU stats remotely, instead of queueing work items, for the stat_refresh procfs method. This fixes sosreport hang (which uses vmstat_refresh) with spinning SCHED_FIFO process. 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 @@ -1907,11 +1907,20 @@ static DEFINE_PER_CPU(struct delayed_wor int sysctl_stat_interval __read_mostly = HZ; #ifdef CONFIG_PROC_FS +#ifdef CONFIG_HAVE_CMPXCHG_LOCAL +static int refresh_all_vm_stats(void); +#else static void refresh_vm_stats(struct work_struct *work) { refresh_cpu_vm_stats(true); } +static int refresh_all_vm_stats(void) +{ + return schedule_on_each_cpu(refresh_vm_stats); +} +#endif + int vmstat_refresh(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos) { @@ -1931,7 +1940,7 @@ 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 = refresh_all_vm_stats(); if (err) return err; for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++) { @@ -2051,7 +2060,7 @@ static DECLARE_DEFERRABLE_WORK(shepherd, #ifdef CONFIG_HAVE_CMPXCHG_LOCAL /* Flush counters remotely if CPU uses cmpxchg to update its per-CPU counters */ -static void vmstat_shepherd(struct work_struct *w) +static int refresh_all_vm_stats(void) { int cpu; @@ -2061,7 +2070,12 @@ static void vmstat_shepherd(struct work_ cond_resched(); } cpus_read_unlock(); + return 0; +} +static void vmstat_shepherd(struct work_struct *w) +{ + refresh_all_vm_stats(); schedule_delayed_work(&shepherd, round_jiffies_relative(sysctl_stat_interval)); }