* [PATCH] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
@ 2022-07-27 2:59 ` Yu Zhe
0 siblings, 0 replies; 10+ messages in thread
From: Yu Zhe @ 2022-07-27 2:59 UTC (permalink / raw)
To: Felix.Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
airlied, daniel
Cc: Yu Zhe, kernel-janitors, linux-kernel, dri-devel, liqiong, amd-gfx
time_is_before_jiffies deals with timer wrapping correctly.
Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
index a9466d154395..6397926e059c 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
@@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
dev->device_info.event_interrupt_class->interrupt_wq(dev,
ih_ring_entry);
- if (jiffies - start_jiffies > HZ) {
+ if (time_is_before_jiffies(start_jiffies + HZ)) {
/* If we spent more than a second processing signals,
* reschedule the worker to avoid soft-lockup warnings
*/
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
2022-07-27 2:59 ` Yu Zhe
@ 2022-07-27 16:04 ` Felix Kuehling
-1 siblings, 0 replies; 10+ messages in thread
From: Felix Kuehling @ 2022-07-27 16:04 UTC (permalink / raw)
To: Yu Zhe, alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel
Cc: amd-gfx, dri-devel, linux-kernel, kernel-janitors, liqiong
This patch introduces a build warning for me:
CC [M] drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.o
In file included from /home/fkuehlin/compute/kernel/include/linux/spinlock.h:54,
from /home/fkuehlin/compute/kernel/include/linux/mmzone.h:8,
from /home/fkuehlin/compute/kernel/include/linux/gfp.h:6,
from /home/fkuehlin/compute/kernel/include/linux/slab.h:15,
from /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:44:
/home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c: In function ?interrupt_wq?:
/home/fkuehlin/compute/kernel/include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
12 | (void)(&__dummy == &__dummy2); \
| ^~
/home/fkuehlin/compute/kernel/include/linux/jiffies.h:106:3: note: in expansion of macro ?typecheck?
106 | typecheck(unsigned long, b) && \
| ^~~~~~~~~
/home/fkuehlin/compute/kernel/include/linux/jiffies.h:154:35: note: in expansion of macro ?time_after?
154 | #define time_is_before_jiffies(a) time_after(jiffies, a)
| ^~~~~~~~~~
/home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:159:7: note: in expansion of macro ?time_is_before_jiffies?
159 | if (time_is_before_jiffies(start_jiffies + HZ)) {
| ^~~~~~~~~~~~~~~~~~~~~~
I think you need to change the the definition of start_jiffies to be
unsigned long. Do you want to submit a v2 of your patch?
That said, I think the existing code was fine, though the type-mismatch
highlighted by your patch is a bit iffy.
Regards,
Felix
Am 2022-07-26 um 22:59 schrieb Yu Zhe:
> time_is_before_jiffies deals with timer wrapping correctly.
>
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> index a9466d154395..6397926e059c 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> @@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
> while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
> dev->device_info.event_interrupt_class->interrupt_wq(dev,
> ih_ring_entry);
> - if (jiffies - start_jiffies > HZ) {
> + if (time_is_before_jiffies(start_jiffies + HZ)) {
> /* If we spent more than a second processing signals,
> * reschedule the worker to avoid soft-lockup warnings
> */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
@ 2022-07-27 16:04 ` Felix Kuehling
0 siblings, 0 replies; 10+ messages in thread
From: Felix Kuehling @ 2022-07-27 16:04 UTC (permalink / raw)
To: Yu Zhe, alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel
Cc: liqiong, kernel-janitors, dri-devel, amd-gfx, linux-kernel
This patch introduces a build warning for me:
CC [M] drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.o
In file included from /home/fkuehlin/compute/kernel/include/linux/spinlock.h:54,
from /home/fkuehlin/compute/kernel/include/linux/mmzone.h:8,
from /home/fkuehlin/compute/kernel/include/linux/gfp.h:6,
from /home/fkuehlin/compute/kernel/include/linux/slab.h:15,
from /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:44:
/home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c: In function ?interrupt_wq?:
/home/fkuehlin/compute/kernel/include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
12 | (void)(&__dummy == &__dummy2); \
| ^~
/home/fkuehlin/compute/kernel/include/linux/jiffies.h:106:3: note: in expansion of macro ?typecheck?
106 | typecheck(unsigned long, b) && \
| ^~~~~~~~~
/home/fkuehlin/compute/kernel/include/linux/jiffies.h:154:35: note: in expansion of macro ?time_after?
154 | #define time_is_before_jiffies(a) time_after(jiffies, a)
| ^~~~~~~~~~
/home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:159:7: note: in expansion of macro ?time_is_before_jiffies?
159 | if (time_is_before_jiffies(start_jiffies + HZ)) {
| ^~~~~~~~~~~~~~~~~~~~~~
I think you need to change the the definition of start_jiffies to be
unsigned long. Do you want to submit a v2 of your patch?
That said, I think the existing code was fine, though the type-mismatch
highlighted by your patch is a bit iffy.
Regards,
Felix
Am 2022-07-26 um 22:59 schrieb Yu Zhe:
> time_is_before_jiffies deals with timer wrapping correctly.
>
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> index a9466d154395..6397926e059c 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> @@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
> while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
> dev->device_info.event_interrupt_class->interrupt_wq(dev,
> ih_ring_entry);
> - if (jiffies - start_jiffies > HZ) {
> + if (time_is_before_jiffies(start_jiffies + HZ)) {
> /* If we spent more than a second processing signals,
> * reschedule the worker to avoid soft-lockup warnings
> */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
2022-07-27 16:04 ` Felix Kuehling
@ 2022-07-28 2:20 ` Yu Zhe
-1 siblings, 0 replies; 10+ messages in thread
From: Yu Zhe @ 2022-07-28 2:20 UTC (permalink / raw)
To: Felix Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
airlied, daniel
Cc: amd-gfx, dri-devel, linux-kernel, kernel-janitors, liqiong
在 2022年07月28日 00:04, Felix Kuehling 写道:
> This patch introduces a build warning for me:
> CC [M] drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.o
> In file included from /home/fkuehlin/compute/kernel/include/linux/spinlock.h:54,
> from /home/fkuehlin/compute/kernel/include/linux/mmzone.h:8,
> from /home/fkuehlin/compute/kernel/include/linux/gfp.h:6,
> from /home/fkuehlin/compute/kernel/include/linux/slab.h:15,
> from /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:44:
> /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c: In function ?interrupt_wq?:
> /home/fkuehlin/compute/kernel/include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
> 12 | (void)(&__dummy == &__dummy2); \
> | ^~
> /home/fkuehlin/compute/kernel/include/linux/jiffies.h:106:3: note: in expansion of macro ?typecheck?
> 106 | typecheck(unsigned long, b) && \
> | ^~~~~~~~~
> /home/fkuehlin/compute/kernel/include/linux/jiffies.h:154:35: note: in expansion of macro ?time_after?
> 154 | #define time_is_before_jiffies(a) time_after(jiffies, a)
> | ^~~~~~~~~~
> /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:159:7: note: in expansion of macro ?time_is_before_jiffies?
> 159 | if (time_is_before_jiffies(start_jiffies + HZ)) {
> | ^~~~~~~~~~~~~~~~~~~~~~
> I think you need to change the the definition of start_jiffies to be
> unsigned long. Do you want to submit a v2 of your patch?
Yes, I will submit v2 patch later.
> That said, I think the existing code was fine, though the type-mismatch
> highlighted by your patch is a bit iffy.
And if the timer wrap changes in the future you won't have to alter your driver code. So I think it's better.
> Regards,
> Felix
> Am 2022-07-26 um 22:59 schrieb Yu Zhe:
>> time_is_before_jiffies deals with timer wrapping correctly.
>> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
>> ---
>> drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
>> index a9466d154395..6397926e059c 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
>> @@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
>> while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
>> dev->device_info.event_interrupt_class->interrupt_wq(dev,
>> ih_ring_entry);
>> - if (jiffies - start_jiffies > HZ) {
>> + if (time_is_before_jiffies(start_jiffies + HZ)) {
>> /* If we spent more than a second processing signals,
>> * reschedule the worker to avoid soft-lockup warnings
>> */
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
@ 2022-07-28 2:20 ` Yu Zhe
0 siblings, 0 replies; 10+ messages in thread
From: Yu Zhe @ 2022-07-28 2:20 UTC (permalink / raw)
To: Felix Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
airlied, daniel
Cc: liqiong, kernel-janitors, dri-devel, amd-gfx, linux-kernel
在 2022年07月28日 00:04, Felix Kuehling 写道:
> This patch introduces a build warning for me:
> CC [M] drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.o
> In file included from /home/fkuehlin/compute/kernel/include/linux/spinlock.h:54,
> from /home/fkuehlin/compute/kernel/include/linux/mmzone.h:8,
> from /home/fkuehlin/compute/kernel/include/linux/gfp.h:6,
> from /home/fkuehlin/compute/kernel/include/linux/slab.h:15,
> from /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:44:
> /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c: In function ?interrupt_wq?:
> /home/fkuehlin/compute/kernel/include/linux/typecheck.h:12:18: warning: comparison of distinct pointer types lacks a cast
> 12 | (void)(&__dummy == &__dummy2); \
> | ^~
> /home/fkuehlin/compute/kernel/include/linux/jiffies.h:106:3: note: in expansion of macro ?typecheck?
> 106 | typecheck(unsigned long, b) && \
> | ^~~~~~~~~
> /home/fkuehlin/compute/kernel/include/linux/jiffies.h:154:35: note: in expansion of macro ?time_after?
> 154 | #define time_is_before_jiffies(a) time_after(jiffies, a)
> | ^~~~~~~~~~
> /home/fkuehlin/compute/kernel/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_interrupt.c:159:7: note: in expansion of macro ?time_is_before_jiffies?
> 159 | if (time_is_before_jiffies(start_jiffies + HZ)) {
> | ^~~~~~~~~~~~~~~~~~~~~~
> I think you need to change the the definition of start_jiffies to be
> unsigned long. Do you want to submit a v2 of your patch?
Yes, I will submit v2 patch later.
> That said, I think the existing code was fine, though the type-mismatch
> highlighted by your patch is a bit iffy.
And if the timer wrap changes in the future you won't have to alter your driver code. So I think it's better.
> Regards,
> Felix
> Am 2022-07-26 um 22:59 schrieb Yu Zhe:
>> time_is_before_jiffies deals with timer wrapping correctly.
>> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
>> ---
>> drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
>> index a9466d154395..6397926e059c 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
>> @@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
>> while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
>> dev->device_info.event_interrupt_class->interrupt_wq(dev,
>> ih_ring_entry);
>> - if (jiffies - start_jiffies > HZ) {
>> + if (time_is_before_jiffies(start_jiffies + HZ)) {
>> /* If we spent more than a second processing signals,
>> * reschedule the worker to avoid soft-lockup warnings
>> */
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
2022-07-27 2:59 ` Yu Zhe
@ 2022-07-28 3:30 ` Yu Zhe
-1 siblings, 0 replies; 10+ messages in thread
From: Yu Zhe @ 2022-07-28 3:30 UTC (permalink / raw)
To: Felix.Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
airlied, daniel
Cc: amd-gfx, dri-devel, linux-kernel, kernel-janitors, liqiong, Yu Zhe
time_is_before_jiffies deals with timer wrapping correctly.
Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
index a9466d154395..34772fe74296 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
@@ -146,7 +146,7 @@ static void interrupt_wq(struct work_struct *work)
struct kfd_dev *dev = container_of(work, struct kfd_dev,
interrupt_work);
uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE];
- long start_jiffies = jiffies;
+ unsigned long start_jiffies = jiffies;
if (dev->device_info.ih_ring_entry_size > sizeof(ih_ring_entry)) {
dev_err_once(dev->adev->dev, "Ring entry too small\n");
@@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
dev->device_info.event_interrupt_class->interrupt_wq(dev,
ih_ring_entry);
- if (jiffies - start_jiffies > HZ) {
+ if (time_is_before_jiffies(start_jiffies + HZ)) {
/* If we spent more than a second processing signals,
* reschedule the worker to avoid soft-lockup warnings
*/
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
@ 2022-07-28 3:30 ` Yu Zhe
0 siblings, 0 replies; 10+ messages in thread
From: Yu Zhe @ 2022-07-28 3:30 UTC (permalink / raw)
To: Felix.Kuehling, alexander.deucher, christian.koenig, Xinhui.Pan,
airlied, daniel
Cc: Yu Zhe, kernel-janitors, linux-kernel, dri-devel, liqiong, amd-gfx
time_is_before_jiffies deals with timer wrapping correctly.
Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
index a9466d154395..34772fe74296 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
@@ -146,7 +146,7 @@ static void interrupt_wq(struct work_struct *work)
struct kfd_dev *dev = container_of(work, struct kfd_dev,
interrupt_work);
uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE];
- long start_jiffies = jiffies;
+ unsigned long start_jiffies = jiffies;
if (dev->device_info.ih_ring_entry_size > sizeof(ih_ring_entry)) {
dev_err_once(dev->adev->dev, "Ring entry too small\n");
@@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
dev->device_info.event_interrupt_class->interrupt_wq(dev,
ih_ring_entry);
- if (jiffies - start_jiffies > HZ) {
+ if (time_is_before_jiffies(start_jiffies + HZ)) {
/* If we spent more than a second processing signals,
* reschedule the worker to avoid soft-lockup warnings
*/
--
2.11.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
2022-07-28 3:30 ` Yu Zhe
@ 2022-07-28 22:05 ` Felix Kuehling
-1 siblings, 0 replies; 10+ messages in thread
From: Felix Kuehling @ 2022-07-28 22:05 UTC (permalink / raw)
To: Yu Zhe, alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel
Cc: amd-gfx, dri-devel, linux-kernel, kernel-janitors, liqiong
Am 2022-07-27 um 23:30 schrieb Yu Zhe:
> time_is_before_jiffies deals with timer wrapping correctly.
>
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Thank you. This patch looks good to me. I'm applying it to
amd-staging-drm-next.
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> index a9466d154395..34772fe74296 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> @@ -146,7 +146,7 @@ static void interrupt_wq(struct work_struct *work)
> struct kfd_dev *dev = container_of(work, struct kfd_dev,
> interrupt_work);
> uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE];
> - long start_jiffies = jiffies;
> + unsigned long start_jiffies = jiffies;
>
> if (dev->device_info.ih_ring_entry_size > sizeof(ih_ring_entry)) {
> dev_err_once(dev->adev->dev, "Ring entry too small\n");
> @@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
> while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
> dev->device_info.event_interrupt_class->interrupt_wq(dev,
> ih_ring_entry);
> - if (jiffies - start_jiffies > HZ) {
> + if (time_is_before_jiffies(start_jiffies + HZ)) {
> /* If we spent more than a second processing signals,
> * reschedule the worker to avoid soft-lockup warnings
> */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] drm/amdkfd: use time_is_before_jiffies(a + b) to replace "jiffies - a > b"
@ 2022-07-28 22:05 ` Felix Kuehling
0 siblings, 0 replies; 10+ messages in thread
From: Felix Kuehling @ 2022-07-28 22:05 UTC (permalink / raw)
To: Yu Zhe, alexander.deucher, christian.koenig, Xinhui.Pan, airlied, daniel
Cc: liqiong, kernel-janitors, dri-devel, amd-gfx, linux-kernel
Am 2022-07-27 um 23:30 schrieb Yu Zhe:
> time_is_before_jiffies deals with timer wrapping correctly.
>
> Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Thank you. This patch looks good to me. I'm applying it to
amd-staging-drm-next.
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> index a9466d154395..34772fe74296 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
> @@ -146,7 +146,7 @@ static void interrupt_wq(struct work_struct *work)
> struct kfd_dev *dev = container_of(work, struct kfd_dev,
> interrupt_work);
> uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE];
> - long start_jiffies = jiffies;
> + unsigned long start_jiffies = jiffies;
>
> if (dev->device_info.ih_ring_entry_size > sizeof(ih_ring_entry)) {
> dev_err_once(dev->adev->dev, "Ring entry too small\n");
> @@ -156,7 +156,7 @@ static void interrupt_wq(struct work_struct *work)
> while (dequeue_ih_ring_entry(dev, ih_ring_entry)) {
> dev->device_info.event_interrupt_class->interrupt_wq(dev,
> ih_ring_entry);
> - if (jiffies - start_jiffies > HZ) {
> + if (time_is_before_jiffies(start_jiffies + HZ)) {
> /* If we spent more than a second processing signals,
> * reschedule the worker to avoid soft-lockup warnings
> */
^ permalink raw reply [flat|nested] 10+ messages in thread