From: Baoquan He <bhe@redhat.com>
To: Jacek Tomaka <jacekt@dug.com>
Cc: kexec@lists.infradead.org, horms@kernel.org,
dan.j.williams@intel.com, Jacek Tomaka <jacek.tomaka@poczta.fm>
Subject: Re: [PATCH] Add support for soft reserved memory range
Date: Wed, 4 Sep 2024 12:15:14 +0800 [thread overview]
Message-ID: <Ztfe0oKCEDaeHLfb@MiWiFi-R3L-srv> (raw)
In-Reply-To: <CAKVxXCUSCn5QLMTPF2vLdk7wHbMTeQNxBVwnTtYsprNnEnaq=g@mail.gmail.com>
On 09/03/24 at 09:47am, Jacek Tomaka wrote:
> Hi Boaquan,
>
> > Wondering what use cases you have encountered and want to use this patch
> > to resolve. Could you say more about it?
>
> Sure, we are using genders to store kernel arguments for each machine
> so that they are version controlled.
> In order to apply them we boot buildroot kernel, download destination
> kernel, read arguments to be passed,
> then kexec.
>
> In general it works fine, but some of our machines are Sapphire Rapids
> Max and without kexec understanding soft
> reservations we end up with 2GB less total memory, which in general
> would not be a big deal but I think it is the
> HBM memory that is wasted.
Ok, thanks for these details.
So you are using kexec_load interface, does kexec_file_load interface
work well in this case?
>
>
> On Fri, Aug 30, 2024 at 10:45 PM Baoquan He <bhe@redhat.com> wrote:
> >
> > Hi,
> >
> > On 08/14/24 at 01:33pm, Jacek Tomaka wrote:
> > > Essentially catch up with e820 related changes in the kernel.
> > > Intel Sapphire Rappids MAX has high bandwidth memory which is
> > > precious resource that is better not allocated by the kernel.
> >
> > Wondering what use cases you have encountered and want to use this patch
> > to resolve. Could you say more about it?
> >
> > >
> > > Userspace later can enable soft reserved range using daxctl.
> > >
> > > Signed-off-by: Jacek Tomaka <jacek.tomaka@poczta.fm>
> > > ---
> > > include/x86/x86-linux.h | 2 ++
> > > kexec/arch/i386/crashdump-x86.c | 7 +++++++
> > > kexec/arch/i386/kexec-multiboot-x86.c | 1 +
> > > kexec/arch/i386/kexec-x86-common.c | 5 +++++
> > > kexec/arch/i386/x86-linux-setup.c | 3 +++
> > > kexec/firmware_memmap.c | 2 ++
> > > kexec/kexec.h | 1 +
> > > 7 files changed, 21 insertions(+)
> > >
> > > diff --git a/include/x86/x86-linux.h b/include/x86/x86-linux.h
> > > index 9646102835..fbde93df94 100644
> > > --- a/include/x86/x86-linux.h
> > > +++ b/include/x86/x86-linux.h
> > > @@ -23,6 +23,8 @@ struct e820entry {
> > > #define E820_NVS 4
> > > #define E820_PMEM 7
> > > #define E820_PRAM 12
> > > +#define E820_SOFT_RESERVED 0xefffffff
> > > +
> > > } __attribute__((packed));
> > > #endif
> > >
> > > diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
> > > index a01031e570..49108b2032 100644
> > > --- a/kexec/arch/i386/crashdump-x86.c
> > > +++ b/kexec/arch/i386/crashdump-x86.c
> > > @@ -288,6 +288,10 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
> > > type = RANGE_RESERVED;
> > > } else if (memcmp(str, "Reserved\n", 9) == 0) {
> > > type = RANGE_RESERVED;
> > > + } else if (memcmp(str, "soft reserved\n", 14) == 0 ) {
> > > + type = RANGE_SOFT_RESERVED;
> > > + } else if (memcmp(str, "Soft Reserved\n", 14) == 0 ) {
> > > + type = RANGE_SOFT_RESERVED;
> > > } else if (memcmp(str, "GART\n", 5) == 0) {
> > > gart_start = start;
> > > gart_end = end;
> > > @@ -615,6 +619,8 @@ static void cmdline_add_memmap_internal(char *cmdline, unsigned long startk,
> > > strcat (str_mmap, "K@");
> > > else if (type == RANGE_RESERVED)
> > > strcat (str_mmap, "K$");
> > > + else if (type == RANGE_SOFT_RESERVED)
> > > + strcat (str_mmap, "K*");
> > > else if (type == RANGE_ACPI || type == RANGE_ACPI_NVS)
> > > strcat (str_mmap, "K#");
> > > else if (type == RANGE_PRAM)
> > > @@ -985,6 +991,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
> > > if ( !( mem_range[i].type == RANGE_ACPI
> > > || mem_range[i].type == RANGE_ACPI_NVS
> > > || mem_range[i].type == RANGE_RESERVED
> > > + || mem_range[i].type == RANGE_SOFT_RESERVED
> > > || mem_range[i].type == RANGE_PMEM
> > > || mem_range[i].type == RANGE_PRAM))
> > > continue;
> > > diff --git a/kexec/arch/i386/kexec-multiboot-x86.c b/kexec/arch/i386/kexec-multiboot-x86.c
> > > index 33c885a2fa..49d57cb5ae 100644
> > > --- a/kexec/arch/i386/kexec-multiboot-x86.c
> > > +++ b/kexec/arch/i386/kexec-multiboot-x86.c
> > > @@ -379,6 +379,7 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
> > > mmap[i].Type = 4;
> > > break;
> > > case RANGE_RESERVED:
> > > + case RANGE_SOFT_RESERVED:
> > > default:
> > > mmap[i].Type = 2; /* Not RAM (reserved) */
> > > }
> > > diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
> > > index ffc95a9e43..116c4f4fd3 100644
> > > --- a/kexec/arch/i386/kexec-x86-common.c
> > > +++ b/kexec/arch/i386/kexec-x86-common.c
> > > @@ -99,6 +99,9 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
> > > else if (strncasecmp(str, "reserved\n", 9) == 0) {
> > > type = RANGE_RESERVED;
> > > }
> > > + else if (strncasecmp(str, "soft reserved\n", 9) == 0) {
> > > + type = RANGE_SOFT_RESERVED;
> > > + }
> > > else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
> > > type = RANGE_ACPI;
> > > }
> > > @@ -170,6 +173,8 @@ unsigned xen_e820_to_kexec_type(uint32_t type)
> > > return RANGE_PMEM;
> > > case E820_PRAM:
> > > return RANGE_PRAM;
> > > + case E820_SOFT_RESERVED;
> > > + return RANGE_SOFT_RESERVED;
> > > case E820_RESERVED:
> > > default:
> > > return RANGE_RESERVED;
> > > diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
> > > index 73251b9339..afc83fe729 100644
> > > --- a/kexec/arch/i386/x86-linux-setup.c
> > > +++ b/kexec/arch/i386/x86-linux-setup.c
> > > @@ -755,6 +755,9 @@ static void add_e820_map_from_mr(struct x86_linux_param_header *real_mode,
> > > case RANGE_PRAM:
> > > e820[i].type = E820_PRAM;
> > > break;
> > > + case RANGE_SOFT_RESERVED:
> > > + e820[i].type = E820_SOFT_RESERVED;
> > > + break;
> > > default:
> > > case RANGE_RESERVED:
> > > e820[i].type = E820_RESERVED;
> > > diff --git a/kexec/firmware_memmap.c b/kexec/firmware_memmap.c
> > > index 457c3dc9a6..fa0c22140a 100644
> > > --- a/kexec/firmware_memmap.c
> > > +++ b/kexec/firmware_memmap.c
> > > @@ -182,6 +182,8 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)
> > > range->type = RANGE_RESERVED;
> > > else if (strcmp(type, "Reserved") == 0)
> > > range->type = RANGE_RESERVED;
> > > + else if (strcmp(type, "Soft Reserved") == 0)
> > > + range->type = RANGE_SOFT_RESERVED;
> > > else if (strcmp(type, "Unknown E820 type") == 0)
> > > range->type = RANGE_RESERVED;
> > > else if (strcmp(type, "ACPI Non-volatile Storage") == 0)
> > > diff --git a/kexec/kexec.h b/kexec/kexec.h
> > > index 31c323f674..dbb27a7607 100644
> > > --- a/kexec/kexec.h
> > > +++ b/kexec/kexec.h
> > > @@ -139,6 +139,7 @@ struct memory_range {
> > > #define RANGE_UNCACHED 4
> > > #define RANGE_PMEM 6
> > > #define RANGE_PRAM 11
> > > +#define RANGE_SOFT_RESERVED 0xefffffff
> > > };
> > >
> > > struct memory_ranges {
> > > --
> > > 2.17.0
> > >
> > >
> > > _______________________________________________
> > > kexec mailing list
> > > kexec@lists.infradead.org
> > > http://lists.infradead.org/mailman/listinfo/kexec
> > >
> >
>
>
> --
> Jacek Tomaka
> Principal Software Engineer
>
> 76 Kings Park Road
> West Perth 6005 WA, Australia
> tel +61 8 9287 4143
> jacekt@dug.com
> www.dug.com
> www.dug.comwww.dug.com
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2024-09-04 4:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240814052024.25731-1-jacekt@dugeo.com>
2024-08-14 5:33 ` [PATCH] Add support for soft reserved memory range Jacek Tomaka
2024-08-24 2:06 ` Jacek Tomaka
2024-08-30 14:45 ` Baoquan He
2024-09-03 1:47 ` Jacek Tomaka
2024-09-04 4:15 ` Baoquan He [this message]
2024-08-07 2:57 Jacek Tomaka
2024-08-13 14:29 ` Simon Horman
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=Ztfe0oKCEDaeHLfb@MiWiFi-R3L-srv \
--to=bhe@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=horms@kernel.org \
--cc=jacek.tomaka@poczta.fm \
--cc=jacekt@dug.com \
--cc=kexec@lists.infradead.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