From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
"George Dunlap" <george.dunlap@citrix.com>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
Xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v2 3/5] mm/pdx: Standardize region validation wrt pdx compression
Date: Mon, 7 Aug 2023 17:50:50 +0100 [thread overview]
Message-ID: <64d120ec.df0a0220.84f23.bc02@mx.google.com> (raw)
In-Reply-To: <ca38d130-ba56-33b2-3134-3b8d4d0dc4fe@suse.com>
On Mon, Jul 31, 2023 at 05:27:22PM +0200, Jan Beulich wrote:
> On 28.07.2023 09:59, Alejandro Vallejo wrote:
> > --- a/xen/arch/x86/x86_64/mm.c
> > +++ b/xen/arch/x86/x86_64/mm.c
> > @@ -1159,6 +1159,9 @@ static int mem_hotadd_check(unsigned long spfn, unsigned long epfn)
> > {
> > unsigned long s, e, length, sidx, eidx;
> >
> > + paddr_t mem_base = pfn_to_paddr(spfn);
> > + unsigned long mem_npages = epfn - spfn;
> > +
> > if ( (spfn >= epfn) )
> > return 0;
>
> While occasionally groups of declarations indeed want separating, the
> rule of thumb is that the first blank line after declarations separates
> them from statements. I don't see reason here to diverge from this.
Ack.
>
> > @@ -1660,6 +1663,8 @@ static bool __init cf_check rt_range_valid(unsigned long smfn, unsigned long emf
> >
> > void __init efi_init_memory(void)
> > {
> > + paddr_t mem_base;
> > + unsigned long mem_npages;
>
> Why in the outermost scope when ...
>
> > @@ -1732,6 +1737,9 @@ void __init efi_init_memory(void)
> > smfn = PFN_DOWN(desc->PhysicalStart);
> > emfn = PFN_UP(desc->PhysicalStart + len);
> >
> > + mem_base = pfn_to_paddr(smfn);
> > + mem_npages = emfn - smfn;
> > +
> > if ( desc->Attribute & EFI_MEMORY_WB )
> > prot |= _PAGE_WB;
> > else if ( desc->Attribute & EFI_MEMORY_WT )
> > @@ -1759,8 +1767,7 @@ void __init efi_init_memory(void)
> > prot |= _PAGE_NX;
> >
> > if ( pfn_to_pdx(emfn - 1) < (DIRECTMAP_SIZE >> PAGE_SHIFT) &&
> > - !(smfn & pfn_hole_mask) &&
> > - !((smfn ^ (emfn - 1)) & ~pfn_pdx_bottom_mask) )
> > + pdx_is_region_compressible(mem_base, mem_npages))
> > {
> > if ( (unsigned long)mfn_to_virt(emfn - 1) >= HYPERVISOR_VIRT_END )
> > prot &= ~_PAGE_GLOBAL;
>
> ... you use the variables only in an inner one?
No good reason. I defaulted to the top of the function because C90 was
picky about declaring midway through a scope and I didn't consider going to
the top of the scope instead. Ack.
>
> > --- a/xen/common/pdx.c
> > +++ b/xen/common/pdx.c
> > @@ -88,7 +88,7 @@ bool __mfn_valid(unsigned long mfn)
> > }
> >
> > /* Sets all bits from the most-significant 1-bit down to the LSB */
> > -static uint64_t __init fill_mask(uint64_t mask)
> > +static uint64_t fill_mask(uint64_t mask)
> > {
> > while (mask & (mask + 1))
> > mask |= mask + 1;
>
> I see why you want __init dropped here, but the function wasn't written
> for "common use" and hence may want improving first when intended for
> more frequent (post-init) use as well.
It's not so much that I want it rather than I need it. hotadd_mem_check()
uses it and it's not part of the init process. That's the only non-init use
of it, and it hardly qualifies as "common". IMO,
don't matter a whole
> Then again I wonder why original
> checking all got away without using this function ...
>
> Jan
My guess is that most real systems don't exercise the corner cases, and so
the code was just silently broken passing the checks all the time. I could
not find an explanation for the OR check in hotadd_mem_check(), so I just
attributed it to being a bug introduced out of lack of knowledge of pdx.
Thanks,
Alejandro
next prev parent reply other threads:[~2023-08-07 16:51 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 7:58 [PATCH v2 0/5] Make PDX compression optional Alejandro Vallejo
2023-07-28 7:58 ` [PATCH v2 1/5] arm/mm: Document the differences between arm32 and arm64 directmaps Alejandro Vallejo
2023-07-28 9:05 ` Julien Grall
2023-08-07 13:45 ` Julien Grall
2023-07-28 7:59 ` [PATCH v2 2/5] mm: Factor out the pdx compression logic in ma/va converters Alejandro Vallejo
2023-07-28 9:07 ` Julien Grall
2023-07-31 15:15 ` Jan Beulich
2023-08-07 16:26 ` Alejandro Vallejo
2023-08-08 6:05 ` Jan Beulich
2023-08-08 7:58 ` Julien Grall
2023-07-28 7:59 ` [PATCH v2 3/5] mm/pdx: Standardize region validation wrt pdx compression Alejandro Vallejo
2023-07-28 16:19 ` Julien Grall
2023-07-31 15:27 ` Jan Beulich
2023-08-07 16:50 ` Alejandro Vallejo [this message]
2023-07-28 7:59 ` [PATCH v2 4/5] pdx: Reorder pdx.[ch] Alejandro Vallejo
2023-07-28 16:20 ` Julien Grall
2023-07-28 7:59 ` [PATCH v2 5/5] pdx: Add CONFIG_HAS_PDX_COMPRESSION as a common Kconfig option Alejandro Vallejo
2023-07-28 16:27 ` Julien Grall
2023-07-28 16:36 ` Andrew Cooper
2023-07-28 16:58 ` Andrew Cooper
2023-07-31 8:00 ` Jan Beulich
2023-07-31 17:38 ` Andrew Cooper
2023-08-01 7:57 ` Jan Beulich
2023-08-07 16:06 ` Alejandro Vallejo
2023-08-08 6:17 ` Jan Beulich
2023-07-31 9:09 ` Julien Grall
2023-07-31 15:33 ` Jan Beulich
2023-08-07 17:48 ` Julien Grall
2023-08-08 9:52 ` Alejandro Vallejo
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=64d120ec.df0a0220.84f23.bc02@mx.google.com \
--to=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/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.