linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Jason Miu <jasonmiu@google.com>, Alexander Graf <graf@amazon.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Baoquan He <bhe@redhat.com>,
	Changyuan Lyu <changyuanl@google.com>,
	David Matlack <dmatlack@google.com>,
	David Rientjes <rientjes@google.com>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH v4 1/2] kho: Adopt radix tree for preserved memory tracking
Date: Tue, 13 Jan 2026 13:34:42 +0200	[thread overview]
Message-ID: <aWYt0gBHxDCKqj9Q@kernel.org> (raw)
In-Reply-To: <20260112143904.GA812923@nvidia.com>

On Mon, Jan 12, 2026 at 10:39:04AM -0400, Jason Gunthorpe wrote:
> On Mon, Jan 12, 2026 at 12:15:54PM +0200, Mike Rapoport wrote:
> > > + * The tree is traversed using a key that encodes the page's physical address
> > > + * (pa) and its order into a single unsigned long value. The encoded key value
> > > + * is composed of two parts: the 'order bit' in the upper part and the 'page
> > > + * offset' in the lower part.::
> > > + *
> > > + *   +------------+-----------------------------+--------------------------+
> > > + *   | Page Order | Order Bit                   | Page Offset              |
> > > + *   +------------+-----------------------------+--------------------------+
> > > + *   | 0          | ...000100 ... (at bit 52)   | pa >> (PAGE_SHIFT + 0)   |
> > > + *   | 1          | ...000010 ... (at bit 51)   | pa >> (PAGE_SHIFT + 1)   |
> > > + *   | 2          | ...000001 ... (at bit 50)   | pa >> (PAGE_SHIFT + 2)   |
> > > + *   | ...        | ...                         | ...                      |
> > > + *   +------------+-----------------------------+--------------------------+
> > > + *
> > > + * Page Offset:
> > 
> > To me "page offset" reads as offset from somewhere and here it's rather pfn
> > on steroids :) 
> > Also in many places in the kernel "page offset" refers to the offset inside a
> > page.
> > 
> > Can't say I can think of a better name, but it feels that it should express
> > that this is an address more explicitly.
> 
> It is "Shifted Physical Address"
> 
> > > +			node = phys_to_virt((phys_addr_t)node->table[idx]);
> > > +	}
> > > +
> > > +	/* Handle the leaf level bitmap (level 0) */
> > > +	leaf = (struct kho_radix_leaf *)node;
> > > +	idx = kho_radix_get_index(key, 0);
> > > +	__clear_bit(idx, leaf->bitmap);
> > 
> > I think I already mentioned it in earlier reviews, but I don't remember any
> > response.
> > 
> > How do we approach freeing empty bitmaps and intermediate nodes?
> > If we do a few preserve/uppreserve cycles for memory that can be allocated
> > and freed in between we might get many unused bitmaps.
> 
> Surely this is an error case??
> 
> We shouldn't be unpreserving at all in a normal flow?

That's an error case for KHO/LUO, but might not be an error case for other
users of the kho_radix_tree.
For example mshv intends to use kho_radix_tree to track the hypervisor
memory and there unpreserving will be a part of the normal flow.

I'm not saying we must implement freeing of empty bitmaps from day 1, but
at least there should be a comment about it.
 
> Jason

-- 
Sincerely yours,
Mike.


  reply	other threads:[~2026-01-13 11:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-09  0:11 [PATCH v4 0/2] Make KHO Stateless Jason Miu
2026-01-09  0:11 ` [PATCH v4 1/2] kho: Adopt radix tree for preserved memory tracking Jason Miu
2026-01-12 10:15   ` Mike Rapoport
2026-01-12 14:39     ` Jason Gunthorpe
2026-01-13 11:34       ` Mike Rapoport [this message]
2026-01-13 13:05         ` Jason Gunthorpe
2026-01-13 14:46           ` Mike Rapoport
2026-01-13 14:58             ` Jason Gunthorpe
2026-01-13 16:16               ` Pasha Tatashin
2026-01-13  5:33     ` Jason Miu
2026-01-09  0:11 ` [PATCH v4 2/2] kho: Remove finalize state and clients Jason Miu
2026-01-12 10:25   ` Mike Rapoport

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=aWYt0gBHxDCKqj9Q@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=changyuanl@google.com \
    --cc=dmatlack@google.com \
    --cc=graf@amazon.com \
    --cc=jasonmiu@google.com \
    --cc=jgg@nvidia.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=pratyush@kernel.org \
    --cc=rientjes@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox