Skip to content

Commit

Permalink
mm/zsmalloc: take obj index back from find_alloced_obj
Browse files Browse the repository at this point in the history
the obj index value should be updated after return from
find_alloced_obj() to avoid CPU burning caused by unnecessary object
scanning.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ganesh Mahendran <[email protected]>
Reviewed-by: Sergey Senozhatsky <[email protected]>
Acked-by: Minchan Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
yzkqfll authored and gj86 committed Nov 27, 2017
1 parent 7abf51a commit 01147c0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1577,10 +1577,11 @@ static void zs_object_copy(struct size_class *class, unsigned long dst,
* return handle.
*/
static unsigned long find_alloced_obj(struct size_class *class,
struct page *page, int index)
struct page *page, int *obj_idx)
{
unsigned long head;
int offset = 0;
int index = *obj_idx;
unsigned long handle = 0;
void *addr = kmap_atomic(page);

Expand All @@ -1601,6 +1602,9 @@ static unsigned long find_alloced_obj(struct size_class *class,
}

kunmap_atomic(addr);

*obj_idx = index;

return handle;
}

Expand All @@ -1626,7 +1630,7 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class,
int ret = 0;

while (1) {
handle = find_alloced_obj(class, s_page, obj_idx);
handle = find_alloced_obj(class, s_page, &obj_idx);
if (!handle) {
s_page = get_next_page(s_page);
if (!s_page)
Expand Down

0 comments on commit 01147c0

Please sign in to comment.