From: "Christian König" <christian.koenig@amd.com>
To: "Lazar, Lijo" <lijo.lazar@amd.com>,
Philip Yang <Philip.Yang@amd.com>,
amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/1] drm/amdgpu: Update PDEs flush TLB if PTB/PDB moved
Date: Thu, 2 Jun 2022 15:46:07 +0200 [thread overview]
Message-ID: <f58157f0-ea9b-270f-0176-e5af391c983a@amd.com> (raw)
In-Reply-To: <0b8999ec-7bd3-930f-1fc7-80826d155d41@amd.com>
Am 02.06.22 um 15:44 schrieb Lazar, Lijo:
>
>
> On 6/2/2022 7:06 PM, Christian König wrote:
>> Am 02.06.22 um 15:26 schrieb Lazar, Lijo:
>>>
>>>
>>> On 6/2/2022 6:54 PM, Lazar, Lijo wrote:
>>>>
>>>>
>>>> On 6/2/2022 6:50 PM, Philip Yang wrote:
>>>>> Flush TLBs when existing PDEs are updated because a PTB or PDB moved,
>>>>> but avoids unnecessary TLB flushes when new PDBs or PTBs are added to
>>>>> the page table, which commonly happens when memory is mapped for the
>>>>> first time.
>>>>>
>>>>> Suggested-by: Christian König <christian.koenig@amd.com>
>>>>> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
>>>>> ---
>>>>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++++--
>>>>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>>> index 9596c22fded6..1ea204218903 100644
>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
>>>>> @@ -737,6 +737,7 @@ int amdgpu_vm_update_pdes(struct amdgpu_device
>>>>> *adev,
>>>>> {
>>>>> struct amdgpu_vm_update_params params;
>>>>> struct amdgpu_vm_bo_base *entry;
>>>>> + bool flush_tlb_needed = false;
>>>>> int r, idx;
>>>>> if (list_empty(&vm->relocated))
>>>>> @@ -755,6 +756,9 @@ int amdgpu_vm_update_pdes(struct amdgpu_device
>>>>> *adev,
>>>>> goto error;
>>>>> list_for_each_entry(entry, &vm->relocated, vm_status) {
>>>>> + /* vm_flush_needed after updating moved PDEs */
>>>>> + flush_tlb_needed |= entry->moved;
>>>>
>>>> That is a strange thing to do for a bool variable. Why not just
>>>> assign it?
>>>>
>>>
>>> Hmm.. In a loop, perhaps you meant logical OR?
>>
>> Well IIRC C doesn't have a logical or assignment operator "||=", so
>> "|=" is used instead which also gets the job done.
>>
>
> var = var || value; also will work.
>
> BTW, v1 of this patch was incrementing vm->tlb_seq for every entry
> moved. This one increments only once. So is this vm->tlb_seq required
> only to be a bool?
No, it is required to only increment once. It's a sequence number and
changing it signals that a TLB flush is necessary.
Regards,
Christian.
>
> Thanks,
> Lijo
>
>> Christian.
>>
>>>
>>> Thanks,
>>> Lijo
>>>
>>>> Thanks,
>>>> Lijo
>>>>
>>>>> +
>>>>> r = amdgpu_vm_pde_update(¶ms, entry);
>>>>> if (r)
>>>>> goto error;
>>>>> @@ -764,8 +768,8 @@ int amdgpu_vm_update_pdes(struct amdgpu_device
>>>>> *adev,
>>>>> if (r)
>>>>> goto error;
>>>>> - /* vm_flush_needed after updating PDEs */
>>>>> - atomic64_inc(&vm->tlb_seq);
>>>>> + if (flush_tlb_needed)
>>>>> + atomic64_inc(&vm->tlb_seq);
>>>>> while (!list_empty(&vm->relocated)) {
>>>>> entry = list_first_entry(&vm->relocated,
>>>>>
>>
next prev parent reply other threads:[~2022-06-02 13:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-02 13:20 [PATCH v2 1/1] drm/amdgpu: Update PDEs flush TLB if PTB/PDB moved Philip Yang
2022-06-02 13:22 ` Christian König
2022-06-02 13:24 ` Lazar, Lijo
2022-06-02 13:26 ` Lazar, Lijo
2022-06-02 13:36 ` Christian König
2022-06-02 13:44 ` Lazar, Lijo
2022-06-02 13:46 ` Christian König [this message]
2022-06-02 19:15 ` Felix Kuehling
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=f58157f0-ea9b-270f-0176-e5af391c983a@amd.com \
--to=christian.koenig@amd.com \
--cc=Philip.Yang@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=lijo.lazar@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox