Re: [PATCH v22 1/4] mm: add MAP_DROPPABLE for designating always lazily freeable mappings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11.07.24 19:24, David Hildenbrand wrote:
On 11.07.24 19:17, Jason A. Donenfeld wrote:
On Thu, Jul 11, 2024 at 07:09:36PM +0200, Jason A. Donenfeld wrote:
So, hmm... The swapbacked thing really seemed so simple... I wonder if
there's a way of recovering that.

Not wanting to introduce a new bitflag, I went looking and noticed this:

/*
   * Private page markings that may be used by the filesystem that owns the page
   * for its own purposes.
   * - PG_private and PG_private_2 cause release_folio() and co to be invoked
   */
PAGEFLAG(Private, private, PF_ANY)
PAGEFLAG(Private2, private_2, PF_ANY) TESTSCFLAG(Private2, private_2, PF_ANY)
PAGEFLAG(OwnerPriv1, owner_priv_1, PF_ANY)
          TESTCLEARFLAG(OwnerPriv1, owner_priv_1, PF_ANY)

The below +4/-1 diff is pretty hacky and might be illegal in the state
of California, but I think it does work. The idea is that if that bit is
normally only used for filesystems, then in the anonymous case, it's
free to be used for this.

Any opinions about this, or a suggestion on how to do that in a less
ugly way?

Jason


diff --git a/mm/rmap.c b/mm/rmap.c
index 1f9b5a9cb121..090554277e4a 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1403,6 +1403,8 @@ void folio_add_new_anon_rmap(struct folio *folio, struct vm_area_struct *vma,
   	 */
   	if (!(vma->vm_flags & VM_DROPPABLE))
   		__folio_set_swapbacked(folio);
+	else
+		folio_set_owner_priv_1(folio);


PG_owner_priv_1 maps to PG_swapcache? :)

Maybe the combination !swapbacked && swapcache could be used to indicate such folios. (we will never set swapbacked)

But likely we have to be a bit careful here. We don't want folio_test_swapcache() to return for folios that ... are not in the swapcache.

--
Cheers,

David / dhildenb





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux