From: Eric Dumazet <dada1@cosmosbay.com>
To: Nick Piggin <npiggin@suse.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [RFC] non-refcounted pages, application to slab?
Date: Wed, 25 Jan 2006 11:26:01 +0100 [thread overview]
Message-ID: <43D75239.90907@cosmosbay.com> (raw)
In-Reply-To: <20060125093909.GE32653@wotan.suse.de>
Nick Piggin a écrit :
> If an allocator knows exactly the lifetime of its page, then there is no
> need to do refcounting or the final put_page_zestzero (atomic op + mem
> barriers).
>
> This is probably not worthwhile for most cases, but slab did strike me
> as a potential candidate (however the complication here is that some
> code I think uses the refcount of underlying pages of slab allocations
> eg nommu code). So it is not a complete patch, but I wonder if anyone
> thinks the savings might be worth the complexity?
>
> Is there any particular code that is really heavy on slab allocations?
> That isn't mostly handled by the slab's internal freelists?
Hi Nick
After reading your patch, I have some crazy idea.
The atomic op + mem barrier you want to avoid could be avoided more generally
just by changing atomic_dec_and_test(atomic_t *v).
If the current thread is the last referer (refcnt = 1), then it can safely set
the value to 0 because no other CPU can be touching the value (or else there
must be a bug somewhere, as the 'other cpu' could touch the value just after
us and we could free an object still in use by 'other cpu'
Something like :
--- include/asm-i386/atomic.h.orig 2006-01-25 12:11:46.000000000 +0100
+++ include/asm-i386/atomic.h 2006-01-25 12:13:07.000000000 +0100
@@ -130,6 +130,13 @@
printk("BUG: atomic counter underflow at:\n");
dump_stack();
}
+#ifdef CONFIG_SMP
+ /* avoid an atomic op if we are the last user of this atomic */
+ if (atomic_read(v) == 1) {
+ atomic_set(v, 0); /* not a real atomic op on most machines */
+ return 1;
+ }
+#endif
__asm__ __volatile__(
LOCK_PREFIX "decl %0; sete %1"
:"=m" (v->counter), "=qm" (c)
Thank you
Eric
WARNING: multiple messages have this Message-ID (diff)
From: Eric Dumazet <dada1@cosmosbay.com>
To: Nick Piggin <npiggin@suse.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [RFC] non-refcounted pages, application to slab?
Date: Wed, 25 Jan 2006 11:26:01 +0100 [thread overview]
Message-ID: <43D75239.90907@cosmosbay.com> (raw)
In-Reply-To: <20060125093909.GE32653@wotan.suse.de>
Nick Piggin a ecrit :
> If an allocator knows exactly the lifetime of its page, then there is no
> need to do refcounting or the final put_page_zestzero (atomic op + mem
> barriers).
>
> This is probably not worthwhile for most cases, but slab did strike me
> as a potential candidate (however the complication here is that some
> code I think uses the refcount of underlying pages of slab allocations
> eg nommu code). So it is not a complete patch, but I wonder if anyone
> thinks the savings might be worth the complexity?
>
> Is there any particular code that is really heavy on slab allocations?
> That isn't mostly handled by the slab's internal freelists?
Hi Nick
After reading your patch, I have some crazy idea.
The atomic op + mem barrier you want to avoid could be avoided more generally
just by changing atomic_dec_and_test(atomic_t *v).
If the current thread is the last referer (refcnt = 1), then it can safely set
the value to 0 because no other CPU can be touching the value (or else there
must be a bug somewhere, as the 'other cpu' could touch the value just after
us and we could free an object still in use by 'other cpu'
Something like :
--- include/asm-i386/atomic.h.orig 2006-01-25 12:11:46.000000000 +0100
+++ include/asm-i386/atomic.h 2006-01-25 12:13:07.000000000 +0100
@@ -130,6 +130,13 @@
printk("BUG: atomic counter underflow at:\n");
dump_stack();
}
+#ifdef CONFIG_SMP
+ /* avoid an atomic op if we are the last user of this atomic */
+ if (atomic_read(v) == 1) {
+ atomic_set(v, 0); /* not a real atomic op on most machines */
+ return 1;
+ }
+#endif
__asm__ __volatile__(
LOCK_PREFIX "decl %0; sete %1"
:"=m" (v->counter), "=qm" (c)
Thank you
Eric
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-01-25 10:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-25 9:39 [RFC] non-refcounted pages, application to slab? Nick Piggin
2006-01-25 9:39 ` Nick Piggin
2006-01-25 9:54 ` Eric Dumazet
2006-01-25 9:54 ` Eric Dumazet
2006-01-25 9:56 ` Nick Piggin
2006-01-25 9:56 ` Nick Piggin
2006-01-25 10:26 ` Eric Dumazet [this message]
2006-01-25 10:26 ` Eric Dumazet
2006-01-25 10:57 ` Nick Piggin
2006-01-25 10:57 ` Nick Piggin
2006-01-25 11:10 ` Eric Dumazet
2006-01-25 11:10 ` Eric Dumazet
2006-01-25 11:18 ` Nick Piggin
2006-01-25 11:18 ` Nick Piggin
2006-01-25 10:30 ` Pekka Enberg
2006-01-25 10:30 ` Pekka Enberg
2006-01-25 11:00 ` Nick Piggin
2006-01-25 11:00 ` Nick Piggin
2006-01-25 11:19 ` Pekka Enberg
2006-01-25 11:19 ` Pekka Enberg
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=43D75239.90907@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@suse.de \
/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.