From mboxrd@z Thu Jan 1 00:00:00 1970 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 25369C04FFE for ; Tue, 16 Apr 2024 03:23:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A96B86B0082; Mon, 15 Apr 2024 23:23:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A47076B0083; Mon, 15 Apr 2024 23:23:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 933E76B0093; Mon, 15 Apr 2024 23:23:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 769C76B0082 for ; Mon, 15 Apr 2024 23:23:10 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0D96E1607EA for ; Tue, 16 Apr 2024 03:23:10 +0000 (UTC) X-FDA: 82013948940.09.125A000 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf12.hostedemail.com (Postfix) with ESMTP id 9CD2D4000B for ; Tue, 16 Apr 2024 03:23:06 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713237788; 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:in-reply-to:references:references; bh=n/WLy+zPi1qKHK5T/ri5MKccUS478PnzcpiR4G7ju/o=; b=lOIMzLu+/9vmkY4+RoZImIJo46JWk9sbtg+fZWWh8PcUgwOzjFO7hGofIaCHJKpmjCPz5H wMNJjpHUlurt+DVgiMewZH5aFFiys8eZDWyDp3A12ind6SRjsdmv1f8XbxampOsBIByqjr gL7EBOmTh03QxkPV5yaOE4+IDQRbzMg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713237788; a=rsa-sha256; cv=none; b=ejTLfv/gMViidT5nvmh8JhixGhH/7mRTFCPTZa4vIG+iuAGyufal97+n9kNTI5ztM5kuqD 3YoV0WCBqAVh1fOfSzB75AQXzAzXherGYySfxHXtlTItAM7KnyiltAaPBe8YwOCNs9cuzs 5dKqFp4OJCM9ZeiHf0YrpiHA/P9N3Q0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4VJTn118vnz1RCqc; Tue, 16 Apr 2024 11:20:05 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id 6BA721403D1; Tue, 16 Apr 2024 11:23:02 +0800 (CST) Received: from [10.173.135.154] (10.173.135.154) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 16 Apr 2024 11:23:01 +0800 Subject: Re: [PATCH v2] mm/memory-failure: fix deadlock when hugetlb_optimize_vmemmap is enabled To: Andrew Morton CC: Sidhartha Kumar , , , , References: <20240412025754.1897615-1-linmiaohe@huawei.com> <48647e5b-d15b-457b-9879-fb1b6bbaee27@oracle.com> <8d186776-f3b1-5d9a-2f94-fa249dee7d5f@huawei.com> <20240412162111.10f67ad0f001734464b53ad8@linux-foundation.org> From: Miaohe Lin Message-ID: Date: Tue, 16 Apr 2024 11:23:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20240412162111.10f67ad0f001734464b53ad8@linux-foundation.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.135.154] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspamd-Queue-Id: 9CD2D4000B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: tatywu9dt5abhosqb3ia4rwyw6unkh49 X-HE-Tag: 1713237786-973023 X-HE-Meta: U2FsdGVkX1/5Dcxdtw0xM34PwNwxui1GVZXUp2NK38QpFWVoCn1jkKhKXQiG+jnuaLobRU7dIcch19nHFaA4howiVAvuXWVLYekuXQcyVysMtKlk3+rpgUK+sCeEE9pIEApQVr8eFFwQJWs40ZcKEx9EB0LXMol8w0DKkd26tKptA6HnV4vhSFFPoToWaUHIfk3J98QV2t5SxhgFx0wyVfHgc2U+dbZx/Fm7ZJ4u1PL8JW/j0/EU++5fz68lxflBJx7YqrfP7zRBOIYFRHWgXR1D6DVAahe6bUXI7FlHp4rTkQMSzb3CGMRir2gOTAKLy7AkETQhPYDeNlwPzyXjfjnsqXS0Wjg4gyvDuOEUNK2E4VLKZuhYTJgfSs+tBaK4hqNgDP9O6+7vQRkk88WJZGe8AcDidFGb+OG88XOeqO9imiOz2ABBUkTpC2lM45W7Gnh+5bZWlAEwOdG71Rn3j7ZnF92CRbZi3bG6Y4MwDr3tu3xFVG5luPofPYZGXadzk5iDecVVWwI8XFJydvYqCOoa36PizoQlkrhIRNLR44KuMxzrylAO7mltYbPbyjxqq6YfYZLGXyxKs6Gph7o27ihl650kExgQqyzKInZnTiOUS+/A7b5WXAB9yW7don0B4PEHliQqjPPwkLICFnOIEatYeGekTtlfPrs/D3oEA1cjIS9/N4eknZhU3mVN7ppq/WGfXKtajt+sRFO2L7NKLx+TX3YGXfAM28gFyQE/q48uEQr3iJAIkgSy4Cshb2deTcMJxcAj30Iefgk/aoyU1TO6T9Ow94yNTJS8pjcsULd08Vnx8qhTb4GetMXvoXqY/iHZCK2Kb0sXBkRhH+NCt7xsD8GXc8y7gLUIId3CuyjnW/t5foMts0lK7r6mdmealBxJ4GY8z/vWX5lmyJr+rTi8BRmJQMGiS9SdMn4uw4rYYue7eAZS59sRs6zQyKYyLXFEdS3v/vdK82dnzcY ZZUGP3VR 2kCQtDKgnCUiMUt9wPToarMJhXXu7zHroUhHuQeMUv7lq2nbOk+RUOrszO66bawqjKpLjTpeeXgx9fqs1AKTrLSJ8MK5sG/F+h9NtSlceRbYi8eNQTUXGCA8dbgVK8Btfp4Gxsut4ZWJwzk2KWeNGnknNfQIpOv2xv59BSGOoW/Z1sIERIOL8eQA8NNbI0YSkfl+k 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: On 2024/4/13 7:21, Andrew Morton wrote: > On Fri, 12 Apr 2024 16:11:52 +0800 Miaohe Lin wrote: > >>> I recently sent a patch[1] to convert dissolve_free_huge_page() to folios which changes the function name and the name referenced in the comment so this will conflict with my patch. It's in mm-unstable now, would you be able to rebase to that in a new version? >>> > > This patch is a hotfixes, cc:stable one so the mm-unstable material will be > based on top of this change. > > I've queued this change up as a -fix against v1. And I've retained > this changelog addition: > > : This issue won't occur until commit a6b40850c442 ("mm: hugetlb: replace > : hugetlb_free_vmemmap_enabled with a static_key"). As it introduced > : rlock(cpu_hotplug_lock) in dissolve_free_huge_page() code path while > : lock(pcp_batch_high_lock) is already in the __page_handle_poison(). > > And I've queued another -fix to reflow that block comment to 80 columns. > > --- a/mm/memory-failure.c~mm-memory-failure-fix-deadlock-when-hugetlb_optimize_vmemmap-is-enabled-v2-fix > +++ a/mm/memory-failure.c > @@ -155,14 +155,16 @@ static int __page_handle_poison(struct p > int ret; > > /* > - * zone_pcp_disable() can't be used here. It will hold pcp_batch_high_lock and > - * dissolve_free_huge_page() might hold cpu_hotplug_lock via static_key_slow_dec() > - * when hugetlb vmemmap optimization is enabled. This will break current lock > - * dependency chain and leads to deadlock. > - * Disabling pcp before dissolving the page was a deterministic approach because > - * we made sure that those pages cannot end up in any PCP list. Draining PCP lists > - * expels those pages to the buddy system, but nothing guarantees that those pages > - * do not get back to a PCP queue if we need to refill those. > + * zone_pcp_disable() can't be used here. It will > + * hold pcp_batch_high_lock and dissolve_free_huge_page() might hold > + * cpu_hotplug_lock via static_key_slow_dec() when hugetlb vmemmap > + * optimization is enabled. This will break current lock dependency > + * chain and leads to deadlock. > + * Disabling pcp before dissolving the page was a deterministic > + * approach because we made sure that those pages cannot end up in any > + * PCP list. Draining PCP lists expels those pages to the buddy system, > + * but nothing guarantees that those pages do not get back to a PCP > + * queue if we need to refill those. > */ > ret = dissolve_free_huge_page(page); > if (!ret) { > _ > Many thanks for doing this. :) . > . >