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 16F8AFA373F for ; Tue, 25 Oct 2022 06:17:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2241880008; Tue, 25 Oct 2022 02:17:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D3B980007; Tue, 25 Oct 2022 02:17:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C41880008; Tue, 25 Oct 2022 02:17:13 -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 EF16480007 for ; Tue, 25 Oct 2022 02:17:12 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 74056A0646 for ; Tue, 25 Oct 2022 06:17:12 +0000 (UTC) X-FDA: 80058464304.30.86F1EB5 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf20.hostedemail.com (Postfix) with ESMTP id 1F34D1C0009 for ; Tue, 25 Oct 2022 06:17:08 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MxM8n2hyrzJnFP; Tue, 25 Oct 2022 14:14:17 +0800 (CST) Received: from [10.174.151.185] (10.174.151.185) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 25 Oct 2022 14:17:02 +0800 Subject: Re: [PATCH v8 1/4] mm,hwpoison,hugetlb,memory_hotplug: hotremove memory section with hwpoisoned hugepage To: Naoya Horiguchi CC: , Andrew Morton , David Hildenbrand , Mike Kravetz , Yang Shi , Oscar Salvador , Muchun Song , Jane Chu , Naoya Horiguchi , References: <20221024062012.1520887-1-naoya.horiguchi@linux.dev> <20221024062012.1520887-2-naoya.horiguchi@linux.dev> <2484c6be-5075-2203-4f16-9cfdc4876e11@huawei.com> <20221025053559.GA2104800@ik1-406-35019.vs.sakura.ne.jp> From: Miaohe Lin Message-ID: <6decf924-1743-d67e-8222-0f02f83b05c1@huawei.com> Date: Tue, 25 Oct 2022 14:17: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: <20221025053559.GA2104800@ik1-406-35019.vs.sakura.ne.jp> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666678632; a=rsa-sha256; cv=none; b=PDfNM37uvzfmzfZ/zlleSc/HROVTkpoZbmW97OtV2aaHkcHvWyjWqQc7noNIFik7BX8vAB Rx9Ayj7FvQr/ri6HiZg+MMeFpB6duuEavmrRsRUxEM5kS2Ctau3r3TK2vBJ5uL4leaua43 +oWckEjcODyuhQB/ZAoi7ujh0pgbUh8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 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=1666678632; 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=cZYv9dIH4RWWPRl0z3ttUoUMwbrA0is5892gd87uOWM=; b=vng4ngNhPgUHDbUgO1CkWbgbZs2jhKTaqfgZEt9aqf07FhaEr2fUkXOs4NYjvtqzVXoSiZ fHNWrh5f2pe5ws4FWtZIsSXSTlUa1L2ehBo9FtpVRrkCihGAWSJx16ShpwhSjPE8U5KBVx mJ9EBIyqjC6FVZEeinlPLbRw312hyB8= X-Stat-Signature: 66btocopix5383xag9cm7xuwy3kxa3x8 X-Rspamd-Queue-Id: 1F34D1C0009 Authentication-Results: imf20.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf20.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1666678628-320081 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: On 2022/10/25 13:35, Naoya Horiguchi wrote: > On Tue, Oct 25, 2022 at 10:38:11AM +0800, Miaohe Lin wrote: >> On 2022/10/24 14:20, Naoya Horiguchi wrote: >>> From: Naoya Horiguchi >>> >>> HWPoisoned page is not supposed to be accessed once marked, but currently >>> such accesses can happen during memory hotremove because do_migrate_range() >>> can be called before dissolve_free_huge_pages() is called. >>> >>> Clear HPageMigratable for hwpoisoned hugepages to prevent them from being >>> migrated. This should be done in hugetlb_lock to avoid race against >>> isolate_hugetlb(). >>> >>> get_hwpoison_huge_page() needs to have a flag to show it's called from >>> unpoison to take refcount of hwpoisoned hugepages, so add it. >>> >>> Reported-by: Miaohe Lin >>> Signed-off-by: Naoya Horiguchi >>> Reviewed-by: Oscar Salvador >>> Reviewed-by: Miaohe Lin >>> --- >>> ChangeLog v3 -> v7: >>> - introduce TESTCLEARHPAGEFLAG() to determine the value of migratable_cleared >> >> Many thanks for update, Naoya. I'm sorry but TestClearHPageMigratable() might be somewhat >> overkill. As we discussed in previous thread: >> >> """ >> I think I might be nitpicking... But it seems ClearHPageMigratable is not enough here. >> 1. In MF_COUNT_INCREASED case, we don't know whether HPageMigratable is set. >> 2. Even if HPageMigratable is set, there might be a race window before we clear HPageMigratable? >> So "*migratable_cleared = TestClearHPageMigratable" might be better? But I might be wrong. >> """ >> >> The case 2 should be a dumb problem(sorry about it). HPageMigratable() is always cleared while holding >> the hugetlb_lock which is already held by get_huge_page_for_hwpoison(). So the only case we should care >> about is case 1 and that can be handled by below more efficient pattern: >> if (HPageMigratable) >> ClearHPageMigratable() >> >> So the overhead of test and clear atomic ops can be avoided. But this is trival. >> >> Anyway, this patch still looks good to me. And my Reviewed-by tag still applies. Many thanks. > > OK, so I replace this 1/4 with the following one, thank you. Many thanks for your update, Naoya. ;) This version looks good to me too. Thanks, Miaohe Lin