From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by kanga.kvack.org (Postfix) with ESMTP id D96A4828DF for ; Wed, 30 Mar 2016 03:16:39 -0400 (EDT) Received: by mail-pa0-f46.google.com with SMTP id td3so33130627pab.2 for ; Wed, 30 Mar 2016 00:16:39 -0700 (PDT) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com. [58.251.152.64]) by mx.google.com with ESMTPS id qe4si4373079pab.195.2016.03.30.00.16.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 30 Mar 2016 00:16:39 -0700 (PDT) Message-ID: <56FB7D37.5070503@huawei.com> Date: Wed, 30 Mar 2016 15:16:07 +0800 From: Xishi Qiu MIME-Version: 1.0 Subject: Re: [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm? References: <56F14EEE.7060308@huawei.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Shakeel Butt Cc: Linux MM , LKML On 2016/3/22 22:47, Shakeel Butt wrote: > > On Tue, Mar 22, 2016 at 6:55 AM, Xishi Qiu > wrote: > > [root@localhost c_test]# cat /proc/3948/smaps | grep Rss > > The /proc/[pid]/smaps read triggers the traversal of all of process's vmas and then page tables and accumulate RSS on each present page table entry. > > [root@localhost c_test]# cat /proc/3948/statm > 1042 173 154 1 0 48 0 > > The files /proc/[pid]/statm and /proc/[pid]/status uses the counters (MM_ANONPAGES & MM_FILEPAGES) in mm_struct to report RSS of a process. These counters are modified on page table modifications. However the kernel implements an optimization where each thread keeps a local copy of these counters in its task_struct. These local counter are accumulated in the shared counter of mm_struct after some number of page faults (I think 32) faced by the thread and thus there will be mismatch with smaps file. > > Shakeel Hi Shakeel, I malloc and memset 10M, then sleep. It seems that the problem is still exist, the kernel version is v4.1 [root@localhost c_test]# cat /proc/13746/statm 3603 2767 250 1 0 2609 0 [root@localhost c_test]# cat /proc/13746/smaps | grep Rss Rss: 4 kB Rss: 4 kB Rss: 4 kB Rss: 10244 kB Rss: 924 kB Rss: 0 kB Rss: 16 kB Rss: 8 kB Rss: 12 kB Rss: 132 kB Rss: 12 kB Rss: 4 kB Rss: 4 kB Rss: 4 kB Rss: 4 kB Rss: 8 kB Rss: 0 kB Rss: 4 kB Rss: 0 kB -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758663AbcC3HQe (ORCPT ); Wed, 30 Mar 2016 03:16:34 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:61792 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753862AbcC3HQd (ORCPT ); Wed, 30 Mar 2016 03:16:33 -0400 Message-ID: <56FB7D37.5070503@huawei.com> Date: Wed, 30 Mar 2016 15:16:07 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Shakeel Butt CC: Linux MM , LKML Subject: Re: [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm? References: <56F14EEE.7060308@huawei.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.56FB7D4C.00D6,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9fde267bcfb0c919bf9f3f98a03c2f34 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/3/22 22:47, Shakeel Butt wrote: > > On Tue, Mar 22, 2016 at 6:55 AM, Xishi Qiu > wrote: > > [root@localhost c_test]# cat /proc/3948/smaps | grep Rss > > The /proc/[pid]/smaps read triggers the traversal of all of process's vmas and then page tables and accumulate RSS on each present page table entry. > > [root@localhost c_test]# cat /proc/3948/statm > 1042 173 154 1 0 48 0 > > The files /proc/[pid]/statm and /proc/[pid]/status uses the counters (MM_ANONPAGES & MM_FILEPAGES) in mm_struct to report RSS of a process. These counters are modified on page table modifications. However the kernel implements an optimization where each thread keeps a local copy of these counters in its task_struct. These local counter are accumulated in the shared counter of mm_struct after some number of page faults (I think 32) faced by the thread and thus there will be mismatch with smaps file. > > Shakeel Hi Shakeel, I malloc and memset 10M, then sleep. It seems that the problem is still exist, the kernel version is v4.1 [root@localhost c_test]# cat /proc/13746/statm 3603 2767 250 1 0 2609 0 [root@localhost c_test]# cat /proc/13746/smaps | grep Rss Rss: 4 kB Rss: 4 kB Rss: 4 kB Rss: 10244 kB Rss: 924 kB Rss: 0 kB Rss: 16 kB Rss: 8 kB Rss: 12 kB Rss: 132 kB Rss: 12 kB Rss: 4 kB Rss: 4 kB Rss: 4 kB Rss: 4 kB Rss: 8 kB Rss: 0 kB Rss: 4 kB Rss: 0 kB