From patchwork Fri May 19 17:18:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 96550 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1410684vqo; Fri, 19 May 2023 10:42:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4KM/KBbe9qoEutsqe8EpOsbZpzUEweuvcOOUrwX6OHvbpO4H1E2O3GaQ9O/SgazbFWSn36 X-Received: by 2002:a05:6a00:15c9:b0:643:59ed:5dc9 with SMTP id o9-20020a056a0015c900b0064359ed5dc9mr4189418pfu.12.1684518150462; Fri, 19 May 2023 10:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684518150; cv=none; d=google.com; s=arc-20160816; b=OI3tB2RoKon9HCYXspldc0Zqng1ckQG/mz5pDutriNlcCn080wZ/PydlYllunvN89T BIQ6OscxPKYdSxf2r+e2yjv+bfGmOluTekagAUcEaEqxf82nERcocU/ibm+jviwNoTfN 9dPQ37gUgnrlH17bgto/FlOS+4Nq5ylSeyS+KMokTY10AzMkqARNa1R+DdaqYNOPdW7d O1MxssnkBeLA1KTXbP5D0NTd9LsSUhv246XkGQOjXizhCHN3qx959AH8WmQ7da1evdBg uj7tivFnR4s7zfbzHV5NXA9Q5/8h3lp7pb46jb53eJ2Ymv9DrtQEYGXvvv5eL1mzcDOn Ta0g== 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=ofKCq2S0sG4HUWPTrK47G6OxIUEY0NpUnbveH+FrW0Q=; b=zsgxew9o5eX59ZMDQfb00lspHBDcLRbZUS5saQHB9hNBS5iqHT/T9g5ANBe8JXU49n smozxO0FRm3cTzyjnlVOhCH54aVEPSInEwrERKEh0XRyIT+Ihtjz0vsnoWwvIQdqb5JE AT4iA4shJHaJ2iJsK7eJLWinKJkryee+p2JYTpTnYIwsGnUWgMko8uT4p60x6Ht2Mrje VM7sko6ybVWLbUfD73lMPj/7RGQF5YDKu1VShOHxHpS1+1IgbpxYTWyODwrslNp/YOa+ +9TJwaIYsh7j0bYzoVt5QXXinIXfmA7bl1Lq7Q94jCfQlRcAq0gOc/o4NLZikW3NEXab u8ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=li5Y+b1M; 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 z29-20020aa7959d000000b0064d3e651979si653520pfj.233.2023.05.19.10.42.12; Fri, 19 May 2023 10:42:30 -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=li5Y+b1M; 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 S230492AbjESRWp (ORCPT + 99 others); Fri, 19 May 2023 13:22:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231840AbjESRWD (ORCPT ); Fri, 19 May 2023 13:22:03 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E83E5A for ; Fri, 19 May 2023 10:21:34 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-25343f0c693so2483481a91.3 for ; Fri, 19 May 2023 10:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684516891; x=1687108891; 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=ofKCq2S0sG4HUWPTrK47G6OxIUEY0NpUnbveH+FrW0Q=; b=li5Y+b1MKSL5H1TcUJ/gnT7tpJRmScW/yX7Xn4EozrdVenjMOyka4dNkjUbb0TmJ44 u5glYz+gYHxOpEkslJ/3sx7pea49YLQ1oj/Q+flL2o8pYyT1TVZwVbZIPOdhZuFElcEo GWlDeqfsuUlpQPXerEDkwuL+kLQXlybCMyzdI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684516891; x=1687108891; 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=ofKCq2S0sG4HUWPTrK47G6OxIUEY0NpUnbveH+FrW0Q=; b=BDQxjR4kWGmRNUlajh0JBP61Yk/UOsEO31NdkMRS0rBWq5p6H0QTIUzFazM2uoNNqO Q5QTYRqwtz2zM27daqqqGrsl9B0x+2Z8PBPHPtUGC7xC9ekpf53KnPCdXn2sbtpOq6Lr RG4qJtDwTkmU3rj4Tt81u6T9nIPOWUYXULPWMAIC1T4qVZWLSj1T602fO9hxqYjpviVl MJiSmAVmYow4y9wOx6dktLamXzjXuUl8GrXGSso3f9p7r/+ZRGgVvN66B5cmmAZtosNl bdnFJN2g0crwMOsIQpmV0+S87kIfX26ijT2emi+OH33PfSGSJEvi6WZ9Ve5LuaD2+jzg 5wUg== X-Gm-Message-State: AC+VfDw662Lq1GhhTinUt9mVEghQPV+uO398au5g0uILMTR6huw/DaKj 3tLhoVfoeUqiE8Z+5wpXHBgSmA== X-Received: by 2002:a17:90a:c503:b0:253:41b8:13d6 with SMTP id k3-20020a17090ac50300b0025341b813d6mr2750064pjt.21.1684516890703; Fri, 19 May 2023 10:21:30 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:9b89:2dd0:d160:429d]) by smtp.gmail.com with ESMTPSA id gj19-20020a17090b109300b0024e4f169931sm1763835pjb.2.2023.05.19.10.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 May 2023 10:21:29 -0700 (PDT) From: Douglas Anderson To: Petr Mladek , Andrew Morton Cc: Matthias Kaehlcke , kgdb-bugreport@lists.sourceforge.net, Stephane Eranian , mpe@ellerman.id.au, Tzung-Bi Shih , Daniel Thompson , Mark Rutland , linuxppc-dev@lists.ozlabs.org, Sumit Garg , npiggin@gmail.com, davem@davemloft.net, Marc Zyngier , Stephen Boyd , sparclinux@vger.kernel.org, christophe.leroy@csgroup.eu, Catalin Marinas , ravi.v.shankar@intel.com, Randy Dunlap , Pingfan Liu , Guenter Roeck , Lecopzer Chen , Ian Rogers , ito-yuichi@fujitsu.com, ricardo.neri@intel.com, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, Will Deacon , Chen-Yu Tsai , linux-kernel@vger.kernel.org, Masayoshi Mizuma , Andi Kleen , Douglas Anderson Subject: [PATCH v5 17/18] arm64: add hw_nmi_get_sample_period for preparation of lockup detector Date: Fri, 19 May 2023 10:18:41 -0700 Message-ID: <20230519101840.v5.17.Ia9d02578e89c3f44d3cb12eec8b0176603c8ab2f@changeid> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog In-Reply-To: <20230519101840.v5.18.Ia44852044cdcb074f387e80df6b45e892965d4a1@changeid> References: <20230519101840.v5.18.Ia44852044cdcb074f387e80df6b45e892965d4a1@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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766345303945533122?= X-GMAIL-MSGID: =?utf-8?q?1766345303945533122?= From: Lecopzer Chen Set safe maximum CPU frequency to 5 GHz in case a particular platform doesn't implement cpufreq driver. Although, architecture doesn't put any restrictions on maximum frequency but 5 GHz seems to be safe maximum given the available Arm CPUs in the market which are clocked much less than 5 GHz. On the other hand, we can't make it much higher as it would lead to a large hard-lockup detection timeout on parts which are running slower (eg. 1GHz on Developerbox) and doesn't possess a cpufreq driver. Co-developed-by: Sumit Garg Signed-off-by: Sumit Garg Co-developed-by: Pingfan Liu Signed-off-by: Pingfan Liu Signed-off-by: Lecopzer Chen Signed-off-by: Douglas Anderson --- I yanked this patch from the mailing lists [1] into my series just to make it easier to avoid conflicts between my series and the one adding the arm64 perf hardlockup detector, in case someone wanted to test them both together. The only change I made here was to remove an extra blank line that checkpatch complained about. As mentioned in the cover letter, I'm not really expecting this patch to land together with the patches for the buddy detector. I included it with my series simply for convenience of testing both series together. NOTE: the previous patch posted by Lecopzer pointed to Sumit's patch [2] in the commit text but provided no context. I moved it to this "after the cut" note. [1] https://lore.kernel.org/r/20220903093415.15850-6-lecopzer.chen@mediatek.com/ [2] http://lore.kernel.org/linux-arm-kernel/1610712101-14929-1-git-send-email-sumit.garg@linaro.org (no changes since v4) Changes in v4: - Pulled ("add hw_nmi_get_sample_period for ...") into my series for v4. arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/watchdog_hld.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 arch/arm64/kernel/watchdog_hld.c diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 7c2bb4e72476..cc22011ab66a 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o obj-$(CONFIG_MODULES) += module.o obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o obj-$(CONFIG_PERF_EVENTS) += perf_regs.o perf_callchain.o +obj-$(CONFIG_HARDLOCKUP_DETECTOR_PERF) += watchdog_hld.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_CPU_PM) += sleep.o suspend.o obj-$(CONFIG_CPU_IDLE) += cpuidle.o diff --git a/arch/arm64/kernel/watchdog_hld.c b/arch/arm64/kernel/watchdog_hld.c new file mode 100644 index 000000000000..2401eb1b7e55 --- /dev/null +++ b/arch/arm64/kernel/watchdog_hld.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0 +#include + +/* + * Safe maximum CPU frequency in case a particular platform doesn't implement + * cpufreq driver. Although, architecture doesn't put any restrictions on + * maximum frequency but 5 GHz seems to be safe maximum given the available + * Arm CPUs in the market which are clocked much less than 5 GHz. On the other + * hand, we can't make it much higher as it would lead to a large hard-lockup + * detection timeout on parts which are running slower (eg. 1GHz on + * Developerbox) and doesn't possess a cpufreq driver. + */ +#define SAFE_MAX_CPU_FREQ 5000000000UL // 5 GHz +u64 hw_nmi_get_sample_period(int watchdog_thresh) +{ + unsigned int cpu = smp_processor_id(); + unsigned long max_cpu_freq; + + max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL; + if (!max_cpu_freq) + max_cpu_freq = SAFE_MAX_CPU_FREQ; + + return (u64)max_cpu_freq * watchdog_thresh; +}