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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 1 Apr 2013 15:23:33 -0700 (PDT)
From:	David Rientjes <rientjes@...gle.com>
To:	Zhouping Liu <zliu@...hat.com>
cc:	Andrea Arcangeli <aarcange@...hat.com>,
	Hugh Dickins <hughd@...gle.com>, Mel Gorman <mgorman@...e.de>,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	Amos Kong <akong@...hat.com>
Subject: Re: THP: AnonHugePages in /proc/[pid]/smaps is correct or not?

On Mon, 1 Apr 2013, Zhouping Liu wrote:

> Hi all,
> 
> I found THP can't correctly distinguish one anonymous hugepage map.
> 
> 1. when /sys/kernel/mm/transparent_hugepage/enabled is 'always', the
>    amount of THP always is one less.
> 

It's not a problem with identifying an anonymous mapping as a hugepage, 
setting thp enabled to "always" does not guarantee that they will always 
be allocatable or that your mmap() will be 2MB aligned.  Your sample code 
is using mmap() instead of posix_memalign() so you'll probably only get 
100% hugepages only 1/512th of the time.

> 2. when /sys/kernel/mm/transparent_hugepage/enabled is 'madvise', THP can't
>    distinguish any one anonymous hugepage size:
> 
>    Testing code:
> -------- snip --------
> unsigned long hugepagesize = (1UL << 21);
> 
> int main()
> {
> 	void *addr;
> 	int i;
> 
> 	printf("pid is %d\n", getpid());
> 
> 	for (i = 0; i < 5; i++) {
> 		addr = mmap(NULL, hugepagesize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
> 
> 		if (addr == MAP_FAILED) {
> 			perror("mmap");
> 			return -1;
> 		}
> 
> 		if (madvise(addr, hugepagesize, MADV_HUGEPAGE) == -1) {
> 			perror("madvise");
> 			return -1;
> 		}
> 
> 		memset(addr, i, hugepagesize);
> 	}
> 
> 	sleep(50);
> 
> 	return 0;
> }
> --------- snip ----------
> 
> The result is that it can't find any AnonHugePages from /proc/[pid]/smaps :
> -------------- snip -------
> 7f0b38cd0000-7f0b396d0000 rw-p 00000000 00:00 0
> Size:              10240 kB
> Rss:               10240 kB
> Pss:               10240 kB
> Shared_Clean:          0 kB
> Shared_Dirty:          0 kB
> Private_Clean:         0 kB
> Private_Dirty:     10240 kB
> Referenced:        10240 kB
> Anonymous:         10240 kB
> AnonHugePages:         0 kB
> Swap:                  0 kB
> KernelPageSize:        4 kB
> MMUPageSize:           4 kB
> Locked:                0 kB
> VmFlags: rd wr mr mw me ac

"hg" would be shown in VmFlags if your MADV_HUGEPAGE was successful, are 
you sure this is the right vma?
--
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