From: Oleg Nesterov <oleg@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: Fix sys_ioprio_set(.which=IOPRIO_WHO_PGRP) task iteration
Date: Fri, 9 Apr 2021 12:08:37 +0200 [thread overview]
Message-ID: <20210409100836.GB10447@redhat.com> (raw)
In-Reply-To: <e8579a4e-2456-a89b-b750-892d265ba053@kernel.dk>
On 04/08, Jens Axboe wrote:
>
> On 4/8/21 3:46 AM, Peter Zijlstra wrote:
> >
> > do_each_pid_thread() { } while_each_pid_thread() is a double loop and
> > thus break doesn't work as expected. Also, it should be used under
> > tasklist_lock because otherwise we can race against change_pid() for
> > PGID/SID.
>
> Applied, thanks.
Agreed, but can't resist. We can move the "out" label up and avoid the extra
read_unlock(tasklist_lock). IOW, something like below on top of this patch.
Quite possibly this won't change the generated code, gcc is smart enough, but
this makes the code a bit more readable.
Oleg.
--- x/block/ioprio.c~ 2021-04-09 12:00:28.066145563 +0200
+++ x/block/ioprio.c 2021-04-09 12:02:01.817849618 +0200
@@ -123,11 +123,10 @@
read_lock(&tasklist_lock);
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
ret = set_task_ioprio(p, ioprio);
- if (ret) {
- read_unlock(&tasklist_lock);
- goto out;
- }
+ if (ret)
+ goto out_pgrp;
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
+out_pgrp:
read_unlock(&tasklist_lock);
break;
@@ -159,7 +158,6 @@
ret = -EINVAL;
}
-out:
rcu_read_unlock();
return ret;
}
prev parent reply other threads:[~2021-04-09 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 9:46 Peter Zijlstra
2021-04-08 19:44 ` Jens Axboe
2021-04-09 10:08 ` Oleg Nesterov [this message]
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=20210409100836.GB10447@redhat.com \
--to=oleg@redhat.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
/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
all inboxes | Powered by JetHome®