mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bo Zhang <zhangbo0325@gmail.com>
To: baohua@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org
Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org,
	surenb@google.com, liam@infradead.org, ljs@kernel.org,
	vbabka@kernel.org, shakeel.butt@linux.dev, david@kernel.org,
	linux-kernel@vger.kernel.org, zhanghongru@xiaomi.com,
	willy@infradead.org, zhangbo56@xiaomi.com
Subject: Re: [RFC PATCH v1 1/2] x86/mm: use VMA lock for kernel faults on user addresses
Date: Wed, 28 Oct 2026 10:42:42 +0800	[thread overview]
Message-ID: <20261028024242.3394761-1-zhangbo56@xiaomi.com> (raw)
In-Reply-To: <20260802074018.73887-2-baohua@kernel.org>

On Sun, 2 Aug 2026 15:40:17 +0800 "Barry Song (Xiaomi)" <baohua@kernel.org> wrote:
> Use the VMA lock for kernel faults on user addresses. This also
> makes the existing code below meaningful:
>
>   /* Quick path to respond to signals */
>   if (fault_signal_pending(fault, regs)) {
>           if (!user_mode(regs))
>                   kernelmode_fixup_or_oops(regs, error_code, address,
>                                            SIGBUS, BUS_ADRERR,
>                                            ARCH_DEFAULT_PKEY);
>           return;
>   }
>
> Right now, the code above is dead because !user_mode always
> takes the mmap_lock path.
> ---
> -       if (!(flags & FAULT_FLAG_USER))
> -               goto lock_mmap;
> -
>         vma = lock_vma_under_rcu(mm, address);
>         if (!vma)
>                 goto lock_mmap;

I ran some numbers on x86 to quantify this. Using perf I counted how
often kernel faults on user addresses still fall back to the mmap_lock
slow path (lock_mm_and_find_vma), and the total time spent there,
before and after this patch.

Test setup: x86 host, booted with mem=4G.

Workload: vm-scalability case-mmap-pread-rand-mt, a multithreaded
random mmap+pread workload.

Fallback to the mmap_lock slow path (lock_mm_and_find_vma):

  metric        before_cnt  before_ms   after_cnt  after_ms   d_cnt%   d_ms%
  fault path           416   3510.000           5    256.780   -98.8%  -92.7%

The number of kernel faults on user addresses that fall back to the
mmap_lock path drops by ~98%, and the time spent on that path drops
accordingly. So these faults are now handled under the per-VMA lock
as intended, and the corresponding mmap_lock contention goes away.

Thanks,
Bo

  parent reply	other threads:[~2026-10-28  2:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-02  7:40 [RFC PATCH v1 0/2] mm: " Barry Song (Xiaomi)
2026-08-02  7:40 ` [RFC PATCH v1 1/2] x86/mm: " Barry Song (Xiaomi)
2026-08-03 15:18   ` Lorenzo Stoakes (ARM)
2026-08-03 15:47     ` Suren Baghdasaryan
2026-08-03 22:37     ` Barry Song
2026-08-04 14:46       ` Lorenzo Stoakes (ARM)
2026-10-24 11:00         ` Barry Song
2026-10-28  2:42   ` Bo Zhang [this message]
2026-08-02  7:40 ` [RFC PATCH v1 2/2] arm64/mm: " Barry Song (Xiaomi)
2026-08-02  8:49   ` Barry Song
2026-08-03 15:32     ` Lorenzo Stoakes (ARM)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261028024242.3394761-1-zhangbo56@xiaomi.com \
    --to=zhangbo0325@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=willy@infradead.org \
    --cc=x86@kernel.org \
    --cc=zhangbo56@xiaomi.com \
    --cc=zhanghongru@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®