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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS 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 85903C433EF for ; Wed, 15 Sep 2021 04:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5071A61263 for ; Wed, 15 Sep 2021 04:06:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230118AbhIOEHr (ORCPT ); Wed, 15 Sep 2021 00:07:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:50030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbhIOEHq (ORCPT ); Wed, 15 Sep 2021 00:07:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E4BF961261; Wed, 15 Sep 2021 04:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1631678788; bh=WYstT8YUj7N6DeOrzi3FtzLeW79E91ytEQY8XZ7M6Rs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=by//OxjLEOvgfQI9lVob2GQYVf7o03y2Tcf2Iydip8t4e83ps8T/EDJrhSZVH7kGO FoJ39jyJouMWEcJtz2Ycftz2JIYbH1aq9dKxsxz42+xZyeZRyxtoAGrMtIhadDmOD0 XQsmCsJoPzw1uJubuZmb+Z/XQdgjFjGqbCseA5+s= Date: Tue, 14 Sep 2021 21:06:27 -0700 From: Andrew Morton To: Pingfan Liu Cc: linux-kernel@vger.kernel.org, Petr Mladek , Wang Qing , "Peter Zijlstra (Intel)" , Santosh Sivaraj , Sumit Garg , Will Deacon , Mark Rutland Subject: Re: [PATCH 2/5] kernel/watchdog_hld: clarify the condition in hardlockup_detector_event_create() Message-Id: <20210914210627.c92374b3726a22014b359dbd@linux-foundation.org> In-Reply-To: <20210915035103.15586-3-kernelfans@gmail.com> References: <20210915035103.15586-1-kernelfans@gmail.com> <20210915035103.15586-3-kernelfans@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 Sep 2021 11:51:00 +0800 Pingfan Liu wrote: > hardlockup_detector_event_create() indirectly calls > kmem_cache_alloc_node(), which is blockable. > > So here, the really planned context is is_percpu_thread(). > > ... > > --- 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 */ > + BUG_ON(!is_percpu_thread()); Can we avoid adding the BUG()? Find a way to emit a WARNing and then permit the kernel to continue? > + cpu = raw_smp_processor_id(); > wd_attr = &wd_hw_attr; > wd_attr->sample_period = hw_nmi_get_sample_period(watchdog_thresh);