[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<SN6PR02MB4157D5BB1C140D229875AB50D41B2@SN6PR02MB4157.namprd02.prod.outlook.com>
Date: Mon, 29 Apr 2024 15:30:55 +0000
From: Michael Kelley <mhklinux@...look.com>
To: David Hildenbrand <david@...hat.com>, "haiyangz@...rosoft.com"
<haiyangz@...rosoft.com>, "wei.liu@...nel.org" <wei.liu@...nel.org>,
"decui@...rosoft.com" <decui@...rosoft.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "linux-hyperv@...r.kernel.org"
<linux-hyperv@...r.kernel.org>
Subject: RE: [PATCH 1/1] hv_balloon: Enable hot-add for memblock sizes > 128
Mbytes
From: Michael Kelley <mhklinux@...look.com> Sent: Friday, April 26, 2024 9:36 AM
> > > @@ -505,8 +505,9 @@ enum hv_dm_state {
> > >
> > > static __u8 recv_buffer[HV_HYP_PAGE_SIZE];
> > > static __u8 balloon_up_send_buffer[HV_HYP_PAGE_SIZE];
> > > +static unsigned long ha_chunk_pgs;
> >
> > Why not stick to PAGES_IN_2M and call this
> >
> > ha_pages_in_chunk? Much easier to get than "pgs".
>
> OK. I was trying to keep the new identifier short so that
> mechanically substituting it for HA_CHUNK didn't blow up
> the line length.
>
> >
> > Apart from that looks good. Some helper macros to convert size to chunks
> > etc. might make the code even more readable.
>
> I'll look at this. Might help the line length problem too.
>
I didn't see any particular complexity in converting size to chunks. But
this slightly opaque sequence is repeated in three places:
new_inc = (residual / HA_CHUNK) * HA_CHUNK;
if (residual % HA_CHUNK)
new_inc += HA_CHUNK;
If HA_CHUNK (or the new memblock size based variable) is a
power of 2, then these can become:
new_inc = ALIGN(residual, HA_CHUNK);
which is a lot better. I'll make that change, and a couple of other
changes where things are open coded that could be existing
kernel macros.
Question: Is memblock size guaranteed to be a power of 2? It looks
to be so in the x86 code, but I can't tell on s390 and ppc. For safety,
I'll add a check in the Hyper-V balloon driver init code, as the
communication with Hyper-V expects a power of 2.
Michael
Powered by blists - more mailing lists