From patchwork Tue Mar 14 18:59:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13174932 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 9F124C05027 for ; Tue, 14 Mar 2023 19:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E5348E000A; Tue, 14 Mar 2023 15:01:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DD2558E000C; Tue, 14 Mar 2023 15:01:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B89BB8E0001; Tue, 14 Mar 2023 15:01:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9CA4D8E000A for ; Tue, 14 Mar 2023 15:01:16 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 43261160D99 for ; Tue, 14 Mar 2023 19:01:16 +0000 (UTC) X-FDA: 80568421752.25.78997D3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 0BA718001B for ; Tue, 14 Mar 2023 19:01:13 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I0moCVyX; spf=pass (imf30.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=1678820474; 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=lhj3IWSZuEs/JMJM0XIlknwlVBbUg0Rg+4M7Wf596y4WEsC9vqdfjF97zmJH68/IOcfGPV QzjFRyj17PNaP7ROTz8BIa8KKp8kDD+1/8k3ffhqMU+hfU533auHgz0LEmkk3IZMB75eb0 E5Kv6s4EJ0xtPHHcksuE8JztEgno37M= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=I0moCVyX; spf=pass (imf30.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=1678820474; a=rsa-sha256; cv=none; b=tyPp18chmn0b5nuPcVGDB5F/ZrU3YGZ2+Arh9b+mk5ksl1yR7dIO8QDdC8DDxR+dcCQ881 AKVNNitvwkmOl89JbvYKmLjT2L4dUphZIH37hxD6zNA+sV5SE5eGk+AVFZ+Ro8rEbhXF9O iJs+eoAPCPeyZ3Qw4WmaTDY11pJ6fW4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678820473; 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=I0moCVyXjV+b7xtxbNQCPA5LLWOUywDzsOrppZbpHhZdGaqcBHITxVL0TqJOI/tGcMle71 o/nTsn+Za+mgYwfyDQku8QwpyJXAyqu1tMajh1GdbIw+t/5/gX4z8k25LjvJreTBmDoMj4 u+qcgRmEP+1v5T0/csRgmHBi2x+OQYE= 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-661-eTB4kV2KNn62pW4FAutmSg-1; Tue, 14 Mar 2023 15:01:07 -0400 X-MC-Unique: eTB4kV2KNn62pW4FAutmSg-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 30F6B18E0046; Tue, 14 Mar 2023 19:01:05 +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 F26262A68; Tue, 14 Mar 2023 19:01:04 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 7C4E04039C295; Tue, 14 Mar 2023 16:00:44 -0300 (-03) Message-ID: <20230314185951.804121555@redhat.com> User-Agent: quilt/0.67 Date: Tue, 14 Mar 2023 15:59:25 -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 v6 11/12] mm/vmstat: refresh stats remotely instead of via work item References: <20230314185914.836510860@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0BA718001B X-Rspam-User: X-Stat-Signature: wu4frpjwzyw6hqbskbxk8azhx1yrddn5 X-HE-Tag: 1678820473-120386 X-HE-Meta: U2FsdGVkX1/zCgvQCcd/vcNM0/+2R+q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4vDiUJ+47/yloolGyqer7/jsTNv6qPvPvBqKJ2Mrvp3KbcJxqD/I4CE5TZbTZyOSb2Va2MDltg3nT4ZSy0hfvzKQGscAgA= 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)); }