From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: keir@xen.org, Ian.Campbell@citrix.com,
stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com,
Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org,
Dongxiao Xu <dongxiao.xu@intel.com>,
dgdegra@tycho.nsa.gov
Subject: Re: [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest
Date: Mon, 20 Jan 2014 13:17:05 +0000 [thread overview]
Message-ID: <52DD21D1.5010202@citrix.com> (raw)
In-Reply-To: <52DD2F1A02000078001150A4@nat28.tlf.novell.com>
On 20/01/14 13:13, Jan Beulich wrote:
>>>> On 05.12.13 at 10:38, Dongxiao Xu <dongxiao.xu@intel.com> wrote:
>> @@ -1223,6 +1224,45 @@ long arch_do_domctl(
>> }
>> break;
>>
>> + case XEN_DOMCTL_attach_pqos:
>> + {
>> + if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
>> + {
>> + if ( !system_supports_cqm() )
>> + ret = -ENODEV;
>> + else if ( d->arch.pqos_cqm_rmid > 0 )
>> + ret = -EEXIST;
>> + else
>> + {
>> + ret = alloc_cqm_rmid(d);
>> + if ( ret < 0 )
>> + ret = -EUSERS;
> Why don't you have the function return a sensible error code
> (which presumably might also end up being other than -EUSERS,
> e.g. -ENOMEM).
-EUSERS is correct here. This failure like this means "all the
available system rmid's are already being used by other domains".
~Andrew
>
>> + }
>> + }
>> + else
>> + ret = -EINVAL;
>> + }
>> + break;
>> +
>> + case XEN_DOMCTL_detach_pqos:
>> + {
>> + if ( domctl->u.qos_type.flags & XEN_DOMCTL_pqos_cqm )
>> + {
>> + if ( !system_supports_cqm() )
>> + ret = -ENODEV;
>> + else if ( d->arch.pqos_cqm_rmid > 0 )
>> + {
>> + free_cqm_rmid(d);
>> + ret = 0;
>> + }
>> + else
>> + ret = -ENOENT;
>> + }
>> + else
>> + ret = -EINVAL;
>> + }
>> + break;
> For consistency, both of the above would better be changed to a
> single series of if()/else if().../else.
>
>> +bool_t system_supports_cqm(void)
>> +{
>> + return !!cqm;
> So here we go (wrt the remark on patch 1).
>
>> +}
>> +
>> +int alloc_cqm_rmid(struct domain *d)
>> +{
>> + int rc = 0;
>> + unsigned int rmid;
>> + unsigned long flags;
>> +
>> + ASSERT(system_supports_cqm());
>> +
>> + spin_lock_irqsave(&cqm_lock, flags);
> Why not just spin_lock()? Briefly scanning over the following patches
> doesn't point out anything that might require this to be an IRQ-safe
> lock.
>
>> + for ( rmid = cqm->min_rmid; rmid <= cqm->max_rmid; rmid++ )
>> + {
>> + if ( cqm->rmid_to_dom[rmid] != DOMID_INVALID)
>> + continue;
>> +
>> + cqm->rmid_to_dom[rmid] = d->domain_id;
>> + break;
>> + }
>> + spin_unlock_irqrestore(&cqm_lock, flags);
>> +
>> + /* No CQM RMID available, assign RMID=0 by default */
>> + if ( rmid > cqm->max_rmid )
>> + {
>> + rmid = 0;
>> + rc = -1;
>> + }
>> +
>> + d->arch.pqos_cqm_rmid = rmid;
> Is it really safe to do this and the freeing below outside of the
> lock?
>
> Jan
>
next prev parent reply other threads:[~2014-01-20 13:17 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 9:38 [PATCH v6 0/7] enable Cache QoS Monitoring (CQM) feature Dongxiao Xu
2013-12-05 9:38 ` [PATCH v6 1/7] x86: detect and initialize Cache QoS Monitoring feature Dongxiao Xu
2013-12-05 10:54 ` Andrew Cooper
2013-12-06 8:29 ` Jan Beulich
2014-01-20 13:00 ` Jan Beulich
2014-01-28 14:01 ` Xu, Dongxiao
2014-01-28 14:04 ` Jan Beulich
2013-12-05 9:38 ` [PATCH v6 2/7] x86: dynamically attach/detach CQM service for a guest Dongxiao Xu
2014-01-20 13:13 ` Jan Beulich
2014-01-20 13:17 ` Andrew Cooper [this message]
2014-01-20 14:03 ` Jan Beulich
2014-01-28 14:09 ` Xu, Dongxiao
2014-01-28 14:37 ` Jan Beulich
2013-12-05 9:38 ` [PATCH v6 3/7] x86: initialize per socket cpu map Dongxiao Xu
2014-01-20 13:26 ` Jan Beulich
2014-01-28 14:12 ` Xu, Dongxiao
2014-01-28 14:41 ` Jan Beulich
2013-12-05 9:38 ` [PATCH v6 4/7] x86: collect CQM information from all sockets Dongxiao Xu
2014-01-20 13:52 ` Jan Beulich
2014-01-28 14:23 ` Xu, Dongxiao
2014-01-28 14:34 ` Andrew Cooper
2014-01-28 15:03 ` Jan Beulich
2014-01-28 15:15 ` Xu, Dongxiao
2014-01-28 15:21 ` Andrew Cooper
2014-01-28 15:34 ` Jan Beulich
2014-01-28 14:47 ` Jan Beulich
2013-12-05 9:38 ` [PATCH v6 5/7] x86: enable CQM monitoring for each domain RMID Dongxiao Xu
2014-01-20 13:58 ` Jan Beulich
2014-01-28 14:24 ` Xu, Dongxiao
2013-12-05 9:38 ` [PATCH v6 6/7] xsm: add platform QoS related xsm policies Dongxiao Xu
2013-12-05 9:38 ` [PATCH v6 7/7] tools: enable Cache QoS Monitoring feature for libxl/libxc Dongxiao Xu
2013-12-07 5:09 ` [PATCH v6 0/7] enable Cache QoS Monitoring (CQM) feature Xu, Dongxiao
2013-12-09 9:34 ` Jan Beulich
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=52DD21D1.5010202@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=dario.faggioli@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=dongxiao.xu@intel.com \
--cc=keir@xen.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.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.