From: George Dunlap <george.dunlap@citrix.com>
To: Jan Beulich <JBeulich@suse.com>, Chong Li <lichong659@gmail.com>
Cc: Chong Li <chong.li@wustl.edu>, Sisu Xi <xisisu@gmail.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Dario Faggioli <dario.faggioli@citrix.com>,
xen-devel <xen-devel@lists.xen.org>,
Meng Xu <mengxu@cis.upenn.edu>,
Dagaen Golomb <dgolomb@seas.upenn.edu>
Subject: Re: [PATCH v5 for Xen 4.7 1/4] xen: enable per-VCPU parameter settings for RTDS scheduler
Date: Wed, 2 Mar 2016 14:06:02 +0000 [thread overview]
Message-ID: <56D6F34A.4030908@citrix.com> (raw)
In-Reply-To: <56D6FA8602000078000D8567@prv-mh.provo.novell.com>
On 02/03/16 13:36, Jan Beulich wrote:
>>>> On 01.03.16 at 18:58, <lichong659@gmail.com> wrote:
>> On Tue, Feb 9, 2016 at 12:17 PM, Dario Faggioli
>> <dario.faggioli@citrix.com> wrote:
>>> On Thu, 2016-02-04 at 16:50 -0600, Chong Li wrote:
>>>> --- a/xen/common/sched_rt.c
>>>> +++ b/xen/common/sched_rt.c
>>
>>>
>>>> + for ( index = op->u.v.vcpu_index; index < op->u.v.nr_vcpus;
>>>> index++ )
>>>> + {
>>>> + spin_lock_irqsave(&prv->lock, flags);
>>>> + if ( copy_from_guest_offset(&local_sched,
>>>> + op->u.v.vcpus, index, 1) )
>>>> + {
>>>> + rc = -EFAULT;
>>>> + spin_unlock_irqrestore(&prv->lock, flags);
>>>> + break;
>>>> + }
>>>> + if ( local_sched.vcpuid >= d->max_vcpus ||
>>>> + d->vcpu[local_sched.vcpuid] == NULL )
>>>> + {
>>>> + rc = -EINVAL;
>>>> + spin_unlock_irqrestore(&prv->lock, flags);
>>>> + break;
>>>> + }
>>>> + svc = rt_vcpu(d->vcpu[local_sched.vcpuid]);
>>>> + period = MICROSECS(local_sched.s.rtds.period);
>>>> + budget = MICROSECS(local_sched.s.rtds.budget);
>>>> + if ( period > RTDS_MAX_PERIOD || budget <
>>>> RTDS_MIN_BUDGET ||
>>>> + budget > period )
>>>>
>>> Isn't checking against RTDS_MIN_PERIOD missing?
>>
>> Because RTDS_MIN_PERIOD==RTDS_MIN_BUDGET, by checking budget <
>> RTDS_MIN_BUDGET and budget > period, the checking against
>> RTDS_MIN_PERIOD is already covered.
>
> If you make code dependent upon such value matches, the
> dependency should be documented and enforced to be
> noticed if broken by a BUILD_BUG_ON().
To expand upon this:
Code changes. At the moment RTDS_MIN_PERIOD == RTDS_MIN_BUDGET, but the
very fact that you have two different macros implies to anyone coming
along later that you can change one. If someone does change one but not
the other, then that will create a bug in the program which will be very
difficult to detect. It is likely not to be noticed during patch review
(since it probably won't change the code you're now introducing), and it
may not even be noticed in follow-up testing for some time.
After you've been bitten several times by this sort of bug, you learn to
be paranoid about this sort of thing (which is why Dario noticed it).
Two ways to proceed:
1. Don't assume RTDS_MIN_PERIOD == RTDS_MIN_BUDGET here, and add the
extra check Dario mentioned.
2. Assume RTDS_MIN_PERIOD == RTDS_MIN_BUDGET, and add something to the
code which will break the build if this is ever false (as Jan suggested).
-George
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-03-02 14:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 22:50 [PATCH v5 for Xen 4.7 0/4] Enable per-VCPU parameter settings for RTDS scheduler Chong Li
2016-02-04 22:50 ` [PATCH v5 for Xen 4.7 1/4] xen: enable " Chong Li
2016-02-09 18:17 ` Dario Faggioli
2016-03-01 17:58 ` Chong Li
2016-03-02 13:36 ` Jan Beulich
2016-03-02 14:06 ` George Dunlap [this message]
2016-02-04 22:50 ` [PATCH v5 for Xen 4.7 2/4] libxc: " Chong Li
2016-02-05 14:09 ` Wei Liu
2016-02-09 18:20 ` Dario Faggioli
2016-02-04 22:50 ` [PATCH v5 for Xen 4.7 3/4] libxl: " Chong Li
2016-02-05 14:44 ` Wei Liu
2016-02-05 15:59 ` Dario Faggioli
2016-02-05 16:19 ` Wei Liu
2016-02-06 0:10 ` Chong Li
2016-02-08 11:07 ` Wei Liu
2016-02-08 22:59 ` Chong Li
2016-02-09 10:19 ` Wei Liu
2016-02-09 11:05 ` Dario Faggioli
2016-02-09 12:00 ` Dario Faggioli
2016-02-09 16:48 ` Chong Li
2016-02-09 17:38 ` Wei Liu
2016-02-04 22:50 ` [PATCH v5 for Xen 4.7 4/4] xl: " Chong Li
2016-02-05 14:51 ` Wei Liu
2016-02-09 18:25 ` Dario Faggioli
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=56D6F34A.4030908@citrix.com \
--to=george.dunlap@citrix.com \
--cc=JBeulich@suse.com \
--cc=chong.li@wustl.edu \
--cc=dario.faggioli@citrix.com \
--cc=dgolomb@seas.upenn.edu \
--cc=george.dunlap@eu.citrix.com \
--cc=lichong659@gmail.com \
--cc=mengxu@cis.upenn.edu \
--cc=xen-devel@lists.xen.org \
--cc=xisisu@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 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.