Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1617550

Re: [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device thread.

From Michal Hocko <mhocko@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device thread.
Date 2017-04-06 09:00 +0200
Message-ID <tt9yF-52M-13@gated-at.bofh.it> (permalink)
References <trYOZ-8pQ-7@gated-at.bofh.it> <tsKTD-6h0-5@gated-at.bofh.it> <tsNot-7Zm-3@gated-at.bofh.it> <tsNHP-85H-9@gated-at.bofh.it> <tt5ln-2tX-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu 06-04-17 12:23:51, NeilBrown wrote:
[...]
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 0ecb6461ed81..95679d988725 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -847,10 +847,12 @@ static void loop_unprepare_queue(struct loop_device *lo)
>  static int loop_prepare_queue(struct loop_device *lo)
>  {
>  	kthread_init_worker(&lo->worker);
> -	lo->worker_task = kthread_run(kthread_worker_fn,
> +	lo->worker_task = kthread_create(kthread_worker_fn,
>  			&lo->worker, "loop%d", lo->lo_number);
>  	if (IS_ERR(lo->worker_task))
>  		return -ENOMEM;
> +	lo->worker_task->flags |= PF_LESS_THROTTLE;
> +	wake_up_process(lo->worker_task);
>  	set_user_nice(lo->worker_task, MIN_NICE);
>  	return 0;

This should work for the current implementation because kthread_create
will return only after the full initialization has been done. No idea
whether we can rely on that in future. I also think it would be cleaner
to set the flag on current and keep the current semantic that only
current changes its flags.

So while I do not have a strong opinion on this I think defining loop
specific thread function which set PF_LESS_THROTTLE as the first thing
is more elegant and less error prone longerm. A short comment explaining
why we use the flag there would be also preferred.

I will leave the decision to you.

Thanks.

-- 
Michal Hocko
SUSE Labs

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] loop: Add PF_LESS_THROTTLE to block/loop device thread. NeilBrown <neilb@suse.com> - 2017-04-03 03:20 +0200
  Re: [PATCH] loop: Add PF_LESS_THROTTLE to block/loop device thread. Christoph Hellwig <hch@infradead.org> - 2017-04-04 09:20 +0200
    Re: [PATCH] loop: Add PF_LESS_THROTTLE to block/loop device thread. NeilBrown <neilb@suse.com> - 2017-04-05 06:30 +0200
      Re: [PATCH] loop: Add PF_LESS_THROTTLE to block/loop device thread. Ming Lei <tom.leiming@gmail.com> - 2017-04-05 07:20 +0200
  Re: [PATCH] loop: Add PF_LESS_THROTTLE to block/loop device thread. Michal Hocko <mhocko@kernel.org> - 2017-04-04 13:30 +0200
  Re: [PATCH] loop: Add PF_LESS_THROTTLE to block/loop device thread. Ming Lei <tom.leiming@gmail.com> - 2017-04-04 16:30 +0200
    Re: [PATCH] loop: Add PF_LESS_THROTTLE to block/loop device thread. NeilBrown <neilb@suse.com> - 2017-04-05 06:40 +0200
  [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device thread. NeilBrown <neilb@suse.com> - 2017-04-05 06:40 +0200
    Re: [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device thread. Ming Lei <tom.leiming@gmail.com> - 2017-04-05 07:10 +0200
    Re: [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device  thread. Michal Hocko <mhocko@kernel.org> - 2017-04-05 09:20 +0200
      Re: [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device  thread. Michal Hocko <mhocko@kernel.org> - 2017-04-05 09:40 +0200
        Re: [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device thread. NeilBrown <neilb@suse.com> - 2017-04-06 04:30 +0200
          Re: [PATCH v2] loop: Add PF_LESS_THROTTLE to block/loop device  thread. Michal Hocko <mhocko@kernel.org> - 2017-04-06 09:00 +0200
            [PATCH v3] loop: Add PF_LESS_THROTTLE to block/loop device thread. NeilBrown <neilb@suse.com> - 2017-04-07 01:50 +0200

csiph-web