Linux Kernel Mentees Archive mirror
 help / color / mirror / Atom feed
From: Juntong Deng <juntong.deng@outlook.com>
To: Andrey Konovalov <andreyknvl@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>
Cc: ryabinin.a.a@gmail.com, glider@google.com,
	vincenzo.frascino@arm.com, akpm@linux-foundation.org,
	kasan-dev@googlegroups.com, linux-mm@kvack.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-kernel-mentees@lists.linuxfoundation.org"
	<linux-kernel-mentees@lists.linuxfoundation.org>
Subject: Re: [RFC] mm/kasan: Add Allocation, Free, Error timestamps to KASAN report
Date: Fri, 10 Nov 2023 03:40:42 +0800	[thread overview]
Message-ID: <VI1P193MB07522256FD0E0F148F19947A99AFA@VI1P193MB0752.EURP193.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CA+fCnZdRWs=P4EgzC9sSDLfO=Bxbs9FyeOcqAiY8pzvMLUX=Aw@mail.gmail.com>

On 2023/11/2 22:58, Andrey Konovalov wrote:
> On Tue, Oct 31, 2023 at 10:46 AM Dmitry Vyukov <dvyukov@google.com> wrote:
>>
>>>>>> There is also an aspect of memory consumption. KASAN headers increase
>>>>>> the size of every heap object. So we tried to keep them as compact as
>>>>>> possible. At some point CPU numbers and timestamps (IIRC) were already
>>>>>> part of the header, but we removed them to shrink the header to 16
>>>>>> bytes.
> 
>>> Do you think it is worth using the extra bytes to record more
>>> information? If this is a user-configurable feature.
>>
>> If it's user-configurable, then it is OK.
> 
> FWIW, Generic KASAN already stores the auxiliary stack handles in the
> redzone, so the size of the redzone header is 24 bytes. Perhaps, we
> should hide them under a config as well.
> 
> However, the increase of the redzone header size will only affect
> small kmalloc allocations (<= 16 bytes, as kmalloc allocations are
> aligned to the size of the object and the redzone is thus as big as
> the object anyway) and small non-kmalloc slab allocations (<= 64
> bytes, for which optimal_redzone returns 16). So I don't think adding
> new fields to the redzone will increase the memory usage by much. But
> this needs to be tested to make sure.

Yes, I read the design documentation and source code of KASAN
in depth today.

Currently in Generic mode, the alloc meta is stored in the redzone
(unless it doesn't fit) and the free meta is stored in the object
(or in the redzone if it cannot be stored in the object).

Therefore, I also think that using a few extra bytes to record more
information may consume less extra memory than we expected.

I am trying to implement the feature to let KASAN record more
information (configurable) and test it, I will send an PATCH RFC
when I am done.

Thanks.

      reply	other threads:[~2023-11-09 19:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 19:39 [RFC] mm/kasan: Add Allocation, Free, Error timestamps to KASAN report Juntong Deng
2023-10-17 20:10 ` Ricardo B. Marliere
2023-10-17 20:19   ` Juntong Deng
2023-10-25 19:22 ` Andrey Konovalov
2023-10-29  9:05   ` Juntong Deng
2023-10-30  6:29     ` Dmitry Vyukov via Linux-kernel-mentees
2023-10-30  9:28       ` Juntong Deng
2023-10-30 10:10         ` Dmitry Vyukov via Linux-kernel-mentees
2023-10-30 11:32           ` Juntong Deng
2023-10-31  9:46             ` Dmitry Vyukov via Linux-kernel-mentees
2023-11-02 14:58               ` Andrey Konovalov
2023-11-09 19:40                 ` Juntong Deng [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=VI1P193MB07522256FD0E0F148F19947A99AFA@VI1P193MB0752.EURP193.PROD.OUTLOOK.COM \
    --to=juntong.deng@outlook.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryabinin.a.a@gmail.com \
    --cc=vincenzo.frascino@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).