lkml.org 
[lkml]   [2022]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 10/15] mm/page-flags: reuse PG_slab as PG_anon_exclusive for PageAnon() pages
On Fri, Mar 11, 2022 at 08:36:37PM +0100, David Hildenbrand wrote:
> I used PG_error before, but felt like using a bit that is never ever
> valid to be set/cleared/checked on a subpage would be even a better fit:
>
> Note the:
>
> PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD)
>
> whereby PF_ONLY_HEAD translates to:
>
> "for compound page, callers only ever operate on the head page."
>
>
> I can just switch to PG_error, but for the second subpage, PG_waiters
> should be just fine (unless I am missing something important).

I think you're missing something important that almost everybody misses
when looking at this code (including me).

PF_ANY flags can be set on individual pages.
PF_HEAD means "we automatically redirect all operations to the head page".
PF_ONLY_HEAD means "If you try to call this on a tail page, we BUG".
PF_NO_TAIL means "If you try to read this flag on a tail page, we'll
look at the head page instead, but if you try to set/clear this flag
on a tail page, we BUG"
PF_NO_COMPOUND means "We BUG() if you call this on a compound page"

So really, you can reuse any flag as PF_SECOND that isn't PF_ANY.

No, that's not what the documentation currently says. It should be.
I had a patch to reword it at some point, but I guess it got lost.
The current documentation reads like "We replicate the flag currently
set on the head page to all tail pages", but that just isn't what
the code does.

\
 
 \ /
  Last update: 2022-03-11 23:56    [W:0.104 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site