All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <tom.leiming@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Shaohua Li <shli@fusionio.com>, Jens Axboe <axboe@kernel.dk>,
	Fan Du <fan.du@windriver.com>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH] lib/percpu_counter.c: disable local irq when updating percpu couter
Date: Wed, 8 Jan 2014 11:29:32 +0800	[thread overview]
Message-ID: <CACVXFVMbofkaoHDzSPE2BpEcKwhHni-dj4yugqzbn4a8TSPVdg@mail.gmail.com> (raw)
In-Reply-To: <20140107173645.64d6838e.akpm@linux-foundation.org>

Hi Andrew,

On Wed, Jan 8, 2014 at 9:36 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
>> I am wondering if the above patch is more efficient, because:
>>
>> - raw_local_irq_save()/raw_local_irq_restore() should be cheaper
>> than preempt_enable() in theory
>
> Don't think so - local_irq_disable() requires quite some internal
> synchronization in the CPU and is expensive.  preempt_disable() is just

Yes, it might be a little expensive on some CPUs, but should be
arch-dependent(CPU inside things are involved)

> an add+barrier, minus the add if the kernel is non-preemptable.

IMO, generally, from software view, local_irq_save() only save the
CPU's interrupt mask to the local variable 'flag', and sets irq mask
to register, considered local variable can be thought to be in cache,
so I think it might be cheaper than preempt_enable() because
preempt counter may not be in cache.

Also this_cpu_add() won't work in batch path(slow path), we still
need to avoid interrupt coming between reading the percpu counter
and resetting it, otherwise counts might be lost too, :-)

Thanks,
-- 
Ming Lei

  reply	other threads:[~2014-01-08  3:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07 10:29 [PATCH] lib/percpu_counter.c: disable local irq when updating percpu couter Ming Lei
2014-01-07 22:27 ` Andrew Morton
2014-01-08  1:12   ` Ming Lei
2014-01-08  1:36     ` Andrew Morton
2014-01-08  3:29       ` Ming Lei [this message]
2014-01-08  4:30         ` Ming Lei

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=CACVXFVMbofkaoHDzSPE2BpEcKwhHni-dj4yugqzbn4a8TSPVdg@mail.gmail.com \
    --to=tom.leiming@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=fan.du@windriver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=shli@fusionio.com \
    --cc=tj@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 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.