From patchwork Sat Jun 24 05:12:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13291599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34CA5C001B3 for ; Sat, 24 Jun 2023 05:31:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94D358D0006; Sat, 24 Jun 2023 01:31:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FDF08D0001; Sat, 24 Jun 2023 01:31:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79DCA8D0006; Sat, 24 Jun 2023 01:31:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6BAFE8D0001 for ; Sat, 24 Jun 2023 01:31:36 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4C8761C932A for ; Sat, 24 Jun 2023 05:31:36 +0000 (UTC) X-FDA: 80936518992.23.E135569 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 5A11B16001E for ; Sat, 24 Jun 2023 05:31:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Tkj6/aDL"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf08.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.222.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687584693; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DWxKMGlhVIOcwxYZSkni1ma+NCE3p+LmC8CwV158uoQ=; b=bsssgJ9Xh/RCPZfr9JpkViSC5HnNwT4u/+CqYLwSXzU6yIX613d5GZokjBvrMK+kZgWtHf qDKr/asHIaVZmBcDNGIIX6y/fT/i8Y/5zaR3THulfHX4aeyTNc7wopaaXkPFbIEc9WpPti 2fxZzTMcgzIRKJ6d7IEofIU3mJAZdWg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Tkj6/aDL"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf08.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.222.173 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687584693; a=rsa-sha256; cv=none; b=A6f4s4+wTcgH7iAGPdVidUupAppCeGJbm5EtGDWqqvbKVP7b4cwAt8C4GotOJFtiJyj4Hc o5PB1W4dIQcD0kc/4vPNV4GjL+pYD0gdAx6nRNw2ANK1Y3Qtte777D9RUyZse8pm+BvUl9 CG1hfEB67bHgSe9gW2b+SxorlvGVhzc= Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7624af57b21so124706485a.1 for ; Fri, 23 Jun 2023 22:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687584692; x=1690176692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DWxKMGlhVIOcwxYZSkni1ma+NCE3p+LmC8CwV158uoQ=; b=Tkj6/aDLrxhyMZp9C0Bu7YwtXXituRwejp04Q9FvaCfS63ZOBmOGbRv0zf+BfnHFn3 Dm3Y+hAKYvuBGfNyxiguJGE5Drz60p9JekBkkqhLQ2R6o3wYXZ5geKHjrtuZ9xwR6qDB 5A84oWan6OPS9WS8PXeYJtB6IXqRpOLT3EcjY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687584692; x=1690176692; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DWxKMGlhVIOcwxYZSkni1ma+NCE3p+LmC8CwV158uoQ=; b=doTQfEBsF84Q4qfQT2v8zS59VS2MLM/8+cxlYbxgS3SX1Jc++ziygJkQDWf1Qe7Awy 5cI/z7b2q4u60SE798lABVu6tePGyyJhLDqBPSV6bAPdykyDEBiis6SYrNvjuDWAea/o x2cdGkSk0M7lpUvgymeY3vg06k4xmOkHci2DWKO0n51YnszTNXb7ah9/B/6hOdT0IMR+ 5oPYb7bMZh0NpeEDEkU/iKsYbD8n1WJdvjJ/S/HTfGHdGYZGAddpz3nxG5FsxHEEPPKh 4g5hN2c+43zDn5B/wAPEzeqwRm5eRKZWCkufknvTBnUhm9aJaqalyqqa1dDeblfDtBY7 yseA== X-Gm-Message-State: AC+VfDxSmLhAxowYpzMRyd2GmoMZ+iNfK+AdWFLpIc74JleDv2l29z+D kBWZNDDipvhuBtRna6R05t2K4695o7OUn7UUWjc= X-Google-Smtp-Source: ACHHUZ6cpRSLnEvIdQL6C5yzq2Jz418DRJ8c8EEo6m/ckQabR2EwOmEVP4W9pYHLeacaP+WSoxKr7w== X-Received: by 2002:a05:620a:4451:b0:763:dfe8:7be6 with SMTP id w17-20020a05620a445100b00763dfe87be6mr12050561qkp.20.1687584692322; Fri, 23 Jun 2023 22:31:32 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:d7fc:8a97:4a18:6a18]) by smtp.gmail.com with ESMTPSA id 16-20020a17090a0c1000b002563e8a0225sm567069pjs.48.2023.06.23.22.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 22:31:32 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCHv2 3/3] zsmalloc: remove zs_compact_control Date: Sat, 24 Jun 2023 14:12:16 +0900 Message-ID: <20230624053120.643409-4-senozhatsky@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230624053120.643409-1-senozhatsky@chromium.org> References: <20230624053120.643409-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5A11B16001E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 658r5c7fm94omarpxq4cc99nnzsep5xw X-HE-Tag: 1687584693-266168 X-HE-Meta: U2FsdGVkX18O+XOxqoe6R3wFn9ZVbwP790mX1Bk7KuwkxD+zbfT0EU2vfrrnC5+1KGcmWwB5jp0RVIKJqak7tu5amx0qxGHkoE3ehPMLuvr3PCsDNgegW1ubKxVIO7wbaA0MjLUkDLq1EmWtde2DszyAqsZ0FKYIK/z1Ctf0c+DVhUT5EMhNnAZr+sPyJlYw33Xkgh9cQhF0QONsThsR2V47wq0n3jtlUGD/3ZjKA170lm6l2HjMqWj7XkJ1dzWFEHsO4RTHin0hTflPBIbF66qfUQ22Wu6CW2ZR7IYOG2sqrRMyATm5DlwQexgXvgUW2YZuV1db2gO5OfKTTcgO+Bk5Znn3T98S0BEz/zrsY+DUGa2oFggHUELAqfoWTVXO972r2pRSdBYGKSFxmy8OztMNCVYsxPVEzq6iklLDaIh/w9SplCfyqd7mS6Ho+0AZ0yhdk7MUt7Zsf9/wpxM9d6PyaLyrErSn+rp3e2d4jJaHlMRErLsteaqdecuvr+a6/pYl3qJgF47dT/nr65XchAlx6FmhWqIKJyzDx2I+/WaCygTDmg70tbnaQfU6cnzXyX8lqRCZ89AdVjYCZrEFfMs3i2A0Q8arv9i6wuLRPPK2ZDGkLb1ZYcIJzRJbqrUlNTQSRlCBKcOENd0ZjRwEiJxR1mI6tE6hQkOf05SwRG4x2MWM7aq2CTGRTdGPzoEo1R1ylGhdyPjvHO4uOYmRAraYaJgb2uSJ6bBqhjeNsBi4s8cU56gBnd+VE19DPbH7JoRde6v9Y57MGNELDvgu5OImHROE4nefkg2YZaFOD6Pth9oAmhAszpSS73o680Obpph7hBmvPjHC0bapDjmYRZo6stXopTYMDWmdqPqpONFVs4VMtCKsHY5N4jycyzZLtG1tOqq/skuguvvAzhBTiOrRZ6U1nQjqeukh1M9G35LaSTc5isvmTvpgalIgyfzkyO1jNuyZo71VWw5r6Qc +SMXx3Mn MBEc7v5F2m5PcXu5PhWP5IJGTQokJOzZ1EzDTj1B2ruzFZyTBUI0mWX44z7ahwSdXIyQQGgGehEdBFq4VJN3qfn1OVoRV4LPavXZVTe2NtPaPrvPzW4oSjAWp4JB/hw21OcY4W7BrkW6vJE3XHsNwVLzxHZrs79bxS+9R4l/GIPB550arli2vuuHXkp+uLsvxy9RAAFE8csCvaxi1GXE6fLntu3fIegG2rGhZZ+z65qwaqPVu18bL9SJhDqM4up3qlTveqbkPhizeTxOcSZunVrigGRIgT6rcrwMZENWcyJfTaUKihECuWWs25uy95zkzZYQZ5/VZ30I/ir8LP/haFogM8kGQJVP9MenfwSLEWabcWXcyECynWhkna4pTnWlz/Vxb4K7zAMjskQ15Ax803LWgsUQrbREC3Cf1aGqG4C3LOXCiOrwjj0u7omka0u8l3xs1t3CxOHsZvAQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Minchan Kim __zs_compact always putback src_zspage into class list after migrate_zspage. Thus, we don't need to keep last position of src_zspage any more. Let's remove it. Signed-off-by: Minchan Kim Acked-by: Sergey Senozhatsky --- mm/zsmalloc.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 4a84f7877669..84beadc088b8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1590,25 +1590,14 @@ static unsigned long find_alloced_obj(struct size_class *class, return find_tagged_obj(class, page, obj_idx, OBJ_ALLOCATED_TAG); } -struct zs_compact_control { - /* Source spage for migration which could be a subpage of zspage */ - struct page *s_page; - /* Destination page for migration which should be a first page - * of zspage. */ - struct page *d_page; - /* Starting object index within @s_page which used for live object - * in the subpage. */ - int obj_idx; -}; - -static void migrate_zspage(struct zs_pool *pool, struct size_class *class, - struct zs_compact_control *cc) +static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, + struct zspage *dst_zspage) { unsigned long used_obj, free_obj; unsigned long handle; - struct page *s_page = cc->s_page; - struct page *d_page = cc->d_page; - int obj_idx = cc->obj_idx; + int obj_idx = 0; + struct page *s_page = get_first_page(src_zspage); + struct size_class *class = pool->size_class[src_zspage->class]; while (1) { handle = find_alloced_obj(class, s_page, &obj_idx); @@ -1621,24 +1610,20 @@ static void migrate_zspage(struct zs_pool *pool, struct size_class *class, } used_obj = handle_to_obj(handle); - free_obj = obj_malloc(pool, get_zspage(d_page), handle); + free_obj = obj_malloc(pool, dst_zspage, handle); zs_object_copy(class, free_obj, used_obj); obj_idx++; record_obj(handle, free_obj); obj_free(class->size, used_obj); /* Stop if there is no more space */ - if (zspage_full(class, get_zspage(d_page))) + if (zspage_full(class, dst_zspage)) break; /* Stop if there are no more objects to migrate */ - if (zspage_empty(get_zspage(s_page))) + if (zspage_empty(src_zspage)) break; } - - /* Remember last position in this iteration */ - cc->s_page = s_page; - cc->obj_idx = obj_idx; } static struct zspage *isolate_src_zspage(struct size_class *class) @@ -2013,7 +1998,6 @@ static unsigned long zs_can_compact(struct size_class *class) static unsigned long __zs_compact(struct zs_pool *pool, struct size_class *class) { - struct zs_compact_control cc; struct zspage *src_zspage = NULL; struct zspage *dst_zspage = NULL; unsigned long pages_freed = 0; @@ -2031,7 +2015,6 @@ static unsigned long __zs_compact(struct zs_pool *pool, if (!dst_zspage) break; migrate_write_lock(dst_zspage); - cc.d_page = get_first_page(dst_zspage); } src_zspage = isolate_src_zspage(class); @@ -2040,9 +2023,7 @@ static unsigned long __zs_compact(struct zs_pool *pool, migrate_write_lock_nested(src_zspage); - cc.obj_idx = 0; - cc.s_page = get_first_page(src_zspage); - migrate_zspage(pool, class, &cc); + migrate_zspage(pool, src_zspage, dst_zspage); fg = putback_zspage(class, src_zspage); migrate_write_unlock(src_zspage);