Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp135554pxb; Tue, 14 Sep 2021 21:10:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt1pmMJRqkk5GbbXNks5/ZVIEdHWWhWT7qbmWRFzmUcBNMgZHMW/6IiN6b6cOqWqyJE9sR X-Received: by 2002:a2e:89c5:: with SMTP id c5mr18365852ljk.329.1631679015247; Tue, 14 Sep 2021 21:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631679015; cv=none; d=google.com; s=arc-20160816; b=b8mSm7l9QQV7ZYyLpO9m+fNEGkxzyp93rcQVPpStfI6PcknkD9cJGY8aDqN6BGNeSt Te33FEW28AXJSDD30Dsi2soexWYj5vx8egsqmRgQ7M7rmhIw7HjPwosJBhaqdsusC8e0 JHbmjRxCvfVSa6i1pd4h1hEXFtW8MiMuCpbkPeC8q01n1EhhSnUgmVPO7brDqeRWFIF4 HfkgEnnv07uQpcRpNkmGw2wCi1n6rb7SjNwViw6nEyZWd99Kp/qK/LWeCXMjPbhMHpAU 8ia82ryUwbsOEp2ouFGZ93Ux+NaLU2CPTeFFMWxId98bAXkqvLhNmsl1pwA/ypbJcoPZ VATw== 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:subject:cc:to:from:date :dkim-signature; bh=Ke2QQj9AvEK9g9KevVwUi5y5YIPJudHAlPf7SMB5VfU=; b=BGcKWk/PMjjVNj5EFP9IK1v5ZTCY2vpYAMTuQmJBvsLl/jmwumdrxusZWyVB26eHJb c0yvlP1itS0wV4cnfHMIpGd++PqVbDY1zEcPyiIK61Sun0ldD4YdgunBFXgPI9oXJ+wU yM4PrJbcAQ9ZOiR4jxJjjLMjNnZtqWdT2EycOPFhW76+R96w5OiRlFDcO//LE2QJ3Lgg GFHH960DlB5cKW8L/j9jD0+gwHHLjpw4bY3Ddvw05mqwHs1QsdjFcEZzp53cfzjh0NEH E2RYdGZYNK4iiMEkHk6kRogGbbXRcBU6TPOAB5triMjNGN8F9tRvIkH9RgelDj7FlVDb 8vGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="by//OxjL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si16624956ljw.342.2021.09.14.21.09.47; Tue, 14 Sep 2021 21:10:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b="by//OxjL"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230014AbhIOEHq (ORCPT + 99 others); Wed, 15 Sep 2021 00:07:46 -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);