Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp528269ybz; Wed, 29 Apr 2020 04:49:57 -0700 (PDT) X-Google-Smtp-Source: APiQypIhybCj0TJ9FbiVhgVZqbBE+iekdhqRpXZKSVcCxRY9/X+maTVPjHXT7D9YhmYDXDskZn5Q X-Received: by 2002:aa7:d718:: with SMTP id t24mr2004029edq.20.1588160996927; Wed, 29 Apr 2020 04:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588160996; cv=none; d=google.com; s=arc-20160816; b=SCgZwXfYCp44KIBgioXZI+7F+0R/9S5l4sWAn1y1k7xXt/GUx6t/gxU6RbWGdrv8dn iDJsMqRHeT3Xh2jQI4bwSx0a9UFBHKwRPUnPD3THQ36mAhCk5pKZ1u1gdECx29Vd8kdl uaGnH3Z7AyfiGl9qpIHUbKTZj4nXgbKAb4m6MpVwmgkVj7ZEKDFXb8ubooK2+1txKfVQ 9bw8GtQTcoa6p2TcFjE/YESYDB0CXd8Z+XWkBjMmf4GvQADeh0QI7Yq+/Z1I/M5fSjSH CHSi0YPi6+eiXYFT3FfGwAAlws7pyiGpG4cHhtMtBMCxj7E2dv4+3V7wJMR7njjqdlsb IUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=HP/M9twG9ED6APgX0uuXxEqMCBc24aNZnfKI5FXoLwA=; b=T6/vhj/0wcgkYHlXbR1TTzlzyQw0DqjvieineaoX+JXoRvnWCN/+Th0Fx2ZOyyE5NZ frK3/iQZpZ/EM4bKrZ6putdEmfrg0YoLLIYh5niCXLNNIusK3+EQ2YMg3LRk4nfZFmvK xnFiR5/2XdY/cbg4kG9uSF8AQ8oK0IRiBjcI5RJ6IRLwtU7lqWYCJ576TTb8XbvEPHno lBUEj8YUVvn2eVPR1J5Cmir0PTLYcTmMfIITkPBNB5YGD5wEmOgK8l1qp0+1b32GBIqq Az5h7SgFcOdGKN7WCdxS8CyV0z1QwAi28Pavbimr3A6RDw//z80FytGqNq9IO9P62c1c HSkQ== ARC-Authentication-Results: i=1; mx.google.com; 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 22si3934803ejw.409.2020.04.29.04.49.34; Wed, 29 Apr 2020 04:49:56 -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; 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 S1726739AbgD2LsC (ORCPT + 99 others); Wed, 29 Apr 2020 07:48:02 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:48367 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726457AbgD2LsC (ORCPT ); Wed, 29 Apr 2020 07:48:02 -0400 X-IronPort-AV: E=Sophos;i="5.73,331,1583164800"; d="scan'208";a="90776462" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 Apr 2020 19:47:58 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 6CC7E50A996E; Wed, 29 Apr 2020 19:47:58 +0800 (CST) Received: from [10.167.220.69] (10.167.220.69) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 29 Apr 2020 19:47:59 +0800 Message-ID: <5EA9696D.9020505@cn.fujitsu.com> Date: Wed, 29 Apr 2020 19:47:57 +0800 From: Xiao Yang User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.2; zh-CN; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: Joel Fernandes CC: , Steven Rostedt , Ingo Molnar Subject: Re: [PATCH] kernel/trace: Stop and wait for kthread on preempt irq module unload References: <20200424223630.224895-1-joel@joelfernandes.org> <5EA80319.7080005@cn.fujitsu.com> <20200428141505.GA141102@google.com> In-Reply-To: <20200428141505.GA141102@google.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.220.69] X-ClientProxiedBy: G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.203) To G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) X-yoursite-MailScanner-ID: 6CC7E50A996E.ABEDC X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/4/28 22:15, Joel Fernandes wrote: > I am wondering if it is because in your test, the kthread exits too quickly. > We have these comments in kthread_stop(): > * If threadfn() may call do_exit() itself, the caller must ensure > * task_struct can't go away. > > Does the below diff on top of the previous patch help? > > ---8<----------------------- > > diff --git a/kernel/trace/preemptirq_delay_test.c b/kernel/trace/preemptirq_delay_test.c > index 1c28ca20e30b6..8051946a18989 100644 > --- a/kernel/trace/preemptirq_delay_test.c > +++ b/kernel/trace/preemptirq_delay_test.c > @@ -152,6 +152,8 @@ static int __init preemptirq_delay_init(void) > int retval; > > test_task = preemptirq_start_test(); > + get_task_struct(test_task); > + > retval = PTR_ERR_OR_ZERO(test_task); > if (retval != 0) > return retval; > @@ -172,8 +174,10 @@ static void __exit preemptirq_delay_exit(void) > { > kobject_put(preemptirq_delay_kobj); > > - if (test_task) > + if (test_task) { > kthread_stop(test_task); > + put_task_struct(test_task); > + } > } Hi Joel, Thanks for your additional patch. First, We have to avoid kbuild error by including --------------------------------------- kernel/trace/preemptirq_delay_test.c: In function ‘preemptirq_delay_init’: kernel/trace/preemptirq_delay_test.c:155:2: error: implicit declaration of function ‘get_task_struct’; did you mean ‘set_task_cpu’? [-Werror=implicit-function-declaration] get_task_struct(test_task); ^~~~~~~~~~~~~~~ set_task_cpu kernel/trace/preemptirq_delay_test.c: In function ‘preemptirq_delay_exit’: kernel/trace/preemptirq_delay_test.c:179:3: error: implicit declaration of function ‘put_task_struct’; did you mean ‘set_task_cpu’? [-Werror=implicit-function-declaration] put_task_struct(test_task); ^~~~~~~~~~~~~~~ set_task_cpu cc1: some warnings being treated as errors --------------------------------------- Second, I used the following steps to do test and didn't get any warning/panic after applying your additional patch: --------------------------------------- for i in $(seq 1 100); do modprobe preemptirq_delay_test test_mode=irq delay=500000; rmmod preemptirq_delay_test; done for i in $(seq 1 100); do modprobe preemptirq_delay_test test_mode=preempt delay=500000; rmmod preemptirq_delay_test; done --------------------------------------- Thanks, Xiao Yang