Thread (54 messages) flat view 54 messages, 10 authors, 2023-05-02

Re: [PATCH v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings

From: David Hildenbrand <hidden>
Date: 2023-05-02 12:48:24
Also in: bpf, linux-fsdevel, linux-mm, linux-perf-users, lkml

On 02.05.23 14:40, Peter Zijlstra wrote:
On Tue, May 02, 2023 at 02:08:10PM +0200, Peter Zijlstra wrote:
quoted
quoted
quoted

	if (folio_test_anon(folio))
		return true;
This relies on the mapping so belongs below the lockdep assert imo.
Oh, right you are.
quoted
quoted
	/*
	 * Having IRQs disabled (as per GUP-fast) also inhibits RCU
	 * grace periods from making progress, IOW. they imply
	 * rcu_read_lock().
	 */
	lockdep_assert_irqs_disabled();

	/*
	 * Inodes and thus address_space are RCU freed and thus safe to
	 * access at this point.
	 */
	mapping = folio_mapping(folio);
	if (mapping && shmem_mapping(mapping))
		return true;

	return false;
quoted
+}
So arguably you should do *one* READ_ONCE() load of mapping and
consistently use that, this means open-coding both folio_test_anon() and
folio_mapping().
Open-coding folio_test_anon() should not be required. We only care about 
PAGE_MAPPING_FLAGS stored alongside folio->mapping, that will stick 
around until the anon page was freed.

@Lorenzo, you might also want to special-case hugetlb directly using 
folio_test_hugetlb().

-- 
Thanks,

David / dhildenb
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help