linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev,
	tglx@linutronix.de, linux-crypto@vger.kernel.org,
	linux-api@vger.kernel.org, x86@kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Carlos O'Donell <carlos@redhat.com>,
	Florian Weimer <fweimer@redhat.com>,
	Arnd Bergmann <arnd@arndb.de>, Jann Horn <jannh@google.com>,
	Christian Brauner <brauner@kernel.org>,
	David Hildenbrand <dhildenb@redhat.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH v21 1/4] mm: add VM_DROPPABLE for designating always lazily freeable mappings
Date: Mon, 8 Jul 2024 22:24:41 +0200	[thread overview]
Message-ID: <36883da6-a492-4f17-8b55-fa08ca33fa74@redhat.com> (raw)
In-Reply-To: <ZotE3-VwI0SJlM6w@zx2c4.com>

On 08.07.24 03:46, Jason A. Donenfeld wrote:
> Hi David,

Hi Jason,

just catching up on mails here. Most of the stuff is now clear from the 
other subthread.

[...]

>>> @@ -1851,7 +1858,10 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma,
>>>    				 * discarded. Remap the page to page table.
>>>    				 */
>>>    				set_pte_at(mm, address, pvmw.pte, pteval);
>>> -				folio_set_swapbacked(folio);
>>> +				/* Unlike MADV_FREE mappings, VM_DROPPABLE ones
>>> +				 * never get swap backed on failure to drop. */
>>> +				if (!(vma->vm_flags & VM_DROPPABLE))
>>> +					folio_set_swapbacked(folio);
>>>    				ret = false;
>>>    				page_vma_mapped_walk_done(&pvmw);
>>>    				break;
>>
>> A note that in mm/mm-stable, "madvise_free_huge_pmd" exists to optimize
>> MADV_FREE on PMDs. I suspect we'd want to extend that one as well for
>> dropping support, but likely it would also only be a performance
>> improvmeent and not affect functonality if not handled.
> 
> That's for doing the freeing of PTEs after the fact, right? If the
> mapping was created, got filled with some data, and then sometime later
> it got MADV_FREE'd, which is the pattern people follow typically with
> MADV_FREE. If we do this as PROT_/MAP_, then that's not a case we need
> to worry about, if I understand this code correctly.

We essentially now have code to handle PMD-mapped THP: instead of first 
remapping them using PTEs to then unmap+discard via 512 PTEs (due to 
MADV_FREE being set on the folio), we can now simply unmap+discard a 
single PMD. So performance wise, this might be interesting for this 
mechanism as well (when used in combination with THP).

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2024-07-08 20:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-07  0:26 [PATCH v21 0/4] implement getrandom() in vDSO Jason A. Donenfeld
2024-07-07  0:26 ` [PATCH v21 1/4] mm: add VM_DROPPABLE for designating always lazily freeable mappings Jason A. Donenfeld
2024-07-07  7:42   ` David Hildenbrand
2024-07-07 18:19     ` Linus Torvalds
2024-07-07 18:52       ` David Hildenbrand
2024-07-07 19:22         ` Linus Torvalds
2024-07-07 21:01           ` David Hildenbrand
2024-07-08  0:08             ` Linus Torvalds
2024-07-08  8:11               ` David Hildenbrand
2024-07-08  8:23                 ` David Hildenbrand
2024-07-08 13:57                   ` Jason A. Donenfeld
2024-07-08 20:05                     ` David Hildenbrand
2024-07-08 13:55                 ` Jason A. Donenfeld
2024-07-08 14:40                   ` Jason A. Donenfeld
2024-07-08 20:21                     ` David Hildenbrand
2024-07-08 20:26                       ` David Hildenbrand
2024-07-09  2:17                       ` Jason A. Donenfeld
2024-07-10  3:05                         ` David Hildenbrand
2024-07-10  3:34                           ` Jason A. Donenfeld
2024-07-10  3:53                             ` David Hildenbrand
2024-07-08 20:06                   ` David Hildenbrand
2024-07-08 13:50               ` Jason A. Donenfeld
2024-07-08  1:59       ` Jason A. Donenfeld
2024-07-08  1:46     ` Jason A. Donenfeld
2024-07-08 20:24       ` David Hildenbrand [this message]
2024-07-07  0:26 ` [PATCH v21 2/4] random: introduce generic vDSO getrandom() implementation Jason A. Donenfeld
2024-07-07  0:26 ` [PATCH v21 3/4] x86: vdso: Wire up getrandom() vDSO implementation Jason A. Donenfeld
2024-07-07  0:26 ` [PATCH v21 4/4] selftests/vDSO: add tests for vgetrandom Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36883da6-a492-4f17-8b55-fa08ca33fa74@redhat.com \
    --to=david@redhat.com \
    --cc=Jason@zx2c4.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=arnd@arndb.de \
    --cc=brauner@kernel.org \
    --cc=carlos@redhat.com \
    --cc=dhildenb@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jannh@google.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=patches@lists.linux.dev \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).