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: <ZP8EKWev8H9kMka3@dhcp22.suse.cz>
Date:   Mon, 11 Sep 2023 14:12:25 +0200
From:   Michal Hocko <mhocko@...e.com>
To:     "zhaoyang.huang" <zhaoyang.huang@...soc.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Matthew Wilcox <willy@...radead.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org,
        Zhaoyang Huang <huangzhaoyang@...il.com>, ke.wang@...soc.com
Subject: Re: [PATCH] mm: remove redundant clear page when
 CONFIG_INIT_ON_ALLOC_DEFAULT_ON configured

On Mon 11-09-23 18:49:06, zhaoyang.huang wrote:
> From: Zhaoyang Huang <zhaoyang.huang@...soc.com>
> 
> There will be redundant clear page within vma_alloc_zeroed_movable_folio
> when CONFIG_INIT_ON_ALLOC_DEFAULT_ON is on. Remove it by judging related
> configs.

Thanks for spotting this. I suspect this is a fix based on a code review
rather than a real performance issue, right? It is always good to
mention that. From a very quick look it seems that many architectures
just definte vma_alloc_zeroed_movable_folio to use __GFP_ZERO so they
are not affected by this. This means that only a subset of architectures
are really affected. This is an important information as well.
Finally I think it would be more appropriate to mention that the double
initialization is done when init_on_alloc is enabled rather than
referring to the above config option which only controls whether the
functionality is enabled by default.

I would rephrase as follows:
Many architectures (alpha, arm64, ia64, m68k s390, x86) define their own
vma_alloc_zeroed_movable_folio implementations which use __GFP_ZERO for
the page allocation.

Those which rely on the default implementation, however, would currently
go through the initialization twice (oce in the page allocator and
second in vma_alloc_zeroed_movable_folio) if init_on_alloc is enabled
though. Fix this by checking want_init_on_alloc before calling
clear_user_highpage.

> Signed-off-by: Zhaoyang Huang <zhaoyang.huang@...soc.com>

With the changelog updates
Acked-by: Michal Hocko <mhocko@...e.com>

Thanks!

> ---
>  include/linux/highmem.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index 99c474de800d..3926f8414729 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -227,7 +227,7 @@ struct folio *vma_alloc_zeroed_movable_folio(struct vm_area_struct *vma,
>  	struct folio *folio;
>  
>  	folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vaddr, false);
> -	if (folio)
> +	if (folio && !want_init_on_alloc(GFP_HIGHUSER_MOVABLE))
>  		clear_user_highpage(&folio->page, vaddr);
>  
>  	return folio;
> -- 
> 2.25.1

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ