From patchwork Fri Aug 4 14:00:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 131206 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp311676vqb; Fri, 4 Aug 2023 07:45:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWeDUfEOYAWo/TNc3KQU1gWxWuqPmnANpacCcXhIu/huFvCyDFihnxKFrM4aQgWmju7ULk X-Received: by 2002:a19:384d:0:b0:4fd:f85d:f67a with SMTP id d13-20020a19384d000000b004fdf85df67amr1192074lfj.61.1691160332967; Fri, 04 Aug 2023 07:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691160332; cv=none; d=google.com; s=arc-20160816; b=OnTdsDhwkeXdIvC3ZRYAmBdc1G9rghxxId9f0e34L8OifBSrOy9PVaBBZwUCymuLws FAkC/0JdogJIyqRpONf2R3wbnB1C2aiY1jf/Tp1MXnzFzVTTU+/ttUWPjl7e/Dxp7iVe 1bMtS7XK6SrJWa7xJp2vuoL4BjBOEkaVMMmwjy3mrRCqhVIN+GshVVRC56SPaEf1DRtX 5oO/ihlqQrv9+GO5FukKz3l+kBEBNlOvjMf6xPVmNFr8Okv/EMZzUsdN3h/ekwlFY9AB b6lO3WP3px+56j+X9D/3eMkQF7SmpsYB3qDqwS1OyW3lDh4Bv3mmw8OrsIFDzj3T7rya hatA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/ubpHUCUhhdAc9BVTuBszAKxHoy82Y2oolLi025KUkk=; fh=avs7fZ6pz8AoZpPPmikAp2BXzqt3vVG0t7rbESvlVlk=; b=diRR5Chn2Hqfq1719sbntT8TquOCbDZMyw49eB9ZhjjyLhqCNS32nRkJ21LIXdYRXd TyV59Sa22drr8bPJZHQGJCTslC6hoJF9JqAJ+5hKI25tMY/5AYDKvWprM5/BV2NT8zvz eD+7WZoGv5T6jQX7Tii8rls+zaO6plTuJIF2EjONROaDbTdw7ZB0q8vLc6mEnadW17lC MeW9+MkRjHVZRgUoLeBDqztYdHVpK9T4/viuCgcBxjNj07rZpjAVwnKgMnG2aFslbyal t5vCoQRdu4xD7zN0axlK7WQEDWk2pvuK1tEETRYNsP0AzLX+Y4G6WIQzmK22kxCAJidv Kung== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lM7VVMYB; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a056402164a00b00522472b99f5si1614643edx.285.2023.08.04.07.45.07; Fri, 04 Aug 2023 07:45:32 -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=@chromium.org header.s=google header.b=lM7VVMYB; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbjHDOBb (ORCPT + 99 others); Fri, 4 Aug 2023 10:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbjHDOBU (ORCPT ); Fri, 4 Aug 2023 10:01:20 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113FC19AA for ; Fri, 4 Aug 2023 07:01:17 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1bc02bd4eafso18107875ad.1 for ; Fri, 04 Aug 2023 07:01:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691157676; x=1691762476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ubpHUCUhhdAc9BVTuBszAKxHoy82Y2oolLi025KUkk=; b=lM7VVMYBqLq1WWaKyoy1S9d9QHqyvdoAXmQKdUq1F1mGa1KKnkys7Y3zb0ObUNTO/8 D6/0MKl7nUQQi1/P2oo6KBdOlRmoYlfhATagj8O3Gy9Ejq7iU1iRTCueBRDQc5+jkufs Yg6z7jRxvZTeC6ywXmtCoJEaRAjiFYESD7IkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691157676; x=1691762476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ubpHUCUhhdAc9BVTuBszAKxHoy82Y2oolLi025KUkk=; b=AFjF1PhYDqrRqzb4gNavo2MGyzkvIePpBJYvAyD5dErBhroZDn058czly6ykgW42Ty XzvIrcCfny/OAf43WwCiKNCjKDKnfi5rPU+gZrSDGK4ElB5Sh8Khk5a0K+9Vo58y3Qox H0sc50m8SDOtzzN2SGlKUxhGfSd56OByeAEkD4qzkwDBdhaXXY5UzPWRXUoUap/q77dT vnHy7FZ9HdcFnNLMO/VHtqadtU+GPccXBKzcr864ZxrTksVAzHV29ZcLNFksSLbybMTr iazwtSt4to57ud5+AYppzGtUu5NSFZbKlDq625iEQJsfbLATiqLUI5tZ5HvoCChc7d24 wLPA== X-Gm-Message-State: AOJu0Yz9ldFQrDyez6gSNzLJsTM4tWLTi4ngP6YYAQKcJlti87KOS0iN pXXHSSYQnV27jiYsMO2I8z5zCw== X-Received: by 2002:a17:902:b68c:b0:1bc:2036:5338 with SMTP id c12-20020a170902b68c00b001bc20365338mr1611384pls.28.1691157676198; Fri, 04 Aug 2023 07:01:16 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:7e35:e6d0:7bbf:64]) by smtp.gmail.com with ESMTPSA id g5-20020a170902c38500b001b89536974bsm1792291plg.202.2023.08.04.07.01.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 07:01:14 -0700 (PDT) From: Douglas Anderson To: Andrew Morton Cc: Petr Mladek , Michal Hocko , Douglas Anderson , kernel test robot , Lecopzer Chen , Pingfan Liu , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/2] watchdog/hardlockup: Avoid large stack frames in watchdog_hardlockup_check() Date: Fri, 4 Aug 2023 07:00:43 -0700 Message-ID: <20230804065935.v4.2.I501ab68cb926ee33a7c87e063d207abf09b9943c@changeid> X-Mailer: git-send-email 2.41.0.585.gd2178a4bd4-goog In-Reply-To: <20230804065935.v4.1.Ia35521b91fc781368945161d7b28538f9996c182@changeid> References: <20230804065935.v4.1.Ia35521b91fc781368945161d7b28538f9996c182@changeid> MIME-Version: 1.0 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773310137592900551 X-GMAIL-MSGID: 1773310137592900551 After commit 77c12fc95980 ("watchdog/hardlockup: add a "cpu" param to watchdog_hardlockup_check()") we started storing a `struct cpumask` on the stack in watchdog_hardlockup_check(). On systems with CONFIG_NR_CPUS set to 8192 this takes up 1K on the stack. That triggers warnings with `CONFIG_FRAME_WARN` set to 1024. We'll use the new trigger_allbutcpu_cpu_backtrace() to avoid needing to use a CPU mask at all. Fixes: 77c12fc95980 ("watchdog/hardlockup: add a "cpu" param to watchdog_hardlockup_check()") Reported-by: kernel test robot Closes: https://lore.kernel.org/r/202307310955.pLZDhpnl-lkp@intel.com Acked-by: Michal Hocko Signed-off-by: Douglas Anderson Reviewed-by: Petr Mladek --- (no changes since v3) Changes in v3: - Rebase on change introducing trigger_allbutcpu_cpu_backtrace(). Changes in v2: - Allocate space when userspace requests all cpus be backtraced. kernel/watchdog.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 085d7a78f62f..d145305d95fe 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -151,9 +151,6 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) */ if (is_hardlockup(cpu)) { unsigned int this_cpu = smp_processor_id(); - struct cpumask backtrace_mask; - - cpumask_copy(&backtrace_mask, cpu_online_mask); /* Only print hardlockups once. */ if (per_cpu(watchdog_hardlockup_warned, cpu)) @@ -167,10 +164,8 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) show_regs(regs); else dump_stack(); - cpumask_clear_cpu(cpu, &backtrace_mask); } else { - if (trigger_single_cpu_backtrace(cpu)) - cpumask_clear_cpu(cpu, &backtrace_mask); + trigger_single_cpu_backtrace(cpu); } /* @@ -179,7 +174,7 @@ void watchdog_hardlockup_check(unsigned int cpu, struct pt_regs *regs) */ if (sysctl_hardlockup_all_cpu_backtrace && !test_and_set_bit(0, &watchdog_hardlockup_all_cpu_dumped)) - trigger_cpumask_backtrace(&backtrace_mask); + trigger_allbutcpu_cpu_backtrace(cpu); if (hardlockup_panic) nmi_panic(regs, "Hard LOCKUP");