From: David Hildenbrand <david@redhat.com>
To: "Verma, Vishal L" <vishal.l.verma@intel.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"rafael@kernel.org" <rafael@kernel.org>,
"osalvador@suse.de" <osalvador@suse.de>,
"aneesh.kumar@linux.ibm.com" <aneesh.kumar@linux.ibm.com>,
"Williams, Dan J" <dan.j.williams@intel.com>,
"Jiang, Dave" <dave.jiang@intel.com>,
"lenb@kernel.org" <lenb@kernel.org>
Cc: "Huang, Ying" <ying.huang@intel.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Subject: Re: [PATCH 3/3] dax/kmem: Always enroll hotplugged memory for memmap_on_memory
Date: Thu, 13 Jul 2023 17:23:44 +0200 [thread overview]
Message-ID: <80c8654e-21fb-b187-3475-9a1410a53a4e@redhat.com> (raw)
In-Reply-To: <6cb5624ebf3039b18f5180262fc6383b402d26ea.camel@intel.com>
On 13.07.23 17:15, Verma, Vishal L wrote:
> On Thu, 2023-07-13 at 09:23 +0200, David Hildenbrand wrote:
>> On 13.07.23 08:45, Verma, Vishal L wrote:
>>>
>>> I'm taking a shot at implementing the splitting internally in
>>> memory_hotplug.c. The caller (kmem) side does become trivial with this
>>> approach, but there's a slight complication if I don't have the module
>>> param override (patch 1 of this series).
>>>
>>> The kmem diff now looks like:
>>>
>>> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
>>> index 898ca9505754..8be932f63f90 100644
>>> --- a/drivers/dax/kmem.c
>>> +++ b/drivers/dax/kmem.c
>>> @@ -105,6 +105,8 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
>>> data->mgid = rc;
>>>
>>> for (i = 0; i < dev_dax->nr_range; i++) {
>>> + mhp_t mhp_flags = MHP_NID_IS_MGID | MHP_MEMMAP_ON_MEMORY |
>>> + MHP_SPLIT_MEMBLOCKS;
>>> struct resource *res;
>>> struct range range;
>>>
>>> @@ -141,7 +143,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
>>> * this as RAM automatically.
>>> */
>>> rc = add_memory_driver_managed(data->mgid, range.start,
>>> - range_len(&range), kmem_name, MHP_NID_IS_MGID);
>>> + range_len(&range), kmem_name, mhp_flags);
>>>
>>> if (rc) {
>>> dev_warn(dev, "mapping%d: %#llx-%#llx memory add failed\n",
>>>
>>>
>>
>> Why do we need the MHP_SPLIT_MEMBLOCKS?
>
> I thought we still wanted either an opt-in or opt-out for the kmem
> driver to be able to do memmap_on_memory, in case there were
> performance implications or the lack of 1GiB PUDs. I haven't
> implemented that yet, but I was thinking along the lines of a sysfs
> knob exposed by kmem, that controls setting of this new
> MHP_SPLIT_MEMBLOCKS flag.
Why is MHP_MEMMAP_ON_MEMORY not sufficient for that?
>
>>
>> In add_memory_driver_managed(), if memmap_on_memory = 1 AND is effective for a
>> single memory block, you can simply split up internally, no?
>>
>> Essentially in add_memory_resource() something like
>>
>> if (mhp_flags & MHP_MEMMAP_ON_MEMORY &&
>> mhp_supports_memmap_on_memory(memory_block_size_bytes())) {
>> for (cur_start = start, cur_start < start + size;
>> cur_start += memory_block_size_bytes()) {
>> mhp_altmap.free = PHYS_PFN(memory_block_size_bytes());
>> mhp_altmap.base_pfn = PHYS_PFN(start);
>> params.altmap = &mhp_altmap;
>>
>> ret = arch_add_memory(nid, start,
>> memory_block_size_bytes(), ¶ms);
>> if (ret < 0) ...
>>
>> ret = create_memory_block_devices(start, memory_block_size_bytes(),
>> mhp_altmap.alloc, group);
>> if (ret) ...
>>
>> }
>> } else {
>> /* old boring stuff */
>> }
>>
>> Of course, doing it a bit cleaner, factoring out adding of mem+creating devices into
>> a helper so we can use it on the other path, avoiding repeating memory_block_size_bytes()
>> ...
>
> My current approach was looping a level higher, on the call to
> add_memory_resource, but this looks reasonable too, and I can switch to
> this. In fact it is better as in my case I had to loop twice, once for
> the regular add_memory() path and once for the _driver_managed() path.
> Yours should avoid that.
As we only care about the altmap here, handling it for arch_add_memory()
+ create_memory_block_devices() should be sufficient.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2023-07-13 15:23 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 22:00 [PATCH 0/3] mm: use memmap_on_memory semantics for dax/kmem Vishal Verma
2023-06-15 22:00 ` [PATCH 1/3] mm/memory_hotplug: Allow an override for the memmap_on_memory param Vishal Verma
2023-06-16 6:35 ` Huang, Ying
2023-06-16 7:46 ` David Hildenbrand
2023-06-22 13:37 ` Jonathan Cameron
2023-06-23 8:40 ` Aneesh Kumar K.V
2023-06-23 12:35 ` David Hildenbrand
2023-06-15 22:00 ` [PATCH 2/3] mm/memory_hotplug: Export symbol mhp_supports_memmap_on_memory() Vishal Verma
2023-06-16 7:47 ` David Hildenbrand
2023-06-15 22:00 ` [PATCH 3/3] dax/kmem: Always enroll hotplugged memory for memmap_on_memory Vishal Verma
2023-06-16 6:42 ` Huang, Ying
2023-06-16 7:54 ` David Hildenbrand
2023-07-11 14:30 ` Aneesh Kumar K.V
2023-07-11 15:21 ` David Hildenbrand
2023-07-13 6:45 ` Verma, Vishal L
2023-07-13 7:23 ` David Hildenbrand
2023-07-13 15:15 ` Verma, Vishal L
2023-07-13 15:23 ` David Hildenbrand [this message]
2023-07-13 15:40 ` Verma, Vishal L
2023-07-13 15:43 ` David Hildenbrand
2023-06-20 13:14 ` Tarun Sahu
2023-06-16 7:44 ` [PATCH 0/3] mm: use memmap_on_memory semantics for dax/kmem David Hildenbrand
2023-06-21 19:32 ` Verma, Vishal L
2023-06-22 13:55 ` David Hildenbrand
2023-07-13 19:12 ` Jeff Moyer
2023-07-14 8:35 ` David Hildenbrand
2023-07-14 13:54 ` Jeff Moyer
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=80c8654e-21fb-b187-3475-9a1410a53a4e@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
--cc=vishal.l.verma@intel.com \
--cc=ying.huang@intel.com \
/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