From: Andrew Morton <akpm@linux-foundation.org>
To: zhangchun <zhang.chuna@h3c.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
<jiaoxupo@h3c.com>, <zhang.zhengming@h3c.com>,
<zhang.zhansheng@h3c.com>, <shaohaojize@126.com>
Subject: Re: [PATCH v2] mm: Give kmap_lock before call flush_tlb_kernel_rang,avoid kmap_high deadlock.
Date: Wed, 10 Jul 2024 10:36:11 -0700 [thread overview]
Message-ID: <20240710103611.809895ff809df9ed411bfaa8@linux-foundation.org> (raw)
In-Reply-To: <1720614028-2260-1-git-send-email-zhang.chuna@h3c.com>
On Wed, 10 Jul 2024 20:20:28 +0800 zhangchun <zhang.chuna@h3c.com> wrote:
> Use kmap_high and kmap_XXX or kumap_xxx among differt cores at the same
> time may cause deadlock. The issue is like this:
What is kmap_XXX?
> CPU 0: CPU 1:
> kmap_high(){ kmap_xxx() {
> ... irq_disable();
> spin_lock(&kmap_lock)
> ...
> map_new_virtual ...
> flush_all_zero_pkmaps
> flush_tlb_kernel_range /* CPU0 holds the kmap_lock */
> smp_call_function_many spin_lock(&kmap_lock)
> ... ....
> spin_unlock(&kmap_lock)
> ...
>
> CPU 0 holds the kmap_lock, waiting for CPU 1 respond to IPI. But CPU 1
> has disabled irqs, waiting for kmap_lock, cannot answer the IPI. Fix
> this by releasing kmap_lock before call flush_tlb_kernel_range,
> avoid kmap_lock deadlock.
>
> Fixes: 3297e760776a ("highmem: atomic highmem kmap page pinning")
Wow, that's 15 years old. Has the deadlock been observed?
> --- a/mm/highmem.c
> +++ b/mm/highmem.c
> @@ -220,8 +220,11 @@ static void flush_all_zero_pkmaps(void)
> set_page_address(page, NULL);
> need_flush = 1;
> }
> - if (need_flush)
> + if (need_flush) {
> + unlock_kmap();
> flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
> + lock_kmap();
> + }
> }
Why is dropping the lock like this safe? What data is it protecting
and why is it OK to leave that data unprotected here?
next prev parent reply other threads:[~2024-07-10 17:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-10 12:20 zhangchun
2024-07-10 17:36 ` Andrew Morton [this message]
2024-07-11 7:07 ` zhangchun
2024-07-11 21:13 ` Andrew Morton
2024-07-12 7:54 ` zhangchun
2024-07-18 16:18 ` zhangchun
2024-07-24 0:26 ` Andrew Morton
2024-08-19 16:10 ` [PATCH v3] " zhangchun
2024-09-03 11:52 ` zhangchun
2024-10-08 3:23 ` zhangchun
2024-10-14 7:41 ` zhangchun
2024-10-31 15:18 ` [PATCH v4] " zhangchun
2025-02-18 6:30 ` zhangchun
-- strict thread matches above, loose matches on Subject: below --
2024-07-10 7:20 [PATCH v2] " zhangchun
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=20240710103611.809895ff809df9ed411bfaa8@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=jiaoxupo@h3c.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shaohaojize@126.com \
--cc=zhang.chuna@h3c.com \
--cc=zhang.zhansheng@h3c.com \
--cc=zhang.zhengming@h3c.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