lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2baf9a1b-1c69-8168-cfd9-5b5ad45a4cc8@oracle.com>
Date:   Fri, 12 Mar 2021 12:03:37 -0800
From:   Mike Kravetz <mike.kravetz@...cle.com>
To:     Miaohe Lin <linmiaohe@...wei.com>, akpm@...ux-foundation.org
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH 5/5] mm/hugetlb: avoid calculating fault_mutex_hash in
 truncate_op case

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@...wei.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.
-- 
Mike Kravetz

>  
>  			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]);
>  			}
>  
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ