From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9413CC433DF for ; Wed, 20 May 2020 04:57:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4FAEF20748 for ; Wed, 20 May 2020 04:57:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V3r7d5p7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FAEF20748 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D1BD98004E; Wed, 20 May 2020 00:57:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA51F8002C; Wed, 20 May 2020 00:57:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6CA18004E; Wed, 20 May 2020 00:57:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 9B66E8002C for ; Wed, 20 May 2020 00:57:03 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 594FB181AEF2A for ; Wed, 20 May 2020 04:57:03 +0000 (UTC) X-FDA: 76835887926.27.self23_5aaa3ae06b326 X-HE-Tag: self23_5aaa3ae06b326 X-Filterd-Recvd-Size: 5006 Received: from mail-vs1-f68.google.com (mail-vs1-f68.google.com [209.85.217.68]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 04:57:02 +0000 (UTC) Received: by mail-vs1-f68.google.com with SMTP id y13so1077239vsk.8 for ; Tue, 19 May 2020 21:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=hhYpWFFpj+mPmJkahEQ0boj1Iq7da8Oy+qjeAvq+inA=; b=V3r7d5p75UOAxYr3RkxGLUDflcXznPD38W+eiIUnljgklO2YrOqBv8cpsz4QZiqdXw UaiGljBs5N4Kp8b8yKfdw3hAGEavHtieIkv1Hb2eOvjdmqDAxpc3mdDXopUrhciPreC1 lTRk8q5UYRlL+yHqyYkQTHr7t6jDkTaXVcb4ZPijaYvCo4spnI/cVmW8yoofzlGhdHxX m9fV7z88ev/yP9HQoXTyPTvQtGZskht0TQEEMH9zXzdr95mN1slj+Ds1LzZbOuLuv3kr UF9DNAE2VJVM7L66qc3QF4v1uxI7TeB0yV2Xyt5TbGRX4uqbozS00gsA1iiJJOoHZze9 Iw8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=hhYpWFFpj+mPmJkahEQ0boj1Iq7da8Oy+qjeAvq+inA=; b=OH4tGn8BHr+pRwGZdSnVdSYRb2pm4jzU8abFLAEvIEkPTHvKhcul6hW8KW5i2cPx+6 ZxK4fxZwhhbvb+EzY2+Lo7KQgEGnXcKqbtr52gqfMjKXyzFbfuC1mx//Kk1oCje0g6+j uKldGG1iT+1J8o3jXOhGc+JyOoPtICJbjnTrZP3F4DA72qhRbVa3+ezTa/6exd6JD6uj 6JigtdEEELUV2zwP9v1203NoBD8DJk/L54nEgisxtofzGffXdoUIDKJNgXdHjGmjWjAN xYs2BL+dFe4hM3aJtDnqEheZcVb15Jb1gbykC9FRMWXeCRDtbvGMgLBITJ/w7jmGnNiG jEug== X-Gm-Message-State: AOAM5308WX5BZY1AvInOZvTocK4ubdqSZNpSklT4OPAH/qF1P7y2I9W/ xAB2j9qWUmelAoehYH+jU9FIMSLSoX1ycerav5w= X-Google-Smtp-Source: ABdhPJz9iwg23Kb3WpHSFZLQ1x4dqk2Ejk665xpN0AGcIg+g/ZsQIwpv/PnSIk/aUcPXm6q3f4imcdr7Zb2NFqYfxvU= X-Received: by 2002:a67:f60e:: with SMTP id k14mr1880489vso.144.1589950622036; Tue, 19 May 2020 21:57:02 -0700 (PDT) MIME-Version: 1.0 References: <21691.1589947282@turing-police> In-Reply-To: <21691.1589947282@turing-police> From: Pintu Agarwal Date: Wed, 20 May 2020 10:26:50 +0530 Message-ID: Subject: Re: Estimating total memory usage in any Linux system To: =?UTF-8?Q?Valdis_Kl=C4=93tnieks?= Cc: Kernelnewbies , linux-mm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 20 May 2020 at 09:31, Valdis Kl=C4=93tnieks 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 512= MB 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 counter= s. 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 =3D 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. =3D=3D> 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. =3D=3D> But I think vmalloc internally calls kmalloc and use page tables, so it should be already accounted in Slab and PageTables ?? =3D=3D> 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 somewher= e ? =3D=3D> I can see that some counters like (pgalloc_normal, etc. and pgfree) are available as part of /proc/vmstat =3D=3D=3D> But this is like overall allocation and free stats. * Apart from these, do we also need to consider Graphics/3D allocation separately ? Thanks, Pintu