From: Waiman Long <llong@redhat.com>
To: Marco Elver <elver@google.com>, Boqun Feng <boqun.feng@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will.deacon@arm.com>,
linux-kernel@vger.kernel.org,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
Alexander Potapenko <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Dmitry Vyukov <dvyukov@google.com>,
Vincenzo Frascino <vincenzo.frascino@arm.com>,
kasan-dev@googlegroups.com
Subject: Re: [PATCH v3 3/3] locking/lockdep: Disable KASAN instrumentation of lockdep.c
Date: Thu, 13 Feb 2025 15:06:16 -0500 [thread overview]
Message-ID: <45f90875-d4b0-4cea-b857-752bc93fd48b@redhat.com> (raw)
In-Reply-To: <a6993bbd-ec8a-40e1-9ef2-74f920642188@redhat.com>
On 2/12/25 11:57 AM, Waiman Long wrote:
> On 2/12/25 6:30 AM, Marco Elver wrote:
>> On Wed, 12 Feb 2025 at 06:57, Boqun Feng <boqun.feng@gmail.com> wrote:
>>> [Cc KASAN]
>>>
>>> A Reviewed-by or Acked-by from KASAN would be nice, thanks!
>>>
>>> Regards,
>>> Boqun
>>>
>>> On Sun, Feb 09, 2025 at 11:26:12PM -0500, Waiman Long wrote:
>>>> Both KASAN and LOCKDEP are commonly enabled in building a debug
>>>> kernel.
>>>> Each of them can significantly slow down the speed of a debug kernel.
>>>> Enabling KASAN instrumentation of the LOCKDEP code will further slow
>>>> thing down.
>>>>
>>>> Since LOCKDEP is a high overhead debugging tool, it will never get
>>>> enabled in a production kernel. The LOCKDEP code is also pretty mature
>>>> and is unlikely to get major changes. There is also a possibility of
>>>> recursion similar to KCSAN.
>>>>
>>>> To evaluate the performance impact of disabling KASAN instrumentation
>>>> of lockdep.c, the time to do a parallel build of the Linux defconfig
>>>> kernel was used as the benchmark. Two x86-64 systems (Skylake & Zen 2)
>>>> and an arm64 system were used as test beds. Two sets of non-RT and RT
>>>> kernels with similar configurations except mainly CONFIG_PREEMPT_RT
>>>> were used for evaulation.
>>>>
>>>> For the Skylake system:
>>>>
>>>> Kernel Run time Sys time
>>>> ------ -------- --------
>>>> Non-debug kernel (baseline) 0m47.642s 4m19.811s
>>>> Debug kernel 2m11.108s (x2.8) 38m20.467s
>>>> (x8.9)
>>>> Debug kernel (patched) 1m49.602s (x2.3) 31m28.501s (x7.3)
>>>> Debug kernel
>>>> (patched + mitigations=off) 1m30.988s (x1.9) 26m41.993s
>>>> (x6.2)
>>>>
>>>> RT kernel (baseline) 0m54.871s 7m15.340s
>>>> RT debug kernel 6m07.151s (x6.7) 135m47.428s (x18.7)
>>>> RT debug kernel (patched) 3m42.434s (x4.1) 74m51.636s (x10.3)
>>>> RT debug kernel
>>>> (patched + mitigations=off) 2m40.383s (x2.9) 57m54.369s
>>>> (x8.0)
>>>>
>>>> For the Zen 2 system:
>>>>
>>>> Kernel Run time Sys time
>>>> ------ -------- --------
>>>> Non-debug kernel (baseline) 1m42.806s 39m48.714s
>>>> Debug kernel 4m04.524s (x2.4) 125m35.904s
>>>> (x3.2)
>>>> Debug kernel (patched) 3m56.241s (x2.3) 127m22.378s (x3.2)
>>>> Debug kernel
>>>> (patched + mitigations=off) 2m38.157s (x1.5) 92m35.680s
>>>> (x2.3)
>>>>
>>>> RT kernel (baseline) 1m51.500s 14m56.322s
>>>> RT debug kernel 16m04.962s (x8.7) 244m36.463s (x16.4)
>>>> RT debug kernel (patched) 9m09.073s (x4.9) 129m28.439s (x8.7)
>>>> RT debug kernel
>>>> (patched + mitigations=off) 3m31.662s (x1.9) 51m01.391s
>>>> (x3.4)
>>>>
>>>> For the arm64 system:
>>>>
>>>> Kernel Run time Sys time
>>>> ------ -------- --------
>>>> Non-debug kernel (baseline) 1m56.844s 8m47.150s
>>>> Debug kernel 3m54.774s (x2.0) 92m30.098s
>>>> (x10.5)
>>>> Debug kernel (patched) 3m32.429s (x1.8) 77m40.779s (x8.8)
>>>>
>>>> RT kernel (baseline) 4m01.641s 18m16.777s
>>>> RT debug kernel 19m32.977s (x4.9) 304m23.965s (x16.7)
>>>> RT debug kernel (patched) 16m28.354s (x4.1) 234m18.149s (x12.8)
>>>>
>>>> Turning the mitigations off doesn't seems to have any noticeable
>>>> impact
>>>> on the performance of the arm64 system. So the mitigation=off entries
>>>> aren't included.
>>>>
>>>> For the x86 CPUs, cpu mitigations has a much bigger impact on
>>>> performance, especially the RT debug kernel. The SRSO mitigation in
>>>> Zen 2 has an especially big impact on the debug kernel. It is also the
>>>> majority of the slowdown with mitigations on. It is because the
>>>> patched
>>>> ret instruction slows down function returns. A lot of helper functions
>>>> that are normally compiled out or inlined may become real function
>>>> calls in the debug kernel. The KASAN instrumentation inserts a lot
>>>> of __asan_loadX*() and __kasan_check_read() function calls to memory
>>>> access portion of the code. The lockdep's __lock_acquire() function,
>>>> for instance, has 66 __asan_loadX*() and 6 __kasan_check_read() calls
>>>> added with KASAN instrumentation. Of course, the actual numbers may
>>>> vary
>>>> depending on the compiler used and the exact version of the lockdep
>>>> code.
>> For completeness-sake, we'd also have to compare with
>> CONFIG_KASAN_INLINE=y, which gets rid of the __asan_ calls (not the
>> explicit __kasan_ checks). But I leave it up to you - I'm aware it
>> results in slow-downs, too. ;-)
That is not correct. Setting CONFIG_KASAN_INLINE=y does have an effect
in lockdep.c to reduce the number of __asan_* calls. I have posted the
v4 series with the updated test results. I have also added a new patch
to KASAN checking in lock_acquire().
Cheers,
Longman
prev parent reply other threads:[~2025-02-13 20:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 4:26 [PATCH v3 0/3] locking/lockdep: Disable KASAN instrumentation of lockdep.c Waiman Long
2025-02-10 4:26 ` [PATCH v3 1/3] locking/lock_events: Add locking events for rtmutex slow paths Waiman Long
2025-02-10 4:26 ` [PATCH v3 2/3] locking/lock_events: Add locking events for lockdep Waiman Long
2025-02-10 4:26 ` [PATCH v3 3/3] locking/lockdep: Disable KASAN instrumentation of lockdep.c Waiman Long
2025-02-12 5:57 ` Boqun Feng
2025-02-12 11:30 ` Marco Elver
2025-02-12 16:57 ` Waiman Long
2025-02-13 20:06 ` Waiman Long [this message]
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=45f90875-d4b0-4cea-b857-752bc93fd48b@redhat.com \
--to=llong@redhat.com \
--cc=andreyknvl@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=ryabinin.a.a@gmail.com \
--cc=vincenzo.frascino@arm.com \
--cc=will.deacon@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.