Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp648884pxb; Thu, 21 Oct 2021 06:56:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFaB1P5OmPmyImrl4YWxk6DtxxDszqPt88HLd5xzBYH8uvrQnVl1WhXxQe0HwuV48npjeA X-Received: by 2002:a17:906:ccde:: with SMTP id ot30mr7511799ejb.121.1634824606202; Thu, 21 Oct 2021 06:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634824606; cv=none; d=google.com; s=arc-20160816; b=070iWpGDXzZ9f+ZhPu3bqbhHOSXHVyojrVE2A+7pjpIj+WAL67PSiGN+bpML9T8cFC ZsEQuR1JLPOnWIQs0hiIgXXLVe+SH1UzHs7gu5xuydJXBrd/QZrQdnrexdKVC95CzPxN Kv3eZRxK3mhu3L23SZMeQFv4bQXRPM9PJFT3+btgcbot5R0TruhhjzVNdNzW7+/TO51g /0b5GiISUj/XhJge3+ljQtBrkjtpoavOiO6hOfzhD64K+2PeAQFyG6zEHfoKjR6H8bIa 6bGAZNGof8n95G/iYP4w4whiTT2FNMoPimhFWXCxeCo3sSs2/Bzl2CmpvZa+ltAu38wH yr6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=0RnV3L+WTkOkT4MM7/7BRpR0p/fJe1vp9rvAra8P4dg=; b=V6oQigtnQH799a6k+wvmk19DWHc4yyXLIAc1kFqwQuUHchcAMXTTEpyFrEqb19B7NP qtvpzPYg8RUzXgH8nyPCqyN8u/xoBr/xqdcHXv+KVp0s6X07ySievkjB/9XFg3oqMJV6 urJeRaFtoIGy+qy9J/fU0gmp+KEivcnb1v35QrbPmwbJ95MfmM0VEM9ddH5z02wZXNR2 /jZ13x/v1pfY30uWnnrSzvXheNVgE9o+jOxphRqHERjRNIEu2tc2hjz95XVD8Bstmemv KXA4JyTKD3k3qNqc0My6OyNJBVwx5hcCo1IsMJhkkpLB1updMsgzDGbSWc/VqhPEQLIW yPgw== 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 kz7si7119015ejc.714.2021.10.21.06.56.22; Thu, 21 Oct 2021 06:56:46 -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 S231485AbhJUNz3 (ORCPT + 99 others); Thu, 21 Oct 2021 09:55:29 -0400 Received: from mx24.baidu.com ([111.206.215.185]:58514 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231431AbhJUNz1 (ORCPT ); Thu, 21 Oct 2021 09:55:27 -0400 Received: from BJHW-Mail-Ex14.internal.baidu.com (unknown [10.127.64.37]) by Forcepoint Email with ESMTPS id 5C8913B2146AA655D59E; Thu, 21 Oct 2021 21:53:09 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BJHW-Mail-Ex14.internal.baidu.com (10.127.64.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Oct 2021 21:53:09 +0800 Received: from localhost (172.31.63.8) by BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 21 Oct 2021 21:53:08 +0800 Date: Thu, 21 Oct 2021 21:53:12 +0800 From: Cai Huoqing To: Steven Rostedt CC: Bernard Metzler , Doug Ledford , Jason Gunthorpe , Davidlohr Bueso , "Paul E. McKenney" , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , "Ingo Molnar" , Daniel Bristot de Oliveira , , , Subject: Re: [PATCH 1/6] kthread: Add the helper macro kthread_run_on_cpu() Message-ID: <20211021135312.GA3400@LAPTOP-UKSR4ENP.internal.baidu.com> References: <20211021120135.3003-1-caihuoqing@baidu.com> <20211021120135.3003-2-caihuoqing@baidu.com> <20211021091001.26c24d5b@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211021091001.26c24d5b@gandalf.local.home> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [172.31.63.8] X-ClientProxiedBy: BC-Mail-Ex11.internal.baidu.com (172.31.51.51) To BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) X-Baidu-BdMsfe-DateCheck: 1_BJHW-Mail-Ex14_2021-10-21 21:53:09:345 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21 10月 21 09:10:01, Steven Rostedt wrote: > On Thu, 21 Oct 2021 20:01:30 +0800 > Cai Huoqing wrote: > > > the helper macro kthread_run_on_cpu() inculdes > > "includes" > > > kthread_create_on_cpu/wake_up_process(). > > In some cases, use kthread_run_on_cpu() directly instead of > > kthread_create_on_node/kthread_bind/wake_up_process() or > > kthread_create_on_cpu/wake_up_process() or > > kthreadd_create/kthread_bind/wake_up_process() to simplify the code. > > > > Signed-off-by: Cai Huoqing > > --- > > include/linux/kthread.h | 22 ++++++++++++++++++++++ > > 1 file changed, 22 insertions(+) > > > > diff --git a/include/linux/kthread.h b/include/linux/kthread.h > > index 346b0f269161..dfd125523aa9 100644 > > --- a/include/linux/kthread.h > > +++ b/include/linux/kthread.h > > @@ -56,6 +56,28 @@ bool kthread_is_per_cpu(struct task_struct *k); > > __k; \ > > }) > > > > +/** > > + * kthread_run_on_cpu - create and wake a cpu bound thread. > > + * @threadfn: the function to run until signal_pending(current). > > + * @data: data ptr for @threadfn. > > + * @cpu: The cpu on which the thread should be bound, > > + * @namefmt: printf-style name for the thread. Format is restricted > > + * to "name.*%u". Code fills in cpu number. > > + * > > + * Description: Convenient wrapper for kthread_create_on_node() > > + * followed by wake_up_process(). Returns the kthread or > > + * ERR_PTR(-ENOMEM). > > + */ > > +#define kthread_run_on_cpu(threadfn, data, cpu, namefmt) \ > > Why is this a macro and not a static inline function? > > -- Steve Hi,Thanks for your feedback, I think using static inline function is nice, but here try to keep consistent with the other macros, sush as kthread_create/kthread_init_work... Thanks, Cai. > > > +({ \ > > + struct task_struct *__k \ > > + = kthread_create_on_cpu(threadfn, data, cpu_to_node(cpu), \ > > + namefmt); \ > > + if (!IS_ERR(__k)) \ > > + wake_up_process(__k); \ > > + __k; \ > > +}) > > + > > void free_kthread_struct(struct task_struct *k); > > void kthread_bind(struct task_struct *k, unsigned int cpu); > > void kthread_bind_mask(struct task_struct *k, const struct cpumask *mask); >