LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-23-2022, 04:36 PM   #1
vkvk
LQ Newbie
 
Registered: Jun 2022
Posts: 2

Rep: Reputation: 0
Does lock_page set some flag for pte record that tiggers TLB fault if someone tries to write to that page?


Hi everyone, I'm a Linux user space developer.

My application is using memory-mapped files backed by ext4 + spinning disk and it experiences spikes on memory writes up to hundreds of milliseconds. I suspect it has something to do with writeback process.
From the code I see there is a call to lock_page and the locked page is passed to the underlying fs(ext4) write_page (that looks heavy).

So my question is about lock_page.

Does it set something on pte so the write to the mapped vm would generate a tlb fault?
If so, will tlb be fixed only after the page is unlocked?


Great Thanks!
 
Old 06-24-2022, 02:17 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,153

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Extraordinarily unlikely I would posit.

The problem is much more likely a design issue by someone sitting in your chair. If writes to previously allocated pages spike like that it probably indicates you are thrashing. Your target page(s) have been migrated out to disk and now some other pages need to be paged out so your target pages can be paged back in. All takes time - a lot of time these days if still using spinning rust.

Buy some RAM, or reduce the working set of that mapped area would be simple solutions. If you can't, buy a few SSDs - depending on the bus architecture of the box, you should be able to get much faster parallel transfers going. Would "hide" rather than fix the issue, but might be sufficient.
 
1 members found this post helpful.
Old 06-24-2022, 09:17 AM   #3
vkvk
LQ Newbie
 
Registered: Jun 2022
Posts: 2

Original Poster
Rep: Reputation: 0
Great thanks, moreover with tempfs for which write page is just noop(besides swap) I don’t see the latency spikes. Have 256GB Ram but looks like Linux starts page cache out writeback much earlier. Anyway will places SSDs shortly
 
Old 06-24-2022, 09:33 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
Categorically speaking, when you design for a "memory-mapped file," you have to approach it as a file, not as memory. Pay very close attention to things like "locality of reference." (For example, accumulate a list of memory addresses that you intend to reference, then sort that list before traversing through it.) If you instead treat the resource as "real memory," you can encounter thrashing much sooner than you expect. And, yes, you will also be able to observe the internal OS caches being flushed, as you now are seeing.
 
Old 06-25-2022, 02:42 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,153

Rep: Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125Reputation: 4125
Quote:
Originally Posted by vkvk View Post
Great thanks, moreover with tempfs for which write page is just noop(besides swap) I don’t see the latency spikes. Have 256GB Ram but looks like Linux starts page cache out writeback much earlier. Anyway will places SSDs shortly
Swap is of course subject to the same effect once pages start being pushed out.

And tmpfs is non-persistant. But you know all that if you've been in the code. Good luck with it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BUG: Bad page map in process comgt pte:9bc1659f pmd:8f3a1835 calcky Linux - Kernel 1 02-25-2022 12:22 AM
How to identify the cache events (hit/miss/TLB/L1/L2) on some particular kernel code. enfinet Linux - Kernel 1 10-24-2015 01:40 PM
GART TLB error generic level generic Clydesdale Linux - Software 1 08-13-2007 06:47 PM
GART TLB error generic level generic Clydesdale Linux - Hardware 0 08-13-2007 06:18 PM
remove tlb entry ashlesha Linux - Software 0 11-14-2006 12:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration