24 Jul, 2021

1 commit

  • Commit 832b50725373 ("mm: mmap_lock: use local locks instead of
    disabling preemption") fixed a bug by using local locks.

    But commit d01079f3d0c0 ("mm/mmap_lock: remove dead code for
    !CONFIG_TRACING configurations") changed those lines back to the
    original version.

    I guess it was introduced by fixing conflicts.

    Link: https://lkml.kernel.org/r/20210720074228.76342-1-songmuchun@bytedance.com
    Fixes: d01079f3d0c0 ("mm/mmap_lock: remove dead code for !CONFIG_TRACING configurations")
    Signed-off-by: Muchun Song
    Acked-by: Mel Gorman
    Reviewed-by: Yang Shi
    Reviewed-by: Pankaj Gupta
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Muchun Song
     

02 Jul, 2021

1 commit

  • make W=1 generates the following warning in mmap_lock.c for allnoconfig

    mm/mmap_lock.c:213:6: warning: no previous prototype for `__mmap_lock_do_trace_start_locking' [-Wmissing-prototypes]
    void __mmap_lock_do_trace_start_locking(struct mm_struct *mm, bool write)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    mm/mmap_lock.c:219:6: warning: no previous prototype for `__mmap_lock_do_trace_acquire_returned' [-Wmissing-prototypes]
    void __mmap_lock_do_trace_acquire_returned(struct mm_struct *mm, bool write,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    mm/mmap_lock.c:226:6: warning: no previous prototype for `__mmap_lock_do_trace_released' [-Wmissing-prototypes]
    void __mmap_lock_do_trace_released(struct mm_struct *mm, bool write)

    On !CONFIG_TRACING configurations, the code is dead so put it behind an
    #ifdef.

    [cuibixuan@huawei.com: fix warning when CONFIG_TRACING is not defined]
    Link: https://lkml.kernel.org/r/20210531033426.74031-1-cuibixuan@huawei.com

    Link: https://lkml.kernel.org/r/20210520084809.8576-13-mgorman@techsingularity.net
    Signed-off-by: Mel Gorman
    Signed-off-by: Bixuan Cui
    Reviewed-by: Yang Shi
    Acked-by: Vlastimil Babka
    Cc: Dan Streetman
    Cc: David Hildenbrand
    Cc: Michal Hocko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mel Gorman
     

30 Jun, 2021

1 commit

  • mmap_lock will explicitly disable/enable preemption upon manipulating its
    local CPU variables. This is to be expected, but in this case, it doesn't
    play well with PREEMPT_RT. The preemption disabled code section also
    takes a spin-lock. Spin-locks in RT systems will try to schedule, which
    is exactly what we're trying to avoid.

    To mitigate this, convert the explicit preemption handling to local_locks.
    Which are RT aware, and will disable migration instead of preemption when
    PREEMPT_RT=y.

    The faulty call trace looks like the following:
    __mmap_lock_do_trace_*()
    preempt_disable()
    get_mm_memcg_path()
    cgroup_path()
    kernfs_path_from_node()
    spin_lock_irqsave() /* Scheduling while atomic! */

    Link: https://lkml.kernel.org/r/20210604163506.2103900-1-nsaenzju@redhat.com
    Fixes: 2b5067a8143e3 ("mm: mmap_lock: add tracepoints around lock acquisition ")
    Signed-off-by: Nicolas Saenz Julienne
    Tested-by: Axel Rasmussen
    Reviewed-by: Axel Rasmussen
    Cc: Vlastimil Babka
    Cc: Steven Rostedt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicolas Saenz Julienne
     

16 Dec, 2020

1 commit

  • The goal of these tracepoints is to be able to debug lock contention
    issues. This lock is acquired on most (all?) mmap / munmap / page fault
    operations, so a multi-threaded process which does a lot of these can
    experience significant contention.

    We trace just before we start acquisition, when the acquisition returns
    (whether it succeeded or not), and when the lock is released (or
    downgraded). The events are broken out by lock type (read / write).

    The events are also broken out by memcg path. For container-based
    workloads, users often think of several processes in a memcg as a single
    logical "task", so collecting statistics at this level is useful.

    The end goal is to get latency information. This isn't directly included
    in the trace events. Instead, users are expected to compute the time
    between "start locking" and "acquire returned", using e.g. synthetic
    events or BPF. The benefit we get from this is simpler code.

    Because we use tracepoint_enabled() to decide whether or not to trace,
    this patch has effectively no overhead unless tracepoints are enabled at
    runtime. If tracepoints are enabled, there is a performance impact, but
    how much depends on exactly what e.g. the BPF program does.

    [axelrasmussen@google.com: fix use-after-free race and css ref leak in tracepoints]
    Link: https://lkml.kernel.org/r/20201130233504.3725241-1-axelrasmussen@google.com
    [axelrasmussen@google.com: v3]
    Link: https://lkml.kernel.org/r/20201207213358.573750-1-axelrasmussen@google.com
    [rostedt@goodmis.org: in-depth examples of tracepoint_enabled() usage, and per-cpu-per-context buffer design]

    Link: https://lkml.kernel.org/r/20201105211739.568279-2-axelrasmussen@google.com
    Signed-off-by: Axel Rasmussen
    Acked-by: Vlastimil Babka
    Cc: Steven Rostedt
    Cc: Ingo Molnar
    Cc: Michel Lespinasse
    Cc: Daniel Jordan
    Cc: Jann Horn
    Cc: Chinwen Chang
    Cc: Davidlohr Bueso
    Cc: David Rientjes
    Cc: Laurent Dufour
    Cc: Yafang Shao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Axel Rasmussen