[CRIU] [PATCH 04/15] cpuinfo: x86 -- Add local copy of CpuinfoEntry
Pavel Emelyanov
xemul at parallels.com
Tue Sep 23 11:04:25 PDT 2014
On 09/19/2014 06:03 PM, Cyrill Gorcunov wrote:
> We assume that all cpus in the system are same
> family and stepping (it might be not true for
> big systems but they are qute rare and not
> guaranteed to work).
>
> So we will use own local copy of protobuf entry
> to fill it on startup and write into dump. On
> restore we will need it to check caps with one
> fetched from image file.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> arch/x86/cpu.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/arch/x86/cpu.c b/arch/x86/cpu.c
> index e800bf3b62f2..2ea4e06bccc0 100644
> --- a/arch/x86/cpu.c
> +++ b/arch/x86/cpu.c
> @@ -19,9 +19,16 @@
>
> #include "cpu.h"
>
> +#include "protobuf.h"
> +#include "protobuf/cpuinfo.pb-c.h"
> +
> #undef LOG_PREFIX
> #define LOG_PREFIX "cpu: "
>
> +static CpuinfoEntry cpu_info = CPUINFO_ENTRY__INIT;
> +static CpuinfoX86Entry cpu_x86_info = CPUINFO_X86_ENTRY__INIT;
> +static CpuinfoX86Entry *cpu_x86_info_ptr = &cpu_x86_info;
I don't get why we need this thing always at hands. Why not
just allocate one on demand?
> +
> const char * const x86_cap_flags[NCAPINTS_BITS] = {
> [X86_FEATURE_FPU] = "fpu",
> [X86_FEATURE_CX8] = "cx8",
> @@ -106,8 +113,22 @@ static int proc_cpuinfo_match(char *tok)
> return 0;
> }
>
> +#define protobuf_features_words (sizeof(cpu_features) / sizeof(cpu_x86_info.features[0]))
> +
> +static void cpu_init_protobuf(void)
> +{
> + cpu_info.x86_entry = &cpu_x86_info_ptr;
> + cpu_info.n_x86_entry = 1;
> + cpu_info.id = 1;
> +
> + cpu_x86_info.n_features = protobuf_features_words;
> + cpu_x86_info.features = (void *)cpu_features;
Why not initialize this at declaration time?
> +}
> +
> int cpu_init(void)
> {
> + cpu_init_protobuf();
> +
> if (parse_cpuinfo_features(proc_cpuinfo_match))
> return -1;
>
>
More information about the CRIU
mailing list