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;