From patchwork Fri Jun 23 04:40:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13289966 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 67C63EB64D7 for ; Fri, 23 Jun 2023 04:40:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA4178D0003; Fri, 23 Jun 2023 00:40:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D51C98D0001; Fri, 23 Jun 2023 00:40:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCB9E8D0003; Fri, 23 Jun 2023 00:40:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AD6708D0001 for ; Fri, 23 Jun 2023 00:40:36 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6AF29B074E for ; Fri, 23 Jun 2023 04:40:36 +0000 (UTC) X-FDA: 80932761672.11.F2B6675 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) by imf09.hostedemail.com (Postfix) with ESMTP id A824C14000C for ; Fri, 23 Jun 2023 04:40:34 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Cbp1e0QD; spf=pass (imf09.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.52 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687495234; a=rsa-sha256; cv=none; b=1HtiJEbWwKKvPM9OBEeV3+NQWrCLKd3jliw9tAey4f3t/s/FtVkONavo4EUZBugUgecNzp Wd09yB5MuH2GERjsKvtEG6vgqLEcxjzGvcrJcjc4iFYZDO/cDdF0AvUsINk5hwl3+VCsCm XEAYJh4BYNYDhqwf/tqeV9k1GcubOnA= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Cbp1e0QD; spf=pass (imf09.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.52 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687495234; 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=A39gdokmxlm4U38P/Zql/B/dp1bRrgyGGMBd2ncXVBo=; b=ZhbcLK5Ux3qnjGov5wrkfG+bW+u61l+Yw7KodFRE+GskkILE/BmrEMlwn9psDeHEXbTY0z +2GNjJB+58M6B5DnyeHKDsdWj4MKGE0X3QqOcdfzutvFcBo9/GqgsoblaGc2HKIj4jiSst 2XUw/JoCxLNQUn54AZXf7cs8/+IlVwg= Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6b5d7e60015so296598a34.0 for ; Thu, 22 Jun 2023 21:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687495233; x=1690087233; 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=A39gdokmxlm4U38P/Zql/B/dp1bRrgyGGMBd2ncXVBo=; b=Cbp1e0QDlBoMFSQUoDU44b/Cu4zloKVkubwfpVG0voArrICkUtyxlHNDLJm7uQaPWs yMtq2C3UOdpl3PwFBZ6fbcJm75BISUhsaIgsCU5qiVlrVsBW+skGS0Karwa520O8DOTP ScA5bFfNO0Evz3c7RIm+D6tZD1CBxKd0YmmyQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687495233; x=1690087233; 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=A39gdokmxlm4U38P/Zql/B/dp1bRrgyGGMBd2ncXVBo=; b=Tbrmufb9ppJJge0KQqYSH4T3n2ezFASkyQ+shH0RD4xMWn2ebdnzDDHGeWS1O5jWYb CiXDOqXka26+6RVdIcM2vhDIgeby+WpKRVDNXWc2LbEEC+guLvS7HZlMKE3d6aDFg30E NY/ZLgyq5jyP4oF6rLlzYFqfnhj8sbe2f9ZpfZ9UHRXRsSBiDlvXyaeCFrVE9Vwy0wD0 s8PGTnQhx2fDPkLeiS3G1xjmcM11zpPsTslJHxQr3RLmqJajsyjixem52BJGqP2Rl8gK kmKEL4PUXbXs9V2shRdC6X5zgfeaI9rmOwGtcc+l2PzZImzqt5dsHxPUuV1kkxjcXhpK Tyxw== X-Gm-Message-State: AC+VfDzJB1GY4EP1TSR0LLxcOuM40FdzV3xUdcgBq2KrB4CFNUGTZJ1N 4TaQkZ15VSJi7RT6TS3+1hJ84w== X-Google-Smtp-Source: ACHHUZ40SAmzVB3zyhbJ6Kmva/XRtgJ/rNm6Czlb8EAz6WtSXnsypo+QCnvyyJ2uHG4IQuWlO/8oRA== X-Received: by 2002:a05:6358:edc:b0:12b:c378:b090 with SMTP id 28-20020a0563580edc00b0012bc378b090mr14548296rwh.26.1687495233523; Thu, 22 Jun 2023 21:40:33 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:3383:b451:fa2:1538]) by smtp.gmail.com with ESMTPSA id q25-20020a62ae19000000b00666e17004a4sm4237350pff.58.2023.06.22.21.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 21:40:33 -0700 (PDT) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky , Alexey Romanov Subject: [PATCH 1/2] zsmalloc: do not scan for allocated objects in empty zspage Date: Fri, 23 Jun 2023 13:40:01 +0900 Message-ID: <20230623044016.366793-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230623044016.366793-1-senozhatsky@chromium.org> References: <20230623044016.366793-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A824C14000C X-Stat-Signature: p8pwipei1unfiw91d6m3b1yqb8cdu84o X-Rspam-User: X-HE-Tag: 1687495234-672011 X-HE-Meta: U2FsdGVkX1+BTufaORp4Zv1RWFufrkYtzt+bQo7eZwASWlXVFX5R33NFKPf20fMDbeHyPdbHwYUemlxHB3WdqkBqJeSdKNJobKtIBPmtNeT/1SJDjTJiAAdgDgGUXhcz0tnfCr+fOf1lz5LbzYya4mQk2Td9srW+TuwkN9oAsf7BkmIJYnMN6fxMmZutfD4omHIOf08sk36/gJ/ONVF7VUxmuzq3nw8mtpSAS78dGOUYdkbah5kFzqIkHvVStRRJvg3WyblK+jBxhpJ6nQ428yXhwd46gsKRs+s6DLijwr8fkNU8/VUsciDT1Vgk3eOwqvaAXCOl2SQFlcwBrFqOQZXm1oJQJp0O+ZG+LM/uqwaJ7hMpa1YtQGZTslU+cs6VNnnZARNoos+g7soedUucO+xnNJ26rGUFhc5ZRDYY+p1sWWb9Hg2QmAVTVFFW7znneyOUu9vc1hoDorFKUOXNaoLfNiR2WnEUHRcRYEthhrwFdqwKgtt2HWnSzF8ZnOGzmWI6HWPu19ldphODARfwCSyAmI6a8iZU8oOH0wCWzTXY4Y1YUxdEg8QsTMXF886e6BBMajkg4lAKVIlGMZtKCYsDmCrE/V3ksn7ieWpHgbB9BAUDzQBLxUM2reYDSc0NGfREZE7mbM8DOFS6XpLKRjPyyPw/jE169MfmEH9OGN3MAkG9Zmc+CJogf6Kkq6NfcAc2XQJy6TXNmkA8QFWWKS/dKV3sI8q9B1vmwSCeKwSOn+JDT6cu00US2tdqjE6C0RWR9n+Hx5vZCKSbCEXpvAcDygcu06hojc4FqPu1Fyf+AlSwDuQd8wbBCZdpwTY6Spfi3T8jQrXs9zTVwQIzwKmsYg3DBJ8Dcn6+ZhKHewVgo5YPrRBNvFKj+3YKNI1ZpE2jJWAw4kQDiyVwYjeZFlajgGsvqpGYGximy1pS7o6MwTLlUD5Z/iB8EImRR7Z/ClEMe4eehKYPWHeAcAE brI1cxmr b50XdI+XxZ++mGNoKzIdOYKJ1U6cKxPx4rZdKR8Jo3XfZ8rDHdqwrst/qRd3sJVEodfjQEaD5JKkJFgF6RoPNIXiJV9cig7E0PCtt/RD2NxOjdyXePE67ELJmlcvgpaXaw7JrdhaqcuI9JB0CIVf07YWbCo4DR10mqF5dTnHil9gJI40Hbpz0yHrxSkfng8j/c25sy213jDkkj9jhnv7nUdfsEhe3y4XO8kVLFIkLr5FGTqLfvlE94v5U6gRuz0esAQEiZ9AxVz0T4MOXUoUFYgmv0B7WULJgGfLuzEc/dvBIhMUtF97zDHoGDaoDh28vBszOG7Bsqxdk8LBj+je4FSz7wQtyMhB4VN9VjaMjm+6vKnLIlh6TqnIy2wwPjEnOr1D4gWpsH5ekw946AkwL/3YLLvgIAzIT6Erbmw+C04AQZ295pHetrKQyYfo24wnbGTqzjEzFz/utpthOBAHPVcbmpQ== 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: zspage migration can terminate as soon as it moves the last allocated object from the source zspage. Add a simple helper zspage_empty() that tests zspage ->inuse on each migration iteration. Suggested-by: Alexey Romanov Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3f057970504e..5d60eaedc3b7 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1147,6 +1147,11 @@ static bool zspage_full(struct size_class *class, struct zspage *zspage) return get_zspage_inuse(zspage) == class->objs_per_zspage; } +static bool zspage_empty(struct zspage *zspage) +{ + return get_zspage_inuse(zspage) == 0; +} + /** * zs_lookup_class_index() - Returns index of the zsmalloc &size_class * that hold objects of the provided size. @@ -1625,6 +1630,10 @@ static void migrate_zspage(struct zs_pool *pool, struct size_class *class, obj_idx++; record_obj(handle, free_obj); obj_free(class->size, used_obj); + + /* Stop if there are no more objects to migrate */ + if (zspage_empty(get_zspage(s_page))) + break; } /* Remember last position in this iteration */ From patchwork Fri Jun 23 04:40:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13289967 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 EBCCBEB64D7 for ; Fri, 23 Jun 2023 04:40:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C0588D0005; Fri, 23 Jun 2023 00:40:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86FB88D0001; Fri, 23 Jun 2023 00:40:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E9AA8D0005; Fri, 23 Jun 2023 00:40:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5FD3B8D0001 for ; Fri, 23 Jun 2023 00:40:43 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 25A99120CA6 for ; Fri, 23 Jun 2023 04:40:43 +0000 (UTC) X-FDA: 80932761966.16.67C80D0 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf30.hostedemail.com (Postfix) with ESMTP id 3E95880004 for ; Fri, 23 Jun 2023 04:40:40 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JZkAmcGH; spf=pass (imf30.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.170 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687495241; 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=JXozlQ7AGAAc+Nx/NUdVZ9+4KpO/wevqL//8Wl3bnA8=; b=5jfDkeEBr0yTeh9crBg11+XYI28H1DQCKZE+Ursoq3RMO4gdQhcc6hR21kiqOX8rdlALOi 4t5b19juUhPCj7qhRUh+g+ZQwSG8sFtiy1bJO8CoaRqaPem1oo41eMnpmMGt5h4pNi8aAy C6NzPcsFt2HfmdQfuCvNdSpCsymVMyQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JZkAmcGH; spf=pass (imf30.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.170 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687495241; a=rsa-sha256; cv=none; b=ihvaBCXVbKnODtQsym9q6xX1EOIBeiZh8+hLjk1pf3FFSod8Ih0BLba66TYTi4Wyrzwqgl vssm0BNZkIXU52f/Khbbvsr6o1RKk+2POihH5cj7eM8Hdg0anuit30uBO3LDO82HMiB5Xx ZkO9F5Ix92uidtDWqWJDP/y+J1LsKtA= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-666edfc50deso212115b3a.0 for ; Thu, 22 Jun 2023 21:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687495240; x=1690087240; 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=JXozlQ7AGAAc+Nx/NUdVZ9+4KpO/wevqL//8Wl3bnA8=; b=JZkAmcGHq0XM4nsbfCm1f7kHv9MXYtpNPYSkjpMZEj94i95KEaw66wEhaDEXP14a0u v8UJKbJSz5QSo+cbz1k/Jn3kM0ZCI73rrZrfiPok1GnRO+rKCsXMtzz+f6LH0ISwHvNg PomoU6ex9zABeAcfQIPJ3ly1lyoWkasiGVFMY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687495240; x=1690087240; 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=JXozlQ7AGAAc+Nx/NUdVZ9+4KpO/wevqL//8Wl3bnA8=; b=R7UGcu0kiBnYuEwhsdaiMc99aGnLBGySW4zZ0vUzga5bC92hqsWZVXX7REA3naMS9L a+O4I6G5srPzZAXjo+C9XibDH0QNgkh0D7L7+NtfjqGeGl+zfgYvXriBcfdtiXKis23F a2fBdUJbPwWj6kmeK0eUkU3cXSxmNcGU8Q+FULvs1I8QBL/SgZBq0c4MXJxRmh57OdRt 2JHpzyFZ5EPQTa/tPxrbt5RIh2eY9RMSkqeR4XQUJc3r326iAPfhd3yC0fblFco+8N59 NXr31U9JHC1QCXxUaRL9MYzS256gDJdBqMSPUJiYmpCJkHf5ERXDpiXTo78iZ0mIAclN 8NVg== X-Gm-Message-State: AC+VfDzwb6KRkTLYPClqwKWk196YCrRpt8vQivnEJjk8V1GhFX/bRCVf GLR4WjfeTjX2zoO3s29OD9Wocw== X-Google-Smtp-Source: ACHHUZ4n1mZuM7TTU/iqzcSryywffqB9jdQbsWlWm4H5TvuH/7J0J6/AUoSNwQC5ppUUQt0Nu5rzTA== X-Received: by 2002:a05:6a00:1309:b0:64d:42b9:6895 with SMTP id j9-20020a056a00130900b0064d42b96895mr39202386pfu.5.1687495240030; Thu, 22 Jun 2023 21:40:40 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:3383:b451:fa2:1538]) by smtp.gmail.com with ESMTPSA id q25-20020a62ae19000000b00666e17004a4sm4237350pff.58.2023.06.22.21.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 21:40:39 -0700 (PDT) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCH 2/2] zsmalloc: move migration destination zspage inuse check Date: Fri, 23 Jun 2023 13:40:02 +0900 Message-ID: <20230623044016.366793-3-senozhatsky@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230623044016.366793-1-senozhatsky@chromium.org> References: <20230623044016.366793-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3E95880004 X-Rspam-User: X-Stat-Signature: 5q5urn44m7zxdxh7afiprf5hxj53rr1d X-Rspamd-Server: rspam01 X-HE-Tag: 1687495240-844670 X-HE-Meta: U2FsdGVkX18VKC1LdzJJ2UY/JIAEBmkLlj31WTAvzunWLlm1Nk2vUfDQn8mBDSN4FBOHDJ7m5BC4yjPWay6pvDZwOA7lnD2htDORCkn/dQs1E5HUsIt3I2yelmjSKXwv9Htd5VPu2S1S47unLnRW8pgofLMhaj6xLZs2+jDnbCrS++Lnt8eK321+72ShW0tret3suD5QFPqkTkxsUmtfxq4f2ZrT+Ip4oVIsJ35uH/TkAqZ4RT6d4UaC6ICG1m1qVNaU9KN6lb8/esuIz1L3OfmzSsnP4HlT+zHNa+QSbMJGgOVm65d0Hi0+ui1mXJO8LcEmD68ynDJ6ZqbDNad0f5mn607i8hv4eb8HDsaosn1elFB65O9fZEhap+NEuQhErsrv5ktn+6F7BQVi3ifM3FY5Jkorgw0ZyvPRt0+3BZ2XbQsHOxV2EGqctJZEYrKHjbIGEqcuWbFA6SD2vOlJg9lBUUC5uCdKYeMh+F4SiLN53rTa2GDLlZ4wQuVpxG+c0+O77ElqFmzIrUX92y+qisqqan8GVl4ePy7CA5fnRTa4kL9ALhDklOPk55MgfmZgR1TNiclDQoEZc+cL33UefZZSFG0f3CHgDHRi3nzdw0jA6WO8ny2R02tgFfef9qmts7I/47V4MKttpjqJUtKuA/DESO8rxg9PnEBkksg+lpCSCV20/1qNSngj9+0LRo1cU4NJ4/MM93o13NpAhZQYv/ZhcB7uc29oOWUCD82xH38FFjrtQc4hLXSGoiwSY0cUCCYM4xhi4efpOXwrVGLPS/KmYOiJo7OvbggioWmkakJ1pYAXGQcAsdUbHSLmetERz328WUlSMs2X5aYqpVGxtCwsx0fK+MsmIzKUU1Hipz92v//QnT6fMeV3oOgOYEuG8Tyas7QRd2ObYDNlTsGPvRPznWruK5bHNZwLBmbpqMiwdztmcmiVNAzdkTYATlQWdYdTOipYJAiQgftqKma IcH+7iG4 BDq6u6LgQez/FfaYpQTD2shNdBtUtPFSL5+1okCGlr3gTr+OhrKijLqfniaShpAy/w0NG8XDz8NK1EZYj7FAzAaHDjnbPq9fHP/CGbpHcUb9yLgZ2yvHgYdL8+R+i1jPW9A6PxXwX3W3CseSL+gxEGfaT+B8GeSv3xlvGJFU+ElChtMm9Shx//D7xTaHTDfTX80Qbm1OJ4XReK79x7IqYn1oWcWK5A9xRsY+55+c96pQ1UWBzmxzr+ophSutQfav1Bfct7DouRKZ2g5UdAGxpjAzhAqWkIdOWUkVWtTAPmdBM70CaALJVAx+Bht2B5iKEm5lPP9+ZEEdXDmP3UZm1wtZboRzLUofCLRhXIuUsaYMALTjRXu8TyR5WfoEe+trpxiGORawSPnX6iSCklqXugwMNLg== 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: Destination zspage fullness check need to be done after zs_object_copy() because that's where source and destination zspages fullness change. Checking destination zspage fullness before zs_object_copy() may cause migration to loop through source zspage sub-pages scanning for allocate objects just to find out at the end that the destination zspage is full. Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 5d60eaedc3b7..4a84f7877669 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1620,10 +1620,6 @@ static void migrate_zspage(struct zs_pool *pool, struct size_class *class, continue; } - /* Stop if there is no more space */ - if (zspage_full(class, get_zspage(d_page))) - break; - used_obj = handle_to_obj(handle); free_obj = obj_malloc(pool, get_zspage(d_page), handle); zs_object_copy(class, free_obj, used_obj); @@ -1631,6 +1627,10 @@ static void migrate_zspage(struct zs_pool *pool, struct size_class *class, 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))) + break; + /* Stop if there are no more objects to migrate */ if (zspage_empty(get_zspage(s_page))) break;