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: 69813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1942917wrd; Tue, 14 Mar 2023 12:26:14 -0700 (PDT) X-Google-Smtp-Source: AK7set9DEn/8v/iWQE33Z1zzQiLemgZU7Zf/anQ5pUy14TKo0Z1GixwoDgQkOUT4mDnQT24b0PTA X-Received: by 2002:a05:6a20:4320:b0:d0:45c0:1421 with SMTP id h32-20020a056a20432000b000d045c01421mr28177498pzk.48.1678821973966; Tue, 14 Mar 2023 12:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678821973; cv=none; d=google.com; s=arc-20160816; b=LTPZCzZiWM3q4cQ8XGd5VJAQK73uY7n0LZNRyiACpkulFg43db/TFGk7gfwHCIFX9c sIJhXoZVYgfQN+ztPlAso7/iOUr3tCVri6Hm4Wpvr2FnRVNBCf1SFes11qCF4sr3n15M 07taMJeouFUecST2ayxtRfAuianCGrYhjjIRf66swGbAIudJ3xTkvjbqojqem0m0nGLN NsLhrAmy6aLIEKJI3oX01kF4q1uKtzMsROdQZkhBlwqjrjsZ82656O1runTvvNMG5/xj wZxLFtvYYw5WslMNtKis3X7B6MEGIty8lb+ow2YW8MHF0Vp2Ihsy7BkCYcU9mcN33zis ZkSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=BjYqqe7MvmRoNdsZ3mRmEvGJpIWPHc0RoB3EQFJD7pE=; b=dhc0Fu7arBqKIo1AslqbCewBopT294t1I4R4jXApcQ9BLI0Std6+Jb1o/zqDJ18A2p r+fJtBjD+DlNH1qPhmfQUNu0Hhbon0TdtClKtBiGuS5zlQn6zDmoucgUbDO7twCSNzjA dtNs6mEbH7z7mPFBDUmA1Na9fzHLG91NUl0mpj6XKa5Uyrxgz+Fkb/G9sfkwRO5Qwxsc MKYq1SIk5M05UAATYtk3ghYVzkdcV9LsLSdQsMw6HEVJq2BKltAEiCcgh56TqADzuuIt VocroXswv7gJ+fZlaUnylJ/WqafruZPVMMsx2Tx+ATtDg33Esv8bfnSZYBAjlEUhJGrn VoMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eddE9m5+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a20-20020aa794b4000000b0059b98e82de3si480629pfl.314.2023.03.14.12.25.57; Tue, 14 Mar 2023 12:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eddE9m5+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231329AbjCNTCS (ORCPT + 99 others); Tue, 14 Mar 2023 15:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbjCNTBy (ORCPT ); Tue, 14 Mar 2023 15:01:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EBB510C1 for ; Tue, 14 Mar 2023 12:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678820468; 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=eddE9m5+TpTGAN5AvxHHPb98moV/t54s4o06zqcGCrx04GCu62uR4CQ4Vdw8Ha9iLnSCzX N6gQNBN8j6uvq2bI8IXcrPF984cMVzv5amZ/bIzrySLzFYx+DuK4MYRa1vBg6mNIAEft4c wYRWR6UF7wkHlMZAWqN/kNzrFUbv/04= 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760372430146571617?= X-GMAIL-MSGID: =?utf-8?q?1760372430146571617?= 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)); }