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 8F861C67871 for ; Tue, 25 Oct 2022 02:38:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9588880008; Mon, 24 Oct 2022 22:38:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9088180007; Mon, 24 Oct 2022 22:38:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A9DA80008; Mon, 24 Oct 2022 22:38:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 66BF880007 for ; Mon, 24 Oct 2022 22:38:20 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 27ACE1204B0 for ; Tue, 25 Oct 2022 02:38:20 +0000 (UTC) X-FDA: 80057912760.25.984AECF Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id 21D3240014 for ; Tue, 25 Oct 2022 02:38:17 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MxGFr3mrwzmVJt; Tue, 25 Oct 2022 10:33:20 +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 10:38:11 +0800 Subject: Re: [PATCH v7 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> From: Miaohe Lin Message-ID: <2484c6be-5075-2203-4f16-9cfdc4876e11@huawei.com> Date: Tue, 25 Oct 2022 10:38:11 +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: <20221024062012.1520887-2-naoya.horiguchi@linux.dev> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.151.185] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666665499; a=rsa-sha256; cv=none; b=kMkU8HJDD5xUZCVeu1JYmREKC/ali1I0dHgZqeLLKGZbRTBKwTj+sUJJ554nYWXWD4wDmL APNrWcQSTEzqQ2waMxfxZ6Hz9JQVeF75KHCds72XRdoLHTQsZjmQytxgwnJASDDyJ5hb03 UJDhL2wojgqITm/iDT1Vp50O2xndins= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 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=1666665499; 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=iMc/BQzAXgsoe8JcweslCwXRv+Zqwmyqy3PKWjioj5U=; b=UGSNYuRwZkib/beof5cwiHalQWccM3gdtH99fGlU9ay5LbRElqI2Xoatf5FXYdliPVM3Cx o72+TcHumdnyd1RviROQKR1rwiCPHfaV8KplJV6bUwtvc514tR3VogNYGW5PZ3jFRr1TNo zgpIqcdGXEJo7ScUr8K8g1d8t/JWHd0= X-Rspamd-Queue-Id: 21D3240014 Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspamd-Server: rspam12 X-Rspam-User: X-Stat-Signature: xdbfeie9x44mhy3sgm6m934fgfc4mrou X-HE-Tag: 1666665497-566640 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/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. Thanks, Miaohe Lin