Thread (18 messages) flat view 18 messages, 3 authors, 2021-06-07

Re: [PATCH net-next v7 1/5] mm: add a signature in struct page

From: Matteo Croce <hidden>
Date: 2021-06-06 01:51:33
Also in: bpf, linux-mm, linux-rdma, lkml

On Sat, Jun 5, 2021 at 4:32 PM Matthew Wilcox [off-list ref] wrote:
On Sat, Jun 05, 2021 at 12:59:50AM +0200, Matteo Croce wrote:
quoted
On Fri, Jun 4, 2021 at 9:08 PM Matthew Wilcox [off-list ref] wrote:
quoted
On Fri, Jun 04, 2021 at 08:33:45PM +0200, Matteo Croce wrote:
quoted
@@ -130,7 +137,10 @@ struct page {
                      };
              };
              struct {        /* Tail pages of compound page */
-                     unsigned long compound_head;    /* Bit zero is set */
+                     /* Bit zero is set
+                      * Bit one if pfmemalloc page
+                      */
+                     unsigned long compound_head;
I would drop this hunk.  Bit 1 is not used for this purpose in tail
pages; it's used for that purpose in head and base pages.

I suppose we could do something like ...

 static inline void set_page_pfmemalloc(struct page *page)
 {
-       page->index = -1UL;
+       page->lru.next = (void *)2;
 }

if it's causing confusion.
And change all the *_pfmemalloc functions to use page->lru.next like this?
@@ -1668,10 +1668,12 @@ struct address_space *page_mapping(struct page *page);
static inline bool page_is_pfmemalloc(const struct page *page)
{
       /*
-        * Page index cannot be this large so this must be
-        * a pfmemalloc page.
+        * This is not a tail page; compound_head of a head page is unused
+        * at return from the page allocator, and will be overwritten
+        * by callers who do not care whether the page came from the
+        * reserves.
        */
-       return page->index == -1UL;
+       return (uintptr_t)page->lru.next & BIT(1);
}

/*
@@ -1680,12 +1682,12 @@ static inline bool page_is_pfmemalloc(const
struct page *page)
 */
static inline void set_page_pfmemalloc(struct page *page)
{
-       page->index = -1UL;
+       page->lru.next = (void *)BIT(1);
}

static inline void clear_page_pfmemalloc(struct page *page)
{
-       page->index = 0;
+       page->lru.next = NULL;

}

-- 
per aspera ad upstream
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help