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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 6C9D8C43461 for ; Fri, 9 Apr 2021 06:36:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AF1F661182 for ; Fri, 9 Apr 2021 06:36:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF1F661182 Authentication-Results: mail.kernel.org; dmarc=fail (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 0024E6B006C; Fri, 9 Apr 2021 02:36:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF5D76B006E; Fri, 9 Apr 2021 02:36:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D96276B0070; Fri, 9 Apr 2021 02:36:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0107.hostedemail.com [216.40.44.107]) by kanga.kvack.org (Postfix) with ESMTP id C0BDF6B006C for ; Fri, 9 Apr 2021 02:36:10 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 6BA73181ECAD4 for ; Fri, 9 Apr 2021 06:36:10 +0000 (UTC) X-FDA: 78011868900.37.7681CEB Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf22.hostedemail.com (Postfix) with ESMTP id 458A6C0007C6 for ; Fri, 9 Apr 2021 06:36:06 +0000 (UTC) Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FGpH05ts5zPpXF; Fri, 9 Apr 2021 14:33:16 +0800 (CST) Received: from [10.174.179.9] (10.174.179.9) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.498.0; Fri, 9 Apr 2021 14:36:04 +0800 Subject: Re: [PATCH 3/4] mm/hugeltb: fix potential wrong gbl_reserve value for hugetlb_acct_memory() To: Mike Kravetz , CC: , , References: <20210402093249.25137-1-linmiaohe@huawei.com> <20210402093249.25137-4-linmiaohe@huawei.com> <20afccd5-2bc4-9db9-695e-dd6175b0b42b@oracle.com> <1311fcfe-bc5f-e878-3912-ca9a9e0eed90@huawei.com> <0ebaa062-80e8-b380-c02e-7eb72e67f973@huawei.com> <90188b1a-a206-5586-2da9-683f7537f960@oracle.com> <8dfe32a3-1789-6a40-b650-304c2cfb6531@huawei.com> <83e5f2a0-bf92-ab42-c5ff-52a07eab9ee8@oracle.com> From: Miaohe Lin Message-ID: Date: Fri, 9 Apr 2021 14:36:04 +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: <83e5f2a0-bf92-ab42-c5ff-52a07eab9ee8@oracle.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.9] X-CFilter-Loop: Reflected X-Stat-Signature: pj5gs181k8t4pf18edwrjnecw9ju3esi X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 458A6C0007C6 Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf22; identity=mailfrom; envelope-from=""; helo=szxga05-in.huawei.com; client-ip=45.249.212.191 X-HE-DKIM-Result: none/none X-HE-Tag: 1617950166-654836 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/4/9 12:37, Mike Kravetz wrote: > On 4/8/21 8:01 PM, Miaohe Lin wrote: >> On 2021/4/9 6:53, Mike Kravetz wrote: >>> >>> Yes, add a comment to hugetlb_unreserve_pages saying that !resv_map >>> implies freed == 0. >>> >> >> Sounds good! >> >>> It would also be helpful to check for (chg - freed) == 0 and skip the >>> calls to hugepage_subpool_put_pages() and hugetlb_acct_memory(). Both >>> of those routines may perform an unnecessary lock/unlock cycle in this >>> case. >>> >>> A simple >>> if (chg == free) >>> return 0; >>> before the call to hugepage_subpool_put_pages would work. >> >> This may not be really helpful because hugepage_subpool_put_pages() and hugetlb_acct_memory() >> both would handle delta == 0 case without unnecessary lock/unlock cycle. >> Does this make sense for you? If so, I will prepare v2 with the changes to add a comment >> to hugetlb_unreserve_pages() __without__ the check for (chg - freed) == 0. > > Sorry, I forgot about the recent changes to check for delta == 0. > No need for the check here, just the comment. > That's all right. Will add the comment in V2. Thanks.