22 Feb, 2018

1 commit

  • commit d8be75663cec0069b85f80191abd2682ce4a512f upstream.

    Now that kmemcheck is gone, we don't need the NOTRACK flags.

    Link: http://lkml.kernel.org/r/20171007030159.22241-5-alexander.levin@verizon.com
    Signed-off-by: Sasha Levin
    Cc: Alexander Potapenko
    Cc: Eric W. Biederman
    Cc: Michal Hocko
    Cc: Pekka Enberg
    Cc: Steven Rostedt
    Cc: Tim Hansen
    Cc: Vegard Nossum
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Levin, Alexander (Sasha Levin)
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

14 Sep, 2017

1 commit

  • GFP_TEMPORARY was introduced by commit e12ba74d8ff3 ("Group short-lived
    and reclaimable kernel allocations") along with __GFP_RECLAIMABLE. It's
    primary motivation was to allow users to tell that an allocation is
    short lived and so the allocator can try to place such allocations close
    together and prevent long term fragmentation. As much as this sounds
    like a reasonable semantic it becomes much less clear when to use the
    highlevel GFP_TEMPORARY allocation flag. How long is temporary? Can the
    context holding that memory sleep? Can it take locks? It seems there is
    no good answer for those questions.

    The current implementation of GFP_TEMPORARY is basically GFP_KERNEL |
    __GFP_RECLAIMABLE which in itself is tricky because basically none of
    the existing caller provide a way to reclaim the allocated memory. So
    this is rather misleading and hard to evaluate for any benefits.

    I have checked some random users and none of them has added the flag
    with a specific justification. I suspect most of them just copied from
    other existing users and others just thought it might be a good idea to
    use without any measuring. This suggests that GFP_TEMPORARY just
    motivates for cargo cult usage without any reasoning.

    I believe that our gfp flags are quite complex already and especially
    those with highlevel semantic should be clearly defined to prevent from
    confusion and abuse. Therefore I propose dropping GFP_TEMPORARY and
    replace all existing users to simply use GFP_KERNEL. Please note that
    SLAB users with shrinkers will still get __GFP_RECLAIMABLE heuristic and
    so they will be placed properly for memory fragmentation prevention.

    I can see reasons we might want some gfp flag to reflect shorterm
    allocations but I propose starting from a clear semantic definition and
    only then add users with proper justification.

    This was been brought up before LSF this year by Matthew [1] and it
    turned out that GFP_TEMPORARY really doesn't have a clear semantic. It
    seems to be a heuristic without any measured advantage for most (if not
    all) its current users. The follow up discussion has revealed that
    opinions on what might be temporary allocation differ a lot between
    developers. So rather than trying to tweak existing users into a
    semantic which they haven't expected I propose to simply remove the flag
    and start from scratch if we really need a semantic for short term
    allocations.

    [1] http://lkml.kernel.org/r/20170118054945.GD18349@bombadil.infradead.org

    [akpm@linux-foundation.org: fix typo]
    [akpm@linux-foundation.org: coding-style fixes]
    [sfr@canb.auug.org.au: drm/i915: fix up]
    Link: http://lkml.kernel.org/r/20170816144703.378d4f4d@canb.auug.org.au
    Link: http://lkml.kernel.org/r/20170728091904.14627-1-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Signed-off-by: Stephen Rothwell
    Acked-by: Mel Gorman
    Acked-by: Vlastimil Babka
    Cc: Matthew Wilcox
    Cc: Neil Brown
    Cc: "Theodore Ts'o"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Hocko
     

13 Jul, 2017

1 commit

  • __GFP_REPEAT was designed to allow retry-but-eventually-fail semantic to
    the page allocator. This has been true but only for allocations
    requests larger than PAGE_ALLOC_COSTLY_ORDER. It has been always
    ignored for smaller sizes. This is a bit unfortunate because there is
    no way to express the same semantic for those requests and they are
    considered too important to fail so they might end up looping in the
    page allocator for ever, similarly to GFP_NOFAIL requests.

    Now that the whole tree has been cleaned up and accidental or misled
    usage of __GFP_REPEAT flag has been removed for !costly requests we can
    give the original flag a better name and more importantly a more useful
    semantic. Let's rename it to __GFP_RETRY_MAYFAIL which tells the user
    that the allocator would try really hard but there is no promise of a
    success. This will work independent of the order and overrides the
    default allocator behavior. Page allocator users have several levels of
    guarantee vs. cost options (take GFP_KERNEL as an example)

    - GFP_KERNEL & ~__GFP_RECLAIM - optimistic allocation without _any_
    attempt to free memory at all. The most light weight mode which even
    doesn't kick the background reclaim. Should be used carefully because
    it might deplete the memory and the next user might hit the more
    aggressive reclaim

    - GFP_KERNEL & ~__GFP_DIRECT_RECLAIM (or GFP_NOWAIT)- optimistic
    allocation without any attempt to free memory from the current
    context but can wake kswapd to reclaim memory if the zone is below
    the low watermark. Can be used from either atomic contexts or when
    the request is a performance optimization and there is another
    fallback for a slow path.

    - (GFP_KERNEL|__GFP_HIGH) & ~__GFP_DIRECT_RECLAIM (aka GFP_ATOMIC) -
    non sleeping allocation with an expensive fallback so it can access
    some portion of memory reserves. Usually used from interrupt/bh
    context with an expensive slow path fallback.

    - GFP_KERNEL - both background and direct reclaim are allowed and the
    _default_ page allocator behavior is used. That means that !costly
    allocation requests are basically nofail but there is no guarantee of
    that behavior so failures have to be checked properly by callers
    (e.g. OOM killer victim is allowed to fail currently).

    - GFP_KERNEL | __GFP_NORETRY - overrides the default allocator behavior
    and all allocation requests fail early rather than cause disruptive
    reclaim (one round of reclaim in this implementation). The OOM killer
    is not invoked.

    - GFP_KERNEL | __GFP_RETRY_MAYFAIL - overrides the default allocator
    behavior and all allocation requests try really hard. The request
    will fail if the reclaim cannot make any progress. The OOM killer
    won't be triggered.

    - GFP_KERNEL | __GFP_NOFAIL - overrides the default allocator behavior
    and all allocation requests will loop endlessly until they succeed.
    This might be really dangerous especially for larger orders.

    Existing users of __GFP_REPEAT are changed to __GFP_RETRY_MAYFAIL
    because they already had their semantic. No new users are added.
    __alloc_pages_slowpath is changed to bail out for __GFP_RETRY_MAYFAIL if
    there is no progress and we have already passed the OOM point.

    This means that all the reclaim opportunities have been exhausted except
    the most disruptive one (the OOM killer) and a user defined fallback
    behavior is more sensible than keep retrying in the page allocator.

    [akpm@linux-foundation.org: fix arch/sparc/kernel/mdesc.c]
    [mhocko@suse.com: semantic fix]
    Link: http://lkml.kernel.org/r/20170626123847.GM11534@dhcp22.suse.cz
    [mhocko@kernel.org: address other thing spotted by Vlastimil]
    Link: http://lkml.kernel.org/r/20170626124233.GN11534@dhcp22.suse.cz
    Link: http://lkml.kernel.org/r/20170623085345.11304-3-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Acked-by: Vlastimil Babka
    Cc: Alex Belits
    Cc: Chris Wilson
    Cc: Christoph Hellwig
    Cc: Darrick J. Wong
    Cc: David Daney
    Cc: Johannes Weiner
    Cc: Mel Gorman
    Cc: NeilBrown
    Cc: Ralf Baechle
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Hocko
     

27 Jun, 2017

1 commit


20 Apr, 2017

4 commits


27 Mar, 2017

1 commit

  • We got it from the git sources but never used it for anything, with the
    place where this would be somehow used remaining:

    static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
    {
    prefix = NULL;
    if (p->option & RUN_SETUP)
    prefix = NULL; /* setup_perf_directory(); */

    Ditch it.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-uw5swz05vol0qpr32c5lpvus@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

14 Mar, 2017

1 commit

  • Introduce a new option to record PERF_RECORD_NAMESPACES events emitted
    by the kernel when fork, clone, setns or unshare are invoked. And update
    perf-record documentation with the new option to record namespace
    events.

    Committer notes:

    Combined it with a later patch to allow printing it via 'perf report -D'
    and be able to test the feature introduced in this patch. Had to move
    here also perf_ns__name(), that was introduced in another later patch.

    Also used PRIu64 and PRIx64 to fix the build in some enfironments wrt:

    util/event.c:1129:39: error: format '%lx' expects argument of type 'long unsigned int', but argument 6 has type 'long long unsigned int' [-Werror=format=]
    ret += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx
    ^
    Testing it:

    # perf record --namespaces -a
    ^C[ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 1.083 MB perf.data (423 samples) ]
    #
    # perf report -D

    3 2028902078892 0x115140 [0xa0]: PERF_RECORD_NAMESPACES 14783/14783 - nr_namespaces: 7
    [0/net: 3/0xf0000081, 1/uts: 3/0xeffffffe, 2/ipc: 3/0xefffffff, 3/pid: 3/0xeffffffc,
    4/user: 3/0xeffffffd, 5/mnt: 3/0xf0000000, 6/cgroup: 3/0xeffffffb]

    0x1151e0 [0x30]: event: 9
    .
    . ... raw event: size 48 bytes
    . 0000: 09 00 00 00 02 00 30 00 c4 71 82 68 0c 7f 00 00 ......0..q.h....
    . 0010: a9 39 00 00 a9 39 00 00 94 28 fe 63 d8 01 00 00 .9...9...(.c....
    . 0020: 03 00 00 00 00 00 00 00 ce c4 02 00 00 00 00 00 ................

    NAMESPACES events: 1

    #

    Signed-off-by: Hari Bathini
    Acked-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: Alexei Starovoitov
    Cc: Ananth N Mavinakayanahalli
    Cc: Aravinda Prasad
    Cc: Brendan Gregg
    Cc: Daniel Borkmann
    Cc: Eric Biederman
    Cc: Peter Zijlstra
    Cc: Sargun Dhillon
    Cc: Steven Rostedt
    Link: http://lkml.kernel.org/r/148891930386.25309.18412039920746995488.stgit@hbathini.in.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Hari Bathini
     

14 Feb, 2017

1 commit

  • As it is an array, so will always evaluate to 'true', as reported by
    clang:

    builtin-sched.c:2070:19: error: address of array 'sym->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
    if (sym && sym->name) {
    ~~ ~~~~~^~~~
    1 warning generated.

    So just ditch all those useless checks.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-ydpm927col06paixb775jjx5@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

27 Jan, 2017

1 commit

  • Previously these were being ignored, sometimes silently.

    Stop doing that, emitting debug messages and handling the errors.

    Testing it:

    $ cat ~/.perfconfig
    cat: /home/acme/.perfconfig: No such file or directory
    $ perf stat -e cycles usleep 1

    Performance counter stats for 'usleep 1':

    938,996 cycles:u

    0.003813731 seconds time elapsed

    $ perf top --stdio
    Error:
    You may not have permission to collect system-wide stats.

    Consider tweaking /proc/sys/kernel/perf_event_paranoid,

    [ perf record: Captured and wrote 0.019 MB perf.data (7 samples) ]
    [acme@jouet linux]$ perf report --stdio
    # To display the perf.data header info, please use --header/--header-only options.
    # Overhead Command Shared Object Symbol
    # ........ ....... ................. .........................
    71.77% usleep libc-2.24.so [.] _dl_addr
    27.07% usleep ld-2.24.so [.] _dl_next_ld_env_entry
    1.13% usleep [kernel.kallsyms] [k] page_fault
    $
    $ touch ~/.perfconfig
    $ ls -la ~/.perfconfig
    -rw-rw-r--. 1 acme acme 0 Jan 27 12:14 /home/acme/.perfconfig
    $
    $ perf stat -e instructions usleep 1

    Performance counter stats for 'usleep 1':

    244,610 instructions:u

    0.000805383 seconds time elapsed

    $
    [root@jouet ~]# chown acme.acme ~/.perfconfig
    [root@jouet ~]# perf stat -e cycles usleep 1
    Warning: File /root/.perfconfig not owned by current user or root, ignoring it.

    Performance counter stats for 'usleep 1':

    937,615 cycles

    0.000836931 seconds time elapsed
    #

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-j2rq96so6xdqlr8p8rd6a3jx@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

11 Jan, 2017

1 commit

  • The flag was introduced by commit 78afd5612deb ("mm: add
    __GFP_OTHER_NODE flag") to allow proper accounting of remote node
    allocations done by kernel daemons on behalf of a process - e.g.
    khugepaged.

    After "mm: fix remote numa hits statistics" we do not need and actually
    use the flag so we can safely remove it because all allocations which
    are satisfied from their "home" node are accounted properly.

    [mhocko@suse.com: fix build]
    Link: http://lkml.kernel.org/r/20170106122225.GK5556@dhcp22.suse.cz
    Link: http://lkml.kernel.org/r/20170102153057.9451-3-mhocko@kernel.org
    Signed-off-by: Michal Hocko
    Acked-by: Mel Gorman
    Acked-by: Vlastimil Babka
    Cc: Michal Hocko
    Cc: Johannes Weiner
    Cc: Joonsoo Kim
    Cc: Taku Izumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Hocko
     

02 Dec, 2016

1 commit

  • Add option to allow user to control analysis window. e.g., collect data
    for time window and analyze a segment of interest within that window.

    Committer notes:

    Testing it:

    # perf kmem record usleep 1
    [ perf record: Woken up 0 times to write data ]
    [ perf record: Captured and wrote 1.540 MB perf.data (2049 samples) ]
    # perf evlist
    kmem:kmalloc
    kmem:kmalloc_node
    kmem:kfree
    kmem:kmem_cache_alloc
    kmem:kmem_cache_alloc_node
    kmem:kmem_cache_free
    # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
    #
    # # Use 'perf script' to get a first approach, select a chunk for then using
    # # with 'perf kmem stat --time'
    #
    # perf script | tail -15
    usleep 9889 [0] 20119.782088: kmem:kmem_cache_free: (selinux_file_free_security+0x27) call_site=ffffffffb936aa07 ptr=0xffff888a1df49fc0
    perf 9888 [3] 20119.782088: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
    perf 9888 [3] 20119.782089: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
    perf 9888 [3] 20119.782090: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
    perf 9888 [3] 20119.782090: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
    usleep 9889 [0] 20119.782091: kmem:kmem_cache_alloc: (__sigqueue_alloc+0x4a) call_site=ffffffffb90ad33a ptr=0xffff8889f071f6e0 bytes_req=160 bytes_alloc=160 gfp_flags=GFP_ATOMIC|__GFP_NOTRACK
    perf 9888 [3] 20119.782091: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
    perf 9888 [3] 20119.782093: kmem:kmem_cache_free: (__sigqueue_free.part.17+0x33) call_site=ffffffffb90ad3f3 ptr=0xffff8889f071f6e0
    perf 9888 [3] 20119.782098: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
    perf 9888 [3] 20119.782098: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
    perf 9888 [3] 20119.782099: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
    perf 9888 [3] 20119.782100: kmem:kmem_cache_alloc: (alloc_buffer_head+0x21) call_site=ffffffffb9287cc1 ptr=0xffff8889b12722d8 bytes_req=104 bytes_alloc=104 gfp_flags=GFP_NOFS|__GFP_ZERO
    perf 9888 [3] 20119.782101: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
    perf 9888 [3] 20119.782102: kmem:kmem_cache_alloc: (jbd2__journal_start+0x72) call_site=ffffffffb9333b42 ptr=0xffff888bdf1a39c0 bytes_req=48 bytes_alloc=48 gfp_flags=GFP_NOFS|__GFP_ZERO
    perf 9888 [3] 20119.782103: kmem:kmem_cache_free: (jbd2_journal_stop+0x1a1) call_site=ffffffffb9334581 ptr=0xffff888bdf1a39c0
    #
    # # stats for the whole perf.data file, i.e. no interval specified
    #
    # perf kmem stat

    SUMMARY (SLAB allocator)
    ========================
    Total bytes requested: 172,628
    Total bytes allocated: 173,088
    Total bytes freed: 161,280
    Net total bytes allocated: 11,808
    Total bytes wasted on internal fragmentation: 460
    Internal fragmentation: 0.265761%
    Cross CPU allocations: 0/851
    #
    # # stats for an end open interval, after a certain time:
    #
    # perf kmem stat --time 20119.782088,

    SUMMARY (SLAB allocator)
    ========================
    Total bytes requested: 552
    Total bytes allocated: 552
    Total bytes freed: 448
    Net total bytes allocated: 104
    Total bytes wasted on internal fragmentation: 0
    Internal fragmentation: 0.000000%
    Cross CPU allocations: 0/8
    #

    Signed-off-by: David Ahern
    Tested-by: Arnaldo Carvalho de Melo
    Acked-by: Namhyung Kim
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1480439746-42695-6-git-send-email-dsahern@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    David Ahern
     

29 Nov, 2016

1 commit

  • Track freed memory as well as allocations and show the net in the
    summary.

    Committer notes:

    Testing it:

    # perf kmem record usleep 1
    [ perf record: Woken up 0 times to write data ]
    [ perf record: Captured and wrote 1.626 MB perf.data (4208 samples) ]
    [root@jouet ~]# perf kmem stat --slab

    SUMMARY (SLAB allocator)
    ========================
    Total bytes requested: 234,011
    Total bytes allocated: 234,504
    Total bytes freed: 213,328
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1480110133-37039-1-git-send-email-dsahern@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    David Ahern
     

05 Sep, 2016

1 commit

  • We're not using it anymore, few users were, but we really could do
    without it, simplify lots of functions by removing it.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-1zng8wdznn00iiz08bb7q3vn@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

29 Jul, 2016

1 commit

  • After the previous patch, we can distinguish costly allocations that
    should be really lightweight, such as THP page faults, with
    __GFP_NORETRY. This means we don't need to recognize khugepaged
    allocations via PF_KTHREAD anymore. We can also change THP page faults
    in areas where madvise(MADV_HUGEPAGE) was used to try as hard as
    khugepaged, as the process has indicated that it benefits from THP's and
    is willing to pay some initial latency costs.

    We can also make the flags handling less cryptic by distinguishing
    GFP_TRANSHUGE_LIGHT (no reclaim at all, default mode in page fault) from
    GFP_TRANSHUGE (only direct reclaim, khugepaged default). Adding
    __GFP_NORETRY or __GFP_KSWAPD_RECLAIM is done where needed.

    The patch effectively changes the current GFP_TRANSHUGE users as
    follows:

    * get_huge_zero_page() - the zero page lifetime should be relatively
    long and it's shared by multiple users, so it's worth spending some
    effort on it. We use GFP_TRANSHUGE, and __GFP_NORETRY is not added.
    This also restores direct reclaim to this allocation, which was
    unintentionally removed by commit e4a49efe4e7e ("mm: thp: set THP defrag
    by default to madvise and add a stall-free defrag option")

    * alloc_hugepage_khugepaged_gfpmask() - this is khugepaged, so latency
    is not an issue. So if khugepaged "defrag" is enabled (the default), do
    reclaim via GFP_TRANSHUGE without __GFP_NORETRY. We can remove the
    PF_KTHREAD check from page alloc.

    As a side-effect, khugepaged will now no longer check if the initial
    compaction was deferred or contended. This is OK, as khugepaged sleep
    times between collapsion attempts are long enough to prevent noticeable
    disruption, so we should allow it to spend some effort.

    * migrate_misplaced_transhuge_page() - already was masking out
    __GFP_RECLAIM, so just convert to GFP_TRANSHUGE_LIGHT which is
    equivalent.

    * alloc_hugepage_direct_gfpmask() - vma's with VM_HUGEPAGE (via madvise)
    are now allocating without __GFP_NORETRY. Other vma's keep using
    __GFP_NORETRY if direct reclaim/compaction is at all allowed (by default
    it's allowed only for madvised vma's). The rest is conversion to
    GFP_TRANSHUGE(_LIGHT).

    [mhocko@suse.com: suggested GFP_TRANSHUGE_LIGHT]
    Link: http://lkml.kernel.org/r/20160721073614.24395-7-vbabka@suse.cz
    Signed-off-by: Vlastimil Babka
    Acked-by: Michal Hocko
    Acked-by: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vlastimil Babka
     

23 Jun, 2016

2 commits

  • To match the semantics for list.h in the kernel, that are used to
    implement those macros.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Milian Wolff
    Cc: Namhyung Kim
    Cc: Taeung Song
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-qbcjlgj0ffxquxscahbpddi3@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     
  • Lately util/config.h has been added but util/cache.h has declarations of
    functions and a global variable for config features.

    To manage codes about configuration at one spot, move them to
    util/config.h and let source files that need config features include
    config.h And if the source files that included previous cache.h need
    only config.h, remove including cache.h.

    Signed-off-by: Taeung Song
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1466672119-4852-2-git-send-email-treeze.taeung@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Taeung Song
     

15 Apr, 2016

1 commit

  • The recent perf_evsel__fprintf_callchain() move to evsel.c added several
    new symbol requirements to the python binding, for instance:

    # perf test -v python
    16: Try 'import perf' in python, checking link problems :
    --- start ---
    test child forked, pid 18030
    Traceback (most recent call last):
    File "", line 1, in
    ImportError: /tmp/build/perf/python/perf.so: undefined symbol:
    callchain_cursor
    test child finished with -1
    ---- end ----
    Try 'import perf' in python, checking link problems: FAILED!
    #

    This would require linking against callchain.c to access to the global
    callchain_cursor variables.

    Since lots of functions already receive as a parameter a
    callchain_cursor struct pointer, make that be the case for some more
    function so that we can start phasing out usage of yet another global
    variable.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-djko3097eyg2rn66v2qcqfvn@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

16 Mar, 2016

2 commits

  • In tracepoints, it's possible to print gfp flags in a human-friendly
    format through a macro show_gfp_flags(), which defines a translation
    array and passes is to __print_flags(). Since the following patch will
    introduce support for gfp flags printing in printk(), it would be nice
    to reuse the array. This is not straightforward, since __print_flags()
    can't simply reference an array defined in a .c file such as mm/debug.c
    - it has to be a macro to allow the macro magic to communicate the
    format to userspace tools such as trace-cmd.

    The solution is to create a macro __def_gfpflag_names which is used both
    in show_gfp_flags(), and to define the gfpflag_names[] array in
    mm/debug.c.

    On the other hand, mm/debug.c also defines translation tables for page
    flags and vma flags, and desire was expressed (but not implemented in
    this series) to use these also from tracepoints. Thus, this patch also
    renames the events/gfpflags.h file to events/mmflags.h and moves the
    table definitions there, using the same macro approach as for gfpflags.
    This allows translating all three kinds of mm-specific flags both in
    tracepoints and printk.

    Signed-off-by: Vlastimil Babka
    Reviewed-by: Michal Hocko
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Ingo Molnar
    Cc: Rasmus Villemoes
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Sasha Levin
    Cc: "Kirill A. Shutemov"
    Cc: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vlastimil Babka
     
  • When updating tracing's show_gfp_flags() I have noticed that perf's
    gfp_compact_table is also outdated. Fill in the missing flags and place
    a note in gfp.h to increase chance that future updates are synced.
    Convert the __GFP_X flags from "GFP_X" to "__GFP_X" strings in line with
    the previous patch.

    Signed-off-by: Vlastimil Babka
    Acked-by: David Rientjes
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Ingo Molnar
    Cc: Rasmus Villemoes
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Sasha Levin
    Cc: "Kirill A. Shutemov"
    Cc: Mel Gorman
    Cc: Michal Hocko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vlastimil Babka
     

27 Feb, 2016

1 commit

  • Before this patch each subcommand calls perf_config() by themself,
    reading the default configuration together with subcommand specific
    options. If a subcommand doesn't have it own options, it needs to call
    'perf_config(perf_default_config, NULL)' to ensure .perfconfig is
    loaded.

    This patch brings perf_config(perf_default_config, NULL) to the very
    start of main(), so subcommands don't need to do it.

    After this patch, 'llvm.clang-path' works for 'perf trace'.

    Signed-off-by: Wang Nan
    Suggested-and-Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexei Starovoitov
    Cc: Jiri Olsa
    Cc: Li Zefan
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1456479154-136027-4-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     

18 Dec, 2015

1 commit

  • Move the subcommand-related files from perf to a new library named
    libsubcmd.a.

    Since we're moving files anyway, go ahead and rename 'exec_cmd.*' to
    'exec-cmd.*' to be consistent with the naming of all the other files.

    Signed-off-by: Josh Poimboeuf
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/c0a838d4c878ab17fee50998811612b2281355c1.1450193761.git.jpoimboe@redhat.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Josh Poimboeuf
     

01 Oct, 2015

2 commits


02 Jul, 2015

1 commit

  • When an error occurs an error value is just returned without freeing the
    session. So allocating and freeing session have to be matched as a pair
    even if an error occurs.

    Signed-off-by: Taeung Song
    Acked-by: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lkml.kernel.org/r/1435652124-22414-3-git-send-email-treeze.taeung@gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Taeung Song
     

29 May, 2015

1 commit


12 May, 2015

1 commit

  • The last argument to strtok_r doesn't need to be initialized, its just a
    placeholder to make this routine reentrant, but gcc doesn't know about
    that and complains, breaking the build, fix it by setting it to NULL.

    Fixes: 0e11115644b3 ("perf kmem: Print gfp flags in human readable string")
    Cc: Adrian Hunter
    Cc: Borislav Petkov
    Cc: David Ahern
    Cc: Don Zickus
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-iyyvkbnkrd9g19f6ta9zfkem@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

11 May, 2015

1 commit


09 May, 2015

1 commit

  • In addition to using refcounts for the struct thread lifetime
    management, we need to protect access to machine->threads from
    concurrent access.

    That happens in 'perf top', where a thread processes events, inserting
    and deleting entries from that rb_tree while another thread decays
    hist_entries, that end up dropping references and ultimately deleting
    threads from the rb_tree and releasing its resources when no further
    hist_entry (or other data structures, like in 'perf sched') references
    it.

    So the rule is the same for refcounts + protected trees in the kernel,
    get the tree lock, find object, bump the refcount, drop the tree lock,
    return, use object, drop the refcount if no more use of it is needed,
    keep it if storing it in some other data structure, drop when releasing
    that data structure.

    I.e. pair "t = machine__find(new)_thread()" with a "thread__put(t)", and
    "perf_event__preprocess_sample(&al)" with "addr_location__put(&al)".

    The addr_location__put() one is because as we return references to
    several data structures, we may end up adding more reference counting
    for the other data structures and then we'll drop it at
    addr_location__put() time.

    Acked-by: David Ahern
    Cc: Adrian Hunter
    Cc: Borislav Petkov
    Cc: Don Zickus
    Cc: Frederic Weisbecker
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Stephane Eranian
    Link: http://lkml.kernel.org/n/tip-bs9rt4n0jw3hi9f3zxyy3xln@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

06 May, 2015

1 commit

  • Sometimes one can mistakenly run 'perf kmem stat' without running 'perf
    kmem record' before or with a different configuration like recording
    --slab and stat --page. Show a warning message like the one below to
    inform the user:

    # perf kmem stat --page --caller
    No page allocation events found. Have you run 'perf kmem record --page'?

    Signed-off-by: Namhyung Kim
    Acked-by: Pekka Enberg
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Peter Zijlstra
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/1430837572-31395-1-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     

05 May, 2015

4 commits

  • Currently perf kmem command will select --slab if neither --slab nor
    --page is given for backward compatibility. Add kmem.default config
    option to select the default value ('page' or 'slab').

    # cat ~/.perfconfig
    [kmem]
    default = page

    # perf kmem stat

    SUMMARY (page allocator)
    ========================
    Total allocation requests : 1,518 [ 6,096 KB ]
    Total free requests : 1,431 [ 5,748 KB ]

    Total alloc+freed requests : 1,330 [ 5,344 KB ]
    Total alloc-only requests : 188 [ 752 KB ]
    Total free-only requests : 101 [ 404 KB ]

    Total allocation failures : 0 [ 0 KB ]
    ...

    Signed-off-by: Namhyung Kim
    Acked-by: Pekka Enberg
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Peter Zijlstra
    Cc: Taeung Song
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/1429592107-1807-6-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Save libtraceevent output and print it in the header.

    # perf kmem stat --page --caller
    #
    # GFP flags
    # ---------
    # 00000010: NI: GFP_NOIO
    # 000000d0: K: GFP_KERNEL
    # 00000200: NWR: GFP_NOWARN
    # 000084d0: K|R|Z: GFP_KERNEL|GFP_REPEAT|GFP_ZERO
    # 000200d2: HU: GFP_HIGHUSER
    # 000200da: HUM: GFP_HIGHUSER_MOVABLE
    # 000280da: HUM|Z: GFP_HIGHUSER_MOVABLE|GFP_ZERO
    # 002084d0: K|R|Z|NT: GFP_KERNEL|GFP_REPEAT|GFP_ZERO|GFP_NOTRACK
    # 0102005a: NF|HW|M: GFP_NOFS|GFP_HARDWALL|GFP_MOVABLE

    ---------------------------------------------------------------------------------------------------------
    Total alloc (KB) | Hits | Order | Mig.type | GFP flags | Callsite
    ---------------------------------------------------------------------------------------------------------
    60 | 15 | 0 | UNMOVABL | K|R|Z|NT | pte_alloc_one
    40 | 10 | 0 | MOVABLE | HUM|Z | handle_mm_fault
    24 | 6 | 0 | MOVABLE | HUM | do_wp_page
    24 | 6 | 0 | UNMOVABL | K | __pollwait
    ...

    Requested-by: Joonsoo Kim
    Suggested-by: Minchan Kim
    Signed-off-by: Namhyung Kim
    Acked-by: Pekka Enberg
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Peter Zijlstra
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/1429592107-1807-5-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Currently 'perf kmem stat --page' shows total (page) allocation stat by
    default, but sometimes one might want to see live (total alloc-only)
    requests/pages only. The new --live option does this by subtracting freed
    allocation from the stat.

    E.g.:

    # perf kmem stat --page

    SUMMARY (page allocator)
    ========================
    Total allocation requests : 988,858 [ 4,045,368 KB ]
    Total free requests : 886,484 [ 3,624,996 KB ]

    Total alloc+freed requests : 885,969 [ 3,622,628 KB ]
    Total alloc-only requests : 102,889 [ 422,740 KB ]
    Total free-only requests : 515 [ 2,368 KB ]

    Total allocation failures : 0 [ 0 KB ]

    Order Unmovable Reclaimable Movable Reserved CMA/Isolated
    ----- ------------ ------------ ------------ ------------ ------------
    0 172,173 3,083 806,686 . .
    1 284 . . . .
    2 6,124 58 . . .
    3 114 335 . . .
    4 . . . . .
    5 . . . . .
    6 . . . . .
    7 . . . . .
    8 . . . . .
    9 . . 1 . .
    10 . . . . .
    # perf kmem stat --page --live

    SUMMARY (page allocator)
    ========================
    Total allocation requests : 988,858 [ 4,045,368 KB ]
    Total free requests : 886,484 [ 3,624,996 KB ]

    Total alloc+freed requests : 885,969 [ 3,622,628 KB ]
    Total alloc-only requests : 102,889 [ 422,740 KB ]
    Total free-only requests : 515 [ 2,368 KB ]

    Total allocation failures : 0 [ 0 KB ]

    Order Unmovable Reclaimable Movable Reserved CMA/Isolated
    ----- ------------ ------------ ------------ ------------ ------------
    0 2,214 3,025 97,156 . .
    1 59 . . . .
    2 19 58 . . .
    3 23 335 . . .
    4 . . . . .
    5 . . . . .
    6 . . . . .
    7 . . . . .
    8 . . . . .
    9 . . . . .
    10 . . . . .
    #

    Signed-off-by: Namhyung Kim
    Acked-by: Pekka Enberg
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Peter Zijlstra
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/1429592107-1807-4-git-send-email-namhyung@kernel.org
    [ Added examples to the changeset log ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Add new sort keys for page: page, order, migtype, gfp - existing
    'bytes', 'hit' and 'callsite' sort keys also work for page. Note that
    -s/--sort option should be preceded by either of --slab or --page option
    to determine where the sort keys applies.

    Now it properly groups and sorts allocation stats - so same
    page/caller with different order/migtype/gfp will be printed on a
    different line.

    # perf kmem stat --page --caller -l 10 -s order,hit

    -----------------------------------------------------------------------------
    Total alloc (KB) | Hits | Order | Mig.type | GFP flags | Callsite
    -----------------------------------------------------------------------------
    64 | 4 | 2 | RECLAIM | 00285250 | new_slab
    50,144 | 12,536 | 0 | MOVABLE | 0102005a | __page_cache_alloc
    52 | 13 | 0 | UNMOVABL | 002084d0 | pte_alloc_one
    40 | 10 | 0 | MOVABLE | 000280da | handle_mm_fault
    28 | 7 | 0 | UNMOVABL | 000000d0 | __pollwait
    20 | 5 | 0 | MOVABLE | 000200da | do_wp_page
    20 | 5 | 0 | MOVABLE | 000200da | do_cow_fault
    16 | 4 | 0 | UNMOVABL | 00000200 | __tlb_remove_page
    16 | 4 | 0 | UNMOVABL | 000084d0 | __pmd_alloc
    8 | 2 | 0 | UNMOVABL | 000084d0 | __pud_alloc
    ... | ... | ... | ... | ... | ...
    -----------------------------------------------------------------------------

    Signed-off-by: Namhyung Kim
    Acked-by: Pekka Enberg
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Peter Zijlstra
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/1429592107-1807-3-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     

04 May, 2015

1 commit

  • It is 'perf kmem' support caller statistics for page. Unlike slab case,
    the tracepoints in page allocator don't provide callsite info. So it
    records with callchain and extracts callsite info.

    Note that the callchain contains several memory allocation functions
    which has no meaning for users. So skip those functions to get proper
    callsites. I used following regex pattern to skip the allocator
    functions:

    ^_?_?(alloc|get_free|get_zeroed)_pages?

    This gave me a following list of functions:

    # perf kmem record --page sleep 3
    # perf kmem stat --page -v
    ...
    alloc func: __get_free_pages
    alloc func: get_zeroed_page
    alloc func: alloc_pages_exact
    alloc func: __alloc_pages_direct_compact
    alloc func: __alloc_pages_nodemask
    alloc func: alloc_page_interleave
    alloc func: alloc_pages_current
    alloc func: alloc_pages_vma
    alloc func: alloc_page_buffers
    alloc func: alloc_pages_exact_nid
    ...

    The output looks mostly same as --alloc (I also added callsite column
    to that) but groups entries by callsite. Currently, the order,
    migrate type and GFP flag info is for the last allocation and not
    guaranteed to be same for all allocations from the callsite.

    ---------------------------------------------------------------------------------------------
    Total_alloc (KB) | Hits | Order | Mig.type | GFP flags | Callsite
    ---------------------------------------------------------------------------------------------
    1,064 | 266 | 0 | UNMOVABL | 000000d0 | __pollwait
    52 | 13 | 0 | UNMOVABL | 002084d0 | pte_alloc_one
    44 | 11 | 0 | MOVABLE | 000280da | handle_mm_fault
    20 | 5 | 0 | MOVABLE | 000200da | do_cow_fault
    20 | 5 | 0 | MOVABLE | 000200da | do_wp_page
    16 | 4 | 0 | UNMOVABL | 000084d0 | __pmd_alloc
    16 | 4 | 0 | UNMOVABL | 00000200 | __tlb_remove_page
    12 | 3 | 0 | UNMOVABL | 000084d0 | __pud_alloc
    8 | 2 | 0 | UNMOVABL | 00000010 | bio_copy_user_iov
    4 | 1 | 0 | UNMOVABL | 000200d2 | pipe_write
    4 | 1 | 0 | MOVABLE | 000280da | do_wp_page
    4 | 1 | 0 | UNMOVABL | 002084d0 | pgd_alloc
    ---------------------------------------------------------------------------------------------

    Signed-off-by: Namhyung Kim
    Acked-by: Pekka Enberg
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Joonsoo Kim
    Cc: Minchan Kim
    Cc: Peter Zijlstra
    Cc: linux-mm@kvack.org
    Link: http://lkml.kernel.org/r/1429592107-1807-2-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     

29 Apr, 2015

1 commit

  • 0d68bc92c48 breaks compiles on RHEL6/OL6:
    cc1: warnings being treated as errors
    builtin-kmem.c: In function ‘search_page_alloc_stat’:
    builtin-kmem.c:322: error: declaration of ‘stat’ shadows a global declaration
    node = &parent->rb_left;
    /usr/include/sys/stat.h:455: error: shadowed declaration is here
    builtin-kmem.c: In function ‘perf_evsel__process_page_alloc_event’:
    builtin-kmem.c:378: error: declaration of ‘stat’ shadows a global declaration
    /usr/include/sys/stat.h:455: error: shadowed declaration is here
    builtin-kmem.c: In function ‘perf_evsel__process_page_free_event’:
    builtin-kmem.c:431: error: declaration of ‘stat’ shadows a global declaration
    /usr/include/sys/stat.h:455: error: shadowed declaration is here

    Rename local variable to pstat to avoid the name conflict.

    Signed-off-by: David Ahern
    Link: http://lkml.kernel.org/r/1429033773-31383-1-git-send-email-david.ahern@oracle.com
    Signed-off-by: Arnaldo Carvalho de Melo

    David Ahern
     

24 Apr, 2015

1 commit

  • 0d68bc92c48 breaks compiles on RHEL6/OL6:
    cc1: warnings being treated as errors
    builtin-kmem.c: In function ‘search_page_alloc_stat’:
    builtin-kmem.c:322: error: declaration of ‘stat’ shadows a global declaration
    node = &parent->rb_left;
    /usr/include/sys/stat.h:455: error: shadowed declaration is here
    builtin-kmem.c: In function ‘perf_evsel__process_page_alloc_event’:
    builtin-kmem.c:378: error: declaration of ‘stat’ shadows a global declaration
    /usr/include/sys/stat.h:455: error: shadowed declaration is here
    builtin-kmem.c: In function ‘perf_evsel__process_page_free_event’:
    builtin-kmem.c:431: error: declaration of ‘stat’ shadows a global declaration
    /usr/include/sys/stat.h:455: error: shadowed declaration is here

    Rename local variable to pstat to avoid the name conflict.

    Signed-off-by: David Ahern
    Link: http://lkml.kernel.org/r/1429033773-31383-1-git-send-email-david.ahern@oracle.com
    Signed-off-by: Arnaldo Carvalho de Melo

    David Ahern