Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2026508pxb; Thu, 7 Oct 2021 22:07:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7BdxaSj/lhpce1G0XfFMgh09EoTUk/7KJ7c1alwAZSdJxFNYX4g5xg9b7MvXhoM4fl/0r X-Received: by 2002:a05:6402:5209:: with SMTP id s9mr8280548edd.110.1633669658825; Thu, 07 Oct 2021 22:07:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633669658; cv=none; d=google.com; s=arc-20160816; b=chh2q3Idu4uY0oCgTPkA/AD9KRbnWgr5LmZEz4gE2mQdGAtBGyCxoXm3hwJOvBl7AK ITDEHq2d6IAvWdNavBqcjueWJupkpzFhOHTOQixNjyXlJQmDSt+/L/beo12Nklyk5XQW nlwX81IfVDVgfvPZiekXFJmI11J5r0TNrJMX9L8gTD2BB13UiFrKlIpp6kl0qJ/3gVEq mbCFuPdtoarM2wQn4urry2O8NGZKUrJ7mZO13MJKgvp7Fg7H5lhGkFlpjG4Udns7nsa3 WC3rCi1UbEeYZpSlIsK1ZfcDWI0eKHSF3jR9gcMmhN5wt1AOxjoSgQuFSM/LXxApoXfZ EVow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Osq7yHITSy77g/Lrd5YqQ5+z91i4cbWQpNrrgt8Jybc=; b=zfwjYZR5Ov4teOZ/X/UiHjNd1gXvtZ7hb4DOGPGV2QTKG81erEHE7rw/ifP+LOjl0d Nv5L3rvmTZS+9gzXhAjEK5wvKbrDSSFzjPxUOajZmtd3kLt2g4usz37qk5mtVOGxUYuL EsPZ+Q8qKF15M2EQe9ukkEgypRkuMP7wjTXy2/qCaMhbPELxxW+FZNH5Vuoeho/8J/X0 FXUOwCEuvHv/jTHr94TZBmPRUplp77O4uapV93HmRmAR3bj1ComHnWew13fppYWhKWNT O/+QHjLqGQStyjefvVZ1udXaLTRvRbFgnOjH9KhKoh2HV9Ukar9qoOJ48QEuwGX+vuJ0 vo7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MRvjwAt7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f14si1686208edc.450.2021.10.07.22.07.11; Thu, 07 Oct 2021 22:07:38 -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=@redhat.com header.s=mimecast20190719 header.b=MRvjwAt7; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233620AbhJHENj (ORCPT + 99 others); Fri, 8 Oct 2021 00:13:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53640 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbhJHENj (ORCPT ); Fri, 8 Oct 2021 00:13:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633666303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Osq7yHITSy77g/Lrd5YqQ5+z91i4cbWQpNrrgt8Jybc=; b=MRvjwAt7Lc8uTWglJqzwoPvWaAVwrKfZYVVNR5nU6rP7DPyeUN0k3V05fXEtXkBOYx9XsU Cc2A9A0/0cwLxfLzGg9vAWlulVKrCokyNw7FbHBWOiYSXvA3eiebdoLXBplKfEARGK+s4P tw2OqeXye5wjgl55U4h1I1EFjyIG52U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-m1KOfDvHNJ60G1otsXrsww-1; Fri, 08 Oct 2021 00:11:42 -0400 X-MC-Unique: m1KOfDvHNJ60G1otsXrsww-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 088EB362FA; Fri, 8 Oct 2021 04:11:41 +0000 (UTC) Received: from piliu.users.ipa.redhat.com (ovpn-8-26.pek2.redhat.com [10.72.8.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09E9210013D7; Fri, 8 Oct 2021 04:11:36 +0000 (UTC) Date: Fri, 8 Oct 2021 12:11:32 +0800 From: Pingfan Liu To: Petr Mladek Cc: Pingfan Liu , linux-kernel@vger.kernel.org, Andrew Morton , Wang Qing , "Peter Zijlstra (Intel)" , Santosh Sivaraj , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCHv2 2/4] kernel/watchdog_hld: clarify the condition in hardlockup_detector_event_create() Message-ID: References: <20210923140951.35902-1-kernelfans@gmail.com> <20210923140951.35902-3-kernelfans@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 04, 2021 at 02:32:47PM +0200, Petr Mladek wrote: > On Thu 2021-09-23 22:09:49, Pingfan Liu wrote: > > 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()". > > The description is pretty hard to understand. I would suggest > something like: > > Subject: kernel/watchdog_hld: Ensure CPU-bound context when creating > hardlockup detector event > > hardlockup_detector_event_create() should create perf_event on the > current CPU. Preemption could not get disabled because > perf_event_create_kernel_counter() allocates memory. Instead, > the CPU locality is achieved by processing the code in a per-CPU > bound kthread. > > Add a check to prevent mistakes when calling the code in another > code path. > Appreciate for that. I will use it. > > 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 */ > > This does not explain why it is needed. I suggest something like: > > /* > * Preemption is not disabled because memory will be allocated. > * Ensure CPU-locality by calling this in per-CPU kthread. > */ > It sounds good. I will use it. > > > + 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); > > > > Othrewise the change looks good to me. > Thank for your help. Regards, Pingfan > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel