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]
Date:   Mon, 3 Apr 2023 15:07:33 +0200
From:   Vlastimil Babka <vbabka@...e.cz>
To:     "Kirill A. Shutemov" <kirill@...temov.name>
Cc:     "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Borislav Petkov <bp@...en8.de>,
        Andy Lutomirski <luto@...nel.org>,
        Sean Christopherson <seanjc@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Joerg Roedel <jroedel@...e.de>,
        Ard Biesheuvel <ardb@...nel.org>,
        Andi Kleen <ak@...ux.intel.com>,
        Kuppuswamy Sathyanarayanan 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        David Rientjes <rientjes@...gle.com>,
        Tom Lendacky <thomas.lendacky@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Peter Zijlstra <peterz@...radead.org>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Ingo Molnar <mingo@...hat.com>,
        Dario Faggioli <dfaggioli@...e.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Mike Rapoport <rppt@...nel.org>,
        David Hildenbrand <david@...hat.com>,
        Mel Gorman <mgorman@...hsingularity.net>,
        marcelo.cerri@...onical.com, tim.gardner@...onical.com,
        khalid.elmously@...onical.com, philip.cox@...onical.com,
        aarcange@...hat.com, peterx@...hat.com, x86@...nel.org,
        linux-mm@...ck.org, linux-coco@...ts.linux.dev,
        linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org,
        Mike Rapoport <rppt@...ux.ibm.com>
Subject: Re: [PATCHv9 02/14] mm: Add support for unaccepted memory

On 4/3/23 12:02, Kirill A. Shutemov wrote:
> On Mon, Apr 03, 2023 at 11:26:53AM +0200, Vlastimil Babka wrote:
>> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
>> > Acked-by: Mike Rapoport <rppt@...ux.ibm.com>	# memblock
>> 
>> Reviewed-by: Vlastimil Babka <vbabka@...e.cz>
> 
> Thanks!
> 
>> Just a small suggestion below:
>> 
>> > +
>> > +static bool try_to_accept_memory(struct zone *zone, unsigned int order)
>> > +{
>> > +	long to_accept;
>> > +	int ret = false;
>> > +
>> > +	if (!static_branch_unlikely(&zones_with_unaccepted_pages))
>> > +		return false;
>> 
>> 
>> This potentially (depends on what compiler decides) means we'll call this
>> function just to skip the static branch. OTOH forcing it as inline would be
>> wasteful too. So I'd split that away and make the callers do that static
>> branch check inline. Just as deferred_pages_enabled() is used.
> 
> Like this?

Yep.

> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 07e16e9b49c4..80fe5e4b6cca 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -390,6 +390,7 @@ EXPORT_SYMBOL(nr_online_nodes);
>  static bool page_contains_unaccepted(struct page *page, unsigned int order);
>  static void accept_page(struct page *page, unsigned int order);
>  static bool try_to_accept_memory(struct zone *zone, unsigned int order);
> +static inline bool has_unaccepted_memory(void);
>  static bool __free_unaccepted(struct page *page);
>  
>  int page_group_by_mobility_disabled __read_mostly;
> @@ -3464,8 +3465,10 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
>  				       gfp_mask)) {
>  			int ret;
>  
> -			if (try_to_accept_memory(zone, order))
> -				goto try_this_zone;
> +			if (has_unaccepted_memory()) {
> +				if (try_to_accept_memory(zone, order))
> +					goto try_this_zone;
> +			}
>  
>  #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
>  			/*
> @@ -3519,8 +3522,10 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags,
>  
>  			return page;
>  		} else {
> -			if (try_to_accept_memory(zone, order))
> -				goto try_this_zone;
> +			if (has_unaccepted_memory()) {
> +				if (try_to_accept_memory(zone, order))
> +					goto try_this_zone;
> +			}
>  
>  #ifdef CONFIG_DEFERRED_STRUCT_PAGE_INIT
>  			/* Try again if zone has deferred pages */
> @@ -7302,9 +7307,6 @@ static bool try_to_accept_memory(struct zone *zone, unsigned int order)
>  	long to_accept;
>  	int ret = false;
>  
> -	if (!static_branch_unlikely(&zones_with_unaccepted_pages))
> -		return false;
> -
>  	/* How much to accept to get to high watermark? */
>  	to_accept = high_wmark_pages(zone) -
>  		    (zone_page_state(zone, NR_FREE_PAGES) -
> @@ -7321,6 +7323,11 @@ static bool try_to_accept_memory(struct zone *zone, unsigned int order)
>  	return ret;
>  }
>  
> +static inline bool has_unaccepted_memory(void)
> +{
> +	return static_branch_unlikely(&zones_with_unaccepted_pages);
> +}
> +
>  static bool __free_unaccepted(struct page *page)
>  {
>  	struct zone *zone = page_zone(page);
> @@ -7398,6 +7405,11 @@ static bool try_to_accept_memory(struct zone *zone, unsigned int order)
>  	return false;
>  }
>  
> +static inline bool has_unaccepted_memory(void)
> +{
> +	return false;
> +}
> +
>  static bool __free_unaccepted(struct page *page)
>  {
>  	BUILD_BUG();

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ