public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: cl@linux-foundation.org
To: Tejun Heo <tj@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Subject: [this_cpu_xx V6 0/7] Introduce per cpu atomic operations and avoid per cpu address arithmetic
Date: Wed, 07 Oct 2009 17:10:24 -0400	[thread overview]
Message-ID: <20091007211024.442168959@gentwo.org> (raw)

V5->V6:
- Drop patches merged by Tejun.
- Drop irqless slub fastpath for now.
- Patches against Tejun percpu for-next branch.

V4->V5:
- Avoid setup_per_cpu_area() modifications and fold the remainder of the
  patch into the page allocator patch.
- Irq disable / per cpu ptr fixes for page allocator patch.

V3->V4:
- Fix various macro definitions.
- Provide experimental percpu based fastpath that does not disable
  interrupts for SLUB.

V2->V3:
- Available via git tree against latest upstream from
	 git://git.kernel.org/pub/scm/linux/kernel/git/christoph/percpu.git linus
- Rework SLUB per cpu operations. Get rid of dynamic DMA slab creation
  for CONFIG_ZONE_DMA
- Create fallback framework so that 64 bit ops on 32 bit platforms
  can fallback to the use of preempt or interrupt disable. 64 bit
  platforms can use 64 bit atomic per cpu ops.

V1->V2:
- Various minor fixes
- Add SLUB conversion
- Add Page allocator conversion
- Patch against the git tree of today

The patchset introduces various operations to allow efficient access
to per cpu variables for the current processor. Currently there is
no way in the core to calculate the address of the instance
of a per cpu variable without a table lookup. So we see a lot of

	per_cpu_ptr(x, smp_processor_id())

The patchset introduces a way to calculate the address using the offset
that is available in arch specific ways (register or special memory
locations) using

	this_cpu_ptr(x)

In addition macros are provided that can operate on per cpu
variables in a per cpu atomic way. With that scalars in structures
allocated with the new percpu allocator can be modified without disabling
preempt or interrupts. This works by generating a single instruction that
does both the relocation of the address to the proper percpu area and
the RMW action.

F.e.

	this_cpu_add(x->var, 20)

can be used to generate an instruction that uses a segment register for the
relocation of the per cpu address into the per cpu area of the current processor
and then increments the variable by 20. The instruction cannot be interrupted
and therefore the modification is atomic vs the cpu (it either happens or not).
Rescheduling or interrupt can only happen before or after the instruction.

Per cpu atomicness does not provide protection from concurrent modifications from
other processors. In general per cpu data is modified only from the processor
that the per cpu area is associated with. So per cpu atomicness provides a fast
and effective means of dealing with concurrency. It may allow development of
better fastpaths for allocators and other important subsystems.

The per cpu atomic RMW operations can be used to avoid having to dimension pointer
arrays in the allocators (patches for page allocator and slub are provided) and
avoid pointer lookups in the hot paths of the allocators thereby decreasing
latency of critical OS paths. The macros could be used to revise the critical
paths in the allocators to no longer need to disable interrupts (not included).

Per cpu atomic RMW operations are useful to decrease the overhead of counter
maintenance in the kernel. A this_cpu_inc() f.e. can generate a single
instruction that has no needs for registers on x86. preempt on / off can
be avoided in many places.

Patchset will reduce the code size and increase speed of operations for
dynamically allocated per cpu based statistics. A set of patches modifies
the fastpaths of the SLUB allocator reducing code size and cache footprint
through the per cpu atomic operations.

---


             reply	other threads:[~2009-10-07 21:18 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07 21:10 cl [this message]
2009-10-07 21:10 ` [this_cpu_xx V6 1/7] this_cpu_ops: page allocator conversion cl
2009-10-08 10:38   ` Tejun Heo
2009-10-08 10:40     ` Tejun Heo
2009-10-08 16:15     ` Christoph Lameter
2009-10-08 10:53   ` Mel Gorman
2009-10-07 21:10 ` [this_cpu_xx V6 2/7] this_cpu ops: Remove pageset_notifier cl
2009-10-07 21:10 ` [this_cpu_xx V6 3/7] Use this_cpu operations in slub cl
2009-10-12 10:19   ` Tejun Heo
2009-10-12 10:21     ` Tejun Heo
2009-10-12 14:54     ` Christoph Lameter
2009-10-13  2:13       ` Tejun Heo
2009-10-13 14:41         ` Christoph Lameter
2009-10-13 14:56           ` Tejun Heo
2009-10-13 15:20             ` Christoph Lameter
2009-10-14  1:57               ` Tejun Heo
2009-10-14 14:14                 ` Christoph Lameter
2009-10-15  7:47                   ` Tejun Heo
2009-10-16 16:44                     ` Christoph Lameter
2009-10-18  3:11                       ` Tejun Heo
2009-10-07 21:10 ` [this_cpu_xx V6 4/7] SLUB: Get rid of dynamic DMA kmalloc cache allocation cl
2009-10-13 18:48   ` [FIX] patch "SLUB: Get rid of dynamic DMA kmalloc cache allocation" Christoph Lameter
2009-10-07 21:10 ` [this_cpu_xx V6 5/7] this_cpu: Remove slub kmem_cache fields cl
2009-10-07 23:10   ` Christoph Lameter
2009-10-07 21:10 ` [this_cpu_xx V6 6/7] Make slub statistics use this_cpu_inc cl
2009-10-07 21:10 ` [this_cpu_xx V6 7/7] this_cpu: slub aggressive use of this_cpu operations in the hotpaths cl
2009-10-12 10:40   ` Tejun Heo
2009-10-12 13:14     ` Pekka Enberg
2009-10-12 14:55       ` Christoph Lameter
2009-10-13  9:45       ` David Rientjes
2009-10-13 14:43         ` Christoph Lameter
2009-10-13 19:14           ` Christoph Lameter
2009-10-13 19:44             ` Pekka Enberg
2009-10-13 19:48               ` Christoph Lameter
2009-10-13 20:15                 ` David Rientjes
2009-10-13 20:28                   ` Christoph Lameter
2009-10-13 22:53                     ` David Rientjes
2009-10-14 13:34                       ` Mel Gorman
2009-10-14 14:08                         ` Christoph Lameter
2009-10-14 15:49                           ` Mel Gorman
2009-10-14 15:53                             ` Pekka Enberg
2009-10-14 15:56                               ` Christoph Lameter
2009-10-14 16:14                                 ` Pekka Enberg
2009-10-14 18:19                                   ` Christoph Lameter
2009-10-16 10:50                                 ` Mel Gorman
2009-10-16 18:40                                   ` David Rientjes
2009-10-15  9:03                         ` David Rientjes
2009-10-16 16:45                           ` Christoph Lameter
2009-10-16 18:43                             ` David Rientjes
2009-10-16 18:50                               ` Christoph Lameter
2009-10-13 20:25               ` Christoph Lameter
2009-10-14  1:33           ` David Rientjes
2009-10-13 15:40 ` [this_cpu_xx V6 0/7] Introduce per cpu atomic operations and avoid per cpu address arithmetic Mel Gorman
2009-10-13 15:45   ` Christoph Lameter
2009-10-13 16:09     ` Mel Gorman
2009-10-13 17:17       ` Christoph Lameter

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=20091007211024.442168959@gentwo.org \
    --to=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox