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: <87czdjjv6b.fsf@yhuang6-desk2.ccr.corp.intel.com>
Date:   Tue, 02 Aug 2022 09:22:52 +0800
From:   "Huang, Ying" <ying.huang@...el.com>
To:     Peter Xu <peterx@...hat.com>
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Andrea Arcangeli <aarcange@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Kirill A . Shutemov" <kirill@...temov.name>,
        Nadav Amit <nadav.amit@...il.com>,
        Hugh Dickins <hughd@...gle.com>,
        David Hildenbrand <david@...hat.com>,
        Vlastimil Babka <vbabka@...e.cz>
Subject: Re: [PATCH RFC 1/4] mm/swap: Add swp_offset_pfn() to fetch PFN from
 swap entry

Peter Xu <peterx@...hat.com> writes:

> On Mon, Aug 01, 2022 at 11:13:58AM +0800, Huang, Ying wrote:
>> > +/*
>> > + * This should only be called upon a pfn swap entry to get the PFN stored
>> > + * in the swap entry.  Please refers to is_pfn_swap_entry() for definition
>> > + * of pfn swap entry.
>> > + */
>> > +static inline unsigned long swp_offset_pfn(swp_entry_t entry)
>> > +{
>> 
>> Is it good to call is_pfn_swap_entry() here for debug that can be
>> eliminated in the production kernel?
>
> Sure, I'll add a VM_BUG_ON() there in the next spin.
>
>> 
>> > +	return swp_offset(entry) & SWP_PFN_MASK;
>> > +}
>> > +
>> >  /* check whether a pte points to a swap entry */
>> >  static inline int is_swap_pte(pte_t pte)
>> >  {
>> > @@ -369,7 +387,7 @@ static inline int pte_none_mostly(pte_t pte)
>> >  
>> >  static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry)
>> >  {
>> > -	struct page *p = pfn_to_page(swp_offset(entry));
>> > +	struct page *p = pfn_to_page(swp_offset_pfn(entry));
>> >  
>> >  	/*
>> >  	 * Any use of migration entries may only occur while the
>> > @@ -387,6 +405,9 @@ static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry)
>> >   */
>> >  static inline bool is_pfn_swap_entry(swp_entry_t entry)
>> >  {
>> > +	/* Make sure the swp offset can always store the needed fields */
>> > +	BUILD_BUG_ON(SWP_TYPE_SHIFT < SWP_PFN_BITS);
>> 
>> 	BUILD_BUG_ON(SWP_TYPE_SHIFT <= SWP_PFN_BITS);
>
> Logiclaly it's okay to have SWP_TYPE_SHIFT==SWP_PFN_BITS?

Sorry, I misunderstood the original code.  Please ignore this comment.

Best Regards,
Huang, Ying

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ