* [PATCH 2/4] drm/amdkfd: Don't create crat memory sub-table if node has no memory
2021-06-01 19:07 [PATCH 1/4] drm/amdkfd: Create node in kfd sysfs for memory only numa node Oak Zeng
@ 2021-06-01 19:07 ` Oak Zeng
0 siblings, 0 replies; 2+ messages in thread
From: Oak Zeng @ 2021-06-01 19:07 UTC (permalink / raw
To: amd-gfx; +Cc: jinhuieric.huang, felix.kuehling, Oak Zeng
In some configuration, there is CPU-only (no memory) numa node. Don't
create crat memory sub-table for such node.
Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index 56e6dff..dd7772c 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -1583,7 +1583,8 @@ static int kfd_fill_cu_for_cpu(int numa_node_id, int *avail_size,
* @avail_size: Available size in the memory
* @sub_type_hdr: Memory into which compute info will be filled in
*
- * Return 0 if successful else return -ve value
+ * Return memory size in bytes if successful else return -ve value
+ * Returning 0 means this numa node has no memory
*/
static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
int proximity_domain,
@@ -1619,7 +1620,7 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
sub_type_hdr->length_high = upper_32_bits(mem_in_bytes);
sub_type_hdr->proximity_domain = proximity_domain;
- return 0;
+ return mem_in_bytes;
}
#ifdef CONFIG_X86_64
@@ -1746,11 +1747,15 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
pr_err("fill mem for cpu failed\n");
return ret;
}
- crat_table->length += sub_type_hdr->length;
- crat_table->total_entries++;
- sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
- sub_type_hdr->length);
+ /* ret == 0: this node has no memory */
+ if (ret > 0) {
+ crat_table->length += sub_type_hdr->length;
+ crat_table->total_entries++;
+
+ sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
+ sub_type_hdr->length);
+ }
if (kfd_numa_node_to_apic_id(numa_node_id) != -1) {
/* Fill in Subtype: IO Link */
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/4] drm/amdkfd: Don't create crat memory sub-table if node has no memory
@ 2021-06-01 19:38 Oak Zeng
0 siblings, 0 replies; 2+ messages in thread
From: Oak Zeng @ 2021-06-01 19:38 UTC (permalink / raw
To: amd-gfx; +Cc: jinhuieric.huang, felix.kuehling, Oak Zeng
In some configuration, there is CPU-only (no memory) numa node. Don't
create crat memory sub-table for such node.
Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
index 56e6dff..420a312 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
@@ -1583,7 +1583,9 @@ static int kfd_fill_cu_for_cpu(int numa_node_id, int *avail_size,
* @avail_size: Available size in the memory
* @sub_type_hdr: Memory into which compute info will be filled in
*
- * Return 0 if successful else return -ve value
+ * Return 0 if successful
+ * Return -ENOMEM if not enough space in caller allocated crat table
+ * Return -1 if this numa node has no memory
*/
static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
int proximity_domain,
@@ -1615,6 +1617,9 @@ static int kfd_fill_mem_info_for_cpu(int numa_node_id, int *avail_size,
mem_in_bytes += zone_managed_pages(&pgdat->node_zones[zone_type]);
mem_in_bytes <<= PAGE_SHIFT;
+ if (mem_in_bytes == 0)
+ return -1;
+
sub_type_hdr->length_low = lower_32_bits(mem_in_bytes);
sub_type_hdr->length_high = upper_32_bits(mem_in_bytes);
sub_type_hdr->proximity_domain = proximity_domain;
@@ -1742,15 +1747,19 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
ret = kfd_fill_mem_info_for_cpu(numa_node_id, &avail_size,
crat_table->num_domains,
(struct crat_subtype_memory *)sub_type_hdr);
- if (ret < 0) {
+ if (ret == -ENOMEM) {
pr_err("fill mem for cpu failed\n");
return ret;
}
- crat_table->length += sub_type_hdr->length;
- crat_table->total_entries++;
- sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
- sub_type_hdr->length);
+ /* ret == -1: this node has no memory */
+ if (ret == 0) {
+ crat_table->length += sub_type_hdr->length;
+ crat_table->total_entries++;
+
+ sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
+ sub_type_hdr->length);
+ }
if (kfd_numa_node_to_apic_id(numa_node_id) != -1) {
/* Fill in Subtype: IO Link */
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-01 19:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-01 19:38 [PATCH 2/4] drm/amdkfd: Don't create crat memory sub-table if node has no memory Oak Zeng
-- strict thread matches above, loose matches on Subject: below --
2021-06-01 19:07 [PATCH 1/4] drm/amdkfd: Create node in kfd sysfs for memory only numa node Oak Zeng
2021-06-01 19:07 ` [PATCH 2/4] drm/amdkfd: Don't create crat memory sub-table if node has no memory Oak Zeng
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 read-only IMAP folder(s) and NNTP newsgroup(s).