From patchwork Mon Mar 13 16:25:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13172859 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 E4CB4C6FD1F for ; Mon, 13 Mar 2023 16:28:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A6F86B008C; Mon, 13 Mar 2023 12:27:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 40DC76B008A; Mon, 13 Mar 2023 12:27:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 219BA6B008C; Mon, 13 Mar 2023 12:27:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 082B26B0089 for ; Mon, 13 Mar 2023 12:27:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B15B4120C35 for ; Mon, 13 Mar 2023 16:27:54 +0000 (UTC) X-FDA: 80564406468.20.797A4D7 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 C449D1C000D for ; Mon, 13 Mar 2023 16:27:52 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KWaJI1aL; spf=pass (imf18.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=1678724872; 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=BjYqqe7MvmRoNdsZ3mRmEvGJpIWPHc0RoB3EQFJD7pE=; b=4vVNFhQypUcsjWAGQx857lMSvQde/H1MEO6NHW8JHFyAm18C+A4v4YcK0y66uEYZySkuo+ E7SpcMTyKtJmoIZqERbegpSkFILYzGf+kOHu9VIXpXU2aKNnKzscHKIYlE1msqW4SitvcJ Xpu0Hz5hl7D5FcMassYGNY4dAfWJULw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KWaJI1aL; spf=pass (imf18.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=1678724872; a=rsa-sha256; cv=none; b=EwqW5fExz07t/MgrlwDkGJRLRz88BjUaSikPV4Eh8wwPuDy3MOFHn8aBUiTv94uOWg8eSt 9qe101yu+F1KPeOaIvThAPfJCSTzw4L/jldeR1YXki7Vpw75c6TINarpSRDl+aUq0HaETd YybQOSt0LjQkmCo37VYAUdLksEOZSx0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678724872; 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=BjYqqe7MvmRoNdsZ3mRmEvGJpIWPHc0RoB3EQFJD7pE=; b=KWaJI1aLPamKnFGLKcQBFW5OM6sN43ZFI3xSGbQLCNqpSZ5zHqQEv2bIIwoiDlGfdSxnVe nEJe31I32yncCkBTquR1fqKGAQMOKCY8nsH1SozfF1m+q0TDZQehRdqtBiPP+mANiTVVF4 83oh2g6/GK9iQIPOvWm/KJ37id1PLEk= 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-391-PN2FRtEPOj6OfPOguGKUAg-1; Mon, 13 Mar 2023 12:27:42 -0400 X-MC-Unique: PN2FRtEPOj6OfPOguGKUAg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F15C23C0D1AC; Mon, 13 Mar 2023 16:27:41 +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 C736440C6E69; Mon, 13 Mar 2023 16:27:41 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 3EBD84038AB8B; Mon, 13 Mar 2023 13:26:44 -0300 (-03) Message-ID: <20230313162634.535939407@redhat.com> User-Agent: quilt/0.67 Date: Mon, 13 Mar 2023 13:25:18 -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 , Marcelo Tosatti Subject: [PATCH v5 11/12] mm/vmstat: refresh stats remotely instead of via work item References: <20230313162507.032200398@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C449D1C000D X-Rspam-User: X-Stat-Signature: kz167nxuco4416hckgd8fk4zxbgabqs6 X-HE-Tag: 1678724872-695050 X-HE-Meta: U2FsdGVkX19PqTYkPOIBG++5FBkjJ6V3XjD+jRZH2w2u5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1TymChgWMCQc87wcUJ9wwkn8pYvhSGJdc7Xh/B6HJy8O0nRY/a/FKqbEfHfxJI= 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 @@ -1901,11 +1901,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) { @@ -1925,7 +1934,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++) { @@ -2045,7 +2054,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; @@ -2055,7 +2064,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)); }