kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Pintu Agarwal <pintu.ping@gmail.com>
To: "Valdis Klētnieks" <valdis.kletnieks@vt.edu>
Cc: linux-mm <linux-mm@kvack.org>,
	Kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: Estimating total memory usage in any Linux system
Date: Wed, 20 May 2020 10:26:50 +0530	[thread overview]
Message-ID: <CAOuPNLjTP0s=5sOpCnnFVHedBP1dV0A8S2wAiDjBAN1q+C2JZQ@mail.gmail.com> (raw)
In-Reply-To: <21691.1589947282@turing-police>

On Wed, 20 May 2020 at 09:31, Valdis Klētnieks <valdis.kletnieks@vt.edu> wrote:
>
> On Tue, 19 May 2020 22:33:15 +0530, Pintu Agarwal said:
>
> > > Below are some data taken from a small embedded arm32 device with 512MB RAM:
> > >
> >
> > Sorry, I forgot to mention the kernel version. Here it is 3.18 Kernel
>
> That's a kernel from 2014.  You don't seriously expect us to remember how
> all those counters worked back then, do you?
>
Actually I don't care about the kernel version. This was just for reference.
I know it is weird to manually arrive a MemTotal from the values of meminfo.
But I am actually looking for general formula.
I could get some of the answers by tracing the kernel code for each counters.
But still there are some gaps which I want to clarify.
As I see there are several ways to total it: i.e; (PSS way), (Buffers,
Cached), (Active, Inactive)
According to me,
MemTotal = MemFree + Active + Inactive  + SwapCached + Mapped + Shmem
+ Slab + KernelStack + PageTables + (Init Freed from boot) + (alloc
pages) + (min_free_bytes + user_reserve_bytes)
Did I miss anything here ?

With this I could arrive to some result, but I have some doubts:
* Is Mapped already included in Active/Inactive (file) ? Because
mapped is coming from NR_FILE_MAPPED.
  ==> I see that it is accounted from mm/rmap.c
* Do we also need to incude VmallocUsed here ? I see in some cases
people include it too.
  ==> But I think vmalloc internally calls kmalloc and use page
tables, so it should be already accounted in Slab and PageTables ??
  ==> Do I still need to include these values from /proc/vmallocinfo ??
* Is it valid to include min_free_kbytes and user_reserve_kbytes here
? Its kind of reserve for internal purpose but still it contributes to
the total.
* Is kernel internal allocation (alloc_pages) statistics accounted somewhere ?
  ==> I can see that some counters like (pgalloc_normal, etc. and
pgfree) are available as part of /proc/vmstat
  ===> But this is like overall allocation and free stats.
* Apart from these, do we also need to consider Graphics/3D allocation
separately ?


Thanks,
Pintu

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2020-05-20  4:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 17:57 Estimating total memory usage in any Linux system Pintu Agarwal
2020-05-19 17:03 ` Pintu Agarwal
2020-05-20  4:01   ` Valdis Klētnieks
2020-05-20  4:56     ` Pintu Agarwal [this message]
2020-05-20  5:32       ` Valdis Klētnieks
2020-05-20  6:11         ` Pintu Agarwal

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='CAOuPNLjTP0s=5sOpCnnFVHedBP1dV0A8S2wAiDjBAN1q+C2JZQ@mail.gmail.com' \
    --to=pintu.ping@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=linux-mm@kvack.org \
    --cc=valdis.kletnieks@vt.edu \
    /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;
as well as URLs for NNTP newsgroup(s).