All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Michal Orzel <michal.orzel@amd.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH v4 2/3] xen/mm: allow deferred scrub of physmap populate allocated pages
Date: Wed, 28 Jan 2026 20:06:34 +0100	[thread overview]
Message-ID: <aXpeOocblPZtJW5Q@Mac.lan> (raw)
In-Reply-To: <6d7b74b6-1bab-427d-aa14-321f4761d9a0@suse.com>

On Wed, Jan 28, 2026 at 03:46:04PM +0100, Jan Beulich wrote:
> On 28.01.2026 13:03, Roger Pau Monne wrote:
> > @@ -275,7 +339,18 @@ static void populate_physmap(struct memop_args *a)
> >              }
> >              else
> >              {
> > -                page = alloc_domheap_pages(d, a->extent_order, a->memflags);
> > +                unsigned int scrub_start = 0;
> > +                nodeid_t node =
> > +                    (a->memflags & MEMF_exact_node) ? MEMF_get_node(a->memflags)
> > +                                                    : NUMA_NO_NODE;
> > +
> > +                page = get_stashed_allocation(d, a->extent_order, node,
> > +                                              &scrub_start);
> > +
> > +                if ( !page )
> > +                    page = alloc_domheap_pages(d, a->extent_order,
> > +                        a->memflags | (d->creation_finished ? 0
> > +                                                            : MEMF_no_scrub));
> 
> I fear there's a more basic issue here that so far we didn't pay attention to:
> alloc_domheap_pages() is what invokes assign_page(), which in turn resets
> ->count_info for each of the pages. This reset includes setting PGC_allocated,
> which ...
> 
> > @@ -286,6 +361,30 @@ static void populate_physmap(struct memop_args *a)
> >                      goto out;
> >                  }
> >  
> > +                if ( !d->creation_finished )
> > +                {
> > +                    unsigned int dirty_cnt = 0;
> > +
> > +                    /* Check if there's anything to scrub. */
> > +                    for ( j = scrub_start; j < (1U << a->extent_order); j++ )
> > +                    {
> > +                        if ( !test_and_clear_bit(_PGC_need_scrub,
> > +                                                 &page[j].count_info) )
> > +                            continue;
> 
> ... means we will now scrub every page in the block, not just those which weren't
> scrubbed yet, and we end up clearing PGC_allocated. All because of PGC_need_scrub
> aliasing PGC_allocated. I wonder how this didn't end up screwing any testing you
> surely will have done. Or maybe I'm completely off here?

Thanks for spotting this!  No, I didn't see any issues.  I don't see
any check for PGC_allocated in free_domheap_pages(), which could
explain the lack of failures?

I will have to allocate with MEMF_no_owner and then do the
assign_pages() call from populate_physmap() after the scrubbing is
done.  Maybe that would work.  Memory allocated using MEMF_no_owner
still consumes the claim pool if a domain parameter is passed to
alloc_heap_pages().

Roger.


  reply	other threads:[~2026-01-28 19:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 12:03 [PATCH v4 0/3] xen/mm: limit in-place scrubbing Roger Pau Monne
2026-01-28 12:03 ` [PATCH v4 1/3] xen/mm: enforce SCRUB_DEBUG checks for MEMF_no_scrub allocations Roger Pau Monne
2026-01-28 12:03 ` [PATCH v4 2/3] xen/mm: allow deferred scrub of physmap populate allocated pages Roger Pau Monne
2026-01-28 12:44   ` Andrew Cooper
2026-01-28 13:33     ` Roger Pau Monné
2026-01-28 14:34       ` Jan Beulich
2026-01-29 17:33         ` Roger Pau Monné
2026-01-28 14:46   ` Jan Beulich
2026-01-28 19:06     ` Roger Pau Monné [this message]
2026-01-29  7:53       ` Jan Beulich
2026-01-29 10:52         ` Roger Pau Monné
2026-01-28 12:03 ` [PATCH v4 3/3] xen/mm: limit non-scrubbed allocations to a specific order Roger Pau Monne

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=aXpeOocblPZtJW5Q@Mac.lan \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --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.