xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Yi Sun <yi.y.sun@linux.intel.com>
To: xen-devel@lists.xenproject.org
Cc: wei.liu2@citrix.com, he.chen@linux.intel.com,
	andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com,
	Yi Sun <yi.y.sun@linux.intel.com>,
	jbeulich@suse.com, chao.p.peng@linux.intel.com
Subject: [PATCH v3 10/15] x86: refactor psr: Implement function to get the max cos_max.
Date: Tue, 25 Oct 2016 11:40:58 +0800	[thread overview]
Message-ID: <1477366863-5246-11-git-send-email-yi.y.sun@linux.intel.com> (raw)
In-Reply-To: <1477366863-5246-1-git-send-email-yi.y.sun@linux.intel.com>

When set ASSOC register, we need a cos_mask to calculate the COS
ID to set. The cos_mask is calculated by cos_max. When supporting
more than one feature, the cos_max to calculate cos_mask should be
the max one of all features.

This patch implements 'get_max_cos_max' function and the corresponding
callback function to get the max cos_max of all features.

Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
 xen/arch/x86/psr.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index b8bb09b..fdf4e3a 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -55,6 +55,8 @@ struct feat_ops {
     /* get_val is used to get feature COS register value. */
     int (*get_val)(const struct feat_node *feat, unsigned int cos,
                    enum cbm_type type, uint64_t *val);
+    /* get_max_cos_max is used to get feature's cos_max. */
+    unsigned int (*get_max_cos_max)(const struct feat_node *feat);
 };
 
 /* CAT/CDP HW info data structure. */
@@ -279,10 +281,16 @@ static int l3_cat_get_val(const struct feat_node *feat, unsigned int cos,
     return 1;
 }
 
+static unsigned int l3_cat_get_max_cos_max(const struct feat_node *feat)
+{
+    return feat->info.cos_max;
+}
+
 struct feat_ops l3_cat_ops = {
     .init_feature = l3_cat_init_feature,
     .get_feat_info = l3_cat_get_feat_info,
     .get_val = l3_cat_get_val,
+    .get_max_cos_max = l3_cat_get_max_cos_max,
 };
 
 static unsigned int get_socket_cpu(unsigned int socket)
@@ -434,6 +442,18 @@ void psr_free_rmid(struct domain *d)
     d->arch.psr_rmid = 0;
 }
 
+static inline unsigned int get_max_cos_max(
+                       const struct psr_cat_socket_info *info)
+{
+    const struct feat_node *feat_tmp;
+    unsigned int cos_max = 0;
+
+    list_for_each_entry(feat_tmp, &info->feat_list, list)
+        cos_max = max(feat_tmp->ops.get_max_cos_max(feat_tmp), cos_max);
+
+    return cos_max;
+}
+
 static inline void psr_assoc_init(void)
 {
     struct psr_assoc *psra = &this_cpu(psr_assoc);
@@ -441,16 +461,11 @@ static inline void psr_assoc_init(void)
     if ( cat_socket_info )
     {
         unsigned int socket = cpu_to_socket(smp_processor_id());
-        struct psr_cat_socket_info *info = cat_socket_info + socket;
-        struct feat_node *feat_tmp;
-
-        feat_tmp = get_feat_l3(info);
-        if ( !feat_tmp )
-            return;
+        const struct psr_cat_socket_info *info = cat_socket_info + socket;
+        unsigned int cos_max = get_max_cos_max(info);
 
         if ( info->feat_mask )
-            psra->cos_mask = ((1ull << get_count_order(
-                              feat_tmp->info.cos_max)) - 1) << 32;
+            psra->cos_mask = ((1ull << get_count_order(cos_max)) - 1) << 32;
     }
 
     if ( psr_cmt_enabled() || psra->cos_mask )
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-10-25  2:34 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-25  3:40 [PATCH v3 00/15] Enable L2 Cache Allocation Technology Yi Sun
2016-10-25  3:40 ` [PATCH v3 01/15] docs: L2 Cache Allocation Technology (CAT) feature document Yi Sun
2016-10-25 13:37   ` Jan Beulich
2016-10-26  1:01     ` Yi Sun
2016-10-30 15:51   ` Meng Xu
2016-11-01  4:40     ` Yi Sun
2016-11-11 21:33   ` Konrad Rzeszutek Wilk
2016-11-14  2:15     ` Yi Sun
2016-11-25 17:19     ` Dario Faggioli
2016-11-29  5:20       ` Yi Sun
2016-11-29 12:25         ` Dario Faggioli
2016-11-25 17:39   ` Dario Faggioli
2016-11-29  4:52     ` Yi Sun
2016-11-29 12:22       ` Dario Faggioli
2016-11-30  1:42         ` Yi Sun
2016-10-25  3:40 ` [PATCH v3 02/15] x86: refactor psr: Split 'ref' out Yi Sun
2016-11-25 15:19   ` Jan Beulich
2016-10-25  3:40 ` [PATCH v3 03/15] x86: refactor psr: Remove 'struct psr_cat_cbm' Yi Sun
2016-11-25 15:45   ` Jan Beulich
2016-10-25  3:40 ` [PATCH v3 04/15] x86: refactor psr: Encapsulate 'cbm_len' and 'cbm_max' Yi Sun
2016-11-25 16:27   ` Jan Beulich
2016-11-25 16:57     ` Jan Beulich
2016-11-29  4:38       ` Yi Sun
2016-11-29  9:43         ` Jan Beulich
2016-11-30  9:08           ` Yi Sun
2016-11-30  9:42             ` Jan Beulich
2016-11-30 10:22               ` Yi Sun
2016-10-25  3:40 ` [PATCH v3 05/15] x86: refactor psr: Use 'feat_mask' to record featues enabled Yi Sun
2016-11-25 16:36   ` Jan Beulich
2016-10-25  3:40 ` [PATCH v3 06/15] x86: refactor psr: Create feature list Yi Sun
2016-10-25  3:40 ` [PATCH v3 07/15] x86: refactor psr: Implement feature operations structure Yi Sun
2016-10-25  3:40 ` [PATCH v3 08/15] x86: refactor psr: Implement get hw info callback function Yi Sun
2016-10-25  3:40 ` [PATCH v3 09/15] x86: refactor psr: Implement get value " Yi Sun
2016-10-25  3:40 ` Yi Sun [this message]
2016-10-25  3:40 ` [PATCH v3 11/15] x86: refactor psr: Implement set " Yi Sun
2016-10-25  3:41 ` [PATCH v3 12/15] x86: Implement L2 CAT in psr.c Yi Sun
2016-10-25  3:41 ` [PATCH v3 13/15] x86: Add L2 CAT interfaces in domctl Yi Sun
2016-10-25  3:41 ` [PATCH v3 14/15] x86: Add L2 CAT interfaces in sysctl Yi Sun
2016-10-25  3:41 ` [PATCH v3 15/15] tools & docs: add L2 CAT support in tools and docs Yi Sun
2016-11-09  1:28 ` [PATCH v3 00/15] Enable L2 Cache Allocation Technology Yi Sun
2016-11-09  8:37   ` Jan Beulich
2016-11-10  1:56     ` Yi Sun

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=1477366863-5246-11-git-send-email-yi.y.sun@linux.intel.com \
    --to=yi.y.sun@linux.intel.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=chao.p.peng@linux.intel.com \
    --cc=he.chen@linux.intel.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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).