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: <88a265ab-9ecd-18b7-c150-517a5c2e5041@suse.cz>
Date:   Fri, 14 May 2021 13:56:46 +0200
From:   Vlastimil Babka <vbabka@...e.cz>
To:     "Matthew Wilcox (Oracle)" <willy@...radead.org>,
        akpm@...ux-foundation.org
Cc:     linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, Zi Yan <ziy@...dia.com>,
        Christoph Hellwig <hch@....de>,
        Jeff Layton <jlayton@...nel.org>
Subject: Re: [PATCH v10 07/33] mm: Add folio_get

Nitpick: function names in subject should IMHO also end with (). But not a
reason for resend all patches that don't...

On 5/11/21 11:47 PM, Matthew Wilcox (Oracle) wrote:
> If we know we have a folio, we can call folio_get() instead
> of get_page() and save the overhead of calling compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> Reviewed-by: Zi Yan <ziy@...dia.com>
> Reviewed-by: Christoph Hellwig <hch@....de>
> Acked-by: Jeff Layton <jlayton@...nel.org>

Acked-by: Vlastimil Babka <vbabka@...e.cz>

> ---
>  include/linux/mm.h | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 610948f0cb43..feb4645ef4f2 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1219,18 +1219,26 @@ static inline bool is_pci_p2pdma_page(const struct page *page)
>  }
>  
>  /* 127: arbitrary random number, small enough to assemble well */
> -#define page_ref_zero_or_close_to_overflow(page) \
> -	((unsigned int) page_ref_count(page) + 127u <= 127u)
> +#define folio_ref_zero_or_close_to_overflow(folio) \
> +	((unsigned int) folio_ref_count(folio) + 127u <= 127u)
> +
> +/**
> + * folio_get - Increment the reference count on a folio.
> + * @folio: The folio.
> + *
> + * Context: May be called in any context, as long as you know that
> + * you have a refcount on the folio.  If you do not already have one,
> + * folio_try_get() may be the right interface for you to use.
> + */
> +static inline void folio_get(struct folio *folio)
> +{
> +	VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio);
> +	folio_ref_inc(folio);
> +}
>  
>  static inline void get_page(struct page *page)
>  {
> -	page = compound_head(page);
> -	/*
> -	 * Getting a normal page or the head of a compound page
> -	 * requires to already have an elevated page->_refcount.
> -	 */
> -	VM_BUG_ON_PAGE(page_ref_zero_or_close_to_overflow(page), page);
> -	page_ref_inc(page);
> +	folio_get(page_folio(page));
>  }
>  
>  bool __must_check try_grab_page(struct page *page, unsigned int flags);
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ