<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/linux/slab_def.h, branch v4.10.3</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.10.3</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.10.3'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2016-07-28T23:07:41Z</updated>
<entry>
<title>mm, kasan: switch SLUB to stackdepot, enable memory quarantine for SLUB</title>
<updated>2016-07-28T23:07:41Z</updated>
<author>
<name>Alexander Potapenko</name>
<email>glider@google.com</email>
</author>
<published>2016-07-28T22:49:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=80a9201a5965f4715d5c09790862e0df84ce0614'/>
<id>urn:sha1:80a9201a5965f4715d5c09790862e0df84ce0614</id>
<content type='text'>
For KASAN builds:
 - switch SLUB allocator to using stackdepot instead of storing the
   allocation/deallocation stacks in the objects;
 - change the freelist hook so that parts of the freelist can be put
   into the quarantine.

[aryabinin@virtuozzo.com: fixes]
  Link: http://lkml.kernel.org/r/1468601423-28676-1-git-send-email-aryabinin@virtuozzo.com
Link: http://lkml.kernel.org/r/1468347165-41906-3-git-send-email-glider@google.com
Signed-off-by: Alexander Potapenko &lt;glider@google.com&gt;
Cc: Andrey Konovalov &lt;adech.fo@gmail.com&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Cc: Steven Rostedt (Red Hat) &lt;rostedt@goodmis.org&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Kostya Serebryany &lt;kcc@google.com&gt;
Cc: Andrey Ryabinin &lt;aryabinin@virtuozzo.com&gt;
Cc: Kuthonuzo Luruo &lt;kuthonuzo.luruo@hpe.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm: reorganize SLAB freelist randomization</title>
<updated>2016-07-26T23:19:19Z</updated>
<author>
<name>Thomas Garnier</name>
<email>thgarnie@google.com</email>
</author>
<published>2016-07-26T22:21:56Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7c00fce98c3e15334a603925b41aa49f76e83227'/>
<id>urn:sha1:7c00fce98c3e15334a603925b41aa49f76e83227</id>
<content type='text'>
The kernel heap allocators are using a sequential freelist making their
allocation predictable.  This predictability makes kernel heap overflow
easier to exploit.  An attacker can careful prepare the kernel heap to
control the following chunk overflowed.

For example these attacks exploit the predictability of the heap:
 - Linux Kernel CAN SLUB overflow (https://goo.gl/oMNWkU)
 - Exploiting Linux Kernel Heap corruptions (http://goo.gl/EXLn95)

***Problems that needed solving:
 - Randomize the Freelist (singled linked) used in the SLUB allocator.
 - Ensure good performance to encourage usage.
 - Get best entropy in early boot stage.

***Parts:
 - 01/02 Reorganize the SLAB Freelist randomization to share elements
   with the SLUB implementation.
 - 02/02 The SLUB Freelist randomization implementation. Similar approach
   than the SLAB but tailored to the singled freelist used in SLUB.

***Performance data:

slab_test impact is between 3% to 4% on average for 100000 attempts
without smp.  It is a very focused testing, kernbench show the overall
impact on the system is way lower.

Before:

  Single thread testing
  =====================
  1. Kmalloc: Repeatedly allocate then free test
  100000 times kmalloc(8) -&gt; 49 cycles kfree -&gt; 77 cycles
  100000 times kmalloc(16) -&gt; 51 cycles kfree -&gt; 79 cycles
  100000 times kmalloc(32) -&gt; 53 cycles kfree -&gt; 83 cycles
  100000 times kmalloc(64) -&gt; 62 cycles kfree -&gt; 90 cycles
  100000 times kmalloc(128) -&gt; 81 cycles kfree -&gt; 97 cycles
  100000 times kmalloc(256) -&gt; 98 cycles kfree -&gt; 121 cycles
  100000 times kmalloc(512) -&gt; 95 cycles kfree -&gt; 122 cycles
  100000 times kmalloc(1024) -&gt; 96 cycles kfree -&gt; 126 cycles
  100000 times kmalloc(2048) -&gt; 115 cycles kfree -&gt; 140 cycles
  100000 times kmalloc(4096) -&gt; 149 cycles kfree -&gt; 171 cycles
  2. Kmalloc: alloc/free test
  100000 times kmalloc(8)/kfree -&gt; 70 cycles
  100000 times kmalloc(16)/kfree -&gt; 70 cycles
  100000 times kmalloc(32)/kfree -&gt; 70 cycles
  100000 times kmalloc(64)/kfree -&gt; 70 cycles
  100000 times kmalloc(128)/kfree -&gt; 70 cycles
  100000 times kmalloc(256)/kfree -&gt; 69 cycles
  100000 times kmalloc(512)/kfree -&gt; 70 cycles
  100000 times kmalloc(1024)/kfree -&gt; 73 cycles
  100000 times kmalloc(2048)/kfree -&gt; 72 cycles
  100000 times kmalloc(4096)/kfree -&gt; 71 cycles

After:

  Single thread testing
  =====================
  1. Kmalloc: Repeatedly allocate then free test
  100000 times kmalloc(8) -&gt; 57 cycles kfree -&gt; 78 cycles
  100000 times kmalloc(16) -&gt; 61 cycles kfree -&gt; 81 cycles
  100000 times kmalloc(32) -&gt; 76 cycles kfree -&gt; 93 cycles
  100000 times kmalloc(64) -&gt; 83 cycles kfree -&gt; 94 cycles
  100000 times kmalloc(128) -&gt; 106 cycles kfree -&gt; 107 cycles
  100000 times kmalloc(256) -&gt; 118 cycles kfree -&gt; 117 cycles
  100000 times kmalloc(512) -&gt; 114 cycles kfree -&gt; 116 cycles
  100000 times kmalloc(1024) -&gt; 115 cycles kfree -&gt; 118 cycles
  100000 times kmalloc(2048) -&gt; 147 cycles kfree -&gt; 131 cycles
  100000 times kmalloc(4096) -&gt; 214 cycles kfree -&gt; 161 cycles
  2. Kmalloc: alloc/free test
  100000 times kmalloc(8)/kfree -&gt; 66 cycles
  100000 times kmalloc(16)/kfree -&gt; 66 cycles
  100000 times kmalloc(32)/kfree -&gt; 66 cycles
  100000 times kmalloc(64)/kfree -&gt; 66 cycles
  100000 times kmalloc(128)/kfree -&gt; 65 cycles
  100000 times kmalloc(256)/kfree -&gt; 67 cycles
  100000 times kmalloc(512)/kfree -&gt; 67 cycles
  100000 times kmalloc(1024)/kfree -&gt; 64 cycles
  100000 times kmalloc(2048)/kfree -&gt; 67 cycles
  100000 times kmalloc(4096)/kfree -&gt; 67 cycles

Kernbench, before:

  Average Optimal load -j 12 Run (std deviation):
  Elapsed Time 101.873 (1.16069)
  User Time 1045.22 (1.60447)
  System Time 88.969 (0.559195)
  Percent CPU 1112.9 (13.8279)
  Context Switches 189140 (2282.15)
  Sleeps 99008.6 (768.091)

After:

  Average Optimal load -j 12 Run (std deviation):
  Elapsed Time 102.47 (0.562732)
  User Time 1045.3 (1.34263)
  System Time 88.311 (0.342554)
  Percent CPU 1105.8 (6.49444)
  Context Switches 189081 (2355.78)
  Sleeps 99231.5 (800.358)

This patch (of 2):

This commit reorganizes the previous SLAB freelist randomization to
prepare for the SLUB implementation.  It moves functions that will be
shared to slab_common.

The entropy functions are changed to align with the SLUB implementation,
now using get_random_(int|long) functions.  These functions were chosen
because they provide a bit more entropy early on boot and better
performance when specific arch instructions are not available.

[akpm@linux-foundation.org: fix build]
Link: http://lkml.kernel.org/r/1464295031-26375-2-git-send-email-thgarnie@google.com
Signed-off-by: Thomas Garnier &lt;thgarnie@google.com&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm: SLAB freelist randomization</title>
<updated>2016-05-20T02:12:14Z</updated>
<author>
<name>Thomas Garnier</name>
<email>thgarnie@google.com</email>
</author>
<published>2016-05-20T00:10:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c7ce4f60ac199fb3521c5fcd64da21cee801ec2b'/>
<id>urn:sha1:c7ce4f60ac199fb3521c5fcd64da21cee801ec2b</id>
<content type='text'>
Provides an optional config (CONFIG_SLAB_FREELIST_RANDOM) to randomize
the SLAB freelist.  The list is randomized during initialization of a
new set of pages.  The order on different freelist sizes is pre-computed
at boot for performance.  Each kmem_cache has its own randomized
freelist.  Before pre-computed lists are available freelists are
generated dynamically.  This security feature reduces the predictability
of the kernel SLAB allocator against heap overflows rendering attacks
much less stable.

For example this attack against SLUB (also applicable against SLAB)
would be affected:

  https://jon.oberheide.org/blog/2010/09/10/linux-kernel-can-slub-overflow/

Also, since v4.6 the freelist was moved at the end of the SLAB.  It
means a controllable heap is opened to new attacks not yet publicly
discussed.  A kernel heap overflow can be transformed to multiple
use-after-free.  This feature makes this type of attack harder too.

To generate entropy, we use get_random_bytes_arch because 0 bits of
entropy is available in the boot stage.  In the worse case this function
will fallback to the get_random_bytes sub API.  We also generate a shift
random number to shift pre-computed freelist for each new set of pages.

The config option name is not specific to the SLAB as this approach will
be extended to other allocators like SLUB.

Performance results highlighted no major changes:

Hackbench (running 90 10 times):

  Before average: 0.0698
  After average: 0.0663 (-5.01%)

slab_test 1 run on boot.  Difference only seen on the 2048 size test
being the worse case scenario covered by freelist randomization.  New
slab pages are constantly being created on the 10000 allocations.
Variance should be mainly due to getting new pages every few
allocations.

Before:

  Single thread testing
  =====================
  1. Kmalloc: Repeatedly allocate then free test
  10000 times kmalloc(8) -&gt; 99 cycles kfree -&gt; 112 cycles
  10000 times kmalloc(16) -&gt; 109 cycles kfree -&gt; 140 cycles
  10000 times kmalloc(32) -&gt; 129 cycles kfree -&gt; 137 cycles
  10000 times kmalloc(64) -&gt; 141 cycles kfree -&gt; 141 cycles
  10000 times kmalloc(128) -&gt; 152 cycles kfree -&gt; 148 cycles
  10000 times kmalloc(256) -&gt; 195 cycles kfree -&gt; 167 cycles
  10000 times kmalloc(512) -&gt; 257 cycles kfree -&gt; 199 cycles
  10000 times kmalloc(1024) -&gt; 393 cycles kfree -&gt; 251 cycles
  10000 times kmalloc(2048) -&gt; 649 cycles kfree -&gt; 228 cycles
  10000 times kmalloc(4096) -&gt; 806 cycles kfree -&gt; 370 cycles
  10000 times kmalloc(8192) -&gt; 814 cycles kfree -&gt; 411 cycles
  10000 times kmalloc(16384) -&gt; 892 cycles kfree -&gt; 455 cycles
  2. Kmalloc: alloc/free test
  10000 times kmalloc(8)/kfree -&gt; 121 cycles
  10000 times kmalloc(16)/kfree -&gt; 121 cycles
  10000 times kmalloc(32)/kfree -&gt; 121 cycles
  10000 times kmalloc(64)/kfree -&gt; 121 cycles
  10000 times kmalloc(128)/kfree -&gt; 121 cycles
  10000 times kmalloc(256)/kfree -&gt; 119 cycles
  10000 times kmalloc(512)/kfree -&gt; 119 cycles
  10000 times kmalloc(1024)/kfree -&gt; 119 cycles
  10000 times kmalloc(2048)/kfree -&gt; 119 cycles
  10000 times kmalloc(4096)/kfree -&gt; 121 cycles
  10000 times kmalloc(8192)/kfree -&gt; 119 cycles
  10000 times kmalloc(16384)/kfree -&gt; 119 cycles

After:

  Single thread testing
  =====================
  1. Kmalloc: Repeatedly allocate then free test
  10000 times kmalloc(8) -&gt; 130 cycles kfree -&gt; 86 cycles
  10000 times kmalloc(16) -&gt; 118 cycles kfree -&gt; 86 cycles
  10000 times kmalloc(32) -&gt; 121 cycles kfree -&gt; 85 cycles
  10000 times kmalloc(64) -&gt; 176 cycles kfree -&gt; 102 cycles
  10000 times kmalloc(128) -&gt; 178 cycles kfree -&gt; 100 cycles
  10000 times kmalloc(256) -&gt; 205 cycles kfree -&gt; 109 cycles
  10000 times kmalloc(512) -&gt; 262 cycles kfree -&gt; 136 cycles
  10000 times kmalloc(1024) -&gt; 342 cycles kfree -&gt; 157 cycles
  10000 times kmalloc(2048) -&gt; 701 cycles kfree -&gt; 238 cycles
  10000 times kmalloc(4096) -&gt; 803 cycles kfree -&gt; 364 cycles
  10000 times kmalloc(8192) -&gt; 835 cycles kfree -&gt; 404 cycles
  10000 times kmalloc(16384) -&gt; 896 cycles kfree -&gt; 441 cycles
  2. Kmalloc: alloc/free test
  10000 times kmalloc(8)/kfree -&gt; 121 cycles
  10000 times kmalloc(16)/kfree -&gt; 121 cycles
  10000 times kmalloc(32)/kfree -&gt; 123 cycles
  10000 times kmalloc(64)/kfree -&gt; 142 cycles
  10000 times kmalloc(128)/kfree -&gt; 121 cycles
  10000 times kmalloc(256)/kfree -&gt; 119 cycles
  10000 times kmalloc(512)/kfree -&gt; 119 cycles
  10000 times kmalloc(1024)/kfree -&gt; 119 cycles
  10000 times kmalloc(2048)/kfree -&gt; 119 cycles
  10000 times kmalloc(4096)/kfree -&gt; 119 cycles
  10000 times kmalloc(8192)/kfree -&gt; 119 cycles
  10000 times kmalloc(16384)/kfree -&gt; 119 cycles

[akpm@linux-foundation.org: propagate gfp_t into cache_random_seq_create()]
Signed-off-by: Thomas Garnier &lt;thgarnie@google.com&gt;
Acked-by: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Greg Thelen &lt;gthelen@google.com&gt;
Cc: Laura Abbott &lt;labbott@fedoraproject.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm, kasan: SLAB support</title>
<updated>2016-03-25T23:37:42Z</updated>
<author>
<name>Alexander Potapenko</name>
<email>glider@google.com</email>
</author>
<published>2016-03-25T21:21:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7ed2f9e663854db313f177a511145630e398b402'/>
<id>urn:sha1:7ed2f9e663854db313f177a511145630e398b402</id>
<content type='text'>
Add KASAN hooks to SLAB allocator.

This patch is based on the "mm: kasan: unified support for SLUB and SLAB
allocators" patch originally prepared by Dmitry Chernenkov.

Signed-off-by: Alexander Potapenko &lt;glider@google.com&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Andrey Konovalov &lt;adech.fo@gmail.com&gt;
Cc: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Cc: Andrey Ryabinin &lt;ryabinin.a.a@gmail.com&gt;
Cc: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Cc: Konstantin Serebryany &lt;kcc@google.com&gt;
Cc: Dmitry Chernenkov &lt;dmitryc@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm/slab: alternative implementation for DEBUG_SLAB_LEAK</title>
<updated>2016-03-15T23:55:16Z</updated>
<author>
<name>Joonsoo Kim</name>
<email>iamjoonsoo.kim@lge.com</email>
</author>
<published>2016-03-15T21:54:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d31676dfde257cb2b3e52d4e657d8ad2251e4d49'/>
<id>urn:sha1:d31676dfde257cb2b3e52d4e657d8ad2251e4d49</id>
<content type='text'>
DEBUG_SLAB_LEAK is a debug option.  It's current implementation requires
status buffer so we need more memory to use it.  And, it cause
kmem_cache initialization step more complex.

To remove this extra memory usage and to simplify initialization step,
this patch implement this feature with another way.

When user requests to get slab object owner information, it marks that
getting information is started.  And then, all free objects in caches
are flushed to corresponding slab page.  Now, we can distinguish all
freed object so we can know all allocated objects, too.  After
collecting slab object owner information on allocated objects, mark is
checked that there is no free during the processing.  If true, we can be
sure that our information is correct so information is returned to user.

Although this way is rather complex, it has two important benefits
mentioned above.  So, I think it is worth changing.

There is one drawback that it takes more time to get slab object owner
information but it is just a debug option so it doesn't matter at all.

To help review, this patch implements new way only.  Following patch
will remove useless code.

Signed-off-by: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Jesper Dangaard Brouer &lt;brouer@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm: memcontrol: move kmem accounting code to CONFIG_MEMCG</title>
<updated>2016-01-21T01:09:18Z</updated>
<author>
<name>Johannes Weiner</name>
<email>hannes@cmpxchg.org</email>
</author>
<published>2016-01-20T23:02:32Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=127424c86bb6cb87f0b563d9fdcfbbaf3c86ecec'/>
<id>urn:sha1:127424c86bb6cb87f0b563d9fdcfbbaf3c86ecec</id>
<content type='text'>
The cgroup2 memory controller will account important in-kernel memory
consumers per default.  Move all necessary components to CONFIG_MEMCG.

Signed-off-by: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Acked-by: Vladimir Davydov &lt;vdavydov@virtuozzo.com&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;
Cc: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>slab: embed memcg_cache_params to kmem_cache</title>
<updated>2015-02-13T02:54:09Z</updated>
<author>
<name>Vladimir Davydov</name>
<email>vdavydov@parallels.com</email>
</author>
<published>2015-02-12T22:59:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f7ce3190c4a35bf887adb7a1aa1ba899b679872d'/>
<id>urn:sha1:f7ce3190c4a35bf887adb7a1aa1ba899b679872d</id>
<content type='text'>
Currently, kmem_cache stores a pointer to struct memcg_cache_params
instead of embedding it.  The rationale is to save memory when kmem
accounting is disabled.  However, the memcg_cache_params has shrivelled
drastically since it was first introduced:

* Initially:

struct memcg_cache_params {
	bool is_root_cache;
	union {
		struct kmem_cache *memcg_caches[0];
		struct {
			struct mem_cgroup *memcg;
			struct list_head list;
			struct kmem_cache *root_cache;
			bool dead;
			atomic_t nr_pages;
			struct work_struct destroy;
		};
	};
};

* Now:

struct memcg_cache_params {
	bool is_root_cache;
	union {
		struct {
			struct rcu_head rcu_head;
			struct kmem_cache *memcg_caches[0];
		};
		struct {
			struct mem_cgroup *memcg;
			struct kmem_cache *root_cache;
		};
	};
};

So the memory saving does not seem to be a clear win anymore.

OTOH, keeping a pointer to memcg_cache_params struct instead of embedding
it results in touching one more cache line on kmem alloc/free hot paths.
Besides, it makes linking kmem caches in a list chained by a field of
struct memcg_cache_params really painful due to a level of indirection,
while I want to make them linked in the following patch.  That said, let
us embed it.

Signed-off-by: Vladimir Davydov &lt;vdavydov@parallels.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Dave Chinner &lt;david@fromorbit.com&gt;
Cc: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm/slab: use percpu allocator for cpu cache</title>
<updated>2014-10-10T02:25:51Z</updated>
<author>
<name>Joonsoo Kim</name>
<email>iamjoonsoo.kim@lge.com</email>
</author>
<published>2014-10-09T22:26:27Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bf0dea23a9c094ae869a88bb694fbe966671bf6d'/>
<id>urn:sha1:bf0dea23a9c094ae869a88bb694fbe966671bf6d</id>
<content type='text'>
Because of chicken and egg problem, initialization of SLAB is really
complicated.  We need to allocate cpu cache through SLAB to make the
kmem_cache work, but before initialization of kmem_cache, allocation
through SLAB is impossible.

On the other hand, SLUB does initialization in a more simple way.  It uses
percpu allocator to allocate cpu cache so there is no chicken and egg
problem.

So, this patch try to use percpu allocator in SLAB.  This simplifies the
initialization step in SLAB so that we could maintain SLAB code more
easily.

In my testing there is no performance difference.

This implementation relies on percpu allocator.  Because percpu allocator
uses vmalloc address space, vmalloc address space could be exhausted by
this change on many cpu system with *32 bit* kernel.  This implementation
can cover 1024 cpus in worst case by following calculation.

Worst: 1024 cpus * 4 bytes for pointer * 300 kmem_caches *
	120 objects per cpu_cache = 140 MB
Normal: 1024 cpus * 4 bytes for pointer * 150 kmem_caches(slab merge) *
	80 objects per cpu_cache = 46 MB

Signed-off-by: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Acked-by: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Jeremiah Mahler &lt;jmmahler@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next</title>
<updated>2014-01-25T19:17:34Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2014-01-25T19:17:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4ba9920e5e9c0e16b5ed24292d45322907bb9035'/>
<id>urn:sha1:4ba9920e5e9c0e16b5ed24292d45322907bb9035</id>
<content type='text'>
Pull networking updates from David Miller:

 1) BPF debugger and asm tool by Daniel Borkmann.

 2) Speed up create/bind in AF_PACKET, also from Daniel Borkmann.

 3) Correct reciprocal_divide and update users, from Hannes Frederic
    Sowa and Daniel Borkmann.

 4) Currently we only have a "set" operation for the hw timestamp socket
    ioctl, add a "get" operation to match.  From Ben Hutchings.

 5) Add better trace events for debugging driver datapath problems, also
    from Ben Hutchings.

 6) Implement auto corking in TCP, from Eric Dumazet.  Basically, if we
    have a small send and a previous packet is already in the qdisc or
    device queue, defer until TX completion or we get more data.

 7) Allow userspace to manage ipv6 temporary addresses, from Jiri Pirko.

 8) Add a qdisc bypass option for AF_PACKET sockets, from Daniel
    Borkmann.

 9) Share IP header compression code between Bluetooth and IEEE802154
    layers, from Jukka Rissanen.

10) Fix ipv6 router reachability probing, from Jiri Benc.

11) Allow packets to be captured on macvtap devices, from Vlad Yasevich.

12) Support tunneling in GRO layer, from Jerry Chu.

13) Allow bonding to be configured fully using netlink, from Scott
    Feldman.

14) Allow AF_PACKET users to obtain the VLAN TPID, just like they can
    already get the TCI.  From Atzm Watanabe.

15) New "Heavy Hitter" qdisc, from Terry Lam.

16) Significantly improve the IPSEC support in pktgen, from Fan Du.

17) Allow ipv4 tunnels to cache routes, just like sockets.  From Tom
    Herbert.

18) Add Proportional Integral Enhanced packet scheduler, from Vijay
    Subramanian.

19) Allow openvswitch to mmap'd netlink, from Thomas Graf.

20) Key TCP metrics blobs also by source address, not just destination
    address.  From Christoph Paasch.

21) Support 10G in generic phylib.  From Andy Fleming.

22) Try to short-circuit GRO flow compares using device provided RX
    hash, if provided.  From Tom Herbert.

The wireless and netfilter folks have been busy little bees too.

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (2064 commits)
  net/cxgb4: Fix referencing freed adapter
  ipv6: reallocate addrconf router for ipv6 address when lo device up
  fib_frontend: fix possible NULL pointer dereference
  rtnetlink: remove IFLA_BOND_SLAVE definition
  rtnetlink: remove check for fill_slave_info in rtnl_have_link_slave_info
  qlcnic: update version to 5.3.55
  qlcnic: Enhance logic to calculate msix vectors.
  qlcnic: Refactor interrupt coalescing code for all adapters.
  qlcnic: Update poll controller code path
  qlcnic: Interrupt code cleanup
  qlcnic: Enhance Tx timeout debugging.
  qlcnic: Use bool for rx_mac_learn.
  bonding: fix u64 division
  rtnetlink: add missing IFLA_BOND_AD_INFO_UNSPEC
  sfc: Use the correct maximum TX DMA ring size for SFC9100
  Add Shradha Shah as the sfc driver maintainer.
  net/vxlan: Share RX skb de-marking and checksum checks with ovs
  tulip: cleanup by using ARRAY_SIZE()
  ip_tunnel: clear IPCB in ip_tunnel_xmit() in case dst_link_failure() is called
  net/cxgb4: Don't retrieve stats during recovery
  ...
</content>
</entry>
<entry>
<title>reciprocal_divide: update/correction of the algorithm</title>
<updated>2014-01-22T07:17:20Z</updated>
<author>
<name>Hannes Frederic Sowa</name>
<email>hannes@stressinduktion.org</email>
</author>
<published>2014-01-22T01:29:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=809fa972fd90ff27225294b17a027e908b2d7b7a'/>
<id>urn:sha1:809fa972fd90ff27225294b17a027e908b2d7b7a</id>
<content type='text'>
Jakub Zawadzki noticed that some divisions by reciprocal_divide()
were not correct [1][2], which he could also show with BPF code
after divisions are transformed into reciprocal_value() for runtime
invariance which can be passed to reciprocal_divide() later on;
reverse in BPF dump ended up with a different, off-by-one K in
some situations.

This has been fixed by Eric Dumazet in commit aee636c4809fa5
("bpf: do not use reciprocal divide"). This follow-up patch
improves reciprocal_value() and reciprocal_divide() to work in
all cases by using Granlund and Montgomery method, so that also
future use is safe and without any non-obvious side-effects.
Known problems with the old implementation were that division by 1
always returned 0 and some off-by-ones when the dividend and divisor
where very large. This seemed to not be problematic with its
current users, as far as we can tell. Eric Dumazet checked for
the slab usage, we cannot surely say so in the case of flex_array.
Still, in order to fix that, we propose an extension from the
original implementation from commit 6a2d7a955d8d resp. [3][4],
by using the algorithm proposed in "Division by Invariant Integers
Using Multiplication" [5], Torbjörn Granlund and Peter L.
Montgomery, that is, pseudocode for q = n/d where q, n, d is in
u32 universe:

1) Initialization:

  int l = ceil(log_2 d)
  uword m' = floor((1&lt;&lt;32)*((1&lt;&lt;l)-d)/d)+1
  int sh_1 = min(l,1)
  int sh_2 = max(l-1,0)

2) For q = n/d, all uword:

  uword t = (n*m')&gt;&gt;32
  q = (t+((n-t)&gt;&gt;sh_1))&gt;&gt;sh_2

The assembler implementation from Agner Fog [6] also helped a lot
while implementing. We have tested the implementation on x86_64,
ppc64, i686, s390x; on x86_64/haswell we're still half the latency
compared to normal divide.

Joint work with Daniel Borkmann.

  [1] http://www.wireshark.org/~darkjames/reciprocal-buggy.c
  [2] http://www.wireshark.org/~darkjames/set-and-dump-filter-k-bug.c
  [3] https://gmplib.org/~tege/division-paper.pdf
  [4] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
  [5] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.1.2556
  [6] http://www.agner.org/optimize/asmlib.zip

Reported-by: Jakub Zawadzki &lt;darkjames-ws@darkjames.pl&gt;
Cc: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: Austin S Hemmelgarn &lt;ahferroin7@gmail.com&gt;
Cc: linux-kernel@vger.kernel.org
Cc: Jesse Gross &lt;jesse@nicira.com&gt;
Cc: Jamal Hadi Salim &lt;jhs@mojatatu.com&gt;
Cc: Stephen Hemminger &lt;stephen@networkplumber.org&gt;
Cc: Matt Mackall &lt;mpm@selenic.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: Christoph Lameter &lt;cl@linux-foundation.org&gt;
Cc: Andy Gospodarek &lt;andy@greyhouse.net&gt;
Cc: Veaceslav Falico &lt;vfalico@redhat.com&gt;
Cc: Jay Vosburgh &lt;fubar@us.ibm.com&gt;
Cc: Jakub Zawadzki &lt;darkjames-ws@darkjames.pl&gt;
Signed-off-by: Daniel Borkmann &lt;dborkman@redhat.com&gt;
Signed-off-by: Hannes Frederic Sowa &lt;hannes@stressinduktion.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
