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 0642BC433DB for ; Sat, 13 Mar 2021 02:49:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 60C6664DF5 for ; Sat, 13 Mar 2021 02:49:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60C6664DF5 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 C695F6B006C; Fri, 12 Mar 2021 21:49:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3F396B006E; Fri, 12 Mar 2021 21:49:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ADF796B0070; Fri, 12 Mar 2021 21:49:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0072.hostedemail.com [216.40.44.72]) by kanga.kvack.org (Postfix) with ESMTP id 8F7806B006C for ; Fri, 12 Mar 2021 21:49:44 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CDADCAF6B for ; Sat, 13 Mar 2021 02:49:41 +0000 (UTC) X-FDA: 77913320562.26.26922DB Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by imf13.hostedemail.com (Postfix) with ESMTP id AF226E0011D2 for ; Sat, 13 Mar 2021 02:49:37 +0000 (UTC) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Dy6Y921MKz8xKG; Sat, 13 Mar 2021 10:47:41 +0800 (CST) Received: from [10.174.179.232] (10.174.179.232) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Sat, 13 Mar 2021 10:49:26 +0800 Subject: Re: [PATCH 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case To: Mike Kravetz , CC: , References: <20210308112809.26107-1-linmiaohe@huawei.com> <20210308112809.26107-6-linmiaohe@huawei.com> <2baf9a1b-1c69-8168-cfd9-5b5ad45a4cc8@oracle.com> From: Miaohe Lin Message-ID: Date: Sat, 13 Mar 2021 10:49:26 +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: <2baf9a1b-1c69-8168-cfd9-5b5ad45a4cc8@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: e5eun8rehs79iamkosyapqkf4j5useoq X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: AF226E0011D2 Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=szxga07-in.huawei.com; client-ip=45.249.212.35 X-HE-DKIM-Result: none/none X-HE-Tag: 1615603777-267123 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: Hi: On 2021/3/13 4:03, Mike Kravetz wrote: > On 3/8/21 3:28 AM, Miaohe Lin wrote: >> The fault_mutex hashing overhead can be avoided in truncate_op case because >> page faults can not race with truncation in this routine. So calculate hash >> for fault_mutex only in !truncate_op case to save some cpu cycles. >> >> Signed-off-by: Miaohe Lin >> --- >> fs/hugetlbfs/inode.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c >> index c262566f7c5d..d81f52b87bd7 100644 >> --- a/fs/hugetlbfs/inode.c >> +++ b/fs/hugetlbfs/inode.c >> @@ -482,10 +482,9 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart, >> >> for (i = 0; i < pagevec_count(&pvec); ++i) { >> struct page *page = pvec.pages[i]; >> - u32 hash; >> + u32 hash = 0; > > Do we need to initialize hash here? > I would not bring this up normally, but the purpose of the patch is to save > cpu cycles. The hash is initialized here in order to avoid false positive "uninitialized local variable used" warning. Or this is indeed unnecessary? Many thanks for review. >