<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/mm/z3fold.c, branch linux-4.20.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.20.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.20.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-11-18T18:15:09Z</updated>
<entry>
<title>z3fold: fix possible reclaim races</title>
<updated>2018-11-18T18:15:09Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2018-11-16T23:07:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ca0246bb97c23da9d267c2107c07fb77e38205c9'/>
<id>urn:sha1:ca0246bb97c23da9d267c2107c07fb77e38205c9</id>
<content type='text'>
Reclaim and free can race on an object which is basically fine but in
order for reclaim to be able to map "freed" object we need to encode
object length in the handle.  handle_to_chunks() is then introduced to
extract object length from a handle and use it during mapping.

Moreover, to avoid racing on a z3fold "headless" page release, we should
not try to free that page in z3fold_free() if the reclaim bit is set.
Also, in the unlikely case of trying to reclaim a page being freed, we
should not proceed with that page.

While at it, fix the page accounting in reclaim function.

This patch supersedes "[PATCH] z3fold: fix reclaim lock-ups".

Link: http://lkml.kernel.org/r/20181105162225.74e8837d03583a9b707cf559@gmail.com
Signed-off-by: Vitaly Wool &lt;vitaly.vul@sony.com&gt;
Signed-off-by: Jongseok Kim &lt;ks77sj@gmail.com&gt;
Reported-by-by: Jongseok Kim &lt;ks77sj@gmail.com&gt;
Reviewed-by: Snild Dolkow &lt;snild@sony.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>z3fold: fix reclaim lock-ups</title>
<updated>2018-05-12T00:28:45Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2018-05-11T23:01:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6098d7e136692f9c6e23ae362c62ec822343e4d5'/>
<id>urn:sha1:6098d7e136692f9c6e23ae362c62ec822343e4d5</id>
<content type='text'>
Do not try to optimize in-page object layout while the page is under
reclaim.  This fixes lock-ups on reclaim and improves reclaim
performance at the same time.

[akpm@linux-foundation.org: coding-style fixes]
Link: http://lkml.kernel.org/r/20180430125800.444cae9706489f412ad12621@gmail.com
Signed-off-by: Vitaly Wool &lt;vitaly.vul@sony.com&gt;
Reported-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Tested-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Cc: &lt;Oleksiy.Avramchenko@sony.com&gt;
Cc: Matthew Wilcox &lt;mawilcox@microsoft.com&gt;
Cc: &lt;stable@vger.kernel.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/z3fold.c: use gfpflags_allow_blocking</title>
<updated>2018-04-11T17:28:31Z</updated>
<author>
<name>Matthew Wilcox</name>
</author>
<published>2018-04-10T23:29:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8a97ea546bb6532f77a0efe165012ee0d0c4b903'/>
<id>urn:sha1:8a97ea546bb6532f77a0efe165012ee0d0c4b903</id>
<content type='text'>
We have a perfectly good macro to determine whether the gfp flags allow
you to sleep or not; use it instead of trying to infer it.

Link: http://lkml.kernel.org/r/20180408062206.GC16007@bombadil.infradead.org
Signed-off-by: Matthew Wilcox &lt;mawilcox@microsoft.com&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Vitaly Wool &lt;vitalywool@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>z3fold: fix memory leak</title>
<updated>2018-04-11T17:28:31Z</updated>
<author>
<name>Xidong Wang</name>
</author>
<published>2018-04-10T23:29:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1ec6995d1290bfb87cc3a51f0836c889e857cef9'/>
<id>urn:sha1:1ec6995d1290bfb87cc3a51f0836c889e857cef9</id>
<content type='text'>
In z3fold_create_pool(), the memory allocated by __alloc_percpu() is not
released on the error path that pool-&gt;compact_wq , which holds the
return value of create_singlethread_workqueue(), is NULL.  This will
result in a memory leak bug.

[akpm@linux-foundation.org: fix oops on kzalloc() failure, check __alloc_percpu() retval]
Link: http://lkml.kernel.org/r/1522803111-29209-1-git-send-email-wangxidong_97@163.com
Signed-off-by: Xidong Wang &lt;wangxidong_97@163.com&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Mike Rapoport &lt;rppt@linux.vnet.ibm.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>z3fold: limit use of stale list for allocation</title>
<updated>2018-04-06T04:36:25Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2018-04-05T23:23:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5c9bab592f53328b3e00d7293378b714abf47a2a'/>
<id>urn:sha1:5c9bab592f53328b3e00d7293378b714abf47a2a</id>
<content type='text'>
Currently if z3fold couldn't find an unbuddied page it would first try
to pull a page off the stale list.  The problem with this approach is
that we can't 100% guarantee that the page is not processed by the
workqueue thread at the same time unless we run cancel_work_sync() on
it, which we can't do if we're in an atomic context.  So let's just
limit stale list usage to non-atomic contexts only.

Link: http://lkml.kernel.org/r/47ab51e7-e9c1-d30e-ab17-f734dbc3abce@gmail.com
Signed-off-by: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: &lt;Oleksiy.Avramchenko@sony.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: docs: fix parameter names mismatch</title>
<updated>2018-02-07T02:32:48Z</updated>
<author>
<name>Mike Rapoport</name>
</author>
<published>2018-02-06T23:42:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f144c390f9059d9efafe54c4eb22bb13a2cb5534'/>
<id>urn:sha1:f144c390f9059d9efafe54c4eb22bb13a2cb5534</id>
<content type='text'>
There are several places where parameter descriptions do no match the
actual code.  Fix it.

Link: http://lkml.kernel.org/r/1516700871-22279-3-git-send-email-rppt@linux.vnet.ibm.com
Signed-off-by: Mike Rapoport &lt;rppt@linux.vnet.ibm.com&gt;
Cc: Jonathan Corbet &lt;corbet@lwn.net&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/z3fold.c: use kref to prevent page free/compact race</title>
<updated>2017-11-18T00:10:00Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2017-11-17T23:26:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5d03a6613957785e94af7a4a6212ad4af66aa5c2'/>
<id>urn:sha1:5d03a6613957785e94af7a4a6212ad4af66aa5c2</id>
<content type='text'>
There is a race in the current z3fold implementation between
do_compact() called in a work queue context and the page release
procedure when page's kref goes to 0.

do_compact() may be waiting for page lock, which is released by
release_z3fold_page_locked right before putting the page onto the
"stale" list, and then the page may be freed as do_compact() modifies
its contents.

The mechanism currently implemented to handle that (checking the
PAGE_STALE flag) is not reliable enough.  Instead, we'll use page's kref
counter to guarantee that the page is not released if its compaction is
scheduled.  It then becomes compaction function's responsibility to
decrease the counter and quit immediately if the page was actually
freed.

Link: http://lkml.kernel.org/r/20171117092032.00ea56f42affbed19f4fcc6c@gmail.com
Signed-off-by: Vitaly Wool &lt;vitaly.wool@sonymobile.com&gt;
Cc: &lt;Oleksiy.Avramchenko@sony.com&gt;
Cc: &lt;stable@vger.kernel.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>z3fold: fix stale list handling</title>
<updated>2017-10-04T00:54:24Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2017-10-03T23:15:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3552935742e0d5f0dafd823736f45bdaa7ba672c'/>
<id>urn:sha1:3552935742e0d5f0dafd823736f45bdaa7ba672c</id>
<content type='text'>
Fix the situation when clear_bit() is called for page-&gt;private before
the page pointer is actually assigned.  While at it, remove work_busy()
check because it is costly and does not give 100% guarantee anyway.

Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Dan Streetman &lt;ddstreet@ieee.org&gt;
Cc: &lt;Oleksiy.Avramchenko@sony.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>z3fold: fix potential race in z3fold_reclaim_page</title>
<updated>2017-10-04T00:54:24Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2017-10-03T23:14:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d5567c9df1ef001b2a7e6684b3b3498371ee4cae'/>
<id>urn:sha1:d5567c9df1ef001b2a7e6684b3b3498371ee4cae</id>
<content type='text'>
It is possible that on a (partially) unsuccessful page reclaim,
kref_put() called in z3fold_reclaim_page() does not yield page release,
but the page is released shortly afterwards by another thread.  Then
z3fold_reclaim_page() would try to list_add() that (released) page again
which is obviously a bug.

To avoid that, spin_lock() has to be taken earlier, before the
kref_put() call mentioned earlier.

Link: http://lkml.kernel.org/r/20170913162937.bfff21c7d12b12a5f47639fd@gmail.com
Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Dan Streetman &lt;ddstreet@ieee.org&gt;
Cc: &lt;Oleksiy.Avramchenko@sony.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>z3fold: use per-cpu unbuddied lists</title>
<updated>2017-09-07T00:27:30Z</updated>
<author>
<name>Vitaly Wool</name>
</author>
<published>2017-09-06T23:24:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d30561c56f4114f7d6595a40498ba364ffa6e28e'/>
<id>urn:sha1:d30561c56f4114f7d6595a40498ba364ffa6e28e</id>
<content type='text'>
It's been noted that z3fold doesn't scale well when it's run in a large
number of threads on many cores, which can be easily reproduced with fio
'randrw' test with --numjobs=32.  E.g.  the result for 1 cluster (4 cores)
is:

Run status group 0 (all jobs):
   READ: io=244785MB, aggrb=496883KB/s, minb=15527KB/s, ...
  WRITE: io=246735MB, aggrb=500841KB/s, minb=15651KB/s, ...

While for 8 cores (2 clusters) the result is:

Run status group 0 (all jobs):
   READ: io=244785MB, aggrb=265942KB/s, minb=8310KB/s, ...
  WRITE: io=246735MB, aggrb=268060KB/s, minb=8376KB/s, ...

The bottleneck here is the pool lock which many threads become waiting
upon.  To reduce that spin lock contention, z3fold can operate only on
the lists local to the current CPU whenever possible.  Due to the nature
of z3fold unbuddied list handling (it only takes the first entry off the
list on a hot path), if the z3fold pool is big enough and balanced well
enough, limiting search to only local unbuddied list doesn't lead to a
significant compression ratio degrade (2.57x vs 2.65x in our
measurements).

This patch also introduces two worker threads: one for async in-page
object layout optimization and one for releasing freed pages.  This is
done to speed up z3fold_free() which is often on a hot path.

The fio results for 8-core case are now the following:

Run status group 0 (all jobs):
   READ: io=244785MB, aggrb=1568.3MB/s, minb=50182KB/s, ...
  WRITE: io=246735MB, aggrb=1580.8MB/s, minb=50582KB/s, ...

So we're in for almost 6x performance increase.

Link: http://lkml.kernel.org/r/20170806181443.f9b65018f8bde25ef990f9e8@gmail.com
Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Dan Streetman &lt;ddstreet@ieee.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>
</feed>
