linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: Mike Kravetz <mike.kravetz@oracle.com>, <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
Date: Sat, 13 Mar 2021 10:49:26 +0800	[thread overview]
Message-ID: <d40df812-7b02-78fd-65d4-41bbcc9d4c6d@huawei.com> (raw)
In-Reply-To: <2baf9a1b-1c69-8168-cfd9-5b5ad45a4cc8@oracle.com>

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 <linmiaohe@huawei.com>
>> ---
>>  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.

> 


  reply	other threads:[~2021-03-13  2:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08 11:28 [PATCH 0/5] Some cleanups for hugetlb Miaohe Lin
2021-03-08 11:28 ` [PATCH 1/5] mm/hugetlb: use some helper functions to cleanup code Miaohe Lin
2021-03-08 11:28 ` [PATCH 2/5] mm/hugetlb: optimize the surplus state transfer code in move_hugetlb_state() Miaohe Lin
2021-03-08 11:28 ` [PATCH 3/5] hugetlb_cgroup: remove unnecessary VM_BUG_ON_PAGE in hugetlb_cgroup_migrate() Miaohe Lin
2021-03-12 19:46   ` Mike Kravetz
2021-03-08 11:28 ` [PATCH 4/5] mm/hugetlb: simplify the code when alloc_huge_page() failed in hugetlb_no_page() Miaohe Lin
2021-03-12 19:58   ` Mike Kravetz
2021-03-13  2:54     ` Miaohe Lin
2021-03-08 11:28 ` [PATCH 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case Miaohe Lin
2021-03-12 20:03   ` Mike Kravetz
2021-03-13  2:49     ` Miaohe Lin [this message]
2021-03-13 21:17       ` Mike Kravetz
2021-03-15  1:50         ` Miaohe Lin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d40df812-7b02-78fd-65d4-41bbcc9d4c6d@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).