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.3 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,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 165BEC433DB for ; Sat, 13 Mar 2021 02:54:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9083564F4E for ; Sat, 13 Mar 2021 02:54:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9083564F4E 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 1FF2A6B006C; Fri, 12 Mar 2021 21:54:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AE896B006E; Fri, 12 Mar 2021 21:54:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07A066B0070; Fri, 12 Mar 2021 21:54:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id DDECC6B006C for ; Fri, 12 Mar 2021 21:54:19 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9851B8E7B for ; Sat, 13 Mar 2021 02:54:18 +0000 (UTC) X-FDA: 77913332196.01.4B56E10 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf20.hostedemail.com (Postfix) with ESMTP id 2BFDA132 for ; Sat, 13 Mar 2021 02:54:13 +0000 (UTC) Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Dy6f34hcNzmWn8; Sat, 13 Mar 2021 10:51:55 +0800 (CST) Received: from [10.174.179.232] (10.174.179.232) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Sat, 13 Mar 2021 10:54:08 +0800 Subject: Re: [PATCH 4/5] mm/hugetlb: simplify the code when alloc_huge_page() failed in hugetlb_no_page() To: Mike Kravetz , CC: , References: <20210308112809.26107-1-linmiaohe@huawei.com> <20210308112809.26107-5-linmiaohe@huawei.com> <987f50e0-5511-7f53-c4b9-d8878d840bb5@oracle.com> From: Miaohe Lin Message-ID: <1d72e0c4-de4d-351c-2867-10981f44b7fb@huawei.com> Date: Sat, 13 Mar 2021 10:54:08 +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: <987f50e0-5511-7f53-c4b9-d8878d840bb5@oracle.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.232] X-CFilter-Loop: Reflected X-Stat-Signature: uf86g77ywqo9q94bqgjc7wtxuksfo59s X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2BFDA132 Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=szxga04-in.huawei.com; client-ip=45.249.212.190 X-HE-DKIM-Result: none/none X-HE-Tag: 1615604053-372256 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/3/13 3:58, Mike Kravetz wrote: > On 3/8/21 3:28 AM, Miaohe Lin wrote: >> Rework the error handling code when alloc_huge_page() failed to remove some >> duplicated code and simplify the code slightly. >> >> Signed-off-by: Miaohe Lin >> --- >> mm/hugetlb.c | 9 +++------ >> 1 file changed, 3 insertions(+), 6 deletions(-) >> >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index 695603071f2c..69b8de866a24 100644 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -4337,13 +4337,10 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, >> * sure there really is no pte entry. >> */ >> ptl = huge_pte_lock(h, mm, ptep); >> - if (!huge_pte_none(huge_ptep_get(ptep))) { >> - ret = 0; >> - spin_unlock(ptl); >> - goto out; >> - } >> + ret = 0; >> + if (huge_pte_none(huge_ptep_get(ptep))) >> + ret = vmf_error(PTR_ERR(page)); > > This new code is simpler. > > The !huge_pte_none() catches an unlikely race. IMO, the existing code > made that very clear. Would have been even more clear with an unlikely > modifier. In any case, the lengthy comment above this code makes it > clear why the check is there. Code changes are fine. > Yep, the lengthy comment above this code makes it much clear why we need the check. Thanks for carefully review! :) > Reviewed-by: Mike Kravetz >