All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm?
@ 2016-03-22 13:55 ` Xishi Qiu
  0 siblings, 0 replies; 7+ messages in thread
From: Xishi Qiu @ 2016-03-22 13:55 UTC (permalink / raw)
  To: Linux MM, LKML

[root@localhost c_test]# cat /proc/3948/smaps | grep Rss
Rss:                   4 kB
Rss:                   4 kB
Rss:                   4 kB
Rss:                 796 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:                  12 kB
Rss:                   0 kB
Rss:                   4 kB
Rss:                   0 kB
[root@localhost c_test]# cat /proc/3948/statm
1042 173 154 1 0 48 0

173 means Rss is 173*4kb=692kb, right?
so why it is different from the sum(1020kb) of "cat /proc/pid/smaps | grep Rss"?

my test code is
...
int main()
{
	sleep(1000);
	return 0;
}

the kernel version is v4.1

Thanks,
Xishi Qiu

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

* [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm?
@ 2016-03-22 13:55 ` Xishi Qiu
  0 siblings, 0 replies; 7+ messages in thread
From: Xishi Qiu @ 2016-03-22 13:55 UTC (permalink / raw)
  To: Linux MM, LKML

[root@localhost c_test]# cat /proc/3948/smaps | grep Rss
Rss:                   4 kB
Rss:                   4 kB
Rss:                   4 kB
Rss:                 796 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:                  12 kB
Rss:                   0 kB
Rss:                   4 kB
Rss:                   0 kB
[root@localhost c_test]# cat /proc/3948/statm
1042 173 154 1 0 48 0

173 means Rss is 173*4kb=692kb, right?
so why it is different from the sum(1020kb) of "cat /proc/pid/smaps | grep Rss"?

my test code is
...
int main()
{
	sleep(1000);
	return 0;
}

the kernel version is v4.1

Thanks,
Xishi Qiu

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm?
  2016-03-22 13:55 ` Xishi Qiu
  (?)
@ 2016-03-22 14:47 ` Shakeel Butt
  2016-03-30  7:16     ` Xishi Qiu
  -1 siblings, 1 reply; 7+ messages in thread
From: Shakeel Butt @ 2016-03-22 14:47 UTC (permalink / raw)
  To: Xishi Qiu; +Cc: Linux MM, LKML

[-- Attachment #1: Type: text/plain, Size: 869 bytes --]

On Tue, Mar 22, 2016 at 6:55 AM, Xishi Qiu <qiuxishi@huawei.com> 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

[-- Attachment #2: Type: text/html, Size: 1749 bytes --]

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

* Re: [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm?
  2016-03-22 14:47 ` Shakeel Butt
@ 2016-03-30  7:16     ` Xishi Qiu
  0 siblings, 0 replies; 7+ messages in thread
From: Xishi Qiu @ 2016-03-30  7:16 UTC (permalink / raw)
  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 <qiuxishi@huawei.com <mailto:qiuxishi@huawei.com>> 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

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

* Re: [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm?
@ 2016-03-30  7:16     ` Xishi Qiu
  0 siblings, 0 replies; 7+ messages in thread
From: Xishi Qiu @ 2016-03-30  7:16 UTC (permalink / raw)
  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 <qiuxishi@huawei.com <mailto:qiuxishi@huawei.com>> 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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm?
  2016-03-30  7:16     ` Xishi Qiu
@ 2016-03-30  9:39       ` Xishi Qiu
  -1 siblings, 0 replies; 7+ messages in thread
From: Xishi Qiu @ 2016-03-30  9:39 UTC (permalink / raw)
  To: Shakeel Butt; +Cc: Linux MM, LKML

On 2016/3/30 15:16, Xishi Qiu wrote:

> On 2016/3/22 22:47, Shakeel Butt wrote:
> 
>>
>> On Tue, Mar 22, 2016 at 6:55 AM, Xishi Qiu <qiuxishi@huawei.com <mailto:qiuxishi@huawei.com>> 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 misunderstand your meaning before. I know the reason now.

Thanks,
Xishi Qiu 

> Hi Shakeel,
> 
> I malloc and memset 10M, then sleep. It seems that the problem is still exist,
> the kernel version is v4.1
>

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

* Re: [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm?
@ 2016-03-30  9:39       ` Xishi Qiu
  0 siblings, 0 replies; 7+ messages in thread
From: Xishi Qiu @ 2016-03-30  9:39 UTC (permalink / raw)
  To: Shakeel Butt; +Cc: Linux MM, LKML

On 2016/3/30 15:16, Xishi Qiu wrote:

> On 2016/3/22 22:47, Shakeel Butt wrote:
> 
>>
>> On Tue, Mar 22, 2016 at 6:55 AM, Xishi Qiu <qiuxishi@huawei.com <mailto:qiuxishi@huawei.com>> 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 misunderstand your meaning before. I know the reason now.

Thanks,
Xishi Qiu 

> Hi Shakeel,
> 
> I malloc and memset 10M, then sleep. It seems that the problem is still exist,
> the kernel version is v4.1
>


--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2016-03-30  9:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22 13:55 [RFC] mm: why cat /proc/pid/smaps | grep Rss is different from cat /proc/pid/statm? Xishi Qiu
2016-03-22 13:55 ` Xishi Qiu
2016-03-22 14:47 ` Shakeel Butt
2016-03-30  7:16   ` Xishi Qiu
2016-03-30  7:16     ` Xishi Qiu
2016-03-30  9:39     ` Xishi Qiu
2016-03-30  9:39       ` Xishi Qiu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.