drm/amdgpu: Rework coredump memory allocation
Subsystems (2)
v6 cover drm/amdgpu: Rework coredump memory allocation
Hi,
The patches of this set are a rework to alloc devcoredump dynamically and to move it to a better source file.
Thanks,
André
Changelog:
v5: https://lore.kernel.org/lkml/[email protected]/
- Added Shashank Sharma R-b tag
v4: https://lore.kernel.org/dri-devel/[email protected]/
- New patch to encapsulate all reset info in a struct
v3: https://lore.kernel.org/dri-devel/[email protected]/
- Changed from kmalloc to kzalloc
- Dropped "Create a module param to disable soft recovery" for now
v2: https://lore.kernel.org/dri-devel/[email protected]/
- Drop the IB and ring patch
- Drop patch that limited information from kernel threads
- Add patch to move coredump to amdgpu_reset
v1: https://lore.kernel.org/dri-devel/[email protected]/
- Drop "Mark contexts guilty for causing soft recoveries" patch
- Use GFP_NOWAIT for devcoredump allocatio
André Almeida (5):
drm/amdgpu: Allocate coredump memory in a nonblocking way drm/amdgpu: Rework coredump to use memory dynamically drm/amdgpu: Encapsulate all device reset info drm/amdgpu: Move coredump code to amdgpu_reset file drm/amdgpu: Create version number for coredumps
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 21 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 10 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 75 ++------------------ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 77 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 13 ++++ 5 files changed, 114 insertions(+), 82 deletions(-)
Signature · 1 line
2.42.0
PATCH v6 1/5 drm/amdgpu: Allocate coredump memory in a nonblocking way
During a GPU reset, a normal memory reclaim could block to reclaim memory. Giving that coredump is a best effort mechanism, it shouldn't disturb the reset path. Change its memory allocation flag to a nonblocking one.
---
v5: no change
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -4847,7 +4847,7 @@ static void amdgpu_reset_capture_coredumpm(struct amdgpu_device *adev)struct drm_device *dev =adev_to_drm (adev);ktime_get_ts64 (&adev->reset_time); -dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_KERNEL , +dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_NOWAIT , amdgpu_devcoredump_read, amdgpu_devcoredump_free); }#endif
Signature · 1 line
2.42.0
Christian König
maintainerRe: [PATCH v6 1/5] drm/amdgpu: Allocate coredump memory in a nonblocking way
Am 11.09.23 um 05:00 schrieb André Almeida:
Quoted 4 lines
During a GPU reset, a normal memory reclaim could block to reclaim memory. Giving that coredump is a best effort mechanism, it shouldn't disturb the reset path. Change its memory allocation flag to a nonblocking one.
Since it is a bug fix I've already pushed this one into our internal branch quite a while ago.
Shashank can you take care of picking up the remaining patches and pushing them to amd-staging-drm-next?
Thanks,
Christian.
Quoted 22 lines
Signed-off-by André Almeida <[email protected]>Reviewed-by Christian König <[email protected]>---
v5: no change--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -4847,7 +4847,7 @@ static void amdgpu_reset_capture_coredumpm(struct amdgpu_device *adev)struct drm_device *dev =adev_to_drm (adev);ktime_get_ts64 (&adev->reset_time); -dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_KERNEL , +dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_NOWAIT , amdgpu_devcoredump_read, amdgpu_devcoredump_free); }#endif
RE: [PATCH v6 1/5] drm/amdgpu: Allocate coredump memory in a nonblocking way
[AMD Official Use Only - General]
Hey Christian,
Will do that.
Regards
Shashank
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Monday, September 11, 2023 1:15 PM
To: André Almeida <[email protected]>; [email protected]; [email protected]; [email protected]; Sharma, Shashank <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Pelloux-Prayer, Pierre-Eric <[email protected]>
Subject: Re: [PATCH v6 1/5] drm/amdgpu: Allocate coredump memory in a nonblocking way
Am 11.09.23 um 05:00 schrieb André Almeida:
Quoted 4 lines
During a GPU reset, a normal memory reclaim could block to reclaim memory. Giving that coredump is a best effort mechanism, it shouldn't disturb the reset path. Change its memory allocation flag to a nonblocking one.
Since it is a bug fix I've already pushed this one into our internal branch quite a while ago.
Shashank can you take care of picking up the remaining patches and pushing them to amd-staging-drm-next?
Thanks,
Christian.
Quoted 23 lines
Signed-off-by André Almeida <[email protected]>Reviewed-by Christian König <[email protected]>---
v5: no change--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -4847,7 +4847,7 @@ static void amdgpu_reset_capture_coredumpm(struct amdgpu_device *adev)struct drm_device *dev =adev_to_drm (adev);ktime_get_ts64 (&adev->reset_time); -dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_KERNEL , +dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_NOWAIT , amdgpu_devcoredump_read, amdgpu_devcoredump_free); }#endif
RE: [PATCH v6 1/5] drm/amdgpu: Allocate coredump memory in a nonblocking way
In reply to Christian König[AMD Official Use Only - General]
Pushed the rest of the patches in the series to amd-staging-drm-next.
Regards
Shashank
-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Monday, September 11, 2023 1:15 PM
To: André Almeida <[email protected]>; [email protected]; [email protected]; [email protected]; Sharma, Shashank <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Pelloux-Prayer, Pierre-Eric <[email protected]>
Subject: Re: [PATCH v6 1/5] drm/amdgpu: Allocate coredump memory in a nonblocking way
Am 11.09.23 um 05:00 schrieb André Almeida:
Quoted 4 lines
During a GPU reset, a normal memory reclaim could block to reclaim memory. Giving that coredump is a best effort mechanism, it shouldn't disturb the reset path. Change its memory allocation flag to a nonblocking one.
Since it is a bug fix I've already pushed this one into our internal branch quite a while ago.
Shashank can you take care of picking up the remaining patches and pushing them to amd-staging-drm-next?
Thanks,
Christian.
Quoted 23 lines
Signed-off-by André Almeida <[email protected]>Reviewed-by Christian König <[email protected]>---
v5: no change--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1
-1@@ -4847,7 +4847,7 @@ static void amdgpu_reset_capture_coredumpm(struct amdgpu_device *adev)struct drm_device *dev =adev_to_drm (adev);ktime_get_ts64 (&adev->reset_time); -dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_KERNEL , +dev_coredumpm (dev->dev,THIS_MODULE , adev,0 ,GFP_NOWAIT , amdgpu_devcoredump_read, amdgpu_devcoredump_free); }#endif
PATCH v6 2/5 drm/amdgpu: Rework coredump to use memory dynamically
In reply to André AlmeidaInstead of storing coredump information inside amdgpu_device struct, move if to a proper separated struct and allocate it dynamically. This will make it easier to further expand the logged information.
---
v6: no change
v5: no change
v4: change kmalloc to kzalloc
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 14 +++-- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 63 ++++++++++++++-------- 2 files changed, 49 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +9 -5
@@ -1088,11 +1088,6 @@ struct amdgpu_device {uint32_t *reset_dump_reg_list;uint32_t *reset_dump_reg_value;int num_regs; -#ifdef CONFIG_DEV_COREDUMP -struct amdgpu_task_info reset_task_info; -bool reset_vram_lost; -struct timespec64 reset_time; -#endif bool scpm_enabled;uint32_t scpm_status;
@@ -1105,6 +1100,15 @@ struct amdgpu_device {uint32_t aid_mask; }; +#ifdef CONFIG_DEV_COREDUMP +struct amdgpu_coredump_info { +struct amdgpu_device *adev; +struct amdgpu_task_info reset_task_info; +struct timespec64 reset_time; +bool reset_vram_lost; +}; +#endif +static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev) { return container_of(ddev, struct amdgpu_device, ddev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +40 -23
102 lines not on this page · raw message
Signature · 1 line
2.42.0
PATCH v6 3/5 drm/amdgpu: Encapsulate all device reset info
In reply to André AlmeidaTo better organize struct amdgpu_device, keep all reset information related fields together in a separated struct.
---
v6: no changes
v5: new patch, as required by Shashank Sharma
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 34 +++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 10 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 +++++----- 3 files changed, 34 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +21 -13
@@ -781,6 +781,26 @@ struct amdgpu_mqd {#define AMDGPU_PRODUCT_NAME_LEN 64struct amdgpu_reset_domain ; +#ifdef CONFIG_DEV_COREDUMP +struct amdgpu_coredump_info { +struct amdgpu_device *adev; +struct amdgpu_task_info reset_task_info; +struct timespec64 reset_time; +bool reset_vram_lost; +}; +#endif + +struct amdgpu_reset_info { +/* reset dump register */ +u32 *reset_dump_reg_list; +u32 *reset_dump_reg_value; +int num_regs; + +#ifdef CONFIG_DEV_COREDUMP +struct amdgpu_coredump_info *coredump_info; +#endif +}; +/* * Non-zero (true) if the GPU has VRAM. Zero (false) otherwise. */
@@ -1084,10 +1104,7 @@ struct amdgpu_device {struct mutex benchmark_mutex; -/* reset dump register */ -uint32_t *reset_dump_reg_list; -uint32_t *reset_dump_reg_value; -int num_regs; +struct amdgpu_reset_info reset_info;bool scpm_enabled;uint32_t scpm_status;
@@ -1100,15 +1117,6 @@ struct amdgpu_device {uint32_t aid_mask; }; -#ifdef CONFIG_DEV_COREDUMP -struct amdgpu_coredump_info { -struct amdgpu_device *adev; -struct amdgpu_task_info reset_task_info; -struct timespec64 reset_time; -bool reset_vram_lost; -}; -#endif -static inline struct amdgpu_device *drm_to_adev (struct drm_device *ddev) { return container_of(ddev, struct amdgpu_device, ddev);
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +5 -5
@@ -2016,8 +2016,8 @@ static ssize_t amdgpu_reset_dump_register_list_read(struct file *f,if (ret)return ret; -for (i =0 ; i < adev->num_regs; i++) { -sprintf (reg_offset,"0x%x\n" , adev->reset_dump_reg_list[i]); +for (i =0 ; i < adev->reset_info.num_regs; i++) { +sprintf (reg_offset,"0x%x\n" , adev->reset_info.reset_dump_reg_list[i]);up_read (&adev->reset_domain->sem);if (copy_to_user (buf + len, reg_offset,strlen (reg_offset)))return -EFAULT ;
@@ -2074,9 +2074,9 @@ static ssize_t amdgpu_reset_dump_register_list_write(struct file *f,if (ret) goto error_free; -swap (adev->reset_dump_reg_list, tmp); -swap (adev->reset_dump_reg_value, new); - adev->num_regs = i; +swap (adev->reset_info.reset_dump_reg_list, tmp); +swap (adev->reset_info.reset_dump_reg_value, new); + adev->reset_info.num_regs = i;up_write (&adev->reset_domain->sem); ret = size;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -8
@@ -4790,10 +4790,10 @@ static int amdgpu_reset_reg_dumps(struct amdgpu_device *adev)lockdep_assert_held (&adev->reset_domain->sem); -for (i =0 ; i < adev->num_regs; i++) { - adev->reset_dump_reg_value[i] =RREG32 (adev->reset_dump_reg_list[i]); -trace_amdgpu_reset_reg_dumps (adev->reset_dump_reg_list[i], - adev->reset_dump_reg_value[i]); +for (i =0 ; i < adev->reset_info.num_regs; i++) { + adev->reset_info.reset_dump_reg_value[i] =RREG32 (adev->reset_info.reset_dump_reg_list[i]); +trace_amdgpu_reset_reg_dumps (adev->reset_info.reset_dump_reg_list[i], + adev->reset_info.reset_dump_reg_value[i]); }return 0 ;
@@ -4831,13 +4831,13 @@ static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset,if (coredump->reset_vram_lost)drm_printf (&p,"VRAM is lost due to GPU reset!\n" ); -if (coredump->adev->num_regs) { +if (coredump->adev->reset_info.num_regs) {drm_printf (&p,"AMDGPU register dumps:\nOffset: Value:\n" ); -for (i =0 ; i < coredump->adev->num_regs; i++) +for (i =0 ; i < coredump->adev->reset_info.num_regs; i++)drm_printf (&p,"0x%08x: 0x%08x\n" , - coredump->adev->reset_dump_reg_list[i], - coredump->adev->reset_dump_reg_value[i]); + coredump->adev->reset_info.reset_dump_reg_list[i], + coredump->adev->reset_info.reset_dump_reg_value[i]); }return count - iter.remain;
Signature · 1 line
2.42.0
PATCH v6 4/5 drm/amdgpu: Move coredump code to amdgpu_reset file
In reply to André AlmeidaGiving that we use codedump just for device resets, move it's functions and structs to a more semantic file, the amdgpu_reset.{c, h}.
---
v6: no change
v5: no change
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 78 ---------------------- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 76 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 10 +++ 4 files changed, 86 insertions(+), 87 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -9
@@ -781,15 +781,6 @@ struct amdgpu_mqd {#define AMDGPU_PRODUCT_NAME_LEN 64struct amdgpu_reset_domain ; -#ifdef CONFIG_DEV_COREDUMP -struct amdgpu_coredump_info { -struct amdgpu_device *adev; -struct amdgpu_task_info reset_task_info; -struct timespec64 reset_time; -bool reset_vram_lost; -}; -#endif -struct amdgpu_reset_info {/* reset dump register */ u32 *reset_dump_reg_list;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -78
90 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +76 -0
87 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +10 -0
@@ -87,6 +87,14 @@ struct amdgpu_reset_domain {atomic_t reset_res; }; +#ifdef CONFIG_DEV_COREDUMP +struct amdgpu_coredump_info { +struct amdgpu_device *adev; +struct amdgpu_task_info reset_task_info; +struct timespec64 reset_time; +bool reset_vram_lost; +}; +#endif int amdgpu_reset_init (struct amdgpu_device *adev);int amdgpu_reset_fini (struct amdgpu_device *adev);
@@ -126,4 +134,6 @@ void amdgpu_device_lock_reset_domain(struct amdgpu_reset_domain *reset_domain);void amdgpu_device_unlock_reset_domain (struct amdgpu_reset_domain *reset_domain); +void amdgpu_coredump (struct amdgpu_device *adev,bool vram_lost, +struct amdgpu_reset_context *reset_context);#endif
Signature · 1 line
2.42.0
PATCH v6 5/5 drm/amdgpu: Create version number for coredumps
In reply to André AlmeidaEven if there's nothing currently parsing amdgpu's coredump files, if we eventually have such tools they will be glad to find a version field to properly read the file.
Create a version number to be displayed on top of coredump file, to be incremented when the file format or content get changed.
---
v6: no change
--- drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 +++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c +1 -0
@@ -192,6 +192,7 @@ static ssize_t amdgpu_devcoredump_read(char *buffer, loff_t offset, p =drm_coredump_printer (&iter);drm_printf (&p,"**** AMDGPU Device Coredump ****\n" ); +drm_printf (&p,"version: " AMDGPU_COREDUMP_VERSION "\n" );drm_printf (&p,"kernel: " UTS_RELEASE "\n" );drm_printf (&p,"module: " KBUILD_MODNAME "\n" );drm_printf (&p,"time: %lld.%09ld\n" , coredump->reset_time.tv_sec, coredump->reset_time.tv_nsec);
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h +3 -0
@@ -88,6 +88,9 @@ struct amdgpu_reset_domain { }; #ifdef CONFIG_DEV_COREDUMP + +#define AMDGPU_COREDUMP_VERSION "1" + struct amdgpu_coredump_info { struct amdgpu_device *adev; struct amdgpu_task_info reset_task_info;
Signature · 1 line
2.42.0