From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Yosry Ahmed <yosry.ahmed@linux.dev>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Nhat Pham <nphamcs@gmail.com>, Minchan Kim <minchan@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Brian Geffon <bgeffon@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] zsmalloc: use actual object size to detect spans
Date: Wed, 7 Jan 2026 14:30:29 +0900 [thread overview]
Message-ID: <zpbzxfmxy2eflg6hfsfcn273h5bjgyxbpnlem555ln2kab3nga@ucutuf2ywwv6> (raw)
In-Reply-To: <u6dy6oa6ztghy7ozficimubhb2mwppcq6gosupepnn63uu6oq7@qyph3nyq7las>
On (26/01/07 05:19), Yosry Ahmed wrote:
> > It seems there is no second page, it's a pow-of-two size class. So
> > we mis-detect spanning.
> >
> > [ 51.406310] zsmalloc: :: size class 48, orig offt 16336, page size 16384, memcpy sizes 40, 8
> > [ 51.407571] Unable to handle kernel paging request at virtual address ffffc04000000000
> > [ 51.420816] pc : __memcpy+0xc/0x44
> >
> > Second memcpy() of sizeof(unsigned long) traps.
>
> I think this case is exactly what you expected earlier (not sure what
> you mean by the pow of 2 reply).
So "pow-of-two" I was just misguided by the second memcpy() size being
8 (which looked like the whole object fits exactly into its physical
page, which I thought was happening only with pow-of-two sizes).
> We increase the offset by 8 bytes (ZS_HANDLE_SIZE), but we still copy 48
> bytes, even though 48 bytes includes both the object and ZS_HANDLE_SIZE.
> So we end up copying 8 bytes beyond the end of the object, which puts us
> in the next page which we should not be copying.
Correct. We increased it twice: off +8 and mem_len +8.
> I think to fix the bug at this point we need to subtract ZS_HANDLE_SIZE
> from class->size before we use it for copying or spanning detection.
I just re-shuffled the patches and it seems to be working, passes all
my tests.
next prev parent reply other threads:[~2026-01-07 5:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 4:25 Sergey Senozhatsky
2026-01-07 0:23 ` Yosry Ahmed
2026-01-07 0:59 ` Sergey Senozhatsky
2026-01-07 1:37 ` Sergey Senozhatsky
2026-01-07 1:56 ` Yosry Ahmed
2026-01-07 2:06 ` Sergey Senozhatsky
2026-01-07 2:10 ` Yosry Ahmed
2026-01-07 2:20 ` Sergey Senozhatsky
2026-01-07 2:22 ` Sergey Senozhatsky
2026-01-07 5:19 ` Yosry Ahmed
2026-01-07 5:30 ` Sergey Senozhatsky [this message]
2026-01-07 7:12 ` Sergey Senozhatsky
2026-01-07 3:03 ` Sergey Senozhatsky
2026-01-07 5:22 ` Yosry Ahmed
2026-01-07 5:38 ` Sergey Senozhatsky
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=zpbzxfmxy2eflg6hfsfcn273h5bjgyxbpnlem555ln2kab3nga@ucutuf2ywwv6 \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=bgeffon@google.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=nphamcs@gmail.com \
--cc=yosry.ahmed@linux.dev \
/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