From patchwork Fri Sep 6 03:45:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13793198 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 94C8FC54FC6 for ; Fri, 6 Sep 2024 03:51:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29CD26B0088; Thu, 5 Sep 2024 23:51:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24CA66B008A; Thu, 5 Sep 2024 23:51:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1143A6B008C; Thu, 5 Sep 2024 23:51:12 -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 E650F6B0088 for ; Thu, 5 Sep 2024 23:51:11 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9996E1C523A for ; Fri, 6 Sep 2024 03:51:11 +0000 (UTC) X-FDA: 82532937942.06.858BF75 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) by imf27.hostedemail.com (Postfix) with ESMTP id D376440009 for ; Fri, 6 Sep 2024 03:51:09 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Nl/PapX3"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf27.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.161.54 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725594645; a=rsa-sha256; cv=none; b=PAS693KxAljMoc1r/uXQhYDKDkJFRgFoLQG14JlKiigExPf9HVvXDivTSeVi2kyH1kOEHf zp0q4pmkBLFN6VCS93z2G/0rM+TNsl9UV/9nFBOI8R33RuWTlRspG1NH/Zf6M8dj0jS1tZ I6IyXmv3ONlTyyaWHTX5nsh4YOiAPfo= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Nl/PapX3"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf27.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.161.54 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=1725594645; 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=iAqeypQfhkuhTUZIBtelAtfJusBm2y6UIbBZ4nA8cGs=; b=zdH4s85w590QLgKvYZxddUvctxVPyHRASRzR/oAPIGl5l1S7ol7lb30pBqYl5AAP2JWd8L AdE9H4lQm+Bz+KfKspqLr9+Chs5FYiFadWjZUkXhTIIukAV4wL09S6/pqG8C0oDwuZSlcy EsRlY6WMdVgP1FcwFWawz20rJJARvx4= Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5dd43ab0458so934993eaf.0 for ; Thu, 05 Sep 2024 20:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725594669; x=1726199469; 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=iAqeypQfhkuhTUZIBtelAtfJusBm2y6UIbBZ4nA8cGs=; b=Nl/PapX3kQlyz0eyBFt+H9dZARntqOO8zqj5Nu1KciGzYe6p963k4ko+iGPYihNQ4L VuSFv0Aano/6Aa9DWIUMO35AYFVfO+lG4oEaolC2WK4CG87i0U2WUVnqfDy3sjp1Wt5B ZZ2poB2+b5jW8yyu5311scx+vzgntQzckEAUs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725594669; x=1726199469; 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=iAqeypQfhkuhTUZIBtelAtfJusBm2y6UIbBZ4nA8cGs=; b=v0otl6A/YUuUHeB3u9iuppx2CQX2MZf67rXfDh8oVaQVi+UD1bKNlhd49pU42kNras S/DnR2n7BuwvLVyuSHOezCPl4bYfPH4moKQDPIJN2SkD3lW0TWdGmOY+SpOJQAUA5GVH hmaQRjt4ywuenSkTlMlqkUnKfs0BOhYETt3X3WIuxpcZ78JYwS96twZlRTO+27/D0bzU beJa88ETFcRbzzXhlXYQStt79ojq6gyWWAHZcDRsJ8ArbdKQDjWY1unClY+sk5vHz1Ow u+LYvh7QmOk/ZTzF0DZeMd6rwUBkKRBhJp09VIM3UWhO1CYwDiElDs7ETHsG7b7Cgs6d rFAA== X-Forwarded-Encrypted: i=1; AJvYcCU3YNymKayCyxDNCzOT3IE4vSVcR5wyPvYWfh3bdYnFlSWOJCcJn1hI2SfxoOfyoc+MYMit0co11w==@kvack.org X-Gm-Message-State: AOJu0Yz4NMuloxd6nMbYpQg+1N69g1tdNWercOeW6rhJ5qMnNT01JEf6 meVF+0UTx9HHWHris24w30yULcPhMo9wprYygES3pyB5Zt0q3+Hdpxan+/o+dByb9+DUdQk7Kbs aSw== X-Google-Smtp-Source: AGHT+IGxujtVNLgTvAFObL24ByIGxrPw1YyqA9moK76Vv3qCoroKoAFrwI5Oaw6ioAAzZdAb1HxuHg== X-Received: by 2002:a05:6870:1697:b0:277:f722:45e1 with SMTP id 586e51a60fabf-27b82e5d645mr1631172fac.17.1725594668906; Thu, 05 Sep 2024 20:51:08 -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-718db3b043bsm60307b3a.101.2024.09.05.20.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Sep 2024 20:51:08 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton Cc: Minchan Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2] zsmalloc: use unique zsmalloc caches names Date: Fri, 6 Sep 2024 12:45:44 +0900 Message-ID: <20240906035103.2435557-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: D376440009 X-Rspamd-Server: rspam01 X-Stat-Signature: 8314hrs5wgmz9abtizo5ttfh7tsx3jt5 X-HE-Tag: 1725594669-84182 X-HE-Meta: U2FsdGVkX19JgeFYV6rOjFe0g2Vhj9qn3/ODlMkIVarSugfos4+Gs+FD4aZMOi7ms6bafQS3QCKF4ohoyfc+1mhbJbBBLmDAwpqlTT0oQAxyUC8R52Rjgb31DAdQGYAOftFcIZx3ZB8V4W9y0wu/zOUy1N+xRsFR2ozKNjxHbHuvl+YK3D8mzsE6JALv5EwJOQKayMW79z6AEqAiN+sWa/8nEygFWT/Pciyb1QUU8p9Y1HNcPsKJ9Rc5ZHXDxDIpPeDceuEbz1EfRJL4quQizh6ckmzrQsAMryJoaE+MRQuDNQfO2F/HTNP7XDh0DFIIMvYpFdyf18JcarJZtoaFWsqwwNtLV7AWTphglmP/OLeTUsao3+NI9C5NixsoAE6SKeVC3mhaxomnpqEdxiY2fERm2j/6tcQFa0LJAgNKPDxfEn564wejVCJVt72OndAXqDGDKS02ZScaSBjEc4P+1wh/5bLLUdTQnkZYw0l0bRrjwuU5kEhzsqArCVsoe/+KbbaqiVAG6BbCIlYjSEGRXFMs9V9K/oZvrD3aJAV4UQPAN6D8oSkM5dDj7Q82FyrBvg28lqv3ilt6e7D+dOt4OW2xD/7ymjLcBKGYMxvB32Q6dS1ZFkwbJ7cPRhbONl85sNsfZkojMc0SpnJ4ZG9hWVimqmpgz6qLVOY9tLV/NrvZEBI1e2yP4RZt4vdGpLEBUr2tIgtYHTR8aYB+FkwvIqAkya0/eib1FinhZrLqZO1f+7Ispcz9i9bnw2j3sOoNUiNWmPLC4D//v19KfMkt3mYPpiXU5GV93m+/57G7mhiJvYigzZjSZDzUL41Fp4tGfp6Y/QnAQ9JtVhS0WTszMhYEfZH4GL1UtPWLERYF/GdrNaxMEOsiNxvc5H07d/C7tdv4EXm6r2Q6gZhgmjCE4yR+eMSsWZXXLMA9abAuZcV8O8iJ6U73QCcLAGe4wmFn7gfhoXDvHODrxScp8C4 L9KtvQX3 RzdquENcJv20ROV619edlWge5GyC2g+SUd799dH0vfJN7ZaVzda/nXvXSSUOE/UFvke6JsZjjNCywSe6DMDxeKRcPEpC23CKZ730ChEAgaFDlO4LWG+EDHFUMOnk56y2L/zNQEvbgFbb2iC18zWr1qVbqQ3RmNo2bqSxyJ6ACMn06llnfCD1Rq17OtMfmTfZSr3/dyP5ZSI4tXbomu/Q5toE7elU9y4HS0dkG4nVVZ2p1Ry0z6qWx4AhC3AEBMLL9j7mJWCem34Qk0W56SGKdTpePKqUujpVFkW9PZoQYveS3i5mH5E0HKEa4BAUwxVDN42eCDJZIQOUlDkPuQVib4gYzCA== 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 ... Fixes: 2e40e163a25a ("zsmalloc: decouple handle and object") Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 73a3ec5b21ad..16a07def09c9 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -293,17 +294,27 @@ 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; + + name = kasprintf(GFP_KERNEL, "zs_handle-%s", pool->name); + if (!name) + return -ENOMEM; + pool->handle_cachep = kmem_cache_create(name, ZS_HANDLE_SIZE, + 0, 0, NULL); + kfree(name); if (!pool->handle_cachep) - return 1; + return -EINVAL; - pool->zspage_cachep = kmem_cache_create("zspage", sizeof(struct zspage), - 0, 0, NULL); + name = kasprintf(GFP_KERNEL, "zspage-%s", pool->name); + if (!name) + return -ENOMEM; + pool->zspage_cachep = kmem_cache_create(name, sizeof(struct zspage), + 0, 0, NULL); + kfree(name); if (!pool->zspage_cachep) { kmem_cache_destroy(pool->handle_cachep); pool->handle_cachep = NULL; - return 1; + return -EINVAL; } return 0;