From: Wang Liang <wangliangzz@126.com>
To: Alberto Garcia <berto@igalia.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: pbonzini@redhat.com, stefanha@redhat.com,
silbe@linux.vnet.ibm.com, Wang Liang <wangliangzz@inspur.com>
Subject: Re: [PATCH] ratelimit: restrict the delay time to a non-negative value
Date: Wed, 21 Sep 2022 09:47:32 +0800 [thread overview]
Message-ID: <f4b8e638285a7cfd2bd2e94c0bf9a1176cca0cb7.camel@126.com> (raw)
In-Reply-To: <w51h712i3pd.fsf@igalia.com>
On Tue, 2022-09-20 at 13:18 +0000, Alberto Garcia wrote:
> On Tue 20 Sep 2022 08:33:50 PM +08, wangliangzz@126.com wrote:
> > From: Wang Liang <wangliangzz@inspur.com>
> >
> > The delay time should never be a negative value.
> >
> > - return limit->slice_end_time - now;
> > + return MAX(limit->slice_end_time - now, 0);
>
> How can this be negative? slice_end_time is guaranteed to be larger
> than
> now:
>
> if (limit->slice_end_time < now) {
> /* Previous, possibly extended, time slice finished; reset
> the
> * accounting. */
> limit->slice_start_time = now;
> limit->slice_end_time = now + limit->slice_ns;
> limit->dispatched = 0;
> }
>
This is just a guarantee.
If slice_end_time is assigned later by
limit->slice_end_time = limit->slice_start_time +
(uint64_t)(delay_slices * limit->slice_ns);
There may be precision issues at that time.
> Berto
next prev parent reply other threads:[~2022-09-21 1:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 12:33 [PATCH] ratelimit: restrict the delay time to a non-negative value wangliangzz
2022-09-20 13:18 ` Alberto Garcia
2022-09-21 1:47 ` Wang Liang [this message]
2022-09-21 4:53 ` Markus Armbruster
2022-09-21 6:26 ` Wang Liang
2022-09-21 8:17 ` Alberto Garcia
2022-09-23 7:14 ` Markus Armbruster
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=f4b8e638285a7cfd2bd2e94c0bf9a1176cca0cb7.camel@126.com \
--to=wangliangzz@126.com \
--cc=berto@igalia.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=silbe@linux.vnet.ibm.com \
--cc=stefanha@redhat.com \
--cc=wangliangzz@inspur.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).