lkml.org 
[lkml]   [2015]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] perf tools: Add hugetlbfs memory recognition
On 2015/6/30 22:50, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jun 30, 2015 at 05:33:05PM +0800, Hou Pengyang escreveu:
>> On 2015/6/29 21:42, Arnaldo Carvalho de Melo wrote:
>>> Em Mon, Jun 29, 2015 at 10:23:29AM -0300, Arnaldo Carvalho de Melo escreveu:
>>>> Em Sat, Jun 27, 2015 at 05:08:20PM +0800, Hou Pengyang escreveu:
>>>>> So I wonder if there is a need to read /proc/pid/smaps instead of
>>>>> /proc/pid/maps to generate MMAP2 event. Or we should solve the problem by
>>>>> another way?
>>>>
>>>> Doing some research now...
>>>
>>> Bummer, seems that only smaps -> ... -> show_smap_vma_flags() will
>>> expose that to userspace...
>>>
>>> Perhaps we can look at some global stat for HugeTLB fs to figure out if
>>> we really, really need to parse smaps instead of just maps? I.e. in my
>>> system, a desktop one, F21, I have:
>>>
>>
>> It seems no other info tell us if one process is using hugetlbfs.
>> So how about an option to tell perf explicitly which file is from
>> hugetlbfs, like:
>>
>> ./perf report --hugetlb-file=/mnt/huge/hugepagefile
>>
>> So that, we can check if a mmap area is from hugetlbfs by its name
>> instead of MAP_HUGETLB.
>
> Well, we _can_ detect this automatically, its just a matter of parsing
> /proc/PID/smaps, right?
>
> What I was discussing was a way only parse smaps when we know we need
> to, i.e. when we, for instance, parsing /proc/PID/maps, find a map that
> we think may be a hugetlb one, maybe some other way to tell us that
> hugetlb maps are in place, looking at the hugetlbfs stats somehow?
>

Another solution, we can parse /proc/self/mounts. Here is the
/proc/self/mounts in my system:

.....
/dev/root / ext2 rw,relatime,errors=remount-ro 0 0
tracefs /sys/kernel/debug/tracing tracefs rw,relatime 0 0
nodev /mnt/huge hugetlbfs rw,relatime 0 0
....

from /proc/self/mounts, we can get mount point of hugetlbfs.
in my system, it is "/mnt/huge". So that, when mmap2 event
comes from userspace, we can compare prefix of filename with
hugetlbfs mount point (e.g "/mnt/huge") to check if it is a
file in hugetlbfs. if it is, set MAP_HUGELTB, otherwise, not set.

There is no need to parse /proc/PID/smaps now, what's more,
it is not difficult to parse "/proc/self/mounts".

> - Arnaldo
>
> .
>




\
 
 \ /
  Last update: 2015-07-03 12:41    [W:0.101 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site