LinuxPPC-Dev Archive on lore.kernel.org
 help / color / Atom feed
* mm: Question about the use of 'accessed' flags and pte_young() helper
@ 2020-10-08  9:49 Christophe Leroy
  2020-10-20 15:52 ` Vlastimil Babka
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy @ 2020-10-08  9:49 UTC (permalink / raw)
  To: linux-mm, linux-kernel, linuxppc-dev, Aneesh Kumar K.V, Nicholas Piggin

In a 10 years old commit 
(https://github.com/linuxppc/linux/commit/d069cb4373fe0d451357c4d3769623a7564dfa9f), powerpc 8xx has 
made the handling of PTE accessed bit conditional to CONFIG_SWAP.
Since then, this has been extended to some other powerpc variants.

That commit means that when CONFIG_SWAP is not selected, the accessed bit is not set by SW TLB miss 
handlers, leading to pte_young() returning garbage, or should I say possibly returning false 
allthough a page has been accessed since its access flag was reset.

Looking at various mm/ places, pte_young() is used independent of CONFIG_SWAP

Is it still valid the not manage accessed flags when CONFIG_SWAP is not selected ?
If yes, should pte_young() always return true in that case ?

While we are at it, I'm wondering whether powerpc should redefine arch_faults_on_old_pte()
On some variants of powerpc, accessed flag is managed by HW. On others, it is managed by SW TLB miss 
handlers via page fault handling.

Thanks
Christophe

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mm: Question about the use of 'accessed' flags and pte_young() helper
  2020-10-08  9:49 mm: Question about the use of 'accessed' flags and pte_young() helper Christophe Leroy
@ 2020-10-20 15:52 ` Vlastimil Babka
  2020-10-20 18:33   ` Johannes Weiner
  0 siblings, 1 reply; 3+ messages in thread
From: Vlastimil Babka @ 2020-10-20 15:52 UTC (permalink / raw)
  To: Christophe Leroy, linux-mm, linux-kernel, linuxppc-dev,
	Aneesh Kumar K.V, Nicholas Piggin, Johannes Weiner

On 10/8/20 11:49 AM, Christophe Leroy wrote:
> In a 10 years old commit
> (https://github.com/linuxppc/linux/commit/d069cb4373fe0d451357c4d3769623a7564dfa9f), powerpc 8xx has
> made the handling of PTE accessed bit conditional to CONFIG_SWAP.
> Since then, this has been extended to some other powerpc variants.
> 
> That commit means that when CONFIG_SWAP is not selected, the accessed bit is not set by SW TLB miss
> handlers, leading to pte_young() returning garbage, or should I say possibly returning false
> allthough a page has been accessed since its access flag was reset.
> 
> Looking at various mm/ places, pte_young() is used independent of CONFIG_SWAP
> 
> Is it still valid the not manage accessed flags when CONFIG_SWAP is not selected ?

AFAIK it's wrong, reclaim needs it to detect accessed pages on inactive list, 
via page_referenced(), including file pages (page cache) where CONFIG_SWAP plays 
no role. Maybe it was different 10 years ago.

> If yes, should pte_young() always return true in that case ?

It should best work as intended. If not possible, true is maybe better, as false 
will lead to inactive file list thrashing.

> While we are at it, I'm wondering whether powerpc should redefine arch_faults_on_old_pte()
> On some variants of powerpc, accessed flag is managed by HW. On others, it is managed by SW TLB miss
> handlers via page fault handling.
> 
> Thanks
> Christophe
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mm: Question about the use of 'accessed' flags and pte_young() helper
  2020-10-20 15:52 ` Vlastimil Babka
@ 2020-10-20 18:33   ` Johannes Weiner
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Weiner @ 2020-10-20 18:33 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: linux-kernel, Nicholas Piggin, linux-mm, linuxppc-dev, Aneesh Kumar K.V

On Tue, Oct 20, 2020 at 05:52:07PM +0200, Vlastimil Babka wrote:
> On 10/8/20 11:49 AM, Christophe Leroy wrote:
> > In a 10 years old commit
> > (https://github.com/linuxppc/linux/commit/d069cb4373fe0d451357c4d3769623a7564dfa9f), powerpc 8xx has
> > made the handling of PTE accessed bit conditional to CONFIG_SWAP.
> > Since then, this has been extended to some other powerpc variants.
> > 
> > That commit means that when CONFIG_SWAP is not selected, the accessed bit is not set by SW TLB miss
> > handlers, leading to pte_young() returning garbage, or should I say possibly returning false
> > allthough a page has been accessed since its access flag was reset.
> > 
> > Looking at various mm/ places, pte_young() is used independent of CONFIG_SWAP
> > 
> > Is it still valid the not manage accessed flags when CONFIG_SWAP is not selected ?
> 
> AFAIK it's wrong, reclaim needs it to detect accessed pages on inactive
> list, via page_referenced(), including file pages (page cache) where
> CONFIG_SWAP plays no role. Maybe it was different 10 years ago.

Yes, we require this bit for properly aging mmapped file pages. The
underlying assumption in the referenced commit is incorrect.

> > If yes, should pte_young() always return true in that case ?
> 
> It should best work as intended. If not possible, true is maybe better, as
> false will lead to inactive file list thrashing.

An unconditional true will cause mmapped file pages to be permanently
mlocked / unevictable.

Either way will break some workloads. The only good answer is the
truth :-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08  9:49 mm: Question about the use of 'accessed' flags and pte_young() helper Christophe Leroy
2020-10-20 15:52 ` Vlastimil Babka
2020-10-20 18:33   ` Johannes Weiner

LinuxPPC-Dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \
		linuxppc-dev@lists.ozlabs.org linuxppc-dev@ozlabs.org
	public-inbox-index linuxppc-dev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git