linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Matthew Wilcox <willy@infradead.org>,
	Randy Dunlap <rdunlap@infradead.org>
Cc: Mikko Rantalainen <mikko.rantalainen@peda.net>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: Why is Shmem included in Cached in /proc/meminfo?
Date: Mon, 30 Aug 2021 18:05:58 +0200	[thread overview]
Message-ID: <14465cfe-281a-0f67-dc17-ead34ec48365@suse.cz> (raw)
In-Reply-To: <YSzuLbHr7fHshafX@casper.infradead.org>

On 8/30/21 16:41, Matthew Wilcox wrote:
> On Mon, Aug 30, 2021 at 07:34:38AM -0700, Randy Dunlap wrote:
>> [add linux-mm mailing list]
>> 
>> On 8/30/21 12:44 AM, Mikko Rantalainen wrote:
>> > 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.
> 
> That's a reasonable position to take.
> 
> Another point of view is that everything in tmpfs is part of the page
> cache and can be written out to swap, so keeping it as part of Cached
> is not misleading.

Yeah, but with that view, anonymous memory can be also written out to swap. But
it's non-intuitive that something called "Cached" will contain something that
(if not dirty) can't be just dropped. I've had to point this Shmem oddity out a
number of times to someone, so I would say that it would be much better if it
was not part of Cached.

However, if we change it now, we might create even larger confusion. People
looking at the output for the first time (and IIRC also the 'free' command uses
it) on a new kernel wouldn't be misled anymore. But people working with both old
and new kernels will now have to take in account that it changed at some
point... not good.

> I can see it both ways, and personally, I'd lean towards clarifying
> the documentation about how shmem is accounted rather than changing
> how the memory usage is reported.
> 



  reply	other threads:[~2021-08-30 16:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5a42eb2b-fd7b-6296-f5d6-619661ad1418@peda.net>
2021-08-30 14:34 ` Randy Dunlap
2021-08-30 14:41   ` Matthew Wilcox
2021-08-30 16:05     ` Vlastimil Babka [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14465cfe-281a-0f67-dc17-ead34ec48365@suse.cz \
    --to=vbabka@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mikko.rantalainen@peda.net \
    --cc=rdunlap@infradead.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox