From: Markus Armbruster <armbru@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
"David Hildenbrand" <david@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Juan Quintela" <quintela@redhat.com>,
"Hyman Huang" <huangy81@chinatelecom.cn>,
qemu-devel <qemu-devel@nongnu.org>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH v10 2/3] cpu-throttle: implement virtual CPU throttle
Date: Thu, 13 Jan 2022 17:22:40 +0100 [thread overview]
Message-ID: <87pmov61wv.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <YdOxDRvCaXutEmOx@xz-m1.local> (Peter Xu's message of "Tue, 4 Jan 2022 10:32:06 +0800")
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.
[...]
next prev parent reply other threads:[~2022-01-13 16:25 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 [this message]
2022-01-14 1:30 ` Hyman Huang
2022-01-14 3:35 ` Peter Xu
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=87pmov61wv.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eduardo@habkost.net \
--cc=huangy81@chinatelecom.cn \
--cc=pbonzini@redhat.com \
--cc=peterx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.