From: Andrew Morton <akpm@linux-foundation.org>
To: Christoph Lameter <cl@linux.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>,
linux-kernel@vger.kernel.org, Pekka Enberg <penberg@kernel.org>
Subject: Re: [percpu] BUG: using __this_cpu_add() in preemptible [00000000] code: init/1
Date: Wed, 19 Mar 2014 15:38:51 -0700 [thread overview]
Message-ID: <20140319153851.34dfdf97616422b159dc153b@linux-foundation.org> (raw)
In-Reply-To: <alpine.DEB.2.10.1403180942030.17965@nuc>
On Tue, 18 Mar 2014 09:43:27 -0500 (CDT) Christoph Lameter <cl@linux.com> wrote:
> Anyways the statistics in slub should be low impact and able to
> be placed anywhere. So I think we need this patch to avoid
> the preemption checks begin triggered.
>
>
> Subject: SLUB: Use raw_cpu_inc for incrementing statistics
>
> Statistics are not critical to the operation of the allocation
> but should also not cause too much overhead.
>
> __this_cpu_inc now checks if preemption is disabled and triggers.
> Use raw_cpu_inc to avoid the checks. Using this_cpu_ops may cause
> interrupt disable/enable sequences on various arches which may
> significantly impact allocator performance.
>
> ...
>
> --- linux.orig/mm/slub.c 2014-03-07 14:10:30.142777022 -0600
> +++ linux/mm/slub.c 2014-03-18 09:39:15.675035324 -0500
> @@ -224,7 +224,7 @@
> static inline void stat(const struct kmem_cache *s, enum stat_item si)
> {
> #ifdef CONFIG_SLUB_STATS
> - __this_cpu_inc(s->cpu_slab->stat[si]);
> + raw_cpu_inc(s->cpu_slab->stat[si]);
> #endif
> }
Please always consider how the code will appear to a naive reader.
That reader won't know why raw_ is being used here, so we should
provide an explanation.
--- a/mm/slub.c~slub-use-raw_cpu_inc-for-incrementing-statistics-fix
+++ a/mm/slub.c
@@ -224,6 +224,10 @@ static inline void memcg_propagate_slab_
static inline void stat(const struct kmem_cache *s, enum stat_item si)
{
#ifdef CONFIG_SLUB_STATS
+ /*
+ * The rmw is racy on a preemptible kernel but this is acceptable, so
+ * avoid this_cpu_add()'s irq-disable overhead.
+ */
raw_cpu_inc(s->cpu_slab->stat[si]);
#endif
}
_
next prev parent reply other threads:[~2014-03-19 22:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-07 1:42 [percpu] BUG: using __this_cpu_add() in preemptible [00000000] code: swapper/0/1 Fengguang Wu
2014-03-07 9:09 ` [percpu] BUG: using __this_cpu_add() in preemptible [00000000] code: init/1 Fengguang Wu
2014-03-07 17:25 ` Christoph Lameter
2014-03-18 14:43 ` Christoph Lameter
2014-03-19 22:38 ` Andrew Morton [this message]
2014-03-07 11:08 ` [__slab_free] " Fengguang Wu
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=20140319153851.34dfdf97616422b159dc153b@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=fengguang.wu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@kernel.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
Powered by JetHome