All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Kuehling <felix.kuehling@amd.com>
To: Philip Yang <yangp@amd.com>, amd-gfx@lists.freedesktop.org
Cc: nicholas.curtis@amd.com
Subject: Re: [PATCH v2] drm/amdkfd: Try to schedule bottom half on same core
Date: Fri, 12 Aug 2022 14:10:58 -0400	[thread overview]
Message-ID: <0d45fb6d-800b-8291-1726-be83ef1af044@amd.com> (raw)
In-Reply-To: <da05c04a-c484-e2a0-8019-27f415f0a726@amd.com>


On 2022-08-12 09:55, Philip Yang wrote:
>
> On 2022-08-11 15:04, Felix Kuehling wrote:
>> On systems that support SMT (hyperthreading) schedule the bottom half of
>> the KFD interrupt handler on the same core. This makes it possible to
>> reserve a core for interrupt handling and have the bottom half run on
>> that same core.
>>
>> On systems without SMT, pick another core in the same NUMA node, as
>> before.
>>
>> Use for_each_cpu_wrap instead of open-coding it.
>>
>> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
>
> nit-pick below, looks better to use new_cpu as iterator, either way 
> this is
>
> Reviewed-by: Philip Yang <Philip.Yang@amd.com>

Thank you. I think I prefer cpu as the iterator and new_cpu as the 
variable that holds the CPU we choose to schedule to.

Regards,
   Felix


>
>> ---
>>   drivers/gpu/drm/amd/amdkfd/kfd_device.c | 20 ++++++++++++++++----
>>   1 file changed, 16 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c 
>> b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
>> index f5853835f03a..4d1284714e7a 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
>> @@ -24,6 +24,7 @@
>>   #include <linux/bsearch.h>
>>   #include <linux/pci.h>
>>   #include <linux/slab.h>
>> +#include <linux/topology.h>
>>   #include "kfd_priv.h"
>>   #include "kfd_device_queue_manager.h"
>>   #include "kfd_pm4_headers_vi.h"
>> @@ -801,13 +802,24 @@ static inline void kfd_queue_work(struct 
>> workqueue_struct *wq,
>>                     struct work_struct *work)
>>   {
>>       int cpu, new_cpu;
>> +    const struct cpumask *mask = NULL;
>>         cpu = new_cpu = smp_processor_id();
>> -    do {
>> -        new_cpu = cpumask_next(new_cpu, cpu_online_mask) % nr_cpu_ids;
>> -        if (cpu_to_node(new_cpu) == numa_node_id())
>> +
>> +#if defined(CONFIG_SCHED_SMT)
>> +    /* CPU threads in the same core */
>> +    mask = cpu_smt_mask(cpu);
>> +#endif
>> +    if (!mask || cpumask_weight(mask) <= 1)
>> +        /* CPU threads in the same NUMA node */
>> +        mask = cpu_cpu_mask(cpu);
>> +    /* Pick the next online CPU thread in the same core or NUMA node */
>> +    for_each_cpu_wrap(cpu, mask, cpu+1) {
>> +        if (cpu != new_cpu && cpu_online(cpu)) {
>> +            new_cpu = cpu;
>>               break;
>> -    } while (cpu != new_cpu);
>> +        }
>> +    }
>>         queue_work_on(new_cpu, wq, work);
>>   }
>
>     for_each_cpu_wrap(new_cpu, mask, cpu + 1) {
>         if (cpu != new_cpu && cpu_online(new_cpu)) {
>             cpu = new_cpu;
>              break;
>         }
>     }
>     queue_work_on(cpu, wq, work);
>

  reply	other threads:[~2022-08-12 18:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10 23:41 [PATCH] drm/amdkfd: Try to schedule bottom half on same core Felix Kuehling
2022-08-11 15:06 ` Felix Kuehling
2022-08-11 19:04 ` [PATCH v2] " Felix Kuehling
2022-08-12 13:55   ` Philip Yang
2022-08-12 18:10     ` Felix Kuehling [this message]
2022-08-12 19:49       ` Dave Airlie

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=0d45fb6d-800b-8291-1726-be83ef1af044@amd.com \
    --to=felix.kuehling@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=nicholas.curtis@amd.com \
    --cc=yangp@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.