Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2672645rwb; Mon, 7 Aug 2023 01:12:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfBtab7+rt0uw+6wCcNFHFAiDGqeaFMU/h3afpHbgEKufzF+i/GGzHiDtdo7YTaX+fHl7C X-Received: by 2002:a05:6808:1055:b0:3a7:349d:35e3 with SMTP id c21-20020a056808105500b003a7349d35e3mr8567770oih.8.1691395943952; Mon, 07 Aug 2023 01:12:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691395943; cv=none; d=google.com; s=arc-20160816; b=JU4lXDDHTWNlwowy6Z0rotX2ExUD2ITTcn7NKeCa3CUIvKajwA4c0TuCU18dlpvs0c K5TrU1PsYQMELDjXXQ4nJv1WeJXEQ5k9I4DbsdFxGF4zBzsc48/dJT0lFueUxMxwhthi ahPZ6QR+jJcCQO3bYO51mItyxZIvFoW/Qvmt5V/3IYMB+WAlzQHsoJNtFJym/8nWjawn lhNybE8k/ZvBkwvvPuYRJ4ayM5GP7rQq2HhZ3m5r4hP0vWFwXyIpvinHA1hhOS5Lz7Il CXqGj3/q6cVQvu5BpLwjbA/JmZ4409C+SCYX5KiOHLA3+nDRkZHqIPLSlXmXkxtBWKID dC6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oVDqCkVf2XQJK4O1h6mLmsszxeVizs+vrchmcAeH1mM=; fh=KTMYdANQ+U6oO86a4icU+HC81MY7yBiO00OJNQmBSho=; b=M+HEutl87E7/vCQfsovNjm4vLDdwr9jGncHTdFmT+Nuq68wryO71eQw6thwIaXHpzQ RQW1Wjd6BifiiH1NNq9cifmY+ngUKX0Q3gpaC/nsoqL7N9fg43TJKVxFO8eRbYdGP19Z j2ZecHfo+mbzYcNyfgbqAZBziQDj/MAcu5bkUwNRtN7gZxm2wRhBn8/UTXifILgfy8XJ DgVwQfeNkgzkts/bd3pm/VohGdE/WyjMuFwAX3k6Zm0waautHM0bz46v48IexNesoxBb 2apREFXtP4ACAB4qKYBSNJaZqtu3sjeqrxSb5hoUVlg7ZOqo7Gb447mhMQeEXtEMMvYs OrqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GgZc4HVb; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m6-20020a17090a414600b00269584b6a10si1434443pjg.15.2023.08.07.01.12.09; Mon, 07 Aug 2023 01:12:23 -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=GgZc4HVb; 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 S229470AbjHGHfo (ORCPT + 99 others); Mon, 7 Aug 2023 03:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbjHGHfn (ORCPT ); Mon, 7 Aug 2023 03:35:43 -0400 Received: from mail-vk1-xa2e.google.com (mail-vk1-xa2e.google.com [IPv6:2607:f8b0:4864:20::a2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82A2010EC for ; Mon, 7 Aug 2023 00:35:40 -0700 (PDT) Received: by mail-vk1-xa2e.google.com with SMTP id 71dfb90a1353d-4871e54ee84so658650e0c.2 for ; Mon, 07 Aug 2023 00:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691393739; x=1691998539; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oVDqCkVf2XQJK4O1h6mLmsszxeVizs+vrchmcAeH1mM=; b=GgZc4HVbVwBDtKoa8hzpHopMi8083b3Mz9ORzFnG0n+Pm7hf19v0EsjuiZnteADzK9 WVWsARUSgVcKqWXhJOGFSMBSgu3FFxGgoi8u9arCf2twrbwyJYuSgeuR4dyTSMjajF0v I8n7QluuJu6VAySsM5yLOwBZ9Gf6kyjHCK/fE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691393739; x=1691998539; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oVDqCkVf2XQJK4O1h6mLmsszxeVizs+vrchmcAeH1mM=; b=X++m1TupLx3Zn/iVKfzQWtrSAjDFR1rKmLYmFI1ppN3f5eikWDLW/y9Tvje9PtzTRa oszUnDXu7euHOJacvVVV3CHHpd2VATWdacbwIHdRoJlU5thh6yOAr8LI4FNKyLjjPOW5 c2KBWxrKCjSFriAnOtUano11mRuSOx3RvdqiE985VYbqMWLMb16mdDrktAE9bX5VVxig TifAYseaoNB8Ou4wVAxQZ6c7jzeo3SB7gLQdHvFafqQ8SQi5Ohkgxq4iWzCui2rqi84F MuJzVKguybUmFDK536rWLr5DXULr8m4UhchtP8Njmtx0ySsuGaXls4XYbTXjWXdC5i/x deGg== X-Gm-Message-State: AOJu0YzB3NNTC+CC2x8F/Zs9jhDKuTessWZwXqfEtKN4A3K5JGt0kb9T sTtsxx2nsWA55wjWW4TKUMp6YA5PgNUgxJYiM7r1pw== X-Received: by 2002:a1f:c8c2:0:b0:486:42c1:5f57 with SMTP id y185-20020a1fc8c2000000b0048642c15f57mr2773409vkf.5.1691393739460; Mon, 07 Aug 2023 00:35:39 -0700 (PDT) MIME-Version: 1.0 References: <20230804065935.v4.1.Ia35521b91fc781368945161d7b28538f9996c182@changeid> In-Reply-To: <20230804065935.v4.1.Ia35521b91fc781368945161d7b28538f9996c182@changeid> From: Chen-Yu Tsai Date: Mon, 7 Aug 2023 15:35:28 +0800 Message-ID: Subject: Re: [PATCH v4 1/2] nmi_backtrace: Allow excluding an arbitrary CPU To: Douglas Anderson Cc: Andrew Morton , Petr Mladek , Michal Hocko , Arnd Bergmann , Borislav Petkov , Christophe Leroy , "Darrick J. Wong" , Dave Hansen , "David S. Miller" , Frederic Weisbecker , Gaosheng Cui , Greg Kroah-Hartman , "Guilherme G. Piccoli" , "H. Peter Anvin" , Huacai Chen , Ingo Molnar , "Jason A. Donenfeld" , Jianmin Lv , Jinyang He , Josh Poimboeuf , Kees Cook , Lecopzer Chen , Marc Zyngier , Mark Rutland , Michael Ellerman , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Pingfan Liu , Qing Zhang , "Russell King (Oracle)" , Russell King , Stephen Rothwell , Thomas Bogendoerfer , Thomas Gleixner , Tom Rix , Ulf Hansson , Valentin Schneider , WANG Xuerui , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 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 On Fri, Aug 4, 2023 at 10:01=E2=80=AFPM Douglas Anderson wrote: > > The APIs that allow backtracing across CPUs have always had a way to > exclude the current CPU. This convenience means callers didn't need to > find a place to allocate a CPU mask just to handle the common case. > > Let's extend the API to take a CPU ID to exclude instead of just a > boolean. This isn't any more complex for the API to handle and allows > the hardlockup detector to exclude a different CPU (the one it already > did a trace for) without needing to find space for a CPU mask. > > Arguably, this new API also encourages safer behavior. Specifically if > the caller wants to avoid tracing the current CPU (maybe because they > already traced the current CPU) this makes it more obvious to the > caller that they need to make sure that the current CPU ID can't > change. > > Acked-by: Michal Hocko > Signed-off-by: Douglas Anderson > --- > > Changes in v4: > - Renamed trigger_allbutself_cpu_backtrace() for when trigger is unsuppor= ted. > > Changes in v3: > - ("nmi_backtrace: Allow excluding an arbitrary CPU") new for v3. > > arch/arm/include/asm/irq.h | 2 +- > arch/arm/kernel/smp.c | 4 ++-- > arch/loongarch/include/asm/irq.h | 2 +- > arch/loongarch/kernel/process.c | 4 ++-- > arch/mips/include/asm/irq.h | 2 +- > arch/mips/kernel/process.c | 4 ++-- > arch/powerpc/include/asm/irq.h | 2 +- > arch/powerpc/kernel/stacktrace.c | 4 ++-- > arch/powerpc/kernel/watchdog.c | 4 ++-- > arch/sparc/include/asm/irq_64.h | 2 +- > arch/sparc/kernel/process_64.c | 6 +++--- > arch/x86/include/asm/irq.h | 2 +- > arch/x86/kernel/apic/hw_nmi.c | 4 ++-- > include/linux/nmi.h | 14 +++++++------- > kernel/watchdog.c | 2 +- > lib/nmi_backtrace.c | 6 +++--- > 16 files changed, 32 insertions(+), 32 deletions(-) > [...] > diff --git a/include/linux/nmi.h b/include/linux/nmi.h > index e3e6a64b98e0..7cf7801856a1 100644 > --- a/include/linux/nmi.h > +++ b/include/linux/nmi.h > @@ -157,31 +157,31 @@ static inline void touch_nmi_watchdog(void) > #ifdef arch_trigger_cpumask_backtrace > static inline bool trigger_all_cpu_backtrace(void) > { > - arch_trigger_cpumask_backtrace(cpu_online_mask, false); > + arch_trigger_cpumask_backtrace(cpu_online_mask, -1); > return true; > } > > -static inline bool trigger_allbutself_cpu_backtrace(void) > +static inline bool trigger_allbutcpu_cpu_backtrace(int exclude_cpu) > { > - arch_trigger_cpumask_backtrace(cpu_online_mask, true); > + arch_trigger_cpumask_backtrace(cpu_online_mask, exclude_cpu); > return true; > } > > static inline bool trigger_cpumask_backtrace(struct cpumask *mask) > { > - arch_trigger_cpumask_backtrace(mask, false); > + arch_trigger_cpumask_backtrace(mask, -1); > return true; > } > > static inline bool trigger_single_cpu_backtrace(int cpu) > { > - arch_trigger_cpumask_backtrace(cpumask_of(cpu), false); > + arch_trigger_cpumask_backtrace(cpumask_of(cpu), -1); > return true; > } > > /* generic implementation */ > void nmi_trigger_cpumask_backtrace(const cpumask_t *mask, > - bool exclude_self, > + int exclude_cpu, > void (*raise)(cpumask_t *mask)); > bool nmi_cpu_backtrace(struct pt_regs *regs); > > @@ -190,7 +190,7 @@ static inline bool trigger_all_cpu_backtrace(void) > { > return false; > } > -static inline bool trigger_allbutself_cpu_backtrace(void) > +static inline bool trigger_allbutcpu_cpu_backtrace(void) ^ The parameter here is still wrong. It should be "int exclude_cpu". This patch in Andrew's queue is causing build errors on next-20230807 on ar= m64: kernel/watchdog.c: In function =E2=80=98watchdog_timer_fn=E2=80=99: kernel/watchdog.c:521:25: error: too many arguments to function =E2=80=98trigger_allbutcpu_cpu_backtrace=E2=80=99 521 | trigger_allbutcpu_cpu_backtrace(smp_processor_id()); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from kernel/watchdog.c:17: ./include/linux/nmi.h:193:20: note: declared here 193 | static inline bool trigger_allbutcpu_cpu_backtrace(void) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ make[3]: *** [scripts/Makefile.build:243: kernel/watchdog.o] Error 1 ChenYu