From: geng sun <sun.gengeration.sun@gmail.com>
To: linux-mm@kvack.org
Subject: An variable used before init
Date: Sat, 11 Nov 2023 23:42:26 +0800 [thread overview]
Message-ID: <C1214BC1-64C1-4DCA-A129-5FDD3D70236A@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]
Hi linux-mm
I find one odd variable “new” in slub, it was used before init.
Maybe the value in new was undefined.
And I can not understand how it work.
Could you explain this code for me?
Thanks.
Best regards.
static void __slab_free(struct kmem_cache *s, struct page *page,
void *head, void *tail, int cnt,
unsigned long addr)
{
void *prior;
int was_frozen;
struct page new;
unsigned long counters;
struct kmem_cache_node *n = NULL;
unsigned long flags;
stat(s, FREE_SLOWPATH);
if (kmem_cache_debug(s) &&
!free_debug_processing(s, page, head, tail, cnt, addr))
return;
do {
if (unlikely(n)) {
spin_unlock_irqrestore(&n->list_lock, flags);
n = NULL;
}
prior = page->freelist;
counters = page->counters;
set_freepointer(s, tail, prior);
new.counters = counters;
was_frozen = new.frozen;
new.inuse -= cnt;
if ((!new.inuse || !prior) && !was_frozen) {
[-- Attachment #2: Type: text/html, Size: 7902 bytes --]
next reply other threads:[~2023-11-11 15:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-11 15:42 geng sun [this message]
2023-11-13 1:35 ` Xiongwei Song
2023-11-13 8:55 ` geng sun
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=C1214BC1-64C1-4DCA-A129-5FDD3D70236A@gmail.com \
--to=sun.gengeration.sun@gmail.com \
--cc=linux-mm@kvack.org \
/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