<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 2025-02-12 23:33, Deng, Emily wrote:<br>
</div>
<blockquote type="cite" cite="mid:PH0PR12MB5417FC100504361B99925E338FFF2@PH0PR12MB5417.namprd12.prod.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
{font-family:Aptos;}@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:"Aptos",sans-serif;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
font-size:10.0pt;
font-family:"Courier New";}span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Arial",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
Yang, Philip <a class="moz-txt-link-rfc2396E" href="mailto:Philip.Yang@amd.com"><Philip.Yang@amd.com></a>
<br>
<b>Sent:</b> Wednesday, February 12, 2025 10:31 PM<br>
<b>To:</b> Deng, Emily <a class="moz-txt-link-rfc2396E" href="mailto:Emily.Deng@amd.com"><Emily.Deng@amd.com></a>;
Yang, Philip <a class="moz-txt-link-rfc2396E" href="mailto:Philip.Yang@amd.com"><Philip.Yang@amd.com></a>; Chen,
Xiaogang <a class="moz-txt-link-rfc2396E" href="mailto:Xiaogang.Chen@amd.com"><Xiaogang.Chen@amd.com></a>;
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [PATCH] drm/amdkfd: Fix the
deadlock in svm_range_restore_work<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p><o:p> </o:p></p>
<div>
<p class="MsoNormal">On 2025-02-12 03:54, Deng, Emily
wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD
Official Use Only - AMD Internal Distribution Only]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">Ping……</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Emily
Deng</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Best
Wishes</span><o:p></o:p></p>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
Deng, Emily
<a href="mailto:Emily.Deng@amd.com" moz-do-not-send="true"><Emily.Deng@amd.com></a>
<br>
<b>Sent:</b> Tuesday, February 11, 2025 8:21
PM<br>
<b>To:</b> Deng, Emily <a href="mailto:Emily.Deng@amd.com" moz-do-not-send="true"><Emily.Deng@amd.com></a>;
Yang, Philip
<a href="mailto:Philip.Yang@amd.com" moz-do-not-send="true"><Philip.Yang@amd.com></a>;
Chen, Xiaogang <a href="mailto:Xiaogang.Chen@amd.com" moz-do-not-send="true">
<Xiaogang.Chen@amd.com></a>; <a href="mailto:amd-gfx@lists.freedesktop.org" moz-do-not-send="true" class="moz-txt-link-freetext">amd-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> RE: [PATCH] drm/amdkfd: Fix
the deadlock in svm_range_restore_work</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD
Official Use Only - AMD Internal Distribution
Only]</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">Hi
Philip,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">
Upon further consideration,
removing amdgpu_amdkfd_unreserve_mem_limit is
challenging because it is paired
with amdgpu_amdkfd_reserve_mem_limit in svm_migrate_ram_to_vram.
However, this pairing does introduce issues, as
it prevents amdgpu_amdkfd_reserve_mem_limit from
accurately detecting out-of-memory conditions.
Ideally, amdgpu_amdkfd_unreserve_mem_limit should
be tied to the actual freeing of memory.
Furthermore, since ttm_bo_delayed_delete delays
the call to amdgpu_vram_mgr_del, there remains a
possibility
that amdgpu_amdkfd_reserve_mem_limit reports
sufficient memory, while a subsequent call
to amdgpu_vram_mgr_new fails. For these reasons,
I believe this patch is still necessary.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Emily
Deng</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Best
Wishes</span><o:p></o:p></p>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org" moz-do-not-send="true" class="moz-txt-link-freetext">amd-gfx-bounces@lists.freedesktop.org</a>>
<b>On Behalf Of </b>Deng, Emily<br>
<b>Sent:</b> Tuesday, February 11, 2025
6:56 PM<br>
<b>To:</b> Yang, Philip <<a href="mailto:Philip.Yang@amd.com" moz-do-not-send="true" class="moz-txt-link-freetext">Philip.Yang@amd.com</a>>;
Chen, Xiaogang <<a href="mailto:Xiaogang.Chen@amd.com" moz-do-not-send="true" class="moz-txt-link-freetext">Xiaogang.Chen@amd.com</a>>;
<a href="mailto:amd-gfx@lists.freedesktop.org" moz-do-not-send="true" class="moz-txt-link-freetext">amd-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> RE: [PATCH] drm/amdkfd:
Fix the deadlock in svm_range_restore_work</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD
Official Use Only - AMD Internal Distribution
Only]</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD
Official Use Only - AMD Internal
Distribution Only]</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid
#E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
Yang, Philip <<a href="mailto:Philip.Yang@amd.com" moz-do-not-send="true" class="moz-txt-link-freetext">Philip.Yang@amd.com</a>>
<br>
<b>Sent:</b> Tuesday, February 11,
2025 6:54 AM<br>
<b>To:</b> Deng, Emily <<a href="mailto:Emily.Deng@amd.com" moz-do-not-send="true" class="moz-txt-link-freetext">Emily.Deng@amd.com</a>>;
Chen, Xiaogang <<a href="mailto:Xiaogang.Chen@amd.com" moz-do-not-send="true" class="moz-txt-link-freetext">Xiaogang.Chen@amd.com</a>>;
<a href="mailto:amd-gfx@lists.freedesktop.org" moz-do-not-send="true" class="moz-txt-link-freetext">amd-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [PATCH]
drm/amdkfd: Fix the deadlock in
svm_range_restore_work</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p> <o:p></o:p></p>
<div>
<p class="MsoNormal">On 2025-02-10 02:51,
Deng, Emily wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD
Official Use Only - AMD Internal
Distribution Only]</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD
Official Use Only - AMD Internal
Distribution Only]</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid
blue 1.5pt;padding:0in 0in 0in
4.0pt">
<div>
<div style="border:none;border-top:solid
#E1E1E1 1.0pt;padding:3.0pt 0in
0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">
Chen, Xiaogang
<a href="mailto:Xiaogang.Chen@amd.com" moz-do-not-send="true"><Xiaogang.Chen@amd.com></a>
<br>
<b>Sent:</b> Monday,
February 10, 2025 10:18 AM<br>
<b>To:</b> Deng, Emily <a href="mailto:Emily.Deng@amd.com" moz-do-not-send="true"><Emily.Deng@amd.com></a>;
<a href="mailto:amd-gfx@lists.freedesktop.org" moz-do-not-send="true" class="moz-txt-link-freetext">amd-gfx@lists.freedesktop.org</a><br>
<b>Subject:</b> Re: [PATCH]
drm/amdkfd: Fix the deadlock
in svm_range_restore_work</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p> <o:p></o:p></p>
<div>
<p class="MsoNormal">On 2/7/2025
9:02 PM, Deng, Emily wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>[AMD Official Use Only - AMD Internal Distribution Only]<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>[AMD Official Use Only - AMD Internal Distribution Only]<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>Ping.......<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>Emily Deng<o:p></o:p></pre>
<pre>Best Wishes<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>-----Original Message-----<o:p></o:p></pre>
<pre>From: Emily Deng <a href="mailto:Emily.Deng@amd.com" moz-do-not-send="true"><Emily.Deng@amd.com></a><o:p></o:p></pre>
<pre>Sent: Friday, February 7, 2025 6:28 PM<o:p></o:p></pre>
<pre>To: <a href="mailto:amd-gfx@lists.freedesktop.org" moz-do-not-send="true" class="moz-txt-link-freetext">amd-gfx@lists.freedesktop.org</a><o:p></o:p></pre>
<pre>Cc: Deng, Emily <a href="mailto:Emily.Deng@amd.com" moz-do-not-send="true"><Emily.Deng@amd.com></a><o:p></o:p></pre>
<pre>Subject: [PATCH] drm/amdkfd: Fix the deadlock in svm_range_restore_work<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>It will hit deadlock in svm_range_restore_work ramdonly.<o:p></o:p></pre>
<pre>Detail as below:<o:p></o:p></pre>
<pre>1.svm_range_restore_work<o:p></o:p></pre>
<pre> ->svm_range_list_lock_and_flush_work<o:p></o:p></pre>
<pre> ->mmap_write_lock<o:p></o:p></pre>
<pre>2.svm_range_restore_work<o:p></o:p></pre>
<pre> ->svm_range_validate_and_map<o:p></o:p></pre>
<pre> ->amdgpu_vm_update_range<o:p></o:p></pre>
<pre> ->amdgpu_vm_ptes_update<o:p></o:p></pre>
<pre> ->amdgpu_vm_pt_alloc<o:p></o:p></pre>
<pre> ->svm_range_evict_svm_bo_worker<o:p></o:p></pre>
</blockquote>
</blockquote>
<p>svm_range_evict_svm_bo_worker is
a function running by a kernel
task from default system_wq. It is
not the task that runs
svm_range_restore_work which is
from system_freezable_wq. The
second task may need wait the
first task to release
mmap_write_lock, but there is no
cycle lock dependency.<o:p></o:p></p>
<p>Can you explain more how deadlock
happened? If a deadlock exists
between two tasks there are should
be at least two locks used by both
tasks.<o:p></o:p></p>
<p>Regards<o:p></o:p></p>
<p style="margin-left:11.0pt">Xiaogang
<o:p></o:p></p>
<p style="margin-left:5.5pt">In Step
2, during
the amdgpu_vm_pt_alloc process,
the system encounters insufficient
memory and triggers an eviction.
This initiates
the svm_range_evict_svm_bo_worker task,
and waits for
the eviction_fence to be signaled.
However,
the svm_range_evict_svm_bo_worker cannot
acquire the mmap_read_lock(mm),
preventing it from signaling
the eviction_fence. As a
result, amdgpu_vm_pt_alloc remains
incomplete and cannot release
the mmap_write_lock(mm).
<o:p></o:p></p>
<p style="margin-left:5.5pt">Which
means
the svm_range_restore_work task
holds the mmap_write_lock(mm) and
is stuck waiting for
the eviction_fence to be signaled
by svm_range_evict_svm_bo_worker.
However, svm_range_evict_svm_bo_worker is itself blocked, unable to
acquire the mmap_read_lock(mm).
This creates a deadlock.<o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
<p>The deadlock situation should not happen
as svm_range_restore_work is only used for
xnack off case, there is no VRAM over
commitment with KFD
amdgpu_amdkfd_reserve_mem_limit. We
reserved VRAM ESTIMATE_PT_SIZE for page
table allocation to prevent this
situation.<o:p></o:p></p>
<p>Regards,<o:p></o:p></p>
<p>Philip<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">Hi
Philip,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">
You're correct. Upon further
investigation, the issue arises from the
additional call
to amdgpu_amdkfd_unreserve_mem_limit in svm_migrate_ram_to_vram,
which
prevents amdgpu_amdkfd_reserve_mem_limit from
detecting the out-of-memory condition. I
will submit another patch to remove
the amdgpu_amdkfd_unreserve_mem_limit call
in svm_migrate_ram_to_vram.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p>We check all SVM memory must fit in system memory, don't
account svm VRAM usage. For xnack off, application should
check available VRAM size and avoid VRAM over commitment.<o:p></o:p></p>
<p>svm_range_restore_worker ensure all SVM ranges are mapped
to GPUs then resume queues, this is done by taking mmap
write lock and flush deferred_range_list. downgrade to
mmap read lock cannot prevent unmap from CPU as mmu
notifier callback can add range to deferred_range_list
again and unmap from GPUs, so this patch can not work.<o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Arial",sans-serif">Maybe
I understand wrong. but downgrading to a read lock could
also prevent svm_range_deferred_list_work from acquiring
a write lock. As a result, it could potentially block
unmapping operations from GPUs.</span></p>
</div>
</div>
</div>
</blockquote>
<p>no, svm_range_cpu_invalidate_pagetables takes prange lock to
split prange, and add to deferred_list if needed, then unmap from
GPU and return.</p>
<p>This needs app fix, not over commitment, prefetch svm ranges to
VRAM if xnack is off.<br>
</p>
<p>Regards,</p>
<p>Philip<br>
</p>
<blockquote type="cite" cite="mid:PH0PR12MB5417FC100504361B99925E338FFF2@PH0PR12MB5417.namprd12.prod.outlook.com">
<div>
<div class="WordSection1">
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<p><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Emily
Deng<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Best
Wishes<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p>We should not use mmap write lock to sync with mmu
notifier, there is a plan to rework svm locks to fix this.<o:p></o:p></p>
<p>Regards,<o:p></o:p></p>
<p>Philip<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div>
<div style="border:none;border-left:solid blue
1.5pt;padding:0in 0in 0in 4.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Emily
Deng</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Best
Wishes</span><o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div style="border:none;border-left:solid
blue 1.5pt;padding:0in 0in 0in 4.0pt">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Emily
Deng</span><o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-ligatures:standardcontextual">Best
Wishes</span><o:p></o:p></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<p><span style="font-size:11.0pt;font-family:"Arial",sans-serif"> </span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre> ->mmap_read_lock(deadlock here, because already get mmap_write_lock)<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>How to fix?<o:p></o:p></pre>
<pre>Downgrade the write lock to read lock.<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>Signed-off-by: Emily Deng <a href="mailto:Emily.Deng@amd.com" moz-do-not-send="true"><Emily.Deng@amd.com></a><o:p></o:p></pre>
<pre>---<o:p></o:p></pre>
<pre>drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 ++-<o:p></o:p></pre>
<pre>1 file changed, 2 insertions(+), 1 deletion(-)<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c<o:p></o:p></pre>
<pre>b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c<o:p></o:p></pre>
<pre>index bd3e20d981e0..c907e2de3dde 100644<o:p></o:p></pre>
<pre>--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c<o:p></o:p></pre>
<pre>+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c<o:p></o:p></pre>
<pre>@@ -1841,6 +1841,7 @@ static void svm_range_restore_work(struct work_struct<o:p></o:p></pre>
<pre>*work)<o:p></o:p></pre>
<pre> mutex_lock(&process_info->lock);<o:p></o:p></pre>
<pre> svm_range_list_lock_and_flush_work(svms, mm);<o:p></o:p></pre>
<pre> mutex_lock(&svms->lock);<o:p></o:p></pre>
<pre>+ mmap_write_downgrade(mm);<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre> evicted_ranges = atomic_read(&svms->evicted_ranges);<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>@@ -1890,7 +1891,7 @@ static void svm_range_restore_work(struct work_struct<o:p></o:p></pre>
<pre>*work)<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>out_reschedule:<o:p></o:p></pre>
<pre> mutex_unlock(&svms->lock);<o:p></o:p></pre>
<pre>- mmap_write_unlock(mm);<o:p></o:p></pre>
<pre>+ mmap_read_unlock(mm);<o:p></o:p></pre>
<pre> mutex_unlock(&process_info->lock);<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre> /* If validation failed, reschedule another attempt */<o:p></o:p></pre>
<pre>--<o:p></o:p></pre>
<pre>2.34.1<o:p></o:p></pre>
</blockquote>
<pre> <o:p></o:p></pre>
</blockquote>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</body>
</html>