From: Stefan Hajnoczi <stefanha@redhat.com>
To: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org, qemu-devel@nongnu.org,
Wen Congyang <wencongyang2@huawei.com>,
Xie Changlong <xiechanglong.d@gmail.com>,
Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>
Subject: Re: [RFC PATCH 2/6] job: _locked functions and public job_lock/unlock for next patch
Date: Tue, 13 Jul 2021 14:32:14 +0100 [thread overview]
Message-ID: <YO2V3mSEVVj987lS@stefanha-x1.localdomain> (raw)
In-Reply-To: <1df55204-89ea-6e5b-e698-d985e85702a4@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2397 bytes --]
On Mon, Jul 12, 2021 at 10:43:07AM +0200, Emanuele Giuseppe Esposito wrote:
>
>
> On 08/07/2021 12:50, Stefan Hajnoczi wrote:
> > On Wed, Jul 07, 2021 at 06:58:09PM +0200, Emanuele Giuseppe Esposito wrote:
> > > diff --git a/job.c b/job.c
> > > index 872bbebb01..96fb8e9730 100644
> > > --- a/job.c
> > > +++ b/job.c
> > > @@ -32,6 +32,10 @@
> > > #include "trace/trace-root.h"
> > > #include "qapi/qapi-events-job.h"
> > > +/* job_mutex protexts the jobs list, but also the job operations. */
> > > +static QemuMutex job_mutex;
> >
> > It's unclear what protecting "job operations" means. I would prefer a
> > fine-grained per-job lock that protects the job's fields instead of a
> > global lock with an unclear scope.
>
> As I wrote in the cover letter, I wanted to try to keep things as simple as
> possible with a global lock. It is possible to try and have a per-job lock,
> but I don't know how complex will that be then.
> I will try and see what I can do.
>
> Maybe "job_mutex protexts the jobs list, but also makes the job API
> thread-safe"?
That's clearer, thanks. I thought "job operations" meant the processing
that the actual block jobs do (commit, mirror, stream, backup).
>
> >
> > > +
> > > +/* Protected by job_mutex */
> > > static QLIST_HEAD(, Job) jobs = QLIST_HEAD_INITIALIZER(jobs);
> > > /* Job State Transition Table */
> > > @@ -64,27 +68,22 @@ bool JobVerbTable[JOB_VERB__MAX][JOB_STATUS__MAX] = {
> > > /* Transactional group of jobs */
> > > struct JobTxn {
> > > - /* Is this txn being cancelled? */
> > > + /* Is this txn being cancelled? Atomic.*/
> > > bool aborting;
> >
> > The comment says atomic but this field is not accessed using atomic
> > operations (at least at this point in the patch series)?
>
> Yes sorry I messed up the hunks in one-two patches. These comments were
> supposed to be on patch 4 "job.h: categorize job fields". Even though that
> might also not be ideal, since that patch just introduces the comments,
> without applying the locking/protection yet.
> On the other side, if I merge everything together in patch 5, it will be
> even harder to read.
The commit description can describe changes that currently have no
effect but are anticipating a later patch. That helps reviewers
understand whether the change is intentional/correct.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-07-13 13:36 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-07 16:58 [RFC PATCH 0/6] job: replace AioContext lock with job_mutex Emanuele Giuseppe Esposito
2021-07-07 16:58 ` [RFC PATCH 1/6] job: use getter/setters instead of accessing the Job fields directly Emanuele Giuseppe Esposito
2021-07-07 16:58 ` [RFC PATCH 2/6] job: _locked functions and public job_lock/unlock for next patch Emanuele Giuseppe Esposito
2021-07-08 10:50 ` Stefan Hajnoczi
2021-07-12 8:43 ` Emanuele Giuseppe Esposito
2021-07-13 13:32 ` Stefan Hajnoczi [this message]
2021-07-07 16:58 ` [RFC PATCH 3/6] job: minor changes to simplify locking Emanuele Giuseppe Esposito
2021-07-08 10:55 ` Stefan Hajnoczi
2021-07-12 8:43 ` Emanuele Giuseppe Esposito
2021-07-13 17:56 ` Eric Blake
2021-07-07 16:58 ` [RFC PATCH 4/6] job.h: categorize job fields Emanuele Giuseppe Esposito
2021-07-08 11:02 ` Stefan Hajnoczi
2021-07-12 8:43 ` Emanuele Giuseppe Esposito
2021-07-07 16:58 ` [RFC PATCH 5/6] job: use global job_mutex to protect struct Job Emanuele Giuseppe Esposito
2021-07-08 12:56 ` Stefan Hajnoczi
2021-07-12 8:43 ` Emanuele Giuseppe Esposito
2021-07-07 16:58 ` [RFC PATCH 6/6] jobs: remove unnecessary AioContext aquire/release pairs Emanuele Giuseppe Esposito
2021-07-08 10:36 ` [RFC PATCH 0/6] job: replace AioContext lock with job_mutex Stefan Hajnoczi
2021-07-08 11:32 ` Paolo Bonzini
2021-07-08 12:14 ` Kevin Wolf
2021-07-08 13:04 ` Stefan Hajnoczi
2021-07-12 8:41 ` Emanuele Giuseppe Esposito
2021-07-13 13:10 ` Stefan Hajnoczi
2021-07-13 15:18 ` Vladimir Sementsov-Ogievskiy
2021-07-13 16:38 ` Stefan Hajnoczi
2021-07-15 12:35 ` Vladimir Sementsov-Ogievskiy
2021-07-15 13:29 ` Stefan Hajnoczi
2021-07-16 15:23 ` Kevin Wolf
2021-07-19 9:29 ` Stefan Hajnoczi
2021-07-19 14:54 ` Kevin Wolf
2021-07-08 13:09 ` Stefan Hajnoczi
2021-07-12 8:42 ` Emanuele Giuseppe Esposito
2021-07-13 13:27 ` Stefan Hajnoczi
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=YO2V3mSEVVj987lS@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=eesposit@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.com \
/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).