From: Dan Williams <dan.j.williams@intel.com>
To: D Scott Phillips <scott@os.amperecomputing.com>,
Dan Williams <dan.j.williams@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
AKASHI Takahiro <takahiro.akashi@linaro.org>,
Alison Schofield <alison.schofield@intel.com>,
Baoquan He <bhe@redhat.com>,
Catalin Marinas <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
<patches@amperecomputing.com>,
"Felix Kuehling" <Felix.Kuehling@amd.com>,
<amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v2] resource: limit request_free_mem_region based on arch_get_mappable_range
Date: Wed, 28 Aug 2024 17:08:40 -0700 [thread overview]
Message-ID: <66cfbc08a457f_473472946a@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <86cyltjqwy.fsf@scott-ph-mail.amperecomputing.com>
D Scott Phillips wrote:
[..]
> Hi Dan, sorry for my incredibly delayed response, I lost your message to
> a filter on my end :(
>
> I'm happy to work toward your preferred approach here, though I'm not
> sure I know how to achieve it. I think I understand how cxl is keeping
> device_private_memory out, but I don't think I understand the resource
> system well enough to see how amdgpu can make a properly trimmed
> resource for request_free_mem_region. My novice attempt would be
> something like:
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> index 8ee3d07ffbdfa..d84de6d66ac45 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c
> @@ -1038,7 +1039,14 @@ int kgd2kfd_init_zone_device(struct amdgpu_device *adev)
> pgmap->range.end = adev->gmc.aper_base + adev->gmc.aper_size - 1;
> pgmap->type = MEMORY_DEVICE_COHERENT;
> } else {
> - res = devm_request_free_mem_region(adev->dev, &iomem_resource, size);
> + struct range mappable;
> + struct resource root;
> +
> + mappable = arch_get_mappable_range();
> + root.start = mappable.start;
> + root.end = mappable.end;
> + root.child = iomem_resource.child;
> + res = devm_request_free_mem_region(adev->dev, &root, size);
> if (IS_ERR(res))
> return PTR_ERR(res);
> pgmap->range.start = res->start;
>
> Apart from this being wrong with respect to resource_lock, is that sort
> of the idea? or am I missing the sensible way to hoist the vmemmap range
> into iomem_resource? or maybe I'm just totally off in the weeds.
You have the right idea, however, I think a better solution has appeared
in the meantime. See this recent fix from Thomas regarding collisions
between KASLR and request_free_mem_region():
http://lore.kernel.org/172418629773.2215.4158024254077335422.tip-bot2@tip-bot2
...in that case KASLR is limiting the maximum possible usable address
range that request_free_mem_region() can play. For this
arch_get_mappable_range() restriction can you adjust the new
@physmem_end variable for the same effect?
next prev parent reply other threads:[~2024-08-29 0:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 0:27 [PATCH v2] resource: limit request_free_mem_region based on arch_get_mappable_range D Scott Phillips
2024-07-09 1:31 ` Dan Williams
2024-08-28 2:57 ` D Scott Phillips
2024-08-29 0:08 ` Dan Williams [this message]
2024-08-29 17:19 ` D Scott Phillips
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=66cfbc08a457f_473472946a@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Felix.Kuehling@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhe@redhat.com \
--cc=catalin.marinas@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@amperecomputing.com \
--cc=scott@os.amperecomputing.com \
--cc=takahiro.akashi@linaro.org \
--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