From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB496C433F5 for ; Thu, 23 Sep 2021 14:10:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0ABB61090 for ; Thu, 23 Sep 2021 14:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241645AbhIWOMI (ORCPT ); Thu, 23 Sep 2021 10:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241386AbhIWOL7 (ORCPT ); Thu, 23 Sep 2021 10:11:59 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81ED0C061574 for ; Thu, 23 Sep 2021 07:10:28 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id 203so5797151pfy.13 for ; Thu, 23 Sep 2021 07:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lphzpTahG7LS2U3xUhfApocU7Cvv9rH+VCCr6o+2b8Y=; b=qcsYU/THvUOnuM29w7s91OlHkUBzEAzfkN0KtxkaHKDFjImyTzJqndOA1fNGd3Zzy2 V/zgScFiEUXVSE/K6Kgifv7rXgjkuXKiv12CKNXJX60Q49qn0ssI4aLluyHYEoYNzjzt k2+dUVPzDzViKMNh1gBxudyzkCFUDnPbPNU2yYlsmfzLeWuGKg9xFqpMCqvJjZBoAiKB e6H/epEhJvbb1LAX7GdLBYh99t82SmePrs1Gbxz+7KymQfFjVGjseXrcGrgNBlDJhTV4 fMpluhxmyV7tJ/GkUR4QBWKK7LlCRitECReP7XV4Dib+S/lUUxG3mep6MHltRmlvKgH5 DRkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lphzpTahG7LS2U3xUhfApocU7Cvv9rH+VCCr6o+2b8Y=; b=kzzzxOVonbUhLx13zLms5Y6FzWnNfTpjS7SAk5y5FKkUi2QpLW/2ZhhojJaG14nv55 2H6BQYbsS89hUHx1rrq2zcRIdXfYMdbuj38gK0SYNopGUVbWLcC94zTX7SqszVcjsKFR rMHMNH+jmA6NNUd7wgD3pL8JIrGlToz388qF47CITjghsfrY6WsOVwU5edKQ3Up1NQjj AGdSX+UqPNDmeGE3Po3LeLeiFb1IrXGmR4P9CLaGY/mik6QC0V87DuVi1VwdP5kxjhAa 5XOW5LqfSWZFFyhD6XhlMMxP0iEACzH7KQ/E/hJC1/qLdO1PFc3GT2Hx/4CVfVp6+eGO 1Sjw== X-Gm-Message-State: AOAM532w9kj4VERjR7oZW0zlSVYVxnsXvaNHs83hnttZzdbkdL8+3Qk6 4B49Wdxmn/vGRmruoQLWXsI/kMb0TQ== X-Google-Smtp-Source: ABdhPJxctOD36OToA6v4P61p+mmh1jpY/eX18Gj8H3Mjg2hsLtwZc/MUzJ7DwkGrLBFHW8DzNuvnSA== X-Received: by 2002:a62:7f87:0:b0:444:b077:51ef with SMTP id a129-20020a627f87000000b00444b07751efmr4653569pfd.61.1632406227945; Thu, 23 Sep 2021 07:10:27 -0700 (PDT) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id j6sm5800766pfn.107.2021.09.23.07.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 07:10:27 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Cc: Pingfan Liu , Petr Mladek , Andrew Morton , Wang Qing , "Peter Zijlstra (Intel)" , Santosh Sivaraj , linux-arm-kernel@lists.infradead.org Subject: [PATCHv2 2/4] kernel/watchdog_hld: clarify the condition in hardlockup_detector_event_create() Date: Thu, 23 Sep 2021 22:09:49 +0800 Message-Id: <20210923140951.35902-3-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210923140951.35902-1-kernelfans@gmail.com> References: <20210923140951.35902-1-kernelfans@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As for the context, there are two arguments to change debug_smp_processor_id() to is_percpu_thread(). -1. watchdog_ev is percpu, and migration will frustrate the attempt which try to bind a watchdog_ev to a cpu by protecting this func inside the pair of preempt_disable()/preempt_enable(). -2. hardlockup_detector_event_create() indirectly calls kmem_cache_alloc_node(), which is blockable. So here, spelling out the really planned context "is_percpu_thread()". Signed-off-by: Pingfan Liu Cc: Petr Mladek Cc: Andrew Morton Cc: Wang Qing Cc: "Peter Zijlstra (Intel)" Cc: Santosh Sivaraj Cc: linux-arm-kernel@lists.infradead.org To: linux-kernel@vger.kernel.org --- kernel/watchdog_hld.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 247bf0b1582c..df010df76576 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -165,10 +165,13 @@ static void watchdog_overflow_callback(struct perf_event *event, static int hardlockup_detector_event_create(void) { - unsigned int cpu = smp_processor_id(); + unsigned int cpu; struct perf_event_attr *wd_attr; struct perf_event *evt; + /* This function plans to execute in cpu bound kthread */ + WARN_ON(!is_percpu_thread()); + cpu = raw_smp_processor_id(); wd_attr = &wd_hw_attr; wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh); -- 2.31.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA8FFC433F5 for ; Thu, 23 Sep 2021 14:12:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9AFE160F48 for ; Thu, 23 Sep 2021 14:12:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9AFE160F48 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pyJKqyesQ0csIyncm+p54w/reF9OBCtOY16dEZyUP38=; b=U6SsssNYlvZrMX H2jPcofvfd13eFkxpQBYRjIk7BKoNiOHx1GsoZ0C4p4GC6HxRxYBSzwt1TyN1OrUKfc+YQw+XFwyA Sy2v1RuNtsWHZuCsqMG0HO53LDy3DzupAnB8zmtrwIRDPLEa+rbpAjaMVeuQpVngnUnN/k90YG3Sd HF34SRGqAnkHZw7RNhPTNhewuTrMUdzVw9k4Z87idSbLTsyGlrGMr2ArxOHRQZfM0Kx8Y6rjGIntG AuAg605YJShgdeOG2FvNmubKZuhaTRRjkNMvbIzvM3JooS3lBDrFFDsFmyyi4F2RbApleql9kyPTz AFx4oov9pAq3hPa1f6MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTPR2-00BmIO-Ju; Thu, 23 Sep 2021 14:10:48 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTPQj-00BmC8-0z for linux-arm-kernel@lists.infradead.org; Thu, 23 Sep 2021 14:10:30 +0000 Received: by mail-pf1-x434.google.com with SMTP id s16so5917141pfk.0 for ; Thu, 23 Sep 2021 07:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lphzpTahG7LS2U3xUhfApocU7Cvv9rH+VCCr6o+2b8Y=; b=qcsYU/THvUOnuM29w7s91OlHkUBzEAzfkN0KtxkaHKDFjImyTzJqndOA1fNGd3Zzy2 V/zgScFiEUXVSE/K6Kgifv7rXgjkuXKiv12CKNXJX60Q49qn0ssI4aLluyHYEoYNzjzt k2+dUVPzDzViKMNh1gBxudyzkCFUDnPbPNU2yYlsmfzLeWuGKg9xFqpMCqvJjZBoAiKB e6H/epEhJvbb1LAX7GdLBYh99t82SmePrs1Gbxz+7KymQfFjVGjseXrcGrgNBlDJhTV4 fMpluhxmyV7tJ/GkUR4QBWKK7LlCRitECReP7XV4Dib+S/lUUxG3mep6MHltRmlvKgH5 DRkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lphzpTahG7LS2U3xUhfApocU7Cvv9rH+VCCr6o+2b8Y=; b=qB6YdgfDDziIy6m8naieBIRUN6jJH2Q1/Ns8zaS8QvOYDLSoToslbswQfsCFhxM61k ROE5jf8EP73NFhxmCQkfWYFMXdd/datJ8UpFnLcmCxDqQEn5YZ8UDFYc6ngRfbPHNhpB emXCmExRjvRnf5HilVkk/AU7G5buXuWpHmRNbNHXKpLW2TXBV/Gyb9ahYtt3lQN7PRgb 5Ox27idcqrlSeQaWC5DRSd1662DVAuDftDJtTt3cFr1yWxuADMKSBxsVa+mWmwxetByh gdyM9yDc//nGyJLRy1MxxFYQAZ034dAoD0sfmClwpB+2T6X+vCV2Ghfpd0V9vAcw7Kgr 00DQ== X-Gm-Message-State: AOAM5307bBWmQ3SdDIr171n3zKtcIjHT97UKw005WZqYBh72aRS0kic2 P8K4m+dL+t9lSnsQ1YS+ug== X-Google-Smtp-Source: ABdhPJxctOD36OToA6v4P61p+mmh1jpY/eX18Gj8H3Mjg2hsLtwZc/MUzJ7DwkGrLBFHW8DzNuvnSA== X-Received: by 2002:a62:7f87:0:b0:444:b077:51ef with SMTP id a129-20020a627f87000000b00444b07751efmr4653569pfd.61.1632406227945; Thu, 23 Sep 2021 07:10:27 -0700 (PDT) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id j6sm5800766pfn.107.2021.09.23.07.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 07:10:27 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Cc: Pingfan Liu , Petr Mladek , Andrew Morton , Wang Qing , "Peter Zijlstra (Intel)" , Santosh Sivaraj , linux-arm-kernel@lists.infradead.org Subject: [PATCHv2 2/4] kernel/watchdog_hld: clarify the condition in hardlockup_detector_event_create() Date: Thu, 23 Sep 2021 22:09:49 +0800 Message-Id: <20210923140951.35902-3-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210923140951.35902-1-kernelfans@gmail.com> References: <20210923140951.35902-1-kernelfans@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210923_071029_098063_A9082099 X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As for the context, there are two arguments to change debug_smp_processor_id() to is_percpu_thread(). -1. watchdog_ev is percpu, and migration will frustrate the attempt which try to bind a watchdog_ev to a cpu by protecting this func inside the pair of preempt_disable()/preempt_enable(). -2. hardlockup_detector_event_create() indirectly calls kmem_cache_alloc_node(), which is blockable. So here, spelling out the really planned context "is_percpu_thread()". Signed-off-by: Pingfan Liu Cc: Petr Mladek Cc: Andrew Morton Cc: Wang Qing Cc: "Peter Zijlstra (Intel)" Cc: Santosh Sivaraj Cc: linux-arm-kernel@lists.infradead.org To: linux-kernel@vger.kernel.org --- kernel/watchdog_hld.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/watchdog_hld.c b/kernel/watchdog_hld.c index 247bf0b1582c..df010df76576 100644 --- a/kernel/watchdog_hld.c +++ b/kernel/watchdog_hld.c @@ -165,10 +165,13 @@ static void watchdog_overflow_callback(struct perf_event *event, static int hardlockup_detector_event_create(void) { - unsigned int cpu = smp_processor_id(); + unsigned int cpu; struct perf_event_attr *wd_attr; struct perf_event *evt; + /* This function plans to execute in cpu bound kthread */ + WARN_ON(!is_percpu_thread()); + cpu = raw_smp_processor_id(); wd_attr = &wd_hw_attr; wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh); -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel