All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Roger Pau Monne <roger.pau@citrix.com>, xen-devel@lists.xenproject.org
Cc: Community Manager <community.manager@xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Anthony PERARD <anthony.perard@vates.tech>,
	Michal Orzel <michal.orzel@amd.com>,
	Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH 8/8] pdx: introduce a command line option for offset compression
Date: Tue, 17 Jun 2025 09:09:19 +0200	[thread overview]
Message-ID: <313996d5-8801-4aed-92f8-e96d57dd9429@gmail.com> (raw)
In-Reply-To: <20250611171636.5674-9-roger.pau@citrix.com>

[-- Attachment #1: Type: text/plain, Size: 4877 bytes --]


On 6/11/25 7:16 PM, Roger Pau Monne wrote:
> Allow controlling whether to attempt PDX compression, and which algorithm
> to use to calculate the coefficients.  Document the option and also add a
> CHANGELOG entry for the newly added feature.
>
> Note the work has been originally done to cope with the new Intel
> Sapphire/Granite Rapids, however the compression is not explicitly tied to
> Intel or x86, and hence could be helpful on other architectures.
>
> Signed-off-by: Roger Pau Monné<roger.pau@citrix.com>
> ---
>   CHANGELOG.md                      |  3 +++
>   docs/misc/xen-command-line.pandoc | 22 ++++++++++++++++++
>   xen/common/pdx.c                  | 38 +++++++++++++++++++++++++++----
>   3 files changed, 59 insertions(+), 4 deletions(-)

LGTM: Reviewed-by: Oleksii Kurochko<oleksii.kurochko@gmail.com>

Thanks.

~ Oleksii

>
> diff --git a/CHANGELOG.md b/CHANGELOG.md
> index 23215a8cc1e6..48327f03078f 100644
> --- a/CHANGELOG.md
> +++ b/CHANGELOG.md
> @@ -20,6 +20,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
>        table or foreign memory.
>   
>   ### Added
> + - Introduce new PDX compression algorithm to cope with Intel Sapphire and
> +   Granite Rapids having sparse memory maps.
> +
>    - On x86:
>      - Option to attempt to fixup p2m page-faults on PVH dom0.
>      - Resizable BARs is supported for PVH dom0.
> diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
> index b0eadd2c5d58..06819576a06b 100644
> --- a/docs/misc/xen-command-line.pandoc
> +++ b/docs/misc/xen-command-line.pandoc
> @@ -2072,6 +2072,28 @@ for all of them (`true`), only for those subject to XPTI (`xpti`) or for
>   those not subject to XPTI (`no-xpti`). The feature is used only in case
>   INVPCID is supported and not disabled via `invpcid=false`.
>   
> +### pdx-compress
> +> `= <boolean> | auto | fast | slow`
> +
> +> Default: `auto`
> +
> +Only relevant when hypervisor is build with PFN PDX offset compression
> +`CONFIG_PDX_OFFSET_COMPRESSION`.
> +
> +Controls whether Xen will engage in PFN compression, and which algorithm will
> +be used to calculate the compression coefficients:
> +
> +* `auto`: default choice, attempt fast calculation of compression
> +  coefficients, if that's not successful fallback to slow calculation.
> +
> +* `fast`: only attempt fast calculation of coefficients, if it fails PFN PDX
> +  compression will be disabled.
> +
> +* `slow`: only attempt slow calculation of coefficients, if it fails PFN PDX
> +  compression will be disabled.
> +
> +Note `pdx-compress=true` is equivalent to `pdx-compress=auto`.
> +
>   ### ple_gap
>   > `= <integer>`
>   
> diff --git a/xen/common/pdx.c b/xen/common/pdx.c
> index feabdcded804..5fd01305a7be 100644
> --- a/xen/common/pdx.c
> +++ b/xen/common/pdx.c
> @@ -19,6 +19,7 @@
>   #include <xen/mm.h>
>   #include <xen/bitops.h>
>   #include <xen/nospec.h>
> +#include <xen/param.h>
>   #include <xen/pfn.h>
>   #include <xen/sections.h>
>   #include <xen/sort.h>
> @@ -468,11 +469,40 @@ STATIC void __init pfn_offset_sanitize_ranges(void)
>   }
>   
>   #ifdef __XEN__
> +static enum {
> +    PDX_AUTO, /* Fast first, fallback to slow if fast is not successful. */
> +    PDX_NO,   /* Do not attempt compression. */
> +    PDX_FAST, /* Only attempt fast calculation of compression parameters. */
> +    PDX_SLOW, /* Only attempt slow calculation of compression parameters. */
> +} compress_mode __initdata;
> +
> +static int __init cf_check parse_pdx_param(const char *arg)
> +{
> +    int val;
> +
> +    if ( !arg )
> +        return -EINVAL;
> +
> +    if ( (val = parse_bool(arg, NULL)) != -1 )
> +        compress_mode = val ? PDX_AUTO : PDX_NO;
> +    else if ( !strcmp(arg, "auto") )
> +        compress_mode = PDX_AUTO;
> +    else if ( !strcmp(arg, "fast") )
> +        compress_mode = PDX_FAST;
> +    else if ( !strcmp(arg, "slow") )
> +        compress_mode = PDX_SLOW;
> +    else
> +        return -EINVAL;
> +
> +    return 0;
> +}
> +custom_param("pdx-compress", parse_pdx_param);
> +
>   bool __init pfn_pdx_compression_setup(paddr_t base)
>   {
> -    bool use_slow = false;
> +    bool use_slow = compress_mode == PDX_SLOW;
>   
> -    if ( nr <= 1 )
> +    if ( nr <= 1 || compress_mode == PDX_NO )
>           return false;
>   
>       if ( nr > ARRAY_SIZE(ranges) )
> @@ -507,11 +537,11 @@ bool __init pfn_pdx_compression_setup(paddr_t base)
>               dprintk(XENLOG_DEBUG,
>                       "Find PFN compression coefficients using %s algorithm failed\n",
>                       use_slow ? "slow" : "fast");
> -            if ( use_slow )
> +            if ( compress_mode == PDX_FAST || use_slow )
>                   return false;
>           }
>   
> -        if ( use_slow )
> +        if ( compress_mode == PDX_FAST || use_slow )
>               break;
>       }
>   

[-- Attachment #2: Type: text/html, Size: 5590 bytes --]

  reply	other threads:[~2025-06-17  7:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 17:16 [PATCH 0/8] pdx: introduce a new compression algorithm Roger Pau Monne
2025-06-11 17:16 ` [PATCH 1/8] x86/pdx: simplify calculation of domain struct allocation boundary Roger Pau Monne
2025-06-11 17:58   ` Andrew Cooper
2025-06-12  6:57     ` Roger Pau Monné
2025-06-12  9:03   ` Jan Beulich
2025-06-12 10:46     ` Roger Pau Monné
2025-06-12 12:00       ` Jan Beulich
2025-06-11 17:16 ` [PATCH 2/8] pdx: introduce function to calculate max PFN based on PDX compression Roger Pau Monne
2025-06-12  9:11   ` Jan Beulich
2025-06-12 10:48     ` Roger Pau Monné
2025-06-12 12:02       ` Jan Beulich
2025-06-11 17:16 ` [PATCH 3/8] kconfig: turn PDX compression into a choice Roger Pau Monne
2025-06-12  8:28   ` Jan Beulich
2025-06-11 17:16 ` [PATCH 4/8] pdx: provide a unified set of unit functions Roger Pau Monne
2025-06-12  8:32   ` Jan Beulich
2025-06-12 10:50     ` Roger Pau Monné
2025-06-12  8:36   ` Jan Beulich
2025-06-12 10:51     ` Roger Pau Monné
2025-06-12 12:03       ` Jan Beulich
2025-06-11 17:16 ` [PATCH 5/8] pdx: allow optimizing PDX conversion helpers Roger Pau Monne
2025-06-11 17:16 ` [PATCH 6/8] pdx: introduce a new compression algorithm based on offsets between regions Roger Pau Monne
2025-06-11 19:33   ` Andrew Cooper
2025-06-12  7:26     ` Roger Pau Monné
2025-06-12  7:59       ` Roger Pau Monné
2025-06-12  8:27   ` Jan Beulich
2025-06-12 14:03     ` Roger Pau Monné
2025-06-16  7:50       ` Jan Beulich
2025-06-18 13:02   ` Jan Beulich
2025-06-18 14:11     ` Roger Pau Monné
2025-06-11 17:16 ` [PATCH 7/8] pdx: introduce translation helpers for offset compression Roger Pau Monne
2025-06-11 17:16 ` [PATCH 8/8] pdx: introduce a command line option " Roger Pau Monne
2025-06-17  7:09   ` Oleksii Kurochko [this message]
2025-06-18 13:36   ` Jan Beulich
2025-06-18 14:12     ` Roger Pau Monné

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=313996d5-8801-4aed-92f8-e96d57dd9429@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=community.manager@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=roger.pau@citrix.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.