All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Yi Sun <yi.y.sun@linux.intel.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Julien Grall" <julien.grall@arm.com>,
	"Wei Liu" <wei.liu2@citrix.com>,
	xen-devel@lists.xenproject.org,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH v5] x86: psr: support co-exist features' values setting
Date: Wed, 11 Oct 2017 06:06:49 -0600	[thread overview]
Message-ID: <59DE25790200007800184E78@prv-mh.provo.novell.com> (raw)
In-Reply-To: <1507706438-24486-1-git-send-email-yi.y.sun@linux.intel.com>

>>> On 11.10.17 at 09:20, <yi.y.sun@linux.intel.com> wrote:
> --- a/xen/arch/x86/psr.c
> +++ b/xen/arch/x86/psr.c
> @@ -1111,25 +1111,43 @@ static unsigned int get_socket_cpu(unsigned int socket)
>  struct cos_write_info
>  {
>      unsigned int cos;
> -    struct feat_node *feature;
>      const uint32_t *val;
> -    const struct feat_props *props;
> +    unsigned int array_len;
>  };

The addition wants to go into the hole after "cos".

>  static void do_write_psr_msrs(void *data)
>  {
> -    const struct cos_write_info *info = data;
> -    struct feat_node *feat = info->feature;
> -    const struct feat_props *props = info->props;
> -    unsigned int i, cos = info->cos, cos_num = props->cos_num;
> +    struct cos_write_info *info = data;

const

> +    unsigned int i, index = 0, cos = info->cos;
> +    struct psr_socket_info *socket_info =

const

> +                            get_socket_info(cpu_to_socket(smp_processor_id()));
>  
> -    for ( i = 0; i < cos_num; i++ )
> +    /*
> +     * Iterate all featuers to write different value (not same as MSR) for
> +     * each feature.
> +     */
> +    for ( i = 0; i < ARRAY_SIZE(feat_props); i++ )
>      {
> -        if ( feat->cos_reg_val[cos * cos_num + i] != info->val[i] )
> +        struct feat_node *feat = socket_info->features[i];
> +        const struct feat_props *props = feat_props[i];
> +        unsigned int cos_num, j;
> +
> +        if ( !feat || !props )
> +            continue;
> +
> +        cos_num = props->cos_num;
> +        ASSERT(info->array_len >= index + cos_num);

While this transformation from the original -ENOSPC return looks to
be correct, but not obviously so, it would have been a good idea
to mention this in the commit message. After all the above can be
correct only if the original -ENOSPC return path could have been
an ASSERT() as well.

> +        for ( j = 0; j < cos_num; j++ )
>          {
> -            feat->cos_reg_val[cos * cos_num + i] = info->val[i];
> -            props->write_msr(cos, info->val[i], props->type[i]);
> +            if ( feat->cos_reg_val[cos * cos_num + j] != info->val[index + j] )
> +            {
> +                feat->cos_reg_val[cos * cos_num + j] = info->val[index + j];
> +                props->write_msr(cos, info->val[index + j], props->type[j]);
> +            }
>          }
> +
> +        index += cos_num;

Looks like I only meant to comment on the uses of index above:
If you incremented it alongside j, you could use just index in the
respective array accesses, and you'd avoid the last statement
above altogether.

In the interest of getting the patch in I'll see to make the
adjustments myself. Please double check the result in case I end
up committing what I've come up with.

Jan


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

  reply	other threads:[~2017-10-11 12:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06  9:13 [PATCH v1] x86: psr: support co-exist features' values setting Yi Sun
2017-10-06 14:38 ` Roger Pau Monné
2017-10-08  2:14   ` Yi Sun
2017-10-08  4:22 ` [PATCH v2] " Yi Sun
2017-10-09 14:03   ` Roger Pau Monné
2017-10-10  0:41     ` Yi Sun
2017-10-10  8:22       ` Roger Pau Monné
2017-10-10  9:19 ` [PATCH v3] " Yi Sun
2017-10-10  9:49   ` Roger Pau Monné
2017-10-10 14:44   ` Jan Beulich
2017-10-11  1:55 ` [PATCH v4] " Yi Sun
2017-10-11  6:59   ` Chao Peng
2017-10-11  7:14     ` Yi Sun
2017-10-11  7:20 ` [PATCH v5] " Yi Sun
2017-10-11 12:06   ` Jan Beulich [this message]
2017-10-12  2:52     ` 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=59DE25790200007800184E78@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=julien.grall@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yi.y.sun@linux.intel.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.