linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] zsmalloc: fix linking bug in init_zspage
@ 2018-08-10  0:28 zhouxianrong
  2018-08-13  6:05 ` Minchan Kim
  0 siblings, 1 reply; 8+ messages in thread
From: zhouxianrong @ 2018-08-10  0:28 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, minchan, ngupta, sergey.senozhatsky.work,
	zhouxianrong, zhouxianrong

From: zhouxianrong <zhouxianrong@huawei.com>

The last partial object in last subpage of zspage should not be linked
in allocation list. Otherwise it could trigger BUG_ON explicitly at
function zs_map_object. But it happened rarely.

Signed-off-by: zhouxianrong <zhouxianrong@huawei.com>
---
 mm/zsmalloc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 8d87e973a4f5..24dd8da0aa59 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1040,6 +1040,8 @@ static void init_zspage(struct size_class *class, struct zspage *zspage)
 			 * Reset OBJ_TAG_BITS bit to last link to tell
 			 * whether it's allocated object or not.
 			 */
+			if (off > PAGE_SIZE)
+				link -= class->size / sizeof(*link);
 			link->next = -1UL << OBJ_TAG_BITS;
 		}
 		kunmap_atomic(vaddr);
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH] zsmalloc: fix linking bug in init_zspage
@ 2018-08-09 13:53 zhouxianrong
  2018-08-09 14:41 ` Vlastimil Babka
  0 siblings, 1 reply; 8+ messages in thread
From: zhouxianrong @ 2018-08-09 13:53 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, minchan, ngupta, sergey.senozhatsky.work, zhouxianrong

The last partial object in last subpage of zspage should not be linked
in allocation list.

Signed-off-by: zhouxianrong <zhouxianrong@tom.com>
---
 mm/zsmalloc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 8d87e973a4f5..24dd8da0aa59 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1040,6 +1040,8 @@ static void init_zspage(struct size_class *class, struct zspage *zspage)
 			 * Reset OBJ_TAG_BITS bit to last link to tell
 			 * whether it's allocated object or not.
 			 */
+			if (off > PAGE_SIZE)
+				link -= class->size / sizeof(*link);
 			link->next = -1UL << OBJ_TAG_BITS;
 		}
 		kunmap_atomic(vaddr);
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-16  3:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10  0:28 [PATCH] zsmalloc: fix linking bug in init_zspage zhouxianrong
2018-08-13  6:05 ` Minchan Kim
2018-08-13 10:55   ` Sergey Senozhatsky
2018-08-14  0:24     ` Minchan Kim
2018-08-14  0:51       ` Sergey Senozhatsky
     [not found]       ` <1784999539.213028.1534378242020.JavaMail.root@rz-web2>
2018-08-16  3:46         ` Minchan Kim
  -- strict thread matches above, loose matches on Subject: below --
2018-08-09 13:53 zhouxianrong
2018-08-09 14:41 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).