From patchwork Sat Jun 24 05:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13291600 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 97F46EB64DC for ; Sat, 24 Jun 2023 05:31:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECC3B8D0005; Sat, 24 Jun 2023 01:31:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E7BA68D0001; Sat, 24 Jun 2023 01:31:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1D548D0005; Sat, 24 Jun 2023 01:31:33 -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 C3AAE8D0001 for ; Sat, 24 Jun 2023 01:31:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9E9C8140F11 for ; Sat, 24 Jun 2023 05:31:33 +0000 (UTC) X-FDA: 80936518866.06.626D79F Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf25.hostedemail.com (Postfix) with ESMTP id 8D0FAA0009 for ; Sat, 24 Jun 2023 05:31:31 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=hEVV1PKn; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf25.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.167.175 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=1687584691; 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=xgKSJcPWWgwsyhGhbiLGB3nMAOyVRCAwDEtSpdTWlLnUc5rj315hbXzZMh/mmITmmRHuzH BQAjLoYxTxpYyeevnU4rGiYYEtRaNUaCND6AHCcNCfGqACBCJiXBhuosKpFHKTgGwE8q4S 2A976VA/4pwJBwNducAzUd32qIJa1OU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=hEVV1PKn; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf25.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.167.175 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687584691; a=rsa-sha256; cv=none; b=yT/Ai3G6b+Vg0djtLVu0pt30CpVXPBua4ykEzziyQkBsJ5hLMyLiaLnR48eZMtXy/rb7Pz PSk47MxvRCxqqe//kEan9yipxaszp5gH7o3rLjaE7Z89vBzjeTCbcuv2VN3Kz2gCn27cKj Qkf0Fp4GbwwPpU/RnMM5jgXWJ5C9eDQ= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3a0457d6b77so1129088b6e.0 for ; Fri, 23 Jun 2023 22:31:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687584690; x=1690176690; 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=hEVV1PKnoqRDlkdskPail3UwTi3zNM443LUxpwYsTN8oCAj3XIMmoMXFJnsnxbV+DF wzOj3dtWSlkKaMPk+9t+QowWS3A47K6hiYh9dpNM6u2Wfey5nHSVhk3Ym5ox5sYyZzes K0dyi1ixw9OexMvrCK8P+ImImK/L+xRxsbVYI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687584690; x=1690176690; 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=P1Jz4vANHqvdj86CEEXbRdsQv0W59eDRxnUY1WLWFWxOpidssVjVYWPg4hEOHFZ0KJ 8LW0kBT1MRX7NIPnSS2/TavRzUR0Ux82YbtpJ/ksj7l63AIESl9hSzR0rpenP97RJNt5 Th09DoCOTa/2VHp0wnrBYFKlh51FUOGPljGXYvCR0fno+cZZTmHo7Urtisq+bOhCuKeK en1lttAiIMQz6eU38fgqEgptdI+XTRZuCaLuMj2kwrojtbZZGPCV5VjJb5HHzJXrL6nI WCb1j8DjiN3MMEUOeoEo3RmSKRBpCJ742OBz3ezIJOgzzNIUf8uldokSFCb0i9z0QKtJ 7gCw== X-Gm-Message-State: AC+VfDzkFABE+eYiXOKn4ZaKqDXW6HS24TzpOcl5W7lnn72roFFd1o/C AHrbR+5elxXckamVLLc7Lk1ZMQ== X-Google-Smtp-Source: ACHHUZ5mbSYPloXGVoYuwedg5AUrAtc+B9JDYGgNuwbVgnUzI6YASvLhcPdKURnsv6EOXnYZm8NkVA== X-Received: by 2002:a05:6808:1524:b0:3a1:c0bd:c51f with SMTP id u36-20020a056808152400b003a1c0bdc51fmr270508oiw.28.1687584690736; Fri, 23 Jun 2023 22:31:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 22:31:30 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2 2/3] zsmalloc: move migration destination zspage inuse check Date: Sat, 24 Jun 2023 14:12:15 +0900 Message-ID: <20230624053120.643409-3-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-Server: rspam09 X-Rspamd-Queue-Id: 8D0FAA0009 X-Stat-Signature: d8a5onm5jaq6r4dupfgsgzfb7mroacn4 X-Rspam-User: X-HE-Tag: 1687584691-174677 X-HE-Meta: U2FsdGVkX1+1T1UMpeZpPVKzGJ4kb6sI5ERqHsMeK0FPgPulQ9lvFaoRaJ4e0UgKUEEvftc4Hs2+aq1eLt3uzRONOHnhD79w86xS88kYovpa2EErOh0YhRMJUvggFruQEibXzmPXH9GHkVhFp2dM0WvDzS/UEEkN8f17SA5ys6lJhfaUJkUYhrikBpTuAFEBYbMo8FW5M7Qrdb8OP89tLEj1a++4dK2Tqgbbr5JQ45uge1e56NhGJ3OgeSJJ4HU28DtYjaoJWTos6RxIEUoe1Ou13sDVQAiF1+dq92ueUN12FFn/uBgXBoCjc9NeuSgnVIX8wqkVEutuW9rcdyJ+BcfCndxTM4XK2HIgAs0l5sFDPZQM2YKN2lM1AidmY46xQc64Ycz+7JutvFpTZ+QTzhEeRgyZ+UPveqULnOfGFZiF0+fNy7bWkSKdTWyzvLSEXzTP37BQCEIOMkrjKbfkPrqLU4YZwMPm5RrOb5xbWjNkTemlhVgDBYD2DFtzNYyXW0N89SJLg6YIf/szJVnMVrZ7XDB+sI6oPelzBbc2MSsR4iuAUq/yqQjQkTM/od5wvm//SRn2F6N25SEXbnA/C6XYwCyTT8j1QlV0xL/228Qn+/541UwR21DkiMdfzWBD85IeCcx9oc2JrtkkhE7FUroxlEsx5iIv0j0APEvJ1d0ymVvjczlDSMyMOr+IhnpHhhqDe34yOJ3FJhki82j5dxotznCWkoW3dPYntFGR0Hs1oDhjRAnLbmEWekWZzfvrpGic1dYvQTcX8jzo5UFxYJQsqHlwLcbCHx3Tv1U0u5V+vot0xXx/UwZ4QzE3NM9RjVWnONBojPYTMcjWLoTABPsVywInInRuaXBONJXet3bBhO9noN1/03Z4ZB4QFXtVLUGpkHAGngYisMcaE7aUOBUrTXLuk5hlAOGoJa1gwmXJk39nGNikii6w08QxNPOZi1UCX7c3/IrnI96CRa2 5bQVZ74f eCLb6l0Vuld3hdO/0p5Y7U395gFcOWJS5ZsJPseymW/0fdIDwWDmzKWGinyAe+PjcycssAmmn1lGu2vhyd1DI1Bs5Y7GUDw2yqq5AcONR3j4sea8ZwqA+2qnyiIv7ZZDa7kb/4ZHtaKTtwU+srFBm8rDXF2y3k2RK0b7/2LiSsiAVzOoiBFK5qq8q6D0afoa009Wd1XsLYU7kUQN3UXGgxDZEO8/BYB2rQwPP/sLzg32GtuONQbSwESvbNLEVtn49CTU6tqzz2TCaZmB1OMhYgEepjN6LV47YJtubbsQRq6Hut1jO6axP4xlhM+MRTnJ3vqTwNwYn9QP+ZA0FRhaUgWpAKQ0maKldJ602MGwOMhMK2CpDrrkx47bGtBquQuMjdWP2NDbs5sWrS7j9MngNg+WUfw== 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 Acked-by: Minchan Kim --- 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;