From patchwork Sat Jun 18 07:32:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12886240 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 8D84DC433EF for ; Sat, 18 Jun 2022 07:32:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 066706B0071; Sat, 18 Jun 2022 03:32:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F31116B0072; Sat, 18 Jun 2022 03:32:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD3096B0073; Sat, 18 Jun 2022 03:32:44 -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 C87F26B0071 for ; Sat, 18 Jun 2022 03:32:44 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9F1E335A93 for ; Sat, 18 Jun 2022 07:32:44 +0000 (UTC) X-FDA: 79590539448.15.24AF4D7 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf08.hostedemail.com (Postfix) with ESMTP id E3FF316009D for ; Sat, 18 Jun 2022 07:32:43 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LQ6zS6cS0zjYj3; Sat, 18 Jun 2022 15:31:32 +0800 (CST) Received: from huawei.com (10.175.124.27) 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; Sat, 18 Jun 2022 15:32:40 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm: stricter check on THP migration entry Date: Sat, 18 Jun 2022 15:32:43 +0800 Message-ID: <20220618073243.9423-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] 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=1655537564; a=rsa-sha256; cv=none; b=aJb65z8cui51u6YHr31h0xvet8b7bP8qjY8Npi4frKtY4rU/Pm1WS7nLxOkUFUJLjS5IFU iZTUcsMH6w2gk08PNMKAiiCzXbkVB3+ba9T8bYGH/ZgAQP4x5vaD5HdxngvrPEv1hk2c3W oxPUCwePYi1uXzmv43RlHqKtDwhzsEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655537564; 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: references; bh=OAbiuTvV2vU5AVDerJjqEtaDauItbvLGhiNRLW/8RG0=; b=vIbgWUDMhoZyvqg9H4tFf7sHRKbZaTJITJNcpqs5xOB07y8uamaoFV8L/AulaiW1wv3iGV ISCPzOWInKbUbZNqE5uOfyKh/wCMWLM9zab0vIVsjp9/3aM1sEHcKAz6pAVBuEu3BlhEwD kVUZz8pEu+4RdFUuP9anNn86t+LE/BY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf08.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: E3FF316009D X-Stat-Signature: cqed38f7i89nm6uir4g4q57x6mu7eb8m X-HE-Tag: 1655537563-231770 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: When VM_BUG_ON check for THP migration entry, the existing code only check thp_migration_supported case, but not for !thp_migration_supported case. If !thp_migration_supported() and !pmd_present(), the original code may dead loop in theory. To make the VM_BUG_ON check more consistent, we need to catch both cases. Signed-off-by: Miaohe Lin --- mm/memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index fee2884481f2..6a9a17c7f58a 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5043,10 +5043,9 @@ static vm_fault_t __handle_mm_fault(struct vm_area_struct *vma, barrier(); if (unlikely(is_swap_pmd(vmf.orig_pmd))) { - VM_BUG_ON(thp_migration_supported() && - !is_pmd_migration_entry(vmf.orig_pmd)); - if (is_pmd_migration_entry(vmf.orig_pmd)) - pmd_migration_entry_wait(mm, vmf.pmd); + VM_BUG_ON(!thp_migration_supported() || + !is_pmd_migration_entry(vmf.orig_pmd)); + pmd_migration_entry_wait(mm, vmf.pmd); return 0; } if (pmd_trans_huge(vmf.orig_pmd) || pmd_devmap(vmf.orig_pmd)) {