From: Eric Dumazet <eric.dumazet@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@kernel.dk>,
Dave Chinner <david@fromorbit.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Christoph Lameter <cl@linux-foundation.org>
Subject: Re: [PATCH] percpu_counter : add percpu_counter_add_fast()
Date: Fri, 22 Oct 2010 00:58:14 +0200 [thread overview]
Message-ID: <1287701894.2607.32.camel@edumazet-laptop> (raw)
In-Reply-To: <20101021154333.f67fd870.akpm@linux-foundation.org>
Le jeudi 21 octobre 2010 à 15:43 -0700, Andrew Morton a écrit :
> On Sat, 16 Oct 2010 16:19:14 +0200
> Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> > The current way to change a percpu_counter is to call
> > percpu_counter_add(), which is a bit expensive.
> > (More than 40 instructions, possible false sharing, ...)
>
> This is incorrect. With my compiler it's 25 instructions except in the
> very rare case where a batch overflow occurs.
>
Hmm
> And more than half of that is function call entry/exit overhead.
>
gcc version 4.5.1
count : 5 instructions to call function
c10cfbb5: a1 00 8f 53 c1 mov 0xc1538f00,%eax
c10cfbba: 31 c9 xor %ecx,%ecx
c10cfbbc: 89 04 24 mov %eax,(%esp)
c10cfbbf: ba 01 00 00 00 mov $0x1,%edx
c10cfbc4: b8 c0 5b 50 c1 mov $0xc1505bc0,%eax
c10cfbc9: e8 a2 64 0b 00 call c1186070 <__percpu_counter_add>
Then 39 instructions in hot path (no lock taken)
So its more than 40 as I stated
c1186070 <__percpu_counter_add>:
c1186070: 55 push %ebp
c1186071: 89 e5 mov %esp,%ebp
c1186073: 83 ec 1c sub $0x1c,%esp
c1186076: 89 5d f4 mov %ebx,-0xc(%ebp)
c1186079: 89 75 f8 mov %esi,-0x8(%ebp)
c118607c: 89 7d fc mov %edi,-0x4(%ebp)
c118607f: 89 c3 mov %eax,%ebx
c1186081: 8b 73 20 mov 0x20(%ebx),%esi
c1186084: 64 a1 6c 10 59 c1 mov %fs:0xc159106c,%eax
c118608a: 8b 3c 85 a0 7d 53 c1 mov -0x3eac8260(,%eax,4),%edi
c1186091: 01 fe add %edi,%esi
c1186093: 89 75 e8 mov %esi,-0x18(%ebp)
c1186096: 8b 06 mov (%esi),%eax
c1186098: 8b 75 08 mov 0x8(%ebp),%esi
c118609b: 89 c7 mov %eax,%edi
c118609d: 89 45 ec mov %eax,-0x14(%ebp)
c11860a0: c1 ff 1f sar $0x1f,%edi
c11860a3: 01 55 ec add %edx,-0x14(%ebp)
c11860a6: 89 7d f0 mov %edi,-0x10(%ebp)
c11860a9: 89 f7 mov %esi,%edi
c11860ab: 11 4d f0 adc %ecx,-0x10(%ebp)
c11860ae: c1 ff 1f sar $0x1f,%edi
c11860b1: 39 7d f0 cmp %edi,-0x10(%ebp)
c11860b4: 7f 3a jg c11860f0 <__percpu_counter_add+0x80>
c11860b6: 7d 68 jge c1186120 <__percpu_counter_add+0xb0>
c11860b8: 8b 4d 08 mov 0x8(%ebp),%ecx
c11860bb: f7 d9 neg %ecx
c11860bd: 89 ca mov %ecx,%edx
c11860bf: c1 fa 1f sar $0x1f,%edx
c11860c2: 39 55 f0 cmp %edx,-0x10(%ebp)
c11860c5: 7e 19 jle c11860e0 <__percpu_counter_add+0x70>
c11860c7: 8b 7d ec mov -0x14(%ebp),%edi
c11860ca: 8b 75 e8 mov -0x18(%ebp),%esi
c11860cd: 89 3e mov %edi,(%esi)
c11860cf: 8b 5d f4 mov -0xc(%ebp),%ebx
c11860d2: 8b 75 f8 mov -0x8(%ebp),%esi
c11860d5: 8b 7d fc mov -0x4(%ebp),%edi
c11860d8: c9 leave
c11860d9: c3 ret
c11860da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
c11860e0: 7c 0e jl c11860f0 <__percpu_counter_add+0x80>
c11860e2: 39 4d ec cmp %ecx,-0x14(%ebp)
c11860e5: 77 e0 ja c11860c7 <__percpu_counter_add+0x57>
c11860e7: 89 f6 mov %esi,%esi
c11860e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
c11860f0: 89 d8 mov %ebx,%eax
c11860f2: e8 e9 41 1d 00 call c135a2e0 <_raw_spin_lock>
c11860f7: 8b 45 ec mov -0x14(%ebp),%eax
c11860fa: 8b 55 f0 mov -0x10(%ebp),%edx
c11860fd: 01 43 10 add %eax,0x10(%ebx)
c1186100: 89 d8 mov %ebx,%eax
c1186102: 11 53 14 adc %edx,0x14(%ebx)
c1186105: 8b 55 e8 mov -0x18(%ebp),%edx
c1186108: c7 02 00 00 00 00 movl $0x0,(%edx)
c118610e: e8 6d 41 1d 00 call c135a280 <_raw_spin_unlock>
c1186113: 8b 5d f4 mov -0xc(%ebp),%ebx
c1186116: 8b 75 f8 mov -0x8(%ebp),%esi
c1186119: 8b 7d fc mov -0x4(%ebp),%edi
c118611c: c9 leave
c118611d: c3 ret
c118611e: 66 90 xchg %ax,%ax
c1186120: 8b 7d 08 mov 0x8(%ebp),%edi
c1186123: 39 7d ec cmp %edi,-0x14(%ebp)
c1186126: 73 c8 jae c11860f0 <__percpu_counter_add+0x80>
c1186128: 8b 4d 08 mov 0x8(%ebp),%ecx
c118612b: f7 d9 neg %ecx
c118612d: 89 ca mov %ecx,%edx
c118612f: c1 fa 1f sar $0x1f,%edx
c1186132: 39 55 f0 cmp %edx,-0x10(%ebp)
c1186135: 7f 90 jg c11860c7 <__percpu_counter_add+0x57>
c1186137: eb a7 jmp c11860e0 <__percpu_counter_add+0x70>
next prev parent reply other threads:[~2010-10-21 22:58 UTC|newest]
Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-29 12:18 [PATCH 0/17] fs: Inode cache scalability Dave Chinner
2010-09-29 12:18 ` [PATCH 01/17] kernel: add bl_list Dave Chinner
2010-09-30 4:52 ` Andrew Morton
2010-10-16 7:55 ` Nick Piggin
2010-10-16 16:28 ` Christoph Hellwig
2010-10-01 5:48 ` Christoph Hellwig
2010-09-29 12:18 ` [PATCH 02/17] fs: icache lock s_inodes list Dave Chinner
2010-10-01 5:49 ` Christoph Hellwig
2010-10-16 7:54 ` Nick Piggin
2010-10-16 16:12 ` Christoph Hellwig
2010-10-16 17:09 ` Nick Piggin
2010-10-17 0:42 ` Christoph Hellwig
2010-10-17 2:03 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 03/17] fs: icache lock inode hash Dave Chinner
2010-09-30 4:52 ` Andrew Morton
2010-09-30 6:13 ` Dave Chinner
2010-10-01 6:06 ` Christoph Hellwig
2010-10-16 7:57 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 04/17] fs: icache lock i_state Dave Chinner
2010-10-01 5:54 ` Christoph Hellwig
2010-10-16 7:54 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 05/17] fs: icache lock i_count Dave Chinner
2010-09-30 4:52 ` Andrew Morton
2010-10-01 5:55 ` Christoph Hellwig
2010-10-01 6:04 ` Andrew Morton
2010-10-01 6:16 ` Christoph Hellwig
2010-10-01 6:23 ` Andrew Morton
2010-09-29 12:18 ` [PATCH 06/17] fs: icache lock lru/writeback lists Dave Chinner
2010-09-30 4:52 ` Andrew Morton
2010-09-30 6:16 ` Dave Chinner
2010-10-16 7:55 ` Nick Piggin
2010-10-01 6:01 ` Christoph Hellwig
2010-10-05 22:30 ` Dave Chinner
2010-09-29 12:18 ` [PATCH 07/17] fs: icache atomic inodes_stat Dave Chinner
2010-09-30 4:52 ` Andrew Morton
2010-09-30 6:20 ` Dave Chinner
2010-09-30 6:37 ` Andrew Morton
2010-10-16 7:56 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 08/17] fs: icache protect inode state Dave Chinner
2010-10-01 6:02 ` Christoph Hellwig
2010-10-16 7:54 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 09/17] fs: Make last_ino, iunique independent of inode_lock Dave Chinner
2010-09-30 4:53 ` Andrew Morton
2010-10-01 6:08 ` Christoph Hellwig
2010-10-16 7:54 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 10/17] fs: icache remove inode_lock Dave Chinner
2010-09-29 12:18 ` [PATCH 11/17] fs: Factor inode hash operations into functions Dave Chinner
2010-10-01 6:06 ` Christoph Hellwig
2010-10-16 7:54 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 12/17] fs: Introduce per-bucket inode hash locks Dave Chinner
2010-09-30 1:52 ` Christoph Hellwig
2010-09-30 2:43 ` Dave Chinner
2010-10-16 7:55 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 13/17] fs: Implement lazy LRU updates for inodes Dave Chinner
2010-09-30 2:05 ` Christoph Hellwig
2010-10-16 7:54 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 14/17] fs: Inode counters do not need to be atomic Dave Chinner
2010-09-29 12:18 ` [PATCH 15/17] fs: inode per-cpu last_ino allocator Dave Chinner
2010-09-30 2:07 ` Christoph Hellwig
2010-10-06 6:29 ` Dave Chinner
2010-10-06 8:51 ` Christoph Hellwig
2010-09-30 4:53 ` Andrew Morton
2010-09-30 5:36 ` Eric Dumazet
2010-09-30 7:53 ` Eric Dumazet
2010-09-30 8:14 ` Andrew Morton
2010-09-30 10:22 ` [PATCH] " Eric Dumazet
2010-09-30 16:45 ` Andrew Morton
2010-09-30 17:28 ` Eric Dumazet
2010-09-30 17:39 ` Andrew Morton
2010-09-30 18:05 ` Eric Dumazet
2010-10-01 6:12 ` Christoph Hellwig
2010-10-01 6:45 ` Eric Dumazet
2010-10-16 6:36 ` Nick Piggin
2010-10-16 6:40 ` Nick Piggin
2010-09-29 12:18 ` [PATCH 16/17] fs: Convert nr_inodes to a per-cpu counter Dave Chinner
2010-09-30 2:12 ` Christoph Hellwig
2010-09-30 4:53 ` Andrew Morton
2010-09-30 6:10 ` Dave Chinner
2010-10-16 7:55 ` Nick Piggin
2010-10-16 8:29 ` Eric Dumazet
2010-10-16 9:07 ` Andrew Morton
2010-10-16 9:31 ` Eric Dumazet
2010-10-16 14:19 ` [PATCH] percpu_counter : add percpu_counter_add_fast() Eric Dumazet
2010-10-18 15:24 ` Christoph Lameter
2010-10-18 15:39 ` Eric Dumazet
2010-10-18 16:12 ` Christoph Lameter
2010-10-21 22:37 ` Andrew Morton
2010-10-21 23:10 ` Christoph Lameter
2010-10-22 0:45 ` Andrew Morton
2010-10-22 1:55 ` Andrew Morton
2010-10-22 1:58 ` Nick Piggin
2010-10-22 2:14 ` Andrew Morton
2010-10-22 4:12 ` Eric Dumazet
2010-10-21 22:43 ` Andrew Morton
2010-10-21 22:58 ` Eric Dumazet [this message]
2010-10-21 23:18 ` Andrew Morton
2010-10-21 23:22 ` Eric Dumazet
2010-10-21 22:31 ` [PATCH 16/17] fs: Convert nr_inodes to a per-cpu counter Andrew Morton
2010-10-21 22:58 ` Eric Dumazet
2010-10-02 16:02 ` Christoph Hellwig
2010-09-29 12:18 ` [PATCH 17/17] fs: Clean up inode reference counting Dave Chinner
2010-09-30 2:15 ` Christoph Hellwig
2010-10-16 7:55 ` Nick Piggin
2010-10-16 16:14 ` Christoph Hellwig
2010-10-16 17:09 ` Nick Piggin
2010-09-30 4:53 ` Andrew Morton
2010-09-29 23:57 ` [PATCH 0/17] fs: Inode cache scalability Christoph Hellwig
2010-09-30 0:24 ` Dave Chinner
2010-09-30 2:21 ` Christoph Hellwig
2010-10-02 23:10 ` Carlos Carvalho
2010-10-04 7:22 ` Dave Chinner
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=1287701894.2607.32.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@kernel.dk \
/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