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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12AB6C38A2D for ; Tue, 25 Oct 2022 06:17:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231180AbiJYGRM (ORCPT ); Tue, 25 Oct 2022 02:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbiJYGRH (ORCPT ); Tue, 25 Oct 2022 02:17:07 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46C2DF8 for ; Mon, 24 Oct 2022 23:17:04 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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