All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Julien Grall <julien@xen.org>
Cc: xen-devel@lists.xenproject.org,
	Stefano Stabellini <sstabellini@kernel.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH v4 2/8] pdx: provide a unified set of unit functions
Date: Mon, 11 Aug 2025 10:07:50 +0200	[thread overview]
Message-ID: <aJmk1o7sUT2UZJ8M@macbook.local> (raw)
In-Reply-To: <5b940bdf-9bc0-49b2-af92-7251b2780c71@xen.org>

On Fri, Aug 08, 2025 at 06:21:29PM +0100, Julien Grall wrote:
> Hi Roger,
> 
> On 05/08/2025 10:52, Roger Pau Monne wrote:
> > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> > index a77b31071ed8..ba35bf1fe3bb 100644
> > --- a/xen/arch/arm/setup.c
> > +++ b/xen/arch/arm/setup.c
> > @@ -256,9 +256,11 @@ void __init init_pdx(void)
> >   {
> >       const struct membanks *mem = bootinfo_get_mem();
> >       paddr_t bank_start, bank_size, bank_end, ram_end = 0;
> > -    int bank;
> > +    unsigned int bank;
> >   #ifndef CONFIG_PDX_NONE
> > +    for ( bank = 0 ; bank < mem->nr_banks; bank++ )
> > +        pfn_pdx_add_region(mem->bank[bank].start, mem->bank[bank].size);
> >       /*
> >        * Arm does not have any restrictions on the bits to compress. Pass 0 to
> >        * let the common code further restrict the mask.
> > @@ -266,26 +268,24 @@ void __init init_pdx(void)
> >        * If the logic changes in pfn_pdx_hole_setup we might have to
> >        * update this function too.
> >        */
> > -    uint64_t mask = pdx_init_mask(0x0);
> > -
> > -    for ( bank = 0 ; bank < mem->nr_banks; bank++ )
> > -    {
> > -        bank_start = mem->bank[bank].start;
> > -        bank_size = mem->bank[bank].size;
> > -
> > -        mask |= bank_start | pdx_region_mask(bank_start, bank_size);
> > -    }
> > +    pfn_pdx_compression_setup(0);
> >       for ( bank = 0 ; bank < mem->nr_banks; bank++ )
> >       {
> > -        bank_start = mem->bank[bank].start;
> > -        bank_size = mem->bank[bank].size;
> > -
> > -        if (~mask & pdx_region_mask(bank_start, bank_size))
> > -            mask = 0;
> > +        if ( !pdx_is_region_compressible(
> > +                  mem->bank[bank].start,
> > +                  PFN_UP(mem->bank[bank].start + mem->bank[bank].size) -
> > +                  PFN_DOWN(mem->bank[bank].start)) )
> 
> This code is a bit too verbose. Can we at least introduce "bank =
> &mem->bank[bank]" to reduce a bit the verbosity?

I cannot introduce a `bank` local variable as it's already used as the
index cursor for the loop.  Would you be fine with:

    for ( bank = 0 ; bank < mem->nr_banks; bank++ )
    {
        const struct membank *m = &mem->bank[bank];

        if ( !pdx_is_region_compressible(m->start,
                                         PFN_UP(m->start + m->size) -
                                         PFN_DOWN(m->start)) )
        {
            pfn_pdx_compression_reset();
            printk(XENLOG_WARNING
                   "PFN compression disabled, RAM region [%#" PRIpaddr ", %#"
                   PRIpaddr "] not covered\n",
                   m->start, m->start + m->size - 1);
            break;
        }
    }

> The rest of the logic looks fine. So:
> 
> Acked-by: Julien Grall <jgrall@amazon.com> # ARM

Thanks, Roger.


  reply	other threads:[~2025-08-11  8:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05  9:52 [PATCH v4 0/8] pdx: introduce a new compression algorithm Roger Pau Monne
2025-08-05  9:52 ` [PATCH v4 1/8] kconfig: turn PDX compression into a choice Roger Pau Monne
2025-08-08 17:10   ` Julien Grall
2025-08-05  9:52 ` [PATCH v4 2/8] pdx: provide a unified set of unit functions Roger Pau Monne
2025-08-08 17:21   ` Julien Grall
2025-08-11  8:07     ` Roger Pau Monné [this message]
2025-08-11 16:42       ` Julien Grall
2025-08-05  9:52 ` [PATCH v4 3/8] pdx: introduce command line compression toggle Roger Pau Monne
2025-08-05  9:52 ` [PATCH v4 4/8] pdx: allow per-arch optimization of PDX conversion helpers Roger Pau Monne
2025-08-05 12:11   ` Jan Beulich
2025-08-05 14:20     ` Roger Pau Monné
2025-08-05 15:02       ` Jan Beulich
2025-08-05  9:52 ` [PATCH v4 5/8] test/pdx: add PDX compression unit tests Roger Pau Monne
2025-08-06  8:16   ` Anthony PERARD
2025-08-05  9:52 ` [PATCH v4 6/8] pdx: move some helpers in preparation for new compression Roger Pau Monne
2025-08-05  9:52 ` [PATCH v4 7/8] pdx: introduce a new compression algorithm based on region offsets Roger Pau Monne
2025-08-05 12:28   ` Jan Beulich
2025-08-05 14:37     ` Roger Pau Monné
2025-08-05  9:52 ` [PATCH v4 8/8] x86/mm: adjust loop in arch_init_memory() to iterate over the PDX space Roger Pau Monne
2025-08-05 12:38   ` Jan Beulich
2025-08-05 15:27     ` Roger Pau Monné
2025-08-06  8:11       ` Jan Beulich
2025-08-06 10:25         ` Jan Beulich

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=aJmk1o7sUT2UZJ8M@macbook.local \
    --to=roger.pau@citrix.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=bertrand.marquis@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.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.