All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Robert Hoo <robert.hu@linux.intel.com>
Cc: xiaoyao.li@intel.com, qemu-devel@nongnu.org, armbru@redhat.com,
	robert.hu@intel.com, chenyi.qiang@intel.com, pbonzini@redhat.com,
	rth@twiddle.net
Subject: Re: [PATCH v2 1/2] Introduce (x86) CPU model deprecation API
Date: Mon, 14 Sep 2020 09:38:49 -0400	[thread overview]
Message-ID: <20200914133849.GY1618070@habkost.net> (raw)
In-Reply-To: <b3d7de0e900c199e28702584a90a08987862e655.camel@linux.intel.com>

On Mon, Sep 14, 2020 at 06:50:09PM +0800, Robert Hoo wrote:
> On Fri, 2020-09-11 at 10:00 -0400, Eduardo Habkost wrote:
> > On Fri, Sep 11, 2020 at 02:22:51PM +0800, Robert Hoo wrote:
> > > On Wed, 2020-09-09 at 14:15 -0400, Eduardo Habkost wrote:
[...]
> > > > > +static void x86_cpu_deprecation_check(ObjectClass *oc)
> > > > > +{
> > > > > +    X86CPUClass *xcc = X86_CPU_CLASS(oc);
> > > > > +    X86CPUVersion effective_version;
> > > > > +    const X86CPUVersionDefinition *vdef;
> > > > > +
> > > > > +    if (xcc->model == NULL) {
> > > > > +        return;
> > > > > +    }
> > > > > +
> > > > > +    if (xcc->model->version == CPU_VERSION_LEGACY) {
> > > > > +        /* Treat legacy version as v1 */
> > > > > +        effective_version = 1;
> > > > > +    } else {
> > > > > +        effective_version = x86_cpu_model_resolve_version(xcc-
> > > > > > model);
> > > > > 
> > > > > +    }
> > > > > +
> > > > > +    vdef = xcc->model->cpudef->versions;
> > > > > +
> > > > > +    if (vdef == NULL) {
> > > > > +        return;
> > > > > +    } else {
> > > > > +        if (vdef[effective_version - 1].deprecated) {
> > > > > +            warn_report("Effective CPU model '%s' -- %s",
> > > > > +                    x86_cpu_versioned_model_name(xcc->model-
> > > > > > cpudef,\
> > > > > 
> > > > > +                                                effective_vers
> > > > > ion)
> > > > > ,
> > > > > +                    vdef[effective_version - 1].note);
> > > > > +        }
> > > > > +    }
> > > > 
> > > > Why do we need this extra logic?  Isn't it simpler to just add a
> > > > bool CPUClass::deprecated field, and set:
> > > > 
> > > >    cpu->deprecated = model->deprecated;
> > > > 
> > > > inside x86_cpu_cpudef_class_init()?
> > > > 
> > > 
> > > All these are to fulfill the target you expected earlier:
> > > 
> > > "We need a proper CPU model deprecation API.  Deprecation info
> > > should appear on query-cpu-definitions and should trigger a
> > > warning when using the CPU model."
> > > 
> > > So I think each deprecated model shall have its own deprecation
> > > message, e.g. by which version it's going to be deprecation, etc.
> > 
> > There's nothing x86-specific about having deprecated CPU models,
> > so I don't understand the reason for the x86-specific hook.
> > 
> > If the .note field is the reason you added the arch-specific
> > hook, you can just add a CPUClass::deprecation_note field and
> > make the feature generic.
> > 
> I tend to agree with you on this generalization requirement.
> 
> But then I find it still has some tricky thing, perhaps that's why I
> defined this x86 target specific hook:
> 
> 1) The versioned CPU model is x86 specific (at least at present)

I don't see why this would be an obstacle.  You just need to set
CPUClass::deprecated and/or CPUClass::deprecation_note in the
x86-specific class_init code.

> 
> 2) Each x86 cpudef CPU model has 1 unversioned cpu_model_type then its
> versioned cpu_model_types. Refer to code in
> x86_register_cpudef_types(). The unversioned model won't be marked
> deprecated as it is unkown when registered. In
> machine_run_board_init(), the cpu_model being checked is the
> unversioned one, if I set -cpu to its general unversioned model.
> In short, the unversioned cpudef CPU model would escape the deprecation
> check.

Why is that a problem?  If, for example, Model-v1 is deprecated
and Model-v2 is not deprecated, we must never tell the user that
"-cpu Model" is deprecated.  Even if some machine types resolve
"-cpu Model" to Model-v1.

-- 
Eduardo



  reply	other threads:[~2020-09-14 13:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11  2:47 [PATCH v2 1/2] Introduce (x86) CPU model deprecation API Robert Hoo
2020-06-11  2:47 ` [PATCH v2 2/2] Mark Icelake-Client CPU models deprecated Robert Hoo
2020-06-28 11:30 ` [PATCH v2 1/2] Introduce (x86) CPU model deprecation API Robert Hoo
2020-09-09 18:15 ` Eduardo Habkost
2020-09-10  5:29   ` Philippe Mathieu-Daudé
2020-09-10 19:12     ` Eduardo Habkost
2020-09-10 19:42       ` Philippe Mathieu-Daudé
2020-09-11  6:22   ` Robert Hoo
2020-09-11 14:00     ` Eduardo Habkost
2020-09-14 10:50       ` Robert Hoo
2020-09-14 13:38         ` Eduardo Habkost [this message]
2020-09-15  2:56           ` Robert Hoo
2020-09-15 14:06             ` Eduardo Habkost

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=20200914133849.GY1618070@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=armbru@redhat.com \
    --cc=chenyi.qiang@intel.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=robert.hu@intel.com \
    --cc=robert.hu@linux.intel.com \
    --cc=rth@twiddle.net \
    --cc=xiaoyao.li@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.