All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Guillaume Morin <guillaume@morinfr.org>, linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, Muchun Song <muchun.song@linux.dev>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Xu <peterx@redhat.com>,
	Eric Hagberg <ehagberg@janestreet.com>
Subject: Re: [PATCH v1] hugetlb: support FOLL_FORCE|FOLL_WRITE
Date: Wed, 4 Dec 2024 20:01:48 +0100	[thread overview]
Message-ID: <0dc516ab-b2b0-414d-868e-880bd13b5cdd@redhat.com> (raw)
In-Reply-To: <Z1Ce6j5WiBE3kaGf@bender.morinfr.org>

On 04.12.24 19:26, Guillaume Morin wrote:

Patch prefix should likely be "mm/hugetlb: ..."

> FOLL_FORCE|FOLL_WRITE has never been properly supported for hugetlb
> mappings.  Since 1d8d14641fd94, we explicitly reject it. However

"Since commit 1d8d14641fd9 ("mm/hugetlb: support write-faults in shared 
mappings") ..."

> running software on hugetlb mappings is a useful optimization.
> Multiple tools allow to use that such as Intel iodlr or
> libhugetlbfs.

It would be better to link to the actual request where people ran into 
that when using PTRACE_POKETEXT

That hugetlb is getting used is rather obvious :)

> 
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Eric Hagberg <ehagberg@janestreet.com>
> Signed-off-by: Guillaume Morin <guillaume@morinfr.org>
> ---

[...]

>   		delayacct_wpcopy_end();
>   		return 0;
> @@ -5943,7 +5944,8 @@ static vm_fault_t hugetlb_wp(struct folio *pagecache_folio,
>   	spin_lock(vmf->ptl);
>   	vmf->pte = hugetlb_walk(vma, vmf->address, huge_page_size(h));
>   	if (likely(vmf->pte && pte_same(huge_ptep_get(mm, vmf->address, vmf->pte), pte))) {
> -		pte_t newpte = make_huge_pte(vma, &new_folio->page, !unshare);
> +		const bool writable = !unshare && (vma->vm_flags & VM_WRITE);
> +		pte_t newpte = make_huge_pte(vma, &new_folio->page, writable);
>   
>   		/* Break COW or unshare */
>   		huge_ptep_clear_flush(vma, vmf->address, vmf->pte);

After rebasing to [1] this hunk here can likely be dropped. 
make_huge_pte() will perform the VM_WRITE check.


[1] https://lkml.kernel.org/r/20241204153100.1967364-1-david@redhat.com


-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-12-04 19:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-04 18:26 [PATCH v1] hugetlb: support FOLL_FORCE|FOLL_WRITE Guillaume Morin
2024-12-04 19:01 ` David Hildenbrand [this message]
2024-12-04 19:13   ` Guillaume Morin
2024-12-04 19:30     ` David Hildenbrand
2024-12-05  0:39 ` kernel test robot
2024-12-05  1:42   ` Guillaume Morin
2024-12-05  1:56     ` Guillaume Morin
2024-12-05  1:23 ` kernel test robot
2024-12-05  2:05 ` kernel test robot

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=0dc516ab-b2b0-414d-868e-880bd13b5cdd@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ehagberg@janestreet.com \
    --cc=guillaume@morinfr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=peterx@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.