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 C8D54C52D7B for ; Fri, 9 Aug 2024 02:02:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69DAD6B009E; Thu, 8 Aug 2024 22:02:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64CC76B009F; Thu, 8 Aug 2024 22:02:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 53BA76B00A0; Thu, 8 Aug 2024 22:02:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 30BE46B009E for ; Thu, 8 Aug 2024 22:02:26 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C9A18A7592 for ; Fri, 9 Aug 2024 02:02:25 +0000 (UTC) X-FDA: 82431057450.11.A5FCECD Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf19.hostedemail.com (Postfix) with ESMTP id A2DFB1A000E for ; Fri, 9 Aug 2024 02:02:22 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723168879; 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=WoGyn0DXcJln3N74mFxj/xLh8F+A6PjN4rfpM9XnO/I=; b=IK7ULJUfY2n+X/XQVHl0gNx6XtJVZpn4dPnwegQOy5XPo4khFOc8kyWjrZoqHteKh0rY9B 1GnYR4DIajaFwwXx9+Op+XlBwqYh+OVPDH0tp+Tb1gG6pzgy7r8jDqwaAcfazm6nTmszEy MevNnYxEyzx9V7H89zpIgHsHLUY+3Ho= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723168879; a=rsa-sha256; cv=none; b=WaonRxlRwqaeA385rITBH0wQFojgwSNs4NKkj62hGmT4iyVXskLbJmPly9n20ObsPIZKY6 6FmBsyTMOoKBYac+Bf5xQNKR4dZi/eO2McebAFvvKgpE21Z9LIcl+HR0MIvYToRjpMCEli BWTh+06CdpXS6UuYW1Pn6bytP95d6a0= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.35 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Wg6Vj2Syjz1S7Rx; Fri, 9 Aug 2024 09:57:33 +0800 (CST) Received: from kwepemd200019.china.huawei.com (unknown [7.221.188.193]) by mail.maildlp.com (Postfix) with ESMTPS id BE9F91400C9; Fri, 9 Aug 2024 10:02:18 +0800 (CST) Received: from [10.173.127.72] (10.173.127.72) by kwepemd200019.china.huawei.com (7.221.188.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 9 Aug 2024 10:02:18 +0800 Subject: Re: [PATCH 2/4] mm: memory_hotplug: check hwpoisoned page firstly in do_migrate_range() To: David Hildenbrand CC: Oscar Salvador , Naoya Horiguchi , , Andrew Morton , Kefeng Wang References: <20240725011647.1306045-1-wangkefeng.wang@huawei.com> <20240725011647.1306045-3-wangkefeng.wang@huawei.com> <56b9a389-4c36-4892-962d-b45878f30f4d@huawei.com> <68067a56-4b9c-4636-9d07-41fee371d80c@redhat.com> <05520370-6390-4b08-8fcb-01f255deecbc@huawei.com> <1b77117e-e1ff-4d14-8135-09ea9beda5b8@redhat.com> <1e6cccc5-fedc-8df6-1deb-16ceb52a4094@huawei.com> <1e14d86d-0d17-41da-9400-16c9c6f93f8f@redhat.com> From: Miaohe Lin Message-ID: <3a69f67a-9331-78c7-cf6c-e066d786d059@huawei.com> Date: Fri, 9 Aug 2024 10:02:17 +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: <1e14d86d-0d17-41da-9400-16c9c6f93f8f@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.173.127.72] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemd200019.china.huawei.com (7.221.188.193) X-Rspamd-Queue-Id: A2DFB1A000E X-Stat-Signature: dauf7wjs7tbmo41otakwh89g9wdz7nih X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723168942-784085 X-HE-Meta: U2FsdGVkX18fn7L8Aggonk3jWHg8pCkkUggBurL5C6VDtYFeeOaU0a37OTjhyOrX1YEkNzP3D9JSCe3+D+/MF1Xf3CG9wafIu2LgarC6zuxPE2BfzlgM9nVVqcCy7SlD5/sT8RZI3gF1qhtYyiJ/DavKnwDk/69MdGrrz7Wg4PGSD7XaeFos3A7+q1OqEfRjhoZBBobI0ZymlmPLn8WboIuGgJdslTkw++/4nYvdxpNuqzJpJUJ0FytBNwZRyTZgrSrIElhh+OufPO9GfI9WHXclPAx6NY5XwWiiaKMsgdauU4JGfR+q9XK+bGj/0GG3hB6JVZG5XOp6JJGkW+F7wN05ZJsgywqfCP+iFaDWPwKYKZQZP37cxmeIQsYQsp6elp7mBKZhje216Irh76h+kjSuziayjBgKpN9f4XwA8ETnnkB6naMvyOd4IiggTXBnLZVvFja9yPDWBrv1JCtL6NhVO/3FkPk0938wsl1RcJlIK7p3p80RvJqsqAKlgUy2oaviY9mUnXbraCLmysVz2YLgJ1Y15K3qOpAAum5dIRsUZ5KBYGec9hoX8bdV1mo0rOB/hbGePb4/xpBh6uI20Z3CyBoBYWlr7OhXPcbfdb3YrDZQkn9yZvf8rUFKMvxjGXLEMFrqb7NETzW0SFjvEojeAV62okufF4eKu7n1m4fVUebSTIs9LmEuUorDSgxIxvTHXm28Z7Z5+9KnmUb8yPi6u50WWPE8cMIyqRftXtcsg9z60X7XM2n/Dg6Fh+/od/CCdskK/r1G5T+DDo0amrbvOkE/8wf/79ic2bsVbYD7js+BsD5PiDsu5+Lr0/2482lYWkYfTBYdnpsRxUv8uhd0iYv0PoREUtR0hpjU/EliY6GdGmK0AtQWlitZbR22DrCiwO155I37QV4HeXOOfLW6HFQTPjq0gQV94EcX8acj5T3m2WyqmAP0KrVAXu5srzbYSrz0WiVRzYMoDNf KEwc7LfK X9Sepg0t7dUlOGwPlzqmKpmxVg8stThYA1t7wIGBiQQGGl9CEE+05/Yejw861X22DpJWjTVdrWx+eHLmaoGjWPRSnolRJnzrZfJPhVXym4h2BlAMZ0WT3NloHNBBUBCz+5CTeTIUD7HBlJCHaxWVhJTTJ9ekZl1HGPPxmoOSK2ar9zxoGseIpH4kkwI5MGkU0TAlQKXkw2b8MxrbnRuDnyuYxmUkABNg6UF85DijihpMzoNHnLJf4iVyYQXSelpAOAW/7HGO9QM+kDsQ= 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/8/7 19:14, David Hildenbrand wrote: > On 07.08.24 09:39, Miaohe Lin wrote: >> On 2024/8/6 17:29, David Hildenbrand wrote: >>> On 02.08.24 09:50, Kefeng Wang wrote: >>>> >>>> >>>> On 2024/8/2 4:10, David Hildenbrand wrote: >>>>> >>>>>>> >>>>>>> We're not checking the head page here, will this work reliably for >>>>>>> hugetlb? (I recall some difference in per-page hwpoison handling between >>>>>>> hugetlb and THP due to the vmemmap optimization) >>>>>> >>>>>> Before this changes, the hwposioned hugetlb page won't try to unmap in >>>>>> do_migrate_range(), we hope it already unmapped in memory_failure(), as >>>>>> mentioned from comments, there maybe fail to unmap, so a new safeguard >>>>>> to try to unmap it again here, but we don't need to guarantee it. >>>>> >>>>> Thanks for clarifying! >>>>> >>>>> But I do wonder if the PageHWPoison() is the right thing to do for hugetlb. >>>>> >>>>> IIUC, hugetlb requires folio_test_hwpoison() -- testing the head page >>>>> not the subpage. Reason is that due to the vmemmap optimization we might >>>>> not be able to modify subpages to set hwpoison. >>>> >>>> Yes, HVO is special(only head page with hwpoison), since we always want >>>> to check head page here (next pfn = head_pfn + nr), so it might be >>>> enough to only use PageHWpoison, but just in case, adding hwpoison check >>>> for the head page, >>>> >>>>      if (unlikely(PageHWPoison(page) || folio_test_hwpoison(folio))) >>> >>> I also do wonder if we have to check for large folios folio_test_has_hwpoison(): >>> if any subpage is poisoned, not just the current page. >>> >> >> IMHO, below if condition [1] should be fine to check for any hwpoisoned folio: >> >>   if (folio_test_hwpoison(folio) || >>        (folio_test_large(folio) && folio_test_has_hwpoisoned(folio))) { >> >> 1. For raw pages, folio_test_hwpoison(folio) works fine. >> 2. For thp (memory_failure fails to split it in first place), folio_test_has_hwpoisoned(folio) works fine. >> 3. For hugetlb, we always have hwpoison flag set for folio. So folio_test_hwpoison(folio) works fine. It seems I missed one corner case. When memory_failure meets an isolated thp, get_hwpoison_page() will return EIO and thp won't have has_hwpoison flag set. Above pattern might not work with it. :( >> >> But folio might not be the right hwpoisoned page, i.e. subpages might be hwpoisoned instead. >> Or am I miss something? > > Yes, but we can only migrate full folios, and if any subpage is poisoned we're in trouble and have to effectively force-unmap it? Yes, I agree with you. > > At least that's my understanding :) Thanks. .