linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Miaohe Lin <linmiaohe@huawei.com>, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v2 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in truncate_op case
Date: Mon, 15 Mar 2021 20:07:00 -0700	[thread overview]
Message-ID: <d87264fb-0005-4f8b-7551-a5439108e9e1@oracle.com> (raw)
In-Reply-To: <20210316022758.52993-1-linmiaohe@huawei.com>

On 3/15/21 7:27 PM, 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.
> 
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> ---
> v1->v2:
> remove unnecessary initialization for variable hash
> collect Reviewed-by tag from Mike Kravetz

My apologies for not replying sooner and any misunderstanding from my
previous comments.

If the compiler is going to produce a warning because the variable is
not initialized, then we will need to keep the initialization.
Otherwise, this will show up as a build regression.  Ideally, there
would be a modifier which could be used to tell the compiler the
variable will used.  I do not know if such a modifier exists.

The patch can not produce a new warning.  So, if you need to initialize
the variable then do it.  My Reviewed-by still applies.
-- 
Mike Kravetz

> ---
>  fs/hugetlbfs/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index c262566f7c5d..f7ec94bc7337 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -485,7 +485,6 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
>  			u32 hash;
>  
>  			index = page->index;
> -			hash = hugetlb_fault_mutex_hash(mapping, index);
>  			if (!truncate_op) {
>  				/*
>  				 * Only need to hold the fault mutex in the
> @@ -493,6 +492,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart,
>  				 * page faults.  Races are not possible in the
>  				 * case of truncation.
>  				 */
> +				hash = hugetlb_fault_mutex_hash(mapping, index);
>  				mutex_lock(&hugetlb_fault_mutex_table[hash]);
>  			}
>  
> 


  reply	other threads:[~2021-03-16  3:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16  2:27 Miaohe Lin
2021-03-16  3:07 ` Mike Kravetz [this message]
2021-03-16  6:49   ` Miaohe Lin
2021-03-17  0:27     ` Mike Kravetz
2021-03-17  1:44       ` 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=d87264fb-0005-4f8b-7551-a5439108e9e1@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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