Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11925857rwd; Thu, 22 Jun 2023 22:01:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MFvzB/L8KsPagilpH+9SH+/S3iCBsKPjKE978vf4sXuS1qay54PkEEJSjTtDbN4qhQbXl X-Received: by 2002:a05:6358:9f9c:b0:132:d679:50e1 with SMTP id fy28-20020a0563589f9c00b00132d67950e1mr3170734rwb.19.1687496501259; Thu, 22 Jun 2023 22:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687496501; cv=none; d=google.com; s=arc-20160816; b=s6lu2NVbXU2du0uEgT+7ibrzNr2UWXRcV0MKBubyL1F3BmHyGupAkkTBF7oHMf7tWD 1XKvGRqyYWjeRZ3JGNVXeu39xJ3J+sGwbWJ6+WQYjnX2nLqJ7JhnpLTOqL7yM8Gyyc2N UGbf/BULbLI/WOGs44sG2hHS7PC/vcrgYvVaYI8hEUnW/07mPLjqozdVeDGz/JUGTvNP W7zdyQ6/Y7v3n0z5OR20XG9lx2Mz+Ekn4Em9tWTcuK2HJPsNNKKE2kEgCgNAoW5xIgaT a7n86+x4d0ABdrxtGsKEJhBeY3CcEhC4GAdB+tUr1J1YzjEhiEzE/93SiLlfu73NVtit ZNmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A39gdokmxlm4U38P/Zql/B/dp1bRrgyGGMBd2ncXVBo=; b=a18MyyKqbBzADvtVTiHENFvAY5NhfijsNRc9pEL7fODxb71uj/TD79iUXhe2t8Ki7/ 0c7kogcrdbGngcZP8dvSFAWAukwObmg54uTtCfL1Ygw/uA2CjDUAwfdd3ia2pb30srbb H9BxT1Ow85Rn8EyCa0ffrCcZiyr/OdVLd8UsWGh0R4+djUaXV0Tgn1oWsbMwrvOaA5gT UdUlavy4zL5hOC1FxItC8Zczv4DkV8hmjvK9Ukjjr/4oE0TFpysjtDmM25zsneEEBQFd 1N3VfaIrc/k4W9Y42mwwjouDShXFquQf2D0XNi8kJWs5EgQY1AcI2KJfylKYm3eobkV5 u3Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Cbp1e0QD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g130-20020a636b88000000b00553ced07d17si7460484pgc.123.2023.06.22.22.01.27; Thu, 22 Jun 2023 22:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Cbp1e0QD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231214AbjFWEkj (ORCPT + 99 others); Fri, 23 Jun 2023 00:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229994AbjFWEkg (ORCPT ); Fri, 23 Jun 2023 00:40:36 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 493852126 for ; Thu, 22 Jun 2023 21:40:34 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6b71cdb47e1so280626a34.2 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=YOhcC/C4bL3dkjLwTN/HxBHP3iYC8TUJKMYNFNleZQZoE0ij+mvPk5TW9EsqauVjVN c25SnukxJ764oT4Dx3/BcVXn9i2CXnV/murWNnF35CvBNyVoMxaS8oi8LbL2XudEYBIf ieBsPBwSIRCpVN+G7qXZjxmtycNk4cTVMHcoKrZA8beZ7uU9xWIVV/wOSZM5k93/3RmY FqwGkMzc2ISpdm2JUA4HxIyePUsitKD4K+HOwo0+kXWXD7SDLbAFc9rv0dVZdVB8nmxk PVr0ekf9t8bYx29EyDpDd6IH1myZWzD9LvsnmlBI8QkbLMqZ1U00G4Af+rx5WQR8xCqZ sEYw== X-Gm-Message-State: AC+VfDwV3sS0tIz+rEnyWsZ1RikC4IAP6ylHjHtc7zmNYq3fTrhf5KKw kgtzW/0rO6BeGS/WodSykPqu6Q== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.41.0.162.gfafddb0af9-goog