From: Andrey Konovalov <andreyknvl@gmail.com>
To: Marco Elver <elver@google.com>
Cc: andrey.konovalov@linux.dev,
Andrew Morton <akpm@linux-foundation.org>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Vlastimil Babka <vbabka@suse.cz>,
kasan-dev@googlegroups.com,
Evgenii Stepanov <eugenis@google.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrey Konovalov <andreyknvl@google.com>,
syzbot+186b55175d8360728234@syzkaller.appspotmail.com
Subject: Re: [PATCH mm 2/4] kasan: handle concurrent kasan_record_aux_stack calls
Date: Thu, 14 Dec 2023 01:41:49 +0100 [thread overview]
Message-ID: <CA+fCnZd8_iOgf6HzDSemHJgs8S6doMJJK4YhcwT1M-oBePe7HA@mail.gmail.com> (raw)
In-Reply-To: <CANpmjNPEofU4wkmuqYegjDZgmP84yrf7Bmfc-t4Wp7UyYvDc7A@mail.gmail.com>
On Wed, Dec 13, 2023 at 5:51 PM Marco Elver <elver@google.com> wrote:
>
> > > [1]: Since a depot stack handle is just an u32, we can have a
> > >
> > > union {
> > > depot_stack_handle_t handles[2];
> > > atomic64_t atomic_handle;
> > > } aux_stack;
> > > (BUILD_BUG_ON somewhere if sizeof handles and atomic_handle mismatch.)
> > >
> > > Then in the code here create the same union and load atomic_handle.
> > > Swap handle[1] into handle[0] and write the new one in handles[1].
> > > Then do a cmpxchg loop to store the new atomic_handle.
> >
> > This approach should work. If you prefer, I can do this instead of a spinlock.
> >
> > But we do need some kind of atomicity while rotating the aux handles
> > to make sure nothing gets lost.
>
> Yes, I think that'd be preferable. Although note that not all 32-bit
> architectures have 64-bit atomics, so that may be an issue. Another
> alternative is to have a spinlock next to the aux_stack (it needs to
> be initialized properly). It'll use up a little more space, but that's
> for KASAN configs only, so I think it's ok. Certainly better than a
> global lock.
Ah, hm, actually this is what I indented to do with this change. But
somehow my brain glitched out and decided to use a global lock :)
I'll change this into a local spinlock in v2.
Thank you!
next prev parent reply other threads:[~2023-12-14 0:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 0:13 [PATCH mm 0/4] lib/stackdepot, kasan: fixes for stack eviction series andrey.konovalov
2023-12-12 0:14 ` [PATCH mm 1/4] lib/stackdepot: add printk_deferred_enter/exit guards andrey.konovalov
2023-12-12 18:59 ` Marco Elver
2023-12-12 20:57 ` Andrew Morton
2023-12-13 14:41 ` Andrey Konovalov
2023-12-12 0:14 ` [PATCH mm 2/4] kasan: handle concurrent kasan_record_aux_stack calls andrey.konovalov
2023-12-12 19:28 ` Marco Elver
2023-12-13 14:40 ` Andrey Konovalov
2023-12-13 16:50 ` Marco Elver
2023-12-14 0:41 ` Andrey Konovalov [this message]
2023-12-12 0:14 ` [PATCH mm 3/4] kasan: memset free track in qlink_free andrey.konovalov
2023-12-12 19:30 ` Marco Elver
2023-12-12 0:14 ` [PATCH mm 4/4] lib/stackdepot: fix comment in include/linux/stackdepot.h andrey.konovalov
2023-12-12 19:30 ` Marco Elver
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=CA+fCnZd8_iOgf6HzDSemHJgs8S6doMJJK4YhcwT1M-oBePe7HA@mail.gmail.com \
--to=andreyknvl@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrey.konovalov@linux.dev \
--cc=andreyknvl@google.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=eugenis@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=syzbot+186b55175d8360728234@syzkaller.appspotmail.com \
--cc=vbabka@suse.cz \
/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