lkml.org 
[lkml]   [2022]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH RFC 1/4] mm/swap: Add swp_offset_pfn() to fetch PFN from swap entry
Date
Peter Xu <peterx@redhat.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

\
 
 \ /
  Last update: 2022-08-02 03:25    [W:0.055 / U:1.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site