From patchwork Thu Sep 5 06:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13791786 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 40C68CD4F4D for ; Thu, 5 Sep 2024 06:48:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6FF06B008C; Thu, 5 Sep 2024 02:47:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B20356B00B5; Thu, 5 Sep 2024 02:47:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C2526B00F9; Thu, 5 Sep 2024 02:47:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7DCC06B008C for ; Thu, 5 Sep 2024 02:47:59 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 08739819F3 for ; Thu, 5 Sep 2024 06:47:59 +0000 (UTC) X-FDA: 82529754678.30.F6AB738 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf18.hostedemail.com (Postfix) with ESMTP id 42C1C1C0019 for ; Thu, 5 Sep 2024 06:47:56 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=ZGCvDnnR; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf18.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.182 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725518851; a=rsa-sha256; cv=none; b=StrLYd+J8XoyJ5nHA1tlPlaT35x1ZrmqXqABLqywGCYaK40Nv/IPGT6tLiAQm0VgCEVkQt w5fDhEC/PgG5pVKhBclIamxrzcrFy1n5jQWJXsMCHXEyeuRtofEYnklITwAIMY+QbKMqYT xJjvmJRD4125pZg3sCnmVpwCBvmm6CI= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=ZGCvDnnR; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf18.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.182 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=1725518851; 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:references:dkim-signature; bh=mIhDyqF9M2O2ZjRQd691tori9EsH0IRAbKfkH6ZoQcs=; b=11RJGkLLwR4+b6Mojv8L52qH6nFNJVcr3VtR1WG36oPflsy0/RqcalY+dsb4q4Uxya9m5c x6tLAoZeNOIyLeBnThr2V6NsII21b3MKa47n2XOfXgp83w90z8iPN12IHlPSjcnPDvFnu3 3EiNn00xpQ9/HKS3inXcBw0Y/ezrDtY= Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-715cdc7a153so319492b3a.0 for ; Wed, 04 Sep 2024 23:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725518875; x=1726123675; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mIhDyqF9M2O2ZjRQd691tori9EsH0IRAbKfkH6ZoQcs=; b=ZGCvDnnRDzduUAWG5u6IhIDmoyfnXRvoUNx8pUeqA9YU5KBkeqO73m6AfFYiD2mowH 1ZGYzmj8lOrPpZjLTEqJLdRD1Sf70DMHVZ88pXDmnMDeta2oZtHN8Uqrm8htVf/8nEz7 MeXc3vvYMeTzVy6R3M45UJDMbqN85OqBw587s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725518875; x=1726123675; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mIhDyqF9M2O2ZjRQd691tori9EsH0IRAbKfkH6ZoQcs=; b=M4OJM46rKlroGJV6PdiNvRL+ywlStorProx9TV9qqsWIZ+7whaDB2eFJfyG2KnpXtd I27Tj8UoILdjGw+LLlMhVXTsZ0Lk3SzjgzTJMcx0Lm00XhoAeJxk3oUAfuALm834lbDJ le7yU7lVsWDqXobxeKgDo6emv2sc/KP8Cu/PQAspzJWQ7Pgds680ypbD35Tb5+J7mlqE KOshJS3hFJMaMh4gJZX2E395GkfzQDMmsApiI7hkN+PmqBy1qrsI63CNbyj5J+DtsKNw OQn9WTaG0zU7+fXWBl4zdkt6gk4B2gbp9D9RB0bOWaBGHPpItVMwboMVLMpMCaeFnldt 96oQ== X-Forwarded-Encrypted: i=1; AJvYcCV3FmlsWs4cQeUnxrT+xpxdUxTA9oAihnRqW7jkpv23J8Al7fy/AqJJgjCqbAtJvlnFZGU4clLP9w==@kvack.org X-Gm-Message-State: AOJu0YzlRp9IGXT1xvf8w72U7P9zuxJsrH3ainfs+6Dq+AjANOtHE/gy 0kNS9tEkyu0JydEKUwTK9iapny2tQWES4ZKFQHaRWJE3BTfVxh6CQB5skQnBkg== X-Google-Smtp-Source: AGHT+IEqjRvOmBXN9hJWq8lL6jJY5+QXZ5XSwN6DOK2JdMuzeyss353QZbuBS30FPJ6tDXscqd5zSw== X-Received: by 2002:aa7:8a05:0:b0:714:2371:7a02 with SMTP id d2e1a72fcca58-7177a92d064mr6843904b3a.5.1725518874686; Wed, 04 Sep 2024 23:47:54 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:734f:d85:4585:b52d]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71778598e1dsm2600224b3a.163.2024.09.04.23.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 23:47:54 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton Cc: Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCH] mm: use unique zsmalloc caches names Date: Thu, 5 Sep 2024 15:47:23 +0900 Message-ID: <20240905064736.2250735-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 42C1C1C0019 X-Rspamd-Server: rspam01 X-Stat-Signature: suo353zerqncdw654tgbosffq8nefaps X-HE-Tag: 1725518876-613242 X-HE-Meta: U2FsdGVkX1/SSi2EzZOBMH0rSqGdnRcwQZQp9vA9h+HM5HZgIISeByBFFDm2LOiaSiuKeER6gs19kU3ySeiksTW9JkNZoOQlB49UT9CeTvxbOeOsjJQ9vQJLdSaQwjX6uEgGQYNN+iVJr05nwf1MyBUiERqjXlps6vSp/jsR3KmkLke4KcWpwEUXIzcru5hR2xFGZoUDsn+Z295pSSV6Z/dLrkcgELx2HgDxXCmbmwK0hDRf5lNDY/mwVWIuFV4BJ9Dni+41a9gc3xCNwStIxWnZRlS3GlmE6dXGCerHifTXo9/dfleqEFvW6n5qMMohyFfjvXMglElVU2YcAzHAgpE33W8Frvnw1k3Vg51SeZa8ZrQiFeGuWrhu/2S/gMbfEkPPV1VA/ckqMEnenxhGQrDb7D5T/57DT+R2pDM32qdb8oMBmoCqortV7XZJv2BvZzLOCOBMEvvLT9onk/bEk/CjVtrei8KB9BlXKtBeFcqTANuIU1DihdbIMlflLidPDqh3UUG9ai31L8v+1jQZaAzYe9KrlfhYpF6EGRD+cxp5RiXK4vlWjyiHcHacNwVoBinb6R/ec2aN6kL1oQCBe5RiNKM64iE6lnVJni2B71hLEbWCCFQf1FkpxHQMxjjnkEtSMIv+NHs/UX0QxLmP5aij4u7oA5rYYtONwfyYQ/wGuWc+zW9nOTQ4U2ETzGmwlFlwlzxK4JcEamONeIcwhUodWfVhJkU99q7fMmwfzQIw1FWVo407p83Yzbm0Cd7j4Xl6EtZugjMFexvbMxlqCTglZtppwhB8LWRYDV6wl1B44cIr7QJ3VHPQtyFKbcP64M0Cd7RcsN+Oxe9P5c521iSCNx7nNEAOhqhxoVZbj0q7ym3n8HBWM4Yjf+78JlKW5xCxH6wVp2ROEMNLc76UxG4bjJz5ipJcp+4lgVfAs4nG43As8I5F1Oiul79XvkJMW2DDGyh2twGnJtQ7LaS K9sIvfAS xvIGiNs4+lJM3SH5lP94VbhKMNztB03mVtmII4EahSXJQCo4FXHUMl92+Y/tSobe130bdUY4GN3gexLVqeK+sMHZTHIIwoLm9eUUuYXcE/PgcSPTtIpjtp+4wJhUSoUl8gZ+wYNScbtVAyveDuws0FVFOkpF+oKKkWhROdR6gMeITn9HTiHXhpAnX7SBS9E0GzMXDhSH7kxeh7Hj9wCvf+vY8u5HdbNjb+pTLF/7+c34DDvXk/kxJvdFGecyPgRGgD21CWarEVxdOlFVJCtb0FE81MW/LAoNTjykn8/yvhZf97lwgVcFRXGAEXw== 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: List-Subscribe: List-Unsubscribe: Each zsmalloc pool maintains several named kmem-caches for zs_handle-s and zspage-s. On a system with multiple zsmalloc pools and CONFIG_DEBUG_VM this triggers kmem_cache_sanity_check(): kmem_cache of name 'zspage' already exists WARNING: at mm/slab_common.c:108 do_kmem_cache_create_usercopy+0xb5/0x310 ... kmem_cache of name 'zs_handle' already exists WARNING: at mm/slab_common.c:108 do_kmem_cache_create_usercopy+0xb5/0x310 ... We provide zram device name when init its zsmalloc pool, so we can use that same name for zsmalloc caches and, hence, create unique names that can easily be linked to zram device that has created them. So instead of having this cat /proc/slabinfo slabinfo - version: 2.1 zspage 46 46 ... zs_handle 128 128 ... zspage 34270 34270 ... zs_handle 34816 34816 ... zspage 0 0 ... zs_handle 0 0 ... We now have this cat /proc/slabinfo slabinfo - version: 2.1 zspage-zram2 46 46 ... zs_handle-zram2 128 128 ... zspage-zram0 34270 34270 ... zs_handle-zram0 34816 34816 ... zspage-zram1 0 0 ... zs_handle-zram1 0 0 ... Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 73a3ec5b21ad..896ca02ed75a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -293,13 +293,17 @@ static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) {} static int create_cache(struct zs_pool *pool) { - pool->handle_cachep = kmem_cache_create("zs_handle", ZS_HANDLE_SIZE, - 0, 0, NULL); + char name[32]; + + snprintf(name, sizeof(name), "zs_handle-%s", pool->name); + pool->handle_cachep = kmem_cache_create(name, ZS_HANDLE_SIZE, + 0, 0, NULL); if (!pool->handle_cachep) return 1; - pool->zspage_cachep = kmem_cache_create("zspage", sizeof(struct zspage), - 0, 0, NULL); + snprintf(name, sizeof(name), "zspage-%s", pool->name); + pool->zspage_cachep = kmem_cache_create(name, sizeof(struct zspage), + 0, 0, NULL); if (!pool->zspage_cachep) { kmem_cache_destroy(pool->handle_cachep); pool->handle_cachep = NULL;