The Linux Process Journey — kdmflush (Kernel Device Mapper Flush)

Shlomi Boutnaru, Ph.D.
2 min readApr 13, 2024

--

“kdmflush” is a kernel thread which is based on a workqueue (https://elixir.bootlin.com/linux/v6.5-rc3/source/drivers/md/dm.c#L2131). Its name is created in the pattern of “kdmflush/%s” (where %s is the mapped device name). It is used by the “Device Mapper” (dm) in order to queue up deferred work to other context if doing them immediately so would be problematic (https://www.compuhoy.com/how-do-you-check-which-process-is-using-more-disk-in-linux/) .

It is part of the “Device Mapper” framework and used in order to process deferred work hat it has queued up from other contexts where doing immediately so would be problematic (https://askubuntu.com/questions/986211/what-is-kdmflush). Also, the kernel parameter “vm.dirty_background_ratio” controls the percentage of system memory that can be filled with “dirty” pages (memory pages not written to disk) before “kdmflush” kicks in to write them to disk (https://www.cnblogs.com/cobbliu/articles/11792193.html).

Lastly, there are also other kernel parameters which affect the handling of “dirty” pages, we can check them out using the “sysctl” utility (https://linux.die.net/man/8/sysctl) — as shown in the screenshot below. By the way, “kdmflush” is created as part of the “alloc_dev” function that is responsible for allocating and initializing a blank device with a given minor (https://elixir.bootlin.com/linux/v6.5-rc3/source/drivers/md/dm.c#L2044).

See you in my next writeup ;-) You can follow me on twitter — @boutnaru (https://twitter.com/boutnaru). Also, you can read my other writeups on medium — https://medium.com/@boutnaru. You can find my free eBooks at https://TheLearningJourneyEbooks.com.

--

--