Skip to contentSkip to conversation

flush_cache_page while pte valid

PATCH Manfred Spraul 2 participants 2 messages Nov 11, 2002 – Nov 12, 2002

lore
Share & tools
lore
#0 lore raw

Review

Quoted 6 lines
	/* Nuke the page table entry. */
(quoted diff) +1 -0
+	flush_cache_page(vma, address);
	pte = ptep_get_and_clear(ptep);
	flush_tlb_page(vma, address);
(quoted diff) +0 -1
-	flush_cache_page(vma, address);

Is it correct that this are 3 arch hooks that must appear back to back? What about one hook with all parameters?

	pte = ptep_get_and_clear_and_flush(ptep, vma, address);

The current implementation just asks for such errors.

Documentation:
ptep_get_and_clear_and_flush() removes the page table entry *ptep from the page tables and clears all caches (tlb, cpu cache if virtually tagged).
The return value contains the final value of the pte. The critical information is the dirty bit in the pte - on SMP one cpu can call ptep_get_and_clear_and_flush() while another cpu accesses the mmap'ing from user space.

--
Manfred

#1 lore raw
Quoted 10 lines · Manfred Spraul

Review

Quoted 6 lines
	/* Nuke the page table entry. */
(quoted diff) +1 -0
+	flush_cache_page(vma, address);
	pte = ptep_get_and_clear(ptep);
	flush_tlb_page(vma, address);
(quoted diff) +0 -1
-	flush_cache_page(vma, address);

Is it correct that this are 3 arch hooks that must appear back to back? What about one hook with all parameters?

Quoted 3 lines
	pte = ptep_get_and_clear_and_flush(ptep, vma, address);

The current implementation just asks for such errors.

Its actually a very simple rule. The sequence must be:

- flush cache for area
- change pte entries in area
- flush tlb for area

Anything else is just buggy, and may very well be racy. Think about the race when you flush the tlb entry before changing the pte.

Rather than creating a new interface that's only useful for 10% of the cases, I'd prefer to keep the rule personally. The smaller the number of functions each with their own particular set of behaviours doing almost the same job, the less chance of getting the wrong function. And, IMHO, the easier it is to audit the code.

grep -4 ptep_get_and_clear mm/*.c

vs

"Is this the right function here?"

PS, I see one place where "ptep_get_and_clear_and_flush" would be useful out of 6 uses.

Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html