From: Petr Mladek <pmladek@suse.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Oleg Nesterov <oleg@redhat.com>, Tejun Heo <tj@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Josh Triplett <josh@joshtriplett.org>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jiri Kosina <jkosina@suse.cz>, Borislav Petkov <bp@suse.de>,
Michal Hocko <mhocko@suse.cz>,
linux-mm@kvack.org, Vlastimil Babka <vbabka@suse.cz>,
linux-api@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 02/12] kthread: Kthread worker API cleanup
Date: Mon, 13 Jun 2016 17:13:53 +0200 [thread overview]
Message-ID: <20160613151353.GA2725@pathway.suse.cz> (raw)
In-Reply-To: <20160610152905.e99933d99108fa6d9f8d4dca@linux-foundation.org>
On Fri 2016-06-10 15:29:05, Andrew Morton wrote:
> On Thu, 9 Jun 2016 11:07:10 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > On Thu, 9 Jun 2016 15:51:56 +0200
> > Petr Mladek <pmladek@suse.com> wrote:
> >
> > > A good practice is to prefix the names of functions and macros
> > > by the name of the subsystem.
> > >
> > > The kthread worker API is a mix of classic kthreads and workqueues.
> > > Each worker has a dedicated kthread. It runs a generic function
> > > that process queued works. It is implemented as part of
> > > the kthread subsystem.
> > >
> > > This patch renames the existing kthread worker API to use
> > > the corresponding name from the workqueues API prefixed by
> > > kthread_/KTHREAD_:
> > >
> > > DEFINE_KTHREAD_WORKER() -> KTHREAD_DECLARE_WORKER()
> > > DEFINE_KTHREAD_WORK() -> KTHREAD_DECLARE_WORK()
> > > DEFINE_KTHREAD_WORKER_ONSTACK() -> KTHREAD_DECLARE_WORKER_ONSTACK()
> > > DEFINE_KTHREAD_WORKER_ONSTACK() -> KTHREAD_DECLARE_WORKER_ONSTACK()
> > > __init_kthread_worker() -> __kthread_init_worker()
> > > init_kthread_worker() -> kthread_init_worker()
> > > init_kthread_work() -> kthread_init_work()
> > > insert_kthread_work() -> kthread_insert_work()
> > > queue_kthread_work() -> kthread_queue_work()
> > > flush_kthread_work() -> kthread_flush_work()
> > > flush_kthread_worker() -> kthread_flush_worker()
> > >
> >
> > I know that Andrew suggested this, but I didn't get a chance to respond
> > to his email due to traveling.
> >
> > Does this mean we are going to change all APIs like this? Because we
> > pretty much use this type of naming everywhere. That is, we start with
> > "DEFINE_*" and "DECLARE_*" commonly. As well as "init_*".
> >
> > For example DEFINE_PER_CPU(), DEFINE_SPINLOCK(), DEFINE_LGLOCK(),
> > DEFINE_MUTEX(), DEFINE_RES_MEME(), DEFINE_TIMER(), DEFINE_IDA(),
> > DEFINE_NFS4_*(), and the list goes on. Just do a grep in
> > include/linux/*.h for DEFINE_ and DECLARE_.
>
> Yes, there's so much precedence that DEFINE_KTHREAD_WORKER() and
> friends can/should be left as-is.
>
> But I do think that init_kthread_worker() is a sore thumb and should
> become kthread_worker_init() (not kthread_worker_init())
OK, all wants to keep DEFINE stuff as is:
DEFINE_KTHREAD_WORKER() stay
DEFINE_KTHREAD_WORK() stay
DEFINE_KTHREAD_WORKER_ONSTACK() stay
DEFINE_KTHREAD_WORKER_ONSTACK() stay
Nobody was against renaming the non-init functions:
insert_kthread_work() -> kthread_insert_work()
queue_kthread_work() -> kthread_queue_work()
flush_kthread_work() -> kthread_flush_work()
flush_kthread_worker() -> kthread_flush_worker()
Now, the question seem to be the init() functions.
Andrew would prefer:
__init_kthread_worker() -> __kthread_worker_init()
init_kthread_worker() -> kthread_worker_init()
init_kthread_work() -> kthread_work_init()
AFAIK, Steven would prefer to keep it
__init_kthread_worker() stay as is
init_kthread_worker() stay as is
init_kthread_work() stay as is
I would personally prefer the way from this patch:
__init_kthread_worker() -> __kthread_init_worker()
init_kthread_worker() -> kthread_init_worker()
init_kthread_work() -> kthread_init_work()
I have several reasons:
1. The init functions will be used close to the other functions in
the code. It will be easier if all functions use the same
naming scheme. Here are some snippets:
kthread_init_work(&w_data->balancing_work, clamp_balancing_func);
kthread_init_delayed_work(&w_data->idle_injection_work,
clamp_idle_injection_func);
kthread_queue_work(w_data->worker, &w_data->balancing_work);
or
kthread_init_delayed_work(&kmemleak_scan_work, kmemleak_scan_func);
kmemleak_scan_worker = kthread_create_worker(0, "kmemleak");
2. We are going to add kthread_destroy_worker() which would need
to be another exception. Also this function will be used together
with the others, for example:
kthread_cancel_delayed_work_sync(&rb_producer_hammer_work);
kthread_destroy_worker(rb_producer_worker);
Also here the same naming scheme will help.
3. It is closer to the workqueues API, so it reduces confusion.
4. Note that there are already several precedents, for example:
amd_iommu_init_device()
free_area_init_node()
jump_label_init_type()
regmap_init_mmio_clk()
Andrew, Steven, are you really so strongly against my version
of the init functions, please?
> > Also, are you sure that we should change the DEFINE to a DECLARE,
> > because DEFINE is used to create the object in question, DECLARE is for
> > header files:
>
> Yes2, these macros expand to definitions, not to declarations.
Shame on me. I played with many variants, looked for the most
consistent solution, and got lost in all the constrains.
Best Regards,
Petr
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2016-06-13 15:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-09 13:51 [PATCH v8 00/12] kthread: Kthread worker API improvements Petr Mladek
2016-06-09 13:51 ` [PATCH v8 01/12] kthread: Rename probe_kthread_data() to kthread_probe_data() Petr Mladek
2016-06-09 13:51 ` [PATCH v8 02/12] kthread: Kthread worker API cleanup Petr Mladek
2016-06-09 15:07 ` Steven Rostedt
2016-06-10 22:29 ` Andrew Morton
2016-06-13 15:13 ` Petr Mladek [this message]
2016-06-13 16:03 ` Steven Rostedt
2016-06-09 17:22 ` Peter Zijlstra
2016-06-09 13:51 ` [PATCH v8 03/12] kthread/smpboot: Do not park in kthread_create_on_cpu() Petr Mladek
2016-06-09 13:51 ` [PATCH v8 04/12] kthread: Allow to call __kthread_create_on_node() with va_list args Petr Mladek
2016-06-09 13:51 ` [PATCH v8 05/12] kthread: Add kthread_create_worker*() Petr Mladek
2016-06-09 13:52 ` [PATCH v8 06/12] kthread: Add kthread_drain_worker() Petr Mladek
2016-06-09 13:52 ` [PATCH v8 07/12] kthread: Add kthread_destroy_worker() Petr Mladek
2016-06-09 13:52 ` [PATCH v8 08/12] kthread: Detect when a kthread work is used by more workers Petr Mladek
2016-06-09 13:52 ` [PATCH v8 09/12] kthread: Initial support for delayed kthread work Petr Mladek
2016-06-09 13:52 ` [PATCH v8 10/12] kthread: Allow to cancel " Petr Mladek
2016-06-09 13:52 ` [PATCH v8 11/12] kthread: Allow to modify delayed " Petr Mladek
2016-06-09 13:52 ` [PATCH v8 12/12] kthread: Better support freezable kthread workers Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160613151353.GA2725@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=bp@suse.de \
--cc=jkosina@suse.cz \
--cc=josh@joshtriplett.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).