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 52822C433EF for ; Fri, 24 Jun 2022 09:24:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0DD28E0208; Fri, 24 Jun 2022 05:24:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBDE08E0205; Fri, 24 Jun 2022 05:24:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAD3A8E0208; Fri, 24 Jun 2022 05:24:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AC7158E0205 for ; Fri, 24 Jun 2022 05:24:03 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7608AA94 for ; Fri, 24 Jun 2022 09:24:03 +0000 (UTC) X-FDA: 79612592766.24.635F60B Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf14.hostedemail.com (Postfix) with ESMTP id 9F27810002A for ; Fri, 24 Jun 2022 09:24:01 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LTs7d0brFz1K9QT; Fri, 24 Jun 2022 17:21:33 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) 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.24; Fri, 24 Jun 2022 17:23:42 +0800 Subject: Re: [PATCH v2 2/9] mm/hugetlb: separate path for hwpoison entry in copy_hugetlb_page_range() To: Naoya Horiguchi CC: Andrew Morton , David Hildenbrand , Mike Kravetz , Liu Shixin , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , , Linux-MM References: <20220623235153.2623702-1-naoya.horiguchi@linux.dev> <20220623235153.2623702-3-naoya.horiguchi@linux.dev> From: Miaohe Lin Message-ID: Date: Fri, 24 Jun 2022 17:23:41 +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: <20220623235153.2623702-3-naoya.horiguchi@linux.dev> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656062642; 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=xKhapUt8MlkBhdPtJ+iSBi8fuVsuv4fmvi+y2dAxlnI=; b=EiYnxWnIdWCOcY24lROlCCIzjepVSxp5VA92TXrQRPS6/bO9F1uFkKxnp7wAWrx8KGho2q 8N7IN+e/PP4P1MphTtWnqFHGsB+quY6o8gNLLAG/RixM4OGw0PAdb5zKJYszZV9+glRZ1z HsWR1YYHtHG3m7kNoIptBJgGYc+t4Qc= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656062642; a=rsa-sha256; cv=none; b=GPVWU1a8+u23n7fsrk4lZeIc6e/SiVMcB+rHfSOyqc//BU5vUfFOt2wekAPElOZ9pKS4O7 HbfMXobYjxvKHtIsAXQIqkFmuRjSuDG4o/PTlkfHR0GW9TKozql8dXkXudpg6azyk6kPH3 s4uhkRHb2wyi5UHtHQR1i7JVVYCn5rg= Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: ia7t5p5n3f7mtrxx58bpb6p6s7xf3tsc X-Rspamd-Queue-Id: 9F27810002A X-HE-Tag: 1656062641-11526 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/6/24 7:51, Naoya Horiguchi wrote: > From: Naoya Horiguchi > > Originally copy_hugetlb_page_range() handles migration entries and hwpoisone s/hwpoisone/hwpoisoned/ > entries in similar manner. But recently the related code path has more code > for migration entries, and when is_writable_migration_entry() was converted > to !is_readable_migration_entry(), hwpoison entries on source processes got > to be unexpectedly updated (which is legitimate for migration entries, but > not for hwpoison entries). This results in unexpected serious issues like > kernel panic when foking processes with hwpoison entries in pmd. s/foking/forking/ > > Separate the if branch into one for hwpoison entries and one for migration > entries. > > Fixes: 6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive") > Signed-off-by: Naoya Horiguchi > Cc: # 5.18 This makes sense to me. Thanks for fixing this. Reviewed-by: Miaohe Lin > --- > mm/hugetlb.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index c538278170a2..f59f43c06601 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -4784,8 +4784,13 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, > * sharing with another vma. > */ > ; > - } else if (unlikely(is_hugetlb_entry_migration(entry) || > - is_hugetlb_entry_hwpoisoned(entry))) { > + } else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) { > + bool uffd_wp = huge_pte_uffd_wp(entry); > + > + if (!userfaultfd_wp(dst_vma) && uffd_wp) > + entry = huge_pte_clear_uffd_wp(entry); > + set_huge_swap_pte_at(dst, addr, dst_pte, entry, sz); > + } else if (unlikely(is_hugetlb_entry_migration(entry))) { > swp_entry_t swp_entry = pte_to_swp_entry(entry); > bool uffd_wp = huge_pte_uffd_wp(entry); > >