From patchwork Mon Jul 1 01:45:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: zhangchun X-Patchwork-Id: 13717470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81783C27C4F for ; Mon, 1 Jul 2024 01:47:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F9C86B0096; Sun, 30 Jun 2024 21:47:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A94F6B0098; Sun, 30 Jun 2024 21:47:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB2926B0099; Sun, 30 Jun 2024 21:47:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CCE456B0096 for ; Sun, 30 Jun 2024 21:47:05 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6E7384181F for ; Mon, 1 Jul 2024 01:47:05 +0000 (UTC) X-FDA: 82289495610.25.0706E67 Received: from h3cspam02-ex.h3c.com (smtp.h3c.com [60.191.123.50]) by imf16.hostedemail.com (Postfix) with ESMTP id 2F8EE18000F for ; Mon, 1 Jul 2024 01:47:01 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of zhang.chunA@h3c.com designates 60.191.123.50 as permitted sender) smtp.mailfrom=zhang.chunA@h3c.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719798412; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=K+txfgIBDiC5EBu9Tyu6qcr21MebyAoTXTIWB1FfFmA=; b=tIxOiZv8yEySCGV1mcB9wJX7gTigBIxOTqXbbNWBK3nv7lxc0oTcz0vwjTcnGkkqBjKbhp 9CyaT5Vz/2gvbyXF4xnhIDl/P9hFR+M6Rbi0gv8/jA0L8KiS2fo8ffiTfuRksj7x0lJNn3 YQRWInxk6Q7Qz8gFVZpd8JvHYQs9+T4= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.hostedemail.com: domain of zhang.chunA@h3c.com designates 60.191.123.50 as permitted sender) smtp.mailfrom=zhang.chunA@h3c.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719798412; a=rsa-sha256; cv=none; b=NqAyyAhcaxTamiyvi7fhOu+P5nCs+j88tbe49WoAwpFNJqg38DLh5t4RKlgT5sp2zI1IWK 9bn/dr+jGInhnLYF+Yq736vrrb45h48FE7Hu9p+Emv6+Az+hj/EgBsHNzCKdCJcgjX9XUI ifp+m50ANlWJ3e2fDXLjn8ZVoI51RJs= Received: from mail.maildlp.com ([172.25.15.154]) by h3cspam02-ex.h3c.com with ESMTP id 4611jvHJ024589; Mon, 1 Jul 2024 09:45:57 +0800 (GMT-8) (envelope-from zhang.chunA@h3c.com) Received: from DAG6EX11-BJD.srv.huawei-3com.com (unknown [10.153.34.13]) by mail.maildlp.com (Postfix) with ESMTP id 07A032004BBD; Mon, 1 Jul 2024 09:49:59 +0800 (CST) Received: from DAG6EX09-BJD.srv.huawei-3com.com (10.153.34.11) by DAG6EX11-BJD.srv.huawei-3com.com (10.153.34.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.27; Mon, 1 Jul 2024 09:45:58 +0800 Received: from DAG6EX09-BJD.srv.huawei-3com.com ([fe80::bdc5:ad7:2347:12a5]) by DAG6EX09-BJD.srv.huawei-3com.com ([fe80::bdc5:ad7:2347:12a5%4]) with mapi id 15.02.1258.027; Mon, 1 Jul 2024 09:45:58 +0800 From: Zhangchun To: "shaohaojize@126.com" , "akpm@linux-foundation.org" , "linux-mm@kvack.org" CC: "linux-kernel@vger.kernel.org" , Jiaoxupo , Bailin , Zhangzhansheng , "linux-mm@kvack.org" , wangyu Subject: [PATCH] mm: fix kmap_high deadlock Thread-Topic: [PATCH] mm: fix kmap_high deadlock Thread-Index: AdrLWGWcTXIJ41leRoK9JQLjgSju3w== Date: Mon, 1 Jul 2024 01:45:57 +0000 Message-ID: <079f7b0b129f4fbc86d5f5ee8795fd1b@h3c.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.135.168.35] x-sender-location: DAG2 MIME-Version: 1.0 X-DNSRBL: X-MAIL: h3cspam02-ex.h3c.com 4611jvHJ024589 X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2F8EE18000F X-Stat-Signature: 3ountnp3pcqs8foqrn555s83n87rt6qa X-Rspam-User: X-HE-Tag: 1719798421-857645 X-HE-Meta: U2FsdGVkX1/7Sf+dS8UbMJvz1+cJO630vlGpuosjesDiQHQ5ecfnvekRvSiBTr8spDI+SnQ/bxYCfEPW3iBPtqfQjMAPBcisU12MGiJt0EkHAdQFbKsJPkXSpe6L1LqB/DP4M/JWvEOfL4WzhcosM1+/sepjo+AiyOqZDWGd2Myu3CWypsnx61a7pAi/VixE3/UgP9ICJvLvmHs12+tk7MNAbc+MU4Ot3mBHHOkUIfuZbne40+lNw7PbbQfFmYRNYhlPrwHKA/sj0Xww+qi3K2qjgPHFzlC+XLMoPyDFzqvpccrfQ2lubGyw6FJgIb13LJtxJtBevSxr/CbX0uyPztwFy7Mn0rmxYeaK6YchnN4aBjtel9J72i0/zD5k5msAbqpX5wwG/iZxmzszcqFDQ3Mh4XBxHsBspOAqHjrynsFKItrAdSyAyROvnkCsrD7u6Hm5d+P9EfORh8yVJ8d2l4g7nDVFe8yLsLdQgpcbwePLV8LG2p34f0RReQGewaOscD8WWzHpAXWdKVOCDFejZY+L4wI6HdkUK/MzdkfIN7PVzTB4uOsEj5D7lt3cC7gxInoHvbZ4jxrBjDXsvoFAtUmzb4AOW+3sAqDFu5O18W+2082V6RGyv1GMPvWe/gikvKarAHnt6tZt8T0wXByhX1o2WRYu6nz7nYBOwYY5koOl9qfhz3yIcgzdoVG7M0rlFQ+6qXaABmqB8FmE2v9dYL+U7VNv1TK7UmlvwoLWoGcJUWchxVQ5WnaEWxdWT/GI28pmxw+uuKJDaAO3v4YiAOQdIhH7lNNwrxoAyCDh8sm058c+MZhC16sg9OWAZZgrWrNO93CAJ7k7u2TWENzU1lwGHjYXooM9ilVaYuyk/zruw9fwZB2jyHHaqBuq9eUocZQBelPrpl0vKHN2D+FMpVz8lZp6WhyVoynsTz80gwwsOqJ7+dOf91i2oUhgm1sSKQOKdvxG1tBkWiaKPWU FvbA28/Y pIYiy/4zW4fu8rbpBcbzySbdtE6IzrFw+XP327wLOFKGgsXCT+WG0uHytekwOWeH088pDRzSct7jb9qzf0wKg35ZFnDI6fkaRUEGfYxYqM7fHH6h42E20MqzzpdpFRcfxgICGA9CUFHjpKBaPFtx4pOWU1aZcP6d2F8d0ngy4EgdCJQ13LxV6EV9BKXjE/j7kONbzpgLyYi79JWv5YVczXwT4UujPRYcvk9Mmme5fFPlQLmbtnIc1dscRmcYJhtKET5KmDZGY+CWC9dytmASTlJ3y/I9vjF195TWsGYu2i5E831jIp/zIIE1oZGOtPZA+3j9SKMaWtEs1YKzj+n8A0zmZRQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "zhang.chun" I work with zhangzhansheng(from h3c) find that some situation may casue deadlock when we use kmap_highand kmap_XXX or kumap_xxx between differt cores at the same time.kmap_high->map_new_virtual-> flush_all_zero_pkmaps->flush_tlb_kernel_range->on_each_cpu, On this condition, kmap_high hold the kmap_lock, wait the other cores ack. But the others may disable irq and wait kmap_lock, this is some deadlock condition. I think it's necessary to give kmap_lock before call flush_tlb_kernel_range. Like this: spin_unlock(&kmap_lock); flush_tlb_kernel_range(xxx); spin_lock(&kmap_lock); Signed-off-by: zhang.chun --- mm/highmem.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.34.1 ------------------------------------------------------------------------------------------------------------------------------------- 本邮件及其附件含有新华三集团的保密信息,仅限于发送给上面地址中列出 的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、 或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本 邮件! This e-mail and its attachments contain confidential information from New H3C, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it! diff --git a/mm/highmem.c b/mm/highmem.c index bd48ba445dd4..12d20e551579 100644 --- a/mm/highmem.c +++ b/mm/highmem.c @@ -221,7 +221,9 @@ static void flush_all_zero_pkmaps(void) need_flush = 1; } if (need_flush) +spin_unlock(&kmap_lock); flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP)); +spin_lock(&kmap_lock); } void __kmap_flush_unused(void)