mbox series

[v3,0/5] drm/v3d: Fix GPU stats inconsistencies and race-condition

Message ID 20240420213632.339941-2-mcanal@igalia.com (mailing list archive)
Headers show
Series drm/v3d: Fix GPU stats inconsistencies and race-condition | expand

Message

Maíra Canal April 20, 2024, 9:32 p.m. UTC
The first version of this series had the intention to fix two major
issues with the GPU stats:

1. We were incrementing `enabled_ns` twice by the end of each job.
2. There is a race-condition between the IRQ handler and the users

The first of the issues was already addressed and the fix was applied to
drm-misc-fixes. Now, what is left, addresses the second issue.

Apart from addressing this issue, this series improved the GPU stats
code as a whole. We reduced code repetition, creating functions to start and
update the GPU stats. This will likely reduce the odds of issue #1 happen again.

v1 -> v2: https://lore.kernel.org/dri-devel/20240403203517.731876-1-mcanal@igalia.com/T/

- As the first patch was a bugfix, it was pushed to drm-misc-fixes.
- [1/4] Add Chema Casanova's R-b
- [2/4] s/jobs_sent/jobs_completed and add the reasoning in the commit message
				(Chema Casanova)
- [2/4] Add Chema Casanova's and Tvrtko Ursulin's R-b
- [3/4] Call `local_clock()` only once, by adding a new parameter to the
				`v3d_stats_update` function (Chema Casanova)
- [4/4] Move new line to the correct patch [2/4] (Tvrtko Ursulin)
- [4/4] Use `seqcount_t` as locking primitive instead of a `rw_lock` (Tvrtko Ursulin)

v2 -> v3: https://lore.kernel.org/dri-devel/20240417011021.600889-1-mcanal@igalia.com/T/

- [4/5] New patch: separates the code refactor from the race-condition fix (Tvrtko Ursulin)
- [5/5] s/interruption/interrupt (Tvrtko Ursulin)
- [5/5] s/matches/match (Tvrtko Ursulin)
- [5/5] Add Tvrtko Ursulin's R-b

Best Regards,
- Maíra

Maíra Canal (5):
  drm/v3d: Create two functions to update all GPU stats variables
  drm/v3d: Create a struct to store the GPU stats
  drm/v3d: Create function to update a set of GPU stats
  drm/v3d: Decouple stats calculation from printing
  drm/v3d: Fix race-condition between sysfs/fdinfo and interrupt handler

 drivers/gpu/drm/v3d/v3d_drv.c   | 33 ++++++++----
 drivers/gpu/drm/v3d/v3d_drv.h   | 30 ++++++++---
 drivers/gpu/drm/v3d/v3d_gem.c   |  9 ++--
 drivers/gpu/drm/v3d/v3d_irq.c   | 48 ++---------------
 drivers/gpu/drm/v3d/v3d_sched.c | 94 +++++++++++++++++----------------
 drivers/gpu/drm/v3d/v3d_sysfs.c | 13 ++---
 6 files changed, 109 insertions(+), 118 deletions(-)

Comments

Maíra Canal April 22, 2024, 4:08 p.m. UTC | #1
Hi,

@drm-misc maintainers, is there any chance you could backport commit
35f4f8c9fc97 ("drm/v3d: Don't increment `enabled_ns` twice") [1] to drm-
misc-next?

I would like to apply this series to drm-misc-next because it fixes
another issue with the GPU stats, but this series depends on commit
35f4f8c9fc97, as it has plenty of refactors on the GPU stats code.

Although I could theoretically apply this series in drm-misc-fixes, I
don't believe it would be ideal, as discussed in #dri-devel earlier
today.

[1] 
https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/35f4f8c9fc972248055096d63b782060e473311b

Best Regards,
- Maíra

On 4/20/24 18:32, Maíra Canal wrote:
> The first version of this series had the intention to fix two major
> issues with the GPU stats:
> 
> 1. We were incrementing `enabled_ns` twice by the end of each job.
> 2. There is a race-condition between the IRQ handler and the users
> 
> The first of the issues was already addressed and the fix was applied to
> drm-misc-fixes. Now, what is left, addresses the second issue.
> 
> Apart from addressing this issue, this series improved the GPU stats
> code as a whole. We reduced code repetition, creating functions to start and
> update the GPU stats. This will likely reduce the odds of issue #1 happen again.
> 
> v1 -> v2: https://lore.kernel.org/dri-devel/20240403203517.731876-1-mcanal@igalia.com/T/
> 
> - As the first patch was a bugfix, it was pushed to drm-misc-fixes.
> - [1/4] Add Chema Casanova's R-b
> - [2/4] s/jobs_sent/jobs_completed and add the reasoning in the commit message
> 				(Chema Casanova)
> - [2/4] Add Chema Casanova's and Tvrtko Ursulin's R-b
> - [3/4] Call `local_clock()` only once, by adding a new parameter to the
> 				`v3d_stats_update` function (Chema Casanova)
> - [4/4] Move new line to the correct patch [2/4] (Tvrtko Ursulin)
> - [4/4] Use `seqcount_t` as locking primitive instead of a `rw_lock` (Tvrtko Ursulin)
> 
> v2 -> v3: https://lore.kernel.org/dri-devel/20240417011021.600889-1-mcanal@igalia.com/T/
> 
> - [4/5] New patch: separates the code refactor from the race-condition fix (Tvrtko Ursulin)
> - [5/5] s/interruption/interrupt (Tvrtko Ursulin)
> - [5/5] s/matches/match (Tvrtko Ursulin)
> - [5/5] Add Tvrtko Ursulin's R-b
> 
> Best Regards,
> - Maíra
> 
> Maíra Canal (5):
>    drm/v3d: Create two functions to update all GPU stats variables
>    drm/v3d: Create a struct to store the GPU stats
>    drm/v3d: Create function to update a set of GPU stats
>    drm/v3d: Decouple stats calculation from printing
>    drm/v3d: Fix race-condition between sysfs/fdinfo and interrupt handler
> 
>   drivers/gpu/drm/v3d/v3d_drv.c   | 33 ++++++++----
>   drivers/gpu/drm/v3d/v3d_drv.h   | 30 ++++++++---
>   drivers/gpu/drm/v3d/v3d_gem.c   |  9 ++--
>   drivers/gpu/drm/v3d/v3d_irq.c   | 48 ++---------------
>   drivers/gpu/drm/v3d/v3d_sched.c | 94 +++++++++++++++++----------------
>   drivers/gpu/drm/v3d/v3d_sysfs.c | 13 ++---
>   6 files changed, 109 insertions(+), 118 deletions(-)
>
Maxime Ripard April 23, 2024, 7:05 a.m. UTC | #2
Hi,

On Mon, Apr 22, 2024 at 01:08:44PM -0300, Maíra Canal wrote:
> @drm-misc maintainers, is there any chance you could backport commit
> 35f4f8c9fc97 ("drm/v3d: Don't increment `enabled_ns` twice") [1] to drm-
> misc-next?
> 
> I would like to apply this series to drm-misc-next because it fixes
> another issue with the GPU stats, but this series depends on commit
> 35f4f8c9fc97, as it has plenty of refactors on the GPU stats code.
> 
> Although I could theoretically apply this series in drm-misc-fixes, I
> don't believe it would be ideal, as discussed in #dri-devel earlier
> today.
> 
> [1] https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/35f4f8c9fc972248055096d63b782060e473311b

I just did the backmerge

Maxime
Maíra Canal April 23, 2024, 11:09 p.m. UTC | #3
On 4/23/24 04:05, Maxime Ripard wrote:
> Hi,
> 
> On Mon, Apr 22, 2024 at 01:08:44PM -0300, Maíra Canal wrote:
>> @drm-misc maintainers, is there any chance you could backport commit
>> 35f4f8c9fc97 ("drm/v3d: Don't increment `enabled_ns` twice") [1] to drm-
>> misc-next?
>>
>> I would like to apply this series to drm-misc-next because it fixes
>> another issue with the GPU stats, but this series depends on commit
>> 35f4f8c9fc97, as it has plenty of refactors on the GPU stats code.
>>
>> Although I could theoretically apply this series in drm-misc-fixes, I
>> don't believe it would be ideal, as discussed in #dri-devel earlier
>> today.
>>
>> [1] https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/35f4f8c9fc972248055096d63b782060e473311b
> 
> I just did the backmerge

Thanks Maxime! I just applied the series to drm-misc/drm-misc-next.

Thanks for drm-misc maintainers for the quick action!

Best Regards,
- Maíra

> 
> Maxime