From: Christoph Lameter <cl@linux.com>
To: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Jesper Dangaard Brouer <brouer@redhat.com>
Subject: Re: [PATCH 6/6] mm/slab: allocation fastpath without disabling irq
Date: Mon, 5 Jan 2015 09:28:14 -0600 (CST) [thread overview]
Message-ID: <alpine.DEB.2.11.1501050859520.24213@gentwo.org> (raw)
In-Reply-To: <1420421851-3281-7-git-send-email-iamjoonsoo.kim@lge.com>
On Mon, 5 Jan 2015, Joonsoo Kim wrote:
> index 449fc6b..54656f0 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -168,6 +168,41 @@ typedef unsigned short freelist_idx_t;
>
> #define SLAB_OBJ_MAX_NUM ((1 << sizeof(freelist_idx_t) * BITS_PER_BYTE) - 1)
>
> +#ifdef CONFIG_PREEMPT
> +/*
> + * Calculate the next globally unique transaction for disambiguiation
> + * during cmpxchg. The transactions start with the cpu number and are then
> + * incremented by CONFIG_NR_CPUS.
> + */
> +#define TID_STEP roundup_pow_of_two(CONFIG_NR_CPUS)
> +#else
> +/*
> + * No preemption supported therefore also no need to check for
> + * different cpus.
> + */
> +#define TID_STEP 1
> +#endif
> +
> +static inline unsigned long next_tid(unsigned long tid)
> +{
> + return tid + TID_STEP;
> +}
> +
> +static inline unsigned int tid_to_cpu(unsigned long tid)
> +{
> + return tid % TID_STEP;
> +}
> +
> +static inline unsigned long tid_to_event(unsigned long tid)
> +{
> + return tid / TID_STEP;
> +}
> +
> +static inline unsigned int init_tid(int cpu)
> +{
> + return cpu;
> +}
> +
Ok the above stuff needs to go into the common code. Maybe in mm/slab.h?
And its a significant feature contributed by me so I'd like to have an
attribution here.
> /*
> * true if a page was allocated from pfmemalloc reserves for network-based
> * swap
> @@ -187,7 +222,8 @@ static bool pfmemalloc_active __read_mostly;
> *
> */
> struct array_cache {
> - unsigned int avail;
> + unsigned long avail;
> + unsigned long tid;
> unsigned int limit;
> unsigned int batchcount;
> unsigned int touched;
> @@ -657,7 +693,8 @@ static void start_cpu_timer(int cpu)
> }
> }
This increases the per cpu struct size and should lead to a small
performance penalty.
> - */
> - if (likely(objp)) {
> - STATS_INC_ALLOCHIT(cachep);
> - goto out;
> + objp = ac->entry[avail - 1];
> + if (unlikely(!this_cpu_cmpxchg_double(
> + cachep->cpu_cache->avail, cachep->cpu_cache->tid,
> + avail, tid,
> + avail - 1, next_tid(tid))))
> + goto redo;
Hmm... Ok that looks good.
--
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:[~2015-01-05 15:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-05 1:37 [PATCH 0/6] mm/slab: optimize allocation fastpath Joonsoo Kim
2015-01-05 1:37 ` [PATCH 1/6] mm/slab: fix gfp flags of percpu allocation at boot phase Joonsoo Kim
2015-01-05 1:37 ` [PATCH 2/6] mm/slab: remove kmemleak_erase() call Joonsoo Kim
2015-01-08 12:01 ` Catalin Marinas
2015-01-05 1:37 ` [PATCH 3/6] mm/slab: clean-up __ac_get_obj() to prepare future changes Joonsoo Kim
2015-01-05 1:37 ` [PATCH 4/6] mm/slab: rearrange irq management Joonsoo Kim
2015-01-05 1:37 ` [PATCH 5/6] mm/slab: cleanup ____cache_alloc() Joonsoo Kim
2015-01-05 1:37 ` [PATCH 6/6] mm/slab: allocation fastpath without disabling irq Joonsoo Kim
2015-01-05 15:28 ` Christoph Lameter [this message]
2015-01-06 1:04 ` Joonsoo Kim
2015-01-05 17:21 ` Andreas Mohr
2015-01-05 17:52 ` Christoph Lameter
2015-01-06 1:31 ` Joonsoo Kim
2015-01-06 10:34 ` Andreas Mohr
2015-01-06 15:33 ` Christoph Lameter
2015-01-06 16:26 ` Andreas Mohr
2015-01-08 7:54 ` Joonsoo Kim
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=alpine.DEB.2.11.1501050859520.24213@gentwo.org \
--to=cl@linux.com \
--cc=akpm@linux-foundation.org \
--cc=brouer@redhat.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.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