linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Why is Shmem included in Cached in /proc/meminfo?
@ 2021-08-30  7:44 Mikko Rantalainen
  2021-08-30 14:34 ` Randy Dunlap
  0 siblings, 1 reply; 8+ messages in thread
From: Mikko Rantalainen @ 2021-08-30  7:44 UTC (permalink / raw)
  To: linux-kernel

It's not immediately obvious from fs/proc/meminfo.c function
meminfo_proc_show() but the output of Cached: field seems to always
include all of Shmem: field, too.

Is this intentional? Usually cache is something that can be discarded if
needed but shared memory (e.g. used to contain files in tmpfs) cannot be
discarded without a data-loss. As such, I'd argue that it shouldn't be
included in the Cached: output.

A simple fix could be

-	cached = global_node_page_state(NR_FILE_PAGES) -
-			total_swapcache_pages() - i.bufferram;
+	cached = global_node_page_state(NR_FILE_PAGES) -
+			total_swapcache_pages()
+			- i.bufferram - i.sharedram;

-- 
Mikko

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

end of thread, other threads:[~2021-09-01  8:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-30  7:44 Why is Shmem included in Cached in /proc/meminfo? Mikko Rantalainen
2021-08-30 14:34 ` Randy Dunlap
2021-08-30 14:41   ` Matthew Wilcox
2021-08-30 16:05     ` Vlastimil Babka
2021-08-30 16:17       ` Matthew Wilcox
2021-08-30 17:26         ` Mikko Rantalainen
2021-08-30 19:38           ` Khalid Aziz
2021-09-01  8:57           ` Mikko Rantalainen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).