From patchwork Mon Mar 20 18:03:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13181691 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 E6487C76195 for ; Mon, 20 Mar 2023 18:12:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 63CBA6B0080; Mon, 20 Mar 2023 14:12:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A7DA6B0082; Mon, 20 Mar 2023 14:12:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE2736B0081; Mon, 20 Mar 2023 14:12:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9D9686B0083 for ; Mon, 20 Mar 2023 14:12:12 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 52E9F120D47 for ; Mon, 20 Mar 2023 18:12:12 +0000 (UTC) X-FDA: 80590070904.25.485CF2B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 821621A001B for ; Mon, 20 Mar 2023 18:12:10 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V66n9QQg; spf=pass (imf19.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.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=1679335930; 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=s0eL+muEcWwaDlYOvrz0uKI6cYwztUvQb2dBAOG0XGM=; b=63oA+xyB7NEAyFKKzvsGT8zJ2um8eAjJaWrSegO8rTQ8Ye8HsqPVHUM4vbZTnzbR0xFSQG LtMA4u17YPYPG1B0DYHgP3SqQIQIKte2Lmf0U0k8JbIb8i8zZxfjSIVZ1HfH3T0CzaYW6m malvnBCyM1VgdZNNyo3ZmOyMGRosrgM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V66n9QQg; spf=pass (imf19.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.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=1679335930; a=rsa-sha256; cv=none; b=Q+ja+E07FeKi3BwTWGUB78sWqcYd4n2PiJmmPC1P7Kwn+i32ue6TejUbRTmnVUYgBAQhN3 Jt/9cfYAW+P0sO6CvZeyrAh6LEJKPvwhHxlaCfMnRraNzs1nBj0gB3KDGKwunT17YflrHW GuNBd8DVWLJs6ReJpKqLPhSr1gx1lNI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679335929; 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=s0eL+muEcWwaDlYOvrz0uKI6cYwztUvQb2dBAOG0XGM=; b=V66n9QQgzbB/UMw5q2jKrlD8dLRSaiEiXGB6UPIgQIpOKEbhvwixCKe+lZXCVDpeWkjMJc G0U4C5SROngooCmNu3K7mAjZsLLRcTY2QpeXdrVCBDA27X8SFCGKMbULD7h/qa50HBpc5v PTl4tAHFpDr8vxpHimmzq6XAGk5Ayvk= 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-488-GdUVvJhgPDKBvQym1NCNbg-1; Mon, 20 Mar 2023 14:12:04 -0400 X-MC-Unique: GdUVvJhgPDKBvQym1NCNbg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88568855311; Mon, 20 Mar 2023 18:12:03 +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 5267A2027062; Mon, 20 Mar 2023 18:12:03 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 0EF05403BCD8B; Mon, 20 Mar 2023 15:08:03 -0300 (-03) Message-ID: <20230320180745.832991792@redhat.com> User-Agent: quilt/0.67 Date: Mon, 20 Mar 2023 15:03:44 -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 v7 12/13] mm/vmstat: refresh stats remotely instead of via work item References: <20230320180332.102837832@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Stat-Signature: g98xq33cwm1ramwf39q18ju7goj3wxis X-Rspam-User: X-Rspamd-Queue-Id: 821621A001B X-Rspamd-Server: rspam06 X-HE-Tag: 1679335930-7991 X-HE-Meta: U2FsdGVkX1+HbzAFukaYZ7yADc4IHpKyv+y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T9mmfj3RP/jV5QXS3BopFmAOETVep61kA4fm8u8eu4tk0ys8HsvJBWU4uXtR6Zu/RRZa5biBqlcy8qemAgZUvi0vOkRBXzk= 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)); }