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:   Thu, 8 Dec 2022 22:04:40 +0000
From:   Matthew Wilcox <willy@...radead.org>
To:     Sidhartha Kumar <sidhartha.kumar@...cle.com>
Cc:     Mike Kravetz <mike.kravetz@...cle.com>,
        John Hubbard <jhubbard@...dia.com>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        akpm@...ux-foundation.org, songmuchun@...edance.com,
        tsahu@...ux.ibm.com, david@...hat.com
Subject: Re: [PATCH mm-unstable] mm: clarify folio_set_compound_order() zero
 support

On Thu, Dec 08, 2022 at 01:58:20PM -0800, Sidhartha Kumar wrote:
> 5) improve the style of folio_set_order() by removing ifdefs from inside the
> function to doing
> 
> #ifdef CONFIG_64BIT
>  static inline void folio_set_order(struct folio *folio,
>                  unsigned int order)
>  {
> 	 VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);
> 
> 	 folio->_folio_order = order;
>          folio->_folio_nr_pages = order ? 1U << order : 0;
> }
> #else
> static inline void folio_set_order(struct folio *folio,
>                  unsigned int order)
>  {
> 	 VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);
> 
> 	 folio->_folio_order = order;
> }
> #endif

While we usually prefer to put ifdefs outside the function, I don't
think that's justified in this case.  I'd rather see a comment inside
the function like:

static inline void folio_set_order(struct folio *folio,
                unsigned int order)
{
	VM_BUG_ON_FOLIO(!folio_test_large(folio), folio);

	folio->_folio_order = order;
#ifdef CONFIG_64BIT
	/*
	 * When hugetlb dissolves a folio, we need to clear the tail
	 * page, rather than setting nr_pages to 1.
	 */
	folio->_folio_nr_pages = order ? 1U << order : 0;
#endif
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ