lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1009160950500.24798@tigran.mtv.corp.google.com>
Date:	Thu, 16 Sep 2010 09:56:35 -0700 (PDT)
From:	Hugh Dickins <hughd@...gle.com>
To:	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
cc:	Nikanth Karthikesan <knikanth@...e.de>,
	Matt Mackall <mpm@...enic.com>,
	Richard Guenther <rguenther@...e.de>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>, linux-mm@...ck.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Michael Matz <matz@...ell.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] smaps: fix dirty pages accounting

On Thu, 16 Sep 2010, KOSAKI Motohiro wrote:

> Currently, /proc/<pid>/smaps have wrong dirty pages accounting.
> Shared_Dirty and Private_Dirty output only pte dirty pages and
> ignore PG_dirty page flag. It is difference against documentation,
> but also inconsistent against Referenced field. (Referenced checks
> both pte and page flags)
> 
> This patch fixes it.
> 
> Test program:
> 
>  large-array.c
>  ---------------------------------------------------
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
>  #include <unistd.h>
> 
>  char array[1*1024*1024*1024L];
> 
>  int main(void)
>  {
>          memset(array, 1, sizeof(array));
>          pause();
> 
>          return 0;
>  }
>  ---------------------------------------------------
> 
> Test case:
>  1. run ./large-array
>  2. cat /proc/`pidof large-array`/smaps
>  3. swapoff -a
>  4. cat /proc/`pidof large-array`/smaps again
> 
> Test result:
>  <before patch>
> 
> 00601000-40601000 rw-p 00000000 00:00 0
> Size:            1048576 kB
> Rss:             1048576 kB
> Pss:             1048576 kB
> Shared_Clean:          0 kB
> Shared_Dirty:          0 kB
> Private_Clean:    218992 kB   <-- showed pages as clean incorrectly
> Private_Dirty:    829584 kB
> Referenced:       388364 kB
> Swap:                  0 kB
> KernelPageSize:        4 kB
> MMUPageSize:           4 kB
> 
>  <after patch>
> 
> 00601000-40601000 rw-p 00000000 00:00 0
> Size:            1048576 kB
> Rss:             1048576 kB
> Pss:             1048576 kB
> Shared_Clean:          0 kB
> Shared_Dirty:          0 kB
> Private_Clean:         0 kB
> Private_Dirty:   1048576 kB  <-- fixed
> Referenced:       388480 kB
> Swap:                  0 kB
> KernelPageSize:        4 kB
> MMUPageSize:           4 kB
> 
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>

Certainly you can have my

Acked-by: Hugh Dickins <hughd@...gle.com>

but I think it's for Matt to decide what he's wanting to show there,
and whether it's safe to change after all this time.  I hadn't noticed
the descrepancy between "dirty" and "referenced", that certainly argues
for your patch.

> ---
>  fs/proc/task_mmu.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 439fc1f..7415f13 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -362,13 +362,13 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,
>  			mss->referenced += PAGE_SIZE;
>  		mapcount = page_mapcount(page);
>  		if (mapcount >= 2) {
> -			if (pte_dirty(ptent))
> +			if (pte_dirty(ptent) || PageDirty(page))
>  				mss->shared_dirty += PAGE_SIZE;
>  			else
>  				mss->shared_clean += PAGE_SIZE;
>  			mss->pss += (PAGE_SIZE << PSS_SHIFT) / mapcount;
>  		} else {
> -			if (pte_dirty(ptent))
> +			if (pte_dirty(ptent) || PageDirty(page))
>  				mss->private_dirty += PAGE_SIZE;
>  			else
>  				mss->private_clean += PAGE_SIZE;
> -- 
> 1.6.5.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ