From: Mike Rapoport <rppt@kernel.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Mark Rutland <mark.rutland@arm.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v3 1/2] mm/memblock: Add reserved memory release function
Date: Tue, 18 Feb 2025 09:24:53 +0200 [thread overview]
Message-ID: <Z7Q1xY3jhWjaSdeh@kernel.org> (raw)
In-Reply-To: <173928522350.906035.5626965043208329135.stgit@devnote2>
Hi Masami,
On Tue, Feb 11, 2025 at 11:47:03PM +0900, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> Add reserve_mem_release_by_name() to release a reserved memory region
> with a given name. This allows us to release reserved memory which is
> defined by kernel cmdline, after boot.
>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Mike Rapoport <rppt@kernel.org>
> Cc: linux-mm@kvack.org
...
> +/**
> + * reserve_mem_release_by_name - Release reserved memory region with a given name
> + * @name: The name that is attatched to a reserved memory region
> + *
> + * Forcibly release the pages in the reserved memory region so that those memory
> + * can be used as free memory. After released the reserved region size becomes 0.
> + *
> + * Returns: 1 if released or 0 if not found.
> + */
> +int reserve_mem_release_by_name(const char *name)
> +{
> + struct reserve_mem_table *map;
> + unsigned int page_count;
> + phys_addr_t start;
> +
> + guard(mutex)(&reserve_mem_lock);
> + map = reserve_mem_find_by_name_nolock(name);
> + if (!map)
> + return 0;
> +
> + start = map->start;
> + page_count = DIV_ROUND_UP(map->size, PAGE_SIZE);
> +
> + for (int i = 0; i < page_count; i++) {
> + phys_addr_t addr = start + i * PAGE_SIZE;
> + struct page *page = pfn_to_page(addr >> PAGE_SHIFT);
> +
> + page->flags &= ~BIT(PG_reserved);
> + __free_page(page);
> + }
We have free_reserved_area(), please use it here.
Otherwise
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> + map->size = 0;
> +
> + return 1;
> +}
> +
> /*
> * Parse reserve_mem=nn:align:name
> */
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2025-02-18 7:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 14:46 [PATCH v3 0/2] tracing: Make persistent ring buffer freeable Masami Hiramatsu (Google)
2025-02-11 14:47 ` [PATCH v3 1/2] mm/memblock: Add reserved memory release function Masami Hiramatsu (Google)
2025-02-11 17:52 ` Steven Rostedt
2025-02-11 23:39 ` Masami Hiramatsu
2025-02-18 7:24 ` Mike Rapoport [this message]
2025-02-18 8:42 ` Masami Hiramatsu
2025-02-18 9:47 ` Mike Rapoport
2025-02-18 11:34 ` Mike Rapoport
2025-02-18 13:06 ` Masami Hiramatsu
2025-02-11 14:47 ` [PATCH v3 2/2] tracing: Freeable reserved ring buffer Masami Hiramatsu (Google)
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=Z7Q1xY3jhWjaSdeh@kernel.org \
--to=rppt@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.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