Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux virtual memory parameters

Can anyone tell me the working of dirty_bytes and dirty_background_bytes in the Linux VM tunable parameters.

I infer that dirty_bytes specifies the amount of memory after which the application doing a write, starts writing directly to disk. Is it correct or if the amount of memory allocated is used up, that portion is first transferred to disk and then new data is again stored in memory. eg. suppose I want to transfer a 1 GB file to disk and I set dirty_bytes to be 100 MB then once 100 MB have been written to memory, the application doing the writing now starts writing the data directly to disk or the 100 MB is transferred to the disk and then again 100 MB is written to memory and then transferred to disk and so on?

And in case of dirty_background_bytes, when the portion of dirty memory exceeds this then pdflush writes the dirty data back to disk in the background.

Is my understanding correct for these 2 parameters?

like image 287
randy7 Avatar asked Nov 25 '25 23:11

randy7


1 Answers

No, exceeding dirty_bytes (or dirty_ratio) does not cause processes to start writing directly to disk.

Instead, when a process dirties a page in excess of the limit, that process is used to perform synchronous writeout of some dirty pages - exactly which ones is still decided by the usual heuristics. They may not necessarily even be pages that were originally dirtied by that particular process.

Effectively, the process sees its write (which may just be a memory write) suspended until some writeout has occurred.

You are correct about dirty_background_*. When the background limit is exceeded, asynchronous writeout is started, but the userspace process is allowed to continue.

like image 127
caf Avatar answered Nov 28 '25 00:11

caf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!