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 X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A33CC433DB for ; Tue, 2 Feb 2021 01:33:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CD45664E46 for ; Tue, 2 Feb 2021 01:33:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD45664E46 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 60D5A6B0006; Mon, 1 Feb 2021 20:33:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5BBA36B006E; Mon, 1 Feb 2021 20:33:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D2DE6B0070; Mon, 1 Feb 2021 20:33:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 3B52B6B0006 for ; Mon, 1 Feb 2021 20:33:10 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 09B4B1EE6 for ; Tue, 2 Feb 2021 01:33:10 +0000 (UTC) X-FDA: 77771604540.21.lip36_3e16776275c6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id E5020180442C0 for ; Tue, 2 Feb 2021 01:33:09 +0000 (UTC) X-HE-Tag: lip36_3e16776275c6 X-Filterd-Recvd-Size: 3519 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 01:33:09 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DV6jZ1DpHz7fV9; Tue, 2 Feb 2021 09:31:46 +0800 (CST) Received: from [10.174.179.241] (10.174.179.241) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 2 Feb 2021 09:33:00 +0800 Subject: Re: [PATCH] mm/huge_memory.c: use helper range_in_vma() in __split_huge_p[u|m]d_locked() To: David Rientjes CC: , , References: <20210201093259.52798-1-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <0058619f-6516-fb28-7a7b-6bef710889e9@huawei.com> Date: Tue, 2 Feb 2021 09:33:00 +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: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.241] X-CFilter-Loop: Reflected 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 2021/2/2 5:27, David Rientjes wrote: > On Mon, 1 Feb 2021, Miaohe Lin wrote: > >> The helper range_in_vma() is introduced via commit 017b1660df89 ("mm: >> migration: fix migration of huge PMD shared pages"). But we forgot to >> use it in __split_huge_pud_locked() and __split_huge_pmd_locked(). >> >> Signed-off-by: Miaohe Lin >> --- >> mm/huge_memory.c | 6 ++---- >> 1 file changed, 2 insertions(+), 4 deletions(-) >> >> diff --git a/mm/huge_memory.c b/mm/huge_memory.c >> index 987cf5e4cf90..33353a4f95fb 100644 >> --- a/mm/huge_memory.c >> +++ b/mm/huge_memory.c >> @@ -1959,8 +1959,7 @@ static void __split_huge_pud_locked(struct vm_area_struct *vma, pud_t *pud, >> unsigned long haddr) >> { >> VM_BUG_ON(haddr & ~HPAGE_PUD_MASK); >> - VM_BUG_ON_VMA(vma->vm_start > haddr, vma); >> - VM_BUG_ON_VMA(vma->vm_end < haddr + HPAGE_PUD_SIZE, vma); >> + VM_BUG_ON_VMA(!range_in_vma(vma, haddr, haddr + HPAGE_PUD_SIZE), vma); >> VM_BUG_ON(!pud_trans_huge(*pud) && !pud_devmap(*pud)); >> >> count_vm_event(THP_SPLIT_PUD); >> @@ -2039,8 +2038,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, >> int i; >> >> VM_BUG_ON(haddr & ~HPAGE_PMD_MASK); >> - VM_BUG_ON_VMA(vma->vm_start > haddr, vma); >> - VM_BUG_ON_VMA(vma->vm_end < haddr + HPAGE_PMD_SIZE, vma); >> + VM_BUG_ON_VMA(!range_in_vma(vma, haddr, haddr + HPAGE_PMD_SIZE), vma); >> VM_BUG_ON(!is_pmd_migration_entry(*pmd) && !pmd_trans_huge(*pmd) >> && !pmd_devmap(*pmd)); >> > > This actually loses information, right? Before the patch, we can > determine which conditional is failing because we know the line number > that the VM_BUG_ON() is happening on. After the patch, we don't know > this. > You are right. We can determine which conditional is failing only through line number via VM_BUG_ON_VMA. So this will loses the information. My careless. :( Many thanks for kindly explanation. > I don't think that's crucial, but I'm not sure it makes sense to do this > if the only upside is that we removed one total line of code :) > . >