From: Peter Xu <peterx@redhat.com>
To: Hyman Huang <huangy81@chinatelecom.cn>
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
"David Hildenbrand" <david@redhat.com>,
"Juan Quintela" <quintela@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH v10 2/3] cpu-throttle: implement virtual CPU throttle
Date: Fri, 14 Jan 2022 11:35:14 +0800 [thread overview]
Message-ID: <YeDvckGNTYq7OZTO@xz-m1.local> (raw)
In-Reply-To: <38d0cc91-2995-2d73-d917-e5e1fc4e5206@chinatelecom.cn>
On Fri, Jan 14, 2022 at 09:30:39AM +0800, Hyman Huang wrote:
>
>
> 在 2022/1/14 0:22, Markus Armbruster 写道:
> > Peter Xu <peterx@redhat.com> writes:
> >
> > > On Fri, Dec 31, 2021 at 12:36:40AM +0800, Hyman Huang wrote:
> > > > > > +struct {
> > > > > > + DirtyLimitState *states;
> > > > > > + int max_cpus;
> > > > > > + unsigned long *bmap; /* running thread bitmap */
> > > > > > + unsigned long nr;
> > > > > > + QemuThread thread;
> > > > > > +} *dirtylimit_state;
> > > > > > +
> > > > > > +static bool dirtylimit_quit = true;
> > > > >
> > > > > Again, I think "quit" is not a good wording to show "whether dirtylimit is in
> > > > > service". How about "dirtylimit_global_enabled"?
> > > > >
> > > > > You can actually use "dirtylimit_state" to show whether it's enabled already
> > > > > (then drop the global value) since it's a pointer. It shouldn't need to be
> > > > > init-once-for-all, but we can alloc the strucuture wAhen dirty limit enabled
> > > > > globally, and destroy it (and reset it to NULL) when globally disabled.
> > > > >
> > > > > Then "whether it's enabled" is simply to check "!!dirtylimit_state" under BQL.
> > > > Yes, checking pointer is fairly straightforword, but since dirtylimit thread
> > > > also access the dirtylimit_state when doing the limit, if we free
> > > > dirtylimit_state after last limited vcpu be canceled, dirtylimit thread
> > > > would crash when reference null pointer. And this method turn out to
> > > > introduce a mutex lock to protect dirtylimit_state, comparing with qatomic
> > > > operation, which is better ?
> > >
> > > I don't see much difference here on using either atomic or mutex, because it's
> > > not a hot path.
> >
> > Quick interjection without having bothered to understand the details:
> > correct use of atomics and memory barriers is *much* harder than correct
> > use of locks. Stick to locks unless you *know* they impair performance
Yong,
Just a heads up - You seem to have replied something but there's really nothing
I saw... it happened multiple times, so I hope you didn't miss it by sending
something empty.
I agree with Markus, and that's also what I wanted to express too (it's not a
perf critical path, so we don't necessarily need to use atomics; obviously I
failed again on using English to express myself.. :). But I don't urge it if
the atomics works pretty simple and well. I think I'll read the atomic version
you posted first and I'll comment again there.
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2022-01-14 3:36 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 11:07 [PATCH v10 0/3] support dirty restraint on vCPU huangy81
2021-12-14 11:07 ` [PATCH v10 1/3] migration/dirtyrate: implement vCPU dirtyrate calculation periodically huangy81
2021-12-23 11:12 ` Peter Xu
2021-12-26 15:58 ` Hyman
2021-12-30 5:01 ` Hyman Huang
2021-12-30 6:34 ` Peter Xu
2021-12-14 11:07 ` [PATCH v10 2/3] cpu-throttle: implement virtual CPU throttle huangy81
2021-12-15 7:15 ` Markus Armbruster
2021-12-15 7:40 ` Hyman Huang
2021-12-24 5:12 ` Peter Xu
2021-12-30 16:36 ` Hyman Huang
2022-01-04 2:32 ` Peter Xu
2022-01-04 3:27 ` Hyman Huang
2022-01-13 16:22 ` Markus Armbruster
2022-01-14 1:30 ` Hyman Huang
2022-01-14 3:35 ` Peter Xu [this message]
2021-12-14 11:07 ` [PATCH v10 3/3] cpus-common: implement dirty page limit on virtual CPU huangy81
2021-12-15 7:37 ` Markus Armbruster
2021-12-15 7:56 ` Hyman Huang
2021-12-15 8:09 ` Peter Xu
2021-12-15 8:29 ` Hyman Huang
2021-12-15 10:16 ` Hyman Huang
2021-12-15 13:41 ` Markus Armbruster
2021-12-16 6:22 ` Peter Xu
2021-12-16 9:16 ` Hyman Huang
2021-12-16 10:23 ` Markus Armbruster
2021-12-24 5:16 ` Peter Xu
2021-12-24 5:14 ` Peter Xu
2021-12-26 16:00 ` Hyman
2021-12-24 5:17 ` [PATCH v10 0/3] support dirty restraint on vCPU Peter Xu
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=YeDvckGNTYq7OZTO@xz-m1.local \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eduardo@habkost.net \
--cc=huangy81@chinatelecom.cn \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.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;
as well as URLs for NNTP newsgroup(s).