RE: [EXTERNAL] Re: [RFC PATCH 4/4] x86/Hyper-V: Add memory hot remove function

From: Tianyu Lan
Date: Thu Dec 12 2019 - 08:37:56 EST



> From: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>
>
> > From: Tianyu Lan <Tianyu.Lan@xxxxxxxxxxxxx>
> >
> > @@ -376,6 +391,27 @@ struct dm_hot_add_response {
> > __u32 result;
> > } __packed;
> >
> > +struct dm_hot_remove {
> > + struct dm_header hdr;
> > + __u32 virtual_node;
> > + __u32 page_count;
> > + __u32 qos_flags;
> > + __u32 reservedZ;
> > +} __packed;
> > +
> > +struct dm_hot_remove_response {
> > + struct dm_header hdr;
> > + __u32 result;
> > + __u32 range_count;
> > + __u64 more_pages:1;
> > + __u64 reservedz:63;
> > + union dm_mem_page_range range_array[]; } __packed;
> > +
> > +#define DM_REMOVE_QOS_LARGE (1 << 0)
> > +#define DM_REMOVE_QOS_LOCAL (1 << 1)
> > +#define DM_REMOVE_QoS_MASK (0x3)
>
> Capitalize 'QoS' to make it match previous two lines please.
>

Yes, Will fix it.

> > +
> > /*
> > * Types of information sent from host to the guest.
> > */
> > @@ -457,6 +493,13 @@ struct hot_add_wrk {
> > struct work_struct wrk;
> > };
> >
> > +struct hot_remove_wrk {
> > + __u32 virtual_node;
> > + __u32 page_count;
> > + __u32 qos_flags;
> > + struct work_struct wrk;
> > +};
> > +
> > static bool hot_add = true;
> > static bool do_hot_add;
> > /*
> > @@ -489,6 +532,7 @@ enum hv_dm_state {
> > DM_BALLOON_UP,
> > DM_BALLOON_DOWN,
> > DM_HOT_ADD,
> > + DM_HOT_REMOVE,
> > DM_INIT_ERROR
> > };
> >
> > @@ -515,11 +559,13 @@ struct hv_dynmem_device {
> > * State to manage the ballooning (up) operation.
> > */
> > struct balloon_state balloon_wrk;
> > + struct balloon_state unballoon_wrk;
> >
> > /*
> > * State to execute the "hot-add" operation.
>
> This comment is stale now.
>

Will update. Thanks.

> > */
> > struct hot_add_wrk ha_wrk;
> > + struct hot_remove_wrk hr_wrk;
>
> Do we actually want to work struct and all the problems with their
> serialization? Can we get away with one?

I think it's possible to just use one work to handle all kind of msgs
with a work struct which contains parameters for all dm msgs and identify
the msg type in the work callback function.