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] [day] [month] [year] [list]
Message-ID: <a26624a2-937d-435b-b866-97c1bedb4894@huawei.com>
Date:   Sat, 16 Apr 2022 09:06:04 +0800
From:   Miaohe Lin <linmiaohe@...wei.com>
To:     Naoya Horiguchi <naoya.horiguchi@...ux.dev>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Andrew Morton <akpm@...ux-foundation.org>
CC:     Yang Shi <shy828301@...il.com>,
        Dan Carpenter <dan.carpenter@...cle.com>,
        <naoya.horiguchi@....com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [PATCH 4/3] mm, hugetlb, hwpoison: separate branch for free and
 in-use hugepage

On 2022/4/15 12:18, Naoya Horiguchi wrote:
> From: Naoya Horiguchi <naoya.horiguchi@....com>
> 
> We know that HPageFreed pages should have page refcount 0, so
> get_page_unless_zero() always fails and returns 0.  So explicitly separate
> the branch based on page state for minor optimization and better readability.
> 
> Suggested-by: Mike Kravetz <mike.kravetz@...cle.com>
> Suggested-by: Miaohe Lin <linmiaohe@...wei.com>
> Signed-off-by: Naoya Horiguchi <naoya.horiguchi@....com>
> ---
>  mm/hugetlb.c        | 4 +++-
>  mm/memory-failure.c | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 

Thanks!

Reviewed-by: Miaohe Lin <linmiaohe@...wei.com>

> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index e38cbfdf3e61..3638f166e554 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -6786,7 +6786,9 @@ int get_hwpoison_huge_page(struct page *page, bool *hugetlb)
>  	spin_lock_irq(&hugetlb_lock);
>  	if (PageHeadHuge(page)) {
>  		*hugetlb = true;
> -		if (HPageFreed(page) || HPageMigratable(page))
> +		if (HPageFreed(page))
> +			ret = 0;
> +		else if (HPageMigratable(page))
>  			ret = get_page_unless_zero(page);
>  		else
>  			ret = -EBUSY;
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 5e3ad640f5bb..661079a37f29 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1517,7 +1517,9 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags)
>  	if (flags & MF_COUNT_INCREASED) {
>  		ret = 1;
>  		count_increased = true;
> -	} else if (HPageFreed(head) || HPageMigratable(head)) {
> +	} else if (HPageFreed(head)) {
> +		ret = 0;
> +	} else if (HPageMigratable(head)) {
>  		ret = get_page_unless_zero(head);
>  		if (ret)
>  			count_increased = true;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ