From patchwork Thu Jul 13 04:20:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13311276 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 6D21BEB64DD for ; Thu, 13 Jul 2023 04:21:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 072EE8E0007; Thu, 13 Jul 2023 00:21:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F3D038E0001; Thu, 13 Jul 2023 00:21:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D90008E0007; Thu, 13 Jul 2023 00:21:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CA2D58E0001 for ; Thu, 13 Jul 2023 00:21:31 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A8287120112 for ; Thu, 13 Jul 2023 04:21:31 +0000 (UTC) X-FDA: 81005289582.22.42DC860 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf20.hostedemail.com (Postfix) with ESMTP id D4DD61C0023 for ; Thu, 13 Jul 2023 04:21:29 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=g8WMZWqH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222089; 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=5yfQ6zPraH8dHZa8YhEhQL1VMOJgNkmLyTsm8Haifgs=; b=JGjOQ/OyJsmEh5xm+uFrESEljaxmDtQAT6nl23sdc0V+s608cEiIt/wHYV92dn5RN9+nBF pCFIrTV4h5vzpI/0QPlWfYCVIp6dJI6jmbnYyYk7b0xUa9d+IHmYCzQKhEtgeHnm2ps+Kw exoc6OD1di/+4/MZJJ8Qrv81FC8U6kI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=g8WMZWqH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222089; a=rsa-sha256; cv=none; b=AEb5f+eULKn93oGkEUmEhKgvbEKkpDGwHwhVVNnHeUu16hx8Ej3tUb8o0BYYSrXC35YQq3 uQSSx3mjxLqzK7FriF4xBfvRAAHtWH9uXHViYWdKdEQzgfCv2e0rpuFDeeglErEkpDmUeQ d6/otrD1vPcB039j05ESmyY7yebIWWU= Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-666edfc50deso161735b3a.0 for ; Wed, 12 Jul 2023 21:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222089; x=1691814089; 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=5yfQ6zPraH8dHZa8YhEhQL1VMOJgNkmLyTsm8Haifgs=; b=g8WMZWqHXrrpccZO8HYjWcBBVZeWLTjyD+nWNKQw7fp7VGvy2h/d70QzcUDIj9R2oe YxbhuQWUUag7c5ql2Sz6xOTRQZRl6Wz83EWdeACFTpfUfy6BfevLWPPqBhpvw+maXfJK PwN+uXTrb/UMYeLk+dWQmZT+oq7QBI+afN4uG7iVW4Cuw7ui+Gc79QHpz5qp3l9zaRiw XO2sKqyRNO9V2MtCOpV6ufDEugUXje//Fdy4QBNoMUqMtJHeQgZQjj0pxT1kje47syCr K98RIjHW4oPOlzDbyBqfzS4pdfh+DCmURNBmMNVzuGCRP2Qbf+hL33XqBpmYnvNvHm7x yxpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222089; x=1691814089; 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=5yfQ6zPraH8dHZa8YhEhQL1VMOJgNkmLyTsm8Haifgs=; b=Pc11FpjMCRa3Vl94gpypYlqxFC4jGHxdpXuGtLE3A2H6hSpk7ar9cPk5G3HAUvXi2O BaZ1peFu6N4/vIktIwhkZyX6cEnbDkU/DOOvK8k4aWe3OM7cSM9HvbCeixojiGOtmd6e xCaDP5I0Trz2fAyWiWk2c6HTHrIs84kRdKb5nbUpqrZ7dIpIjT0h6WjFhQA/xQZJYCQA JYI/vdsGwBFpu562xxvB/4rdgGdn2uPgKKal0ONV2eTOj0uj5cQqsVLJ3Vhl0jF3P9Ej +MbUUCmppgYmjxuaQnOpY2FlJ28nYeXGFILpRBpGiRXoB+dTBpfCG5BHysu4VC2t7GKX PXQg== X-Gm-Message-State: ABy/qLYu6YEJ7g2ZLX+CFXHbLc5IMvyHu1DnX+MUJQhBLttoCtEyhJ/t zfHsUYH8A4GMEKzZdV7Wo2ZK8jTpbHlYISia3PtC3g== X-Google-Smtp-Source: APBJJlELtoG4ukoHskrnQbnp45zXdh/TsnPNc0u5P7Tty60WCDZQyFeDcrQPIszYmTm474hUPBaeQg== X-Received: by 2002:a05:6a20:5496:b0:133:5ed9:f00b with SMTP id i22-20020a056a20549600b001335ed9f00bmr69251pzk.13.1689222088604; Wed, 12 Jul 2023 21:21:28 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:28 -0700 (PDT) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Wilcox , Mike Rapoport , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v2 12/21] mm/zsmalloc: convert obj_to_page() and zs_free() to use zsdesc Date: Thu, 13 Jul 2023 13:20:27 +0900 Message-ID: <20230713042037.980211-13-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230713042037.980211-1-42.hyeyoo@gmail.com> References: <20230713042037.980211-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D4DD61C0023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: biwqpiuncbr9wpwk5xe1oet3344s8jca X-HE-Tag: 1689222089-165520 X-HE-Meta: U2FsdGVkX19s0LAQ2RTkPF9/u/rJ33xUtDKpgYxjR8t+GdCPAFdaO1YfQeWiONhKd6Rn1z9dXKVSU/qJpPiC6DaGIY6Dqna1ZivRLovrGp1l5AN/m+4fWVrastArKZ+0AxOadCs2YZebxuC+QEjIqUVFV/sg2LtyxqCijynRFcb6D7bxwgN784nnSCtkE74mPcMIejdgxvZo+a41YML2O9YrUn2/3FFMBRrJV5IZyimsG7anbjrVEvDoktO7059wNg+XEoaxvnHMTk7PxX8fXiOzFn5PVZwYSCaIVqrx/IPZZ37tb/Zl/tbcFFEC4xoO7E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eaj0ZKIoEUnjhZcfyzmCbYs2Q10HA2krbPCyU+iYSFCSWTkCdOVU9H01QeeGgjGD6V4rIOTsRfe1ZfWRI7KcoE8OMxmWRyFCd/JbaWzGD79/1askY/dspDA5hS9MSsbuBBu2KviALDOeiRl+nOY71HEYSW/3j5dJltaWWzWrivjkSZB4p/vT6ETK1Q9+cog== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert obj_to_page() to obj_to_zsdesc() and also convert its user zs_free() to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index c8c3039a751a..5141a0c72c61 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -915,10 +915,10 @@ static void obj_to_location(unsigned long obj, struct zsdesc **zsdesc, *obj_idx = (obj & OBJ_INDEX_MASK); } -static void obj_to_page(unsigned long obj, struct page **page) +static void obj_to_zsdesc(unsigned long obj, struct zsdesc **zsdesc) { obj >>= OBJ_TAG_BITS; - *page = pfn_to_page(obj >> OBJ_INDEX_BITS); + *zsdesc = pfn_zsdesc(obj >> OBJ_INDEX_BITS); } /** @@ -1593,7 +1593,7 @@ static void obj_free(int class_size, unsigned long obj) void zs_free(struct zs_pool *pool, unsigned long handle) { struct zspage *zspage; - struct page *f_page; + struct zsdesc *f_zsdesc; unsigned long obj; struct size_class *class; int fullness; @@ -1607,8 +1607,8 @@ void zs_free(struct zs_pool *pool, unsigned long handle) */ spin_lock(&pool->lock); obj = handle_to_obj(handle); - obj_to_page(obj, &f_page); - zspage = get_zspage(f_page); + obj_to_zsdesc(obj, &f_zsdesc); + zspage = get_zspage(zsdesc_page(f_zsdesc)); class = zspage_class(pool, zspage); class_stat_dec(class, ZS_OBJS_INUSE, 1);