public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Mike Rapoport <rppt@kernel.org>
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: Mon, 12 Jan 2026 10:39:04 -0400	[thread overview]
Message-ID: <20260112143904.GA812923@nvidia.com> (raw)
In-Reply-To: <aWTJ2v9J-Aa6ykBf@kernel.org>

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?

> My view is that we should free the empty bitmaps, maybe asynchronously.
> The intermediate nodes probably don't take that much memory to bother with
> them.

Telling they are empty would be quite expensive. I think we should not
attempt to clean the tree unless there is a really good reason why we
should have good flows with alot of unpreserving activity.

I think we would be better served to treat the root cause and fixup
what ever is doing preserving/unpreserving loops.

Jason

  reply	other threads:[~2026-01-12 14:39 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 [this message]
2026-01-13 11:34       ` Mike Rapoport
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=20260112143904.GA812923@nvidia.com \
    --to=jgg@nvidia.com \
    --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=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 \
    --cc=rppt@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox