<feed xmlns='http://www.w3.org/2005/Atom'>
<title>BMC/Intel-BMC/linux.git/mm/z3fold.c, branch dev-5.2</title>
<subtitle>Intel OpenBMC Linux kernel source tree (mirror)</subtitle>
<id>https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev-5.2</id>
<link rel='self' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/atom?h=dev-5.2'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/'/>
<updated>2019-08-29T06:30:25+00:00</updated>
<entry>
<title>mm/z3fold.c: fix race between migration and destruction</title>
<updated>2019-08-29T06:30:25+00:00</updated>
<author>
<name>Henry Burns</name>
<email>henryburns@google.com</email>
</author>
<published>2019-08-25T00:54:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=764fa2f4ff59591fd04b504f8f8fb46ec16641a9'/>
<id>urn:sha1:764fa2f4ff59591fd04b504f8f8fb46ec16641a9</id>
<content type='text'>
commit d776aaa9895eb6eb770908e899cb7f5bd5025b3c upstream.

In z3fold_destroy_pool() we call destroy_workqueue(&amp;pool-&gt;compact_wq).
However, we have no guarantee that migration isn't happening in the
background at that time.

Migration directly calls queue_work_on(pool-&gt;compact_wq), if destruction
wins that race we are using a destroyed workqueue.

Link: http://lkml.kernel.org/r/20190809213828.202833-1-henryburns@google.com
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: fix z3fold_destroy_pool() race condition</title>
<updated>2019-08-25T14:10:21+00:00</updated>
<author>
<name>Henry Burns</name>
<email>henryburns@google.com</email>
</author>
<published>2019-08-13T22:37:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=a6b0004e741c4a42975fff5d773f2da6cf598b7c'/>
<id>urn:sha1:a6b0004e741c4a42975fff5d773f2da6cf598b7c</id>
<content type='text'>
commit b997052bc3ac444a0bceab1093aff7ae71ed419e upstream.

The constraint from the zpool use of z3fold_destroy_pool() is there are
no outstanding handles to memory (so no active allocations), but it is
possible for there to be outstanding work on either of the two wqs in
the pool.

Calling z3fold_deregister_migration() before the workqueues are drained
means that there can be allocated pages referencing a freed inode,
causing any thread in compaction to be able to trip over the bad pointer
in PageMovable().

Link: http://lkml.kernel.org/r/20190726224810.79660-2-henryburns@google.com
Fixes: 1f862989b04a ("mm/z3fold.c: support page migration")
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Reviewed-by: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Henry Burns &lt;henrywolfeburns@gmail.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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: fix z3fold_destroy_pool() ordering</title>
<updated>2019-08-25T14:10:21+00:00</updated>
<author>
<name>Henry Burns</name>
<email>henryburns@google.com</email>
</author>
<published>2019-08-13T22:37:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=d87e9ae7f6059350188379fd28d813ca7776de0a'/>
<id>urn:sha1:d87e9ae7f6059350188379fd28d813ca7776de0a</id>
<content type='text'>
commit 6051d3bd3b91e96c59e62b8be2dba1cc2b19ee40 upstream.

The constraint from the zpool use of z3fold_destroy_pool() is there are
no outstanding handles to memory (so no active allocations), but it is
possible for there to be outstanding work on either of the two wqs in
the pool.

If there is work queued on pool-&gt;compact_workqueue when it is called,
z3fold_destroy_pool() will do:

   z3fold_destroy_pool()
     destroy_workqueue(pool-&gt;release_wq)
     destroy_workqueue(pool-&gt;compact_wq)
       drain_workqueue(pool-&gt;compact_wq)
         do_compact_page(zhdr)
           kref_put(&amp;zhdr-&gt;refcount)
             __release_z3fold_page(zhdr, ...)
               queue_work_on(pool-&gt;release_wq, &amp;pool-&gt;work) *BOOM*

So compact_wq needs to be destroyed before release_wq.

Link: http://lkml.kernel.org/r/20190726224810.79660-1-henryburns@google.com
Fixes: 5d03a6613957 ("mm/z3fold.c: use kref to prevent page free/compact race")
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Reviewed-by: Jonathan Adams &lt;jwadams@google.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk
Cc: Henry Burns &lt;henrywolfeburns@gmail.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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>mm/z3fold.c: reinitialize zhdr structs after migration</title>
<updated>2019-08-06T17:08:10+00:00</updated>
<author>
<name>Henry Burns</name>
<email>henryburns@google.com</email>
</author>
<published>2019-07-16T23:26:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=8a3dfde5a2b2b914ff1a8c9112dd9c0b08580a11'/>
<id>urn:sha1:8a3dfde5a2b2b914ff1a8c9112dd9c0b08580a11</id>
<content type='text'>
[ Upstream commit c92d2f38563db20c20c8db2f98fa1349290477d5 ]

z3fold_page_migration() calls memcpy(new_zhdr, zhdr, PAGE_SIZE).
However, zhdr contains fields that can't be directly coppied over (ex:
list_head, a circular linked list).  We only need to initialize the
linked lists in new_zhdr, as z3fold_isolate_page() already ensures that
these lists are empty

Additionally it is possible that zhdr-&gt;work has been placed in a
workqueue.  In this case we shouldn't migrate the page, as zhdr-&gt;work
references zhdr as opposed to new_zhdr.

Link: http://lkml.kernel.org/r/20190716000520.230595-1-henryburns@google.com
Fixes: 1f862989b04ade61d3 ("mm/z3fold.c: support page migration")
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Cc: Jonathan Adams &lt;jwadams@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;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>mm/z3fold: don't try to use buddy slots after free</title>
<updated>2019-08-06T17:08:10+00:00</updated>
<author>
<name>Vitaly Wool</name>
<email>vitalywool@gmail.com</email>
</author>
<published>2019-07-16T23:25:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=8bd71641fc130b609246bb3433d09d06a5567a7a'/>
<id>urn:sha1:8bd71641fc130b609246bb3433d09d06a5567a7a</id>
<content type='text'>
[ Upstream commit bb9a374dfa3a2f46581455ab66cd1d24c5e3d183 ]

As reported by Henry Burns:

Running z3fold stress testing with address sanitization showed zhdr-&gt;slots
was being used after it was freed.

  z3fold_free(z3fold_pool, handle)
    free_handle(handle)
      kmem_cache_free(pool-&gt;c_handle, zhdr-&gt;slots)
    release_z3fold_page_locked_list(kref)
      __release_z3fold_page(zhdr, true)
        zhdr_to_pool(zhdr)
          slots_to_pool(zhdr-&gt;slots)  *BOOM*

To fix this, add pointer to the pool back to z3fold_header and modify
zhdr_to_pool to return zhdr-&gt;pool.

Link: http://lkml.kernel.org/r/20190708134808.e89f3bfadd9f6ffd7eff9ba9@gmail.com
Fixes: 7c2b8baa61fe  ("mm/z3fold.c: add structure for buddy handles")
Signed-off-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Reported-by: Henry Burns &lt;henryburns@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Jonathan Adams &lt;jwadams@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;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>mm/z3fold.c: lock z3fold page before __SetPageMovable()</title>
<updated>2019-07-26T07:11:07+00:00</updated>
<author>
<name>Henry Burns</name>
<email>henryburns@google.com</email>
</author>
<published>2019-07-12T03:52:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=6d468c7832f4bc1d3821e21810f92f11bbcc1add'/>
<id>urn:sha1:6d468c7832f4bc1d3821e21810f92f11bbcc1add</id>
<content type='text'>
commit 810481a246089117d98e3373a3cb735c3efc1f90 upstream.

Following zsmalloc.c's example we call trylock_page() and unlock_page().
Also make z3fold_page_migrate() assert that newpage is passed in locked,
as per the documentation.

[akpm@linux-foundation.org: fix trylock_page return value test, per Shakeel]
Link: http://lkml.kernel.org/r/20190702005122.41036-1-henryburns@google.com
Link: http://lkml.kernel.org/r/20190702233538.52793-1-henryburns@google.com
Signed-off-by: Henry Burns &lt;henryburns@google.com&gt;
Suggested-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Acked-by: Vitaly Wool &lt;vitalywool@gmail.com&gt;
Acked-by: David Rientjes &lt;rientjes@google.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Vitaly Vul &lt;vitaly.vul@sony.com&gt;
Cc: Mike Rapoport &lt;rppt@linux.vnet.ibm.com&gt;
Cc: Xidong Wang &lt;wangxidong_97@163.com&gt;
Cc: Jonathan Adams &lt;jwadams@google.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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>z3fold: fix sheduling while atomic</title>
<updated>2019-06-01T22:51:31+00:00</updated>
<author>
<name>Vitaly Wool</name>
<email>vitalywool@gmail.com</email>
</author>
<published>2019-06-01T05:30:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=bb9f6f63f32da40ca34a921e377ad3181a4f9023'/>
<id>urn:sha1:bb9f6f63f32da40ca34a921e377ad3181a4f9023</id>
<content type='text'>
kmem_cache_alloc() may be called from z3fold_alloc() in atomic context, so
we need to pass correct gfp flags to avoid "scheduling while atomic" bug.

Link: http://lkml.kernel.org/r/20190523153245.119dfeed55927e8755250ddd@gmail.com
Fixes: 7c2b8baa61fe5 ("mm/z3fold.c: add structure for buddy handles")
Signed-off-by: Vitaly Wool &lt;vitaly.vul@sony.com&gt;
Reviewed-by: Andrew Morton &lt;akpm@linux-foundation.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>treewide: Add SPDX license identifier for more missed files</title>
<updated>2019-05-21T08:50:45+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2019-05-19T12:08:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=09c434b8a0047c69e48499de0107de312901e798'/>
<id>urn:sha1:09c434b8a0047c69e48499de0107de312901e798</id>
<content type='text'>
Add SPDX license identifiers to all files which:

 - Have no license information of any form

 - Have MODULE_LICENCE("GPL*") inside which was used in the initial
   scan/conversion to ignore the file

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

  GPL-2.0-only

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>mm/z3fold.c: support page migration</title>
<updated>2019-05-14T16:47:50+00:00</updated>
<author>
<name>Vitaly Wool</name>
<email>vitalywool@gmail.com</email>
</author>
<published>2019-05-14T00:22:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=1f862989b04ade61d3aab49184c50e9957f84c7d'/>
<id>urn:sha1:1f862989b04ade61d3aab49184c50e9957f84c7d</id>
<content type='text'>
Now that we are not using page address in handles directly, we can make
z3fold pages movable to decrease the memory fragmentation z3fold may
create over time.

This patch starts advertising non-headless z3fold pages as movable and
uses the existing kernel infrastructure to implement moving of such pages
per memory management subsystem's request.  It thus implements 3 required
callbacks for page migration:

* isolation callback: z3fold_page_isolate(): try to isolate the page by
  removing it from all lists.  Pages scheduled for some activity and
  mapped pages will not be isolated.  Return true if isolation was
  successful or false otherwise

* migration callback: z3fold_page_migrate(): re-check critical
  conditions and migrate page contents to the new page provided by the
  memory subsystem.  Returns 0 on success or negative error code otherwise

* putback callback: z3fold_page_putback(): put back the page if
  z3fold_page_migrate() for it failed permanently (i.  e.  not with
  -EAGAIN code).

[lkp@intel.com: z3fold_page_isolate() can be static]
  Link: http://lkml.kernel.org/r/20190419130924.GA161478@ivb42
Link: http://lkml.kernel.org/r/20190417103922.31253da5c366c4ebe0419cfc@gmail.com
Signed-off-by: Vitaly Wool &lt;vitaly.vul@sony.com&gt;
Signed-off-by: kbuild test robot &lt;lkp@intel.com&gt;
Cc: Bartlomiej Zolnierkiewicz &lt;b.zolnierkie@samsung.com&gt;
Cc: Dan Streetman &lt;ddstreet@ieee.org&gt;
Cc: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Cc: Oleksiy Avramchenko &lt;oleksiy.avramchenko@sonymobile.com&gt;
Cc: Uladzislau Rezki &lt;urezki@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>mm/z3fold.c: add structure for buddy handles</title>
<updated>2019-05-14T16:47:50+00:00</updated>
<author>
<name>Vitaly Wool</name>
<email>vitalywool@gmail.com</email>
</author>
<published>2019-05-14T00:22:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/BMC/Intel-BMC/linux.git/commit/?id=7c2b8baa61fe578af905342938ad12f8dbaeae79'/>
<id>urn:sha1:7c2b8baa61fe578af905342938ad12f8dbaeae79</id>
<content type='text'>
For z3fold to be able to move its pages per request of the memory
subsystem, it should not use direct object addresses in handles.  Instead,
it will create abstract handles (3 per page) which will contain pointers
to z3fold objects.  Thus, it will be possible to change these pointers
when z3fold page is moved.

Link: http://lkml.kernel.org/r/20190417103826.484eaf18c1294d682769880f@gmail.com
Signed-off-by: Vitaly Wool &lt;vitaly.vul@sony.com&gt;
Cc: Bartlomiej Zolnierkiewicz &lt;b.zolnierkie@samsung.com&gt;
Cc: Dan Streetman &lt;ddstreet@ieee.org&gt;
Cc: Krzysztof Kozlowski &lt;k.kozlowski@samsung.com&gt;
Cc: Oleksiy Avramchenko &lt;oleksiy.avramchenko@sonymobile.com&gt;
Cc: Uladzislau Rezki &lt;urezki@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>
</feed>
