From: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
David Hildenbrand <david@redhat.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Anshuman Khandual <anshuman.khandual@arm.com>,
linux-kernel@vger.kernel.org, Steven Price <steven.price@arm.com>,
Suren Baghdasaryan <surenb@google.com>,
Greg Kroah-Hartman <gregkh@google.com>,
Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Pratik Patel <pratikp@codeaurora.org>
Subject: Re: mm/memblock: export memblock_{start/end}_of_DRAM
Date: Mon, 02 Nov 2020 18:51:25 -0800 [thread overview]
Message-ID: <ad242b868a291223218a33c05d6729fd@codeaurora.org> (raw)
In-Reply-To: <20201030083842.GA4319@kernel.org>
On 2020-10-30 01:38, Mike Rapoport wrote:
> On Thu, Oct 29, 2020 at 02:29:27PM -0700, Sudarshan Rajagopalan wrote:
>> Hello all,
>>
>> We have a usecase where a module driver adds certain memory blocks
>> using
>> add_memory_driver_managed(), so that it can perform memory hotplug
>> operations on these blocks. In general, these memory blocks aren’t
>> something
>> that gets physically added later, but is part of actual RAM that
>> system
>> booted up with. Meaning – we set the ‘mem=’ cmdline parameter to limit
>> the
>> memory and later add the remaining ones using add_memory*() variants.
>>
>> The basic idea is to have driver have ownership and manage certain
>> memory
>> blocks for hotplug operations.
>>
>> For the driver be able to know how much memory was limited and how
>> much
>> actually present, we take the delta of ‘bootmem physical end address’
>> and
>> ‘memblock_end_of_DRAM’. The 'bootmem physical end address' is obtained
>> by
>> scanning the reg values in ‘memory’ DT node and determining the max
>> {addr,size}. Since our driver is getting modularized, we won’t have
>> access
>> to memblock_end_of_DRAM (i.e. end address of all memory blocks after
>> ‘mem=’
>> is applied).
>>
>> So checking if memblock_{start/end}_of_DRAM() symbols can be exported?
>> Also,
>> this information can be obtained by userspace by doing ‘cat
>> /proc/iomem’ and
>> greping for ‘System RAM’. So wondering if userspace can have access to
>> such
>> info, can we allow kernel module drivers have access by exporting
>> memblock_{start/end}_of_DRAM().
>
> These functions cannot be exported not because we want to hide this
> information from the modules but because it is unsafe to use them.
> On most architecturs these functions are __init so they are discarded
> after boot anyway. Beisdes, the memory configuration known to memblock
> might be not accurate in many cases as David explained in his reply.
>
I don't see how information contained in memblock_{start/end}_of_DRAM()
is considered hidden if the information can be obtained using 'cat
/proc/iomem'. The memory resource manager adds these blocks either in
"System RAM", "reserved", "Kernel data/code" etc. Inspecting this, one
could determine whats the start and end of memblocks.
I agree on the part that its __init annotated and could be removed after
boot. This is something that the driver can be vary of too.
>> Or are there any other ways where a module driver can get the end
>> address of
>> system memory block?
>
> What do you mean by "system memory block"? There could be a lot of
> interpretations if you take into account memory hotplug, "mem=" option,
> reserved and firmware memory.
I meant the physical end address of memblock. The equivalent of
memblock_end_of_DRAM.
>
> I'd suggest you to describe the entire use case in more detail. Having
> the complete picture would help finding a proper solution.
The usecase in general is have a way to add/remove and online/offline
certain memory blocks which are part of boot. We do this by limiting the
memory using "mem=" and latter add the remaining blocks using
add_memory_driver_mamanaged().
>
>> Sudarshan
>>
>
> --
> Sincerely yours,
> Mike.
Sudarshan
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-11-03 13:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 21:29 mm/memblock: export memblock_{start/end}_of_DRAM Sudarshan Rajagopalan
2020-10-30 6:41 ` David Hildenbrand
2020-11-03 2:15 ` Sudarshan Rajagopalan
2020-10-30 8:38 ` Mike Rapoport
2020-10-31 9:18 ` Christoph Hellwig
2020-10-31 10:05 ` David Hildenbrand
2020-11-03 8:38 ` Christoph Hellwig
2020-11-03 2:51 ` Sudarshan Rajagopalan [this message]
2020-11-03 16:51 ` 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=ad242b868a291223218a33c05d6729fd@codeaurora.org \
--to=sudaraja@codeaurora.org \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=gregkh@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pratikp@codeaurora.org \
--cc=rppt@kernel.org \
--cc=steven.price@arm.com \
--cc=surenb@google.com \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).