From patchwork Thu Jul 13 04:20:16 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: 13311265 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 343AEC001B0 for ; Thu, 13 Jul 2023 04:21:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5A228D0001; Thu, 13 Jul 2023 00:20:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B974C6B007D; Thu, 13 Jul 2023 00:20:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E88A8D0001; Thu, 13 Jul 2023 00:20:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8A1456B007B for ; Thu, 13 Jul 2023 00:20:59 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 60B4D1A00DF for ; Thu, 13 Jul 2023 04:20:59 +0000 (UTC) X-FDA: 81005288238.23.F69B44E Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by imf30.hostedemail.com (Postfix) with ESMTP id 77BC280004 for ; Thu, 13 Jul 2023 04:20:57 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=OmNB2v7c; spf=pass (imf30.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222057; 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=JDYdNA9lDVtoD8B2uXnOlmCKBsx14i431NGid1vWIJk=; b=kSl362G9My8H0OdmrxQRbCouZy62Nzv72271+ZqiczEPXoiSZGLqTZFszaCLU7G3AdZ/ZQ pcY39vh3/gGD0cDZgTlQduQ6uxLbcdwy2Rlo+3ph6UJknGyvfhPnCAx6L5ZE07KHtd40Hs tg1z1N50574TENLpfZpAX21NrESoXH0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=OmNB2v7c; spf=pass (imf30.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222057; a=rsa-sha256; cv=none; b=NYBSXZvzySqjpLyQBVcTEj/0vxpw90y/2IG8WgD5hBpxPMjuBjTYLb7XSNivLUOu1pSYbL NZizNepp/z4q1Wqb8dfkjwCBb6mRd3jP062nlSHoBpAaQZSiw8nAUuWpS9/ZJs1jz+5I64 gEXUO3NkmgVUjRyl/cGyZZe9Tkj/QU4= Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3a3e1152c23so273643b6e.2 for ; Wed, 12 Jul 2023 21:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222056; x=1691814056; 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=JDYdNA9lDVtoD8B2uXnOlmCKBsx14i431NGid1vWIJk=; b=OmNB2v7cPzjVbjCrPHesJGkG5OJ1x1rIpPnLFGkHy+8vUnmdOeiKvfhZnn6H9NJFu7 tjvfzbEKpbhx4EHl53IwQ9rpc1UZNnL1xzNCh5xu44eiS8/Xq+kyQUF0+xh6PU2Zg7Ej KwQhjbRoGatW4uiCRRA6RjICwcrolxwLBciT9JtjbWh/Z8HecM2mRJKFjspy2Q7x0oES PpLTX6U/XS/x2THUtSOszV9RZo0XzKKz+KoLi/FH7+fIwzNjLslWgoiBStNeNMKUYQ1U od21C3PGMosTsyePKwlzjYtOXcv5nFXdISwYjt7DfWwxEnq31xqijLaDKuRDUeC8kiBA GjpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222056; x=1691814056; 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=JDYdNA9lDVtoD8B2uXnOlmCKBsx14i431NGid1vWIJk=; b=IziH5x60MUMoXM9oR36pUoq4z8T41I3nrPsA5QxaptxbBi0MwpuJdQyJhSvxq2jlfP KS8fGmCvwOy98PjWK5tnuGMutYlRdZ2w9xv389MAbcZ1/aazTzkRFxwz6Y52BQFSWISd 1vPSW7nGWmS06Ccue7qN3FYS6moR2hefG7vYPXjd06en3I85UGDOWAuCUVf8YiaaCWHk BykDZB6+hRKeB6u6AsMsCDIY8Xng11x7Z1ZQlac3EyJ76coYwMhbw1hHPwy7jURFRzLp kX6fktNcc+5xh/e5nNeK5sfV5gB9rSj6f3eSijkLF1L4dK3g9dAAwE/Y4Hcdg3OSHoap s1bA== X-Gm-Message-State: ABy/qLZ4wR/SdmKfoTMqYwLqr5hRgPNe+N3W4021me2Ghd4slxaliu0Q /UfEuoD0N5zIZor4crhEEdw= X-Google-Smtp-Source: APBJJlHQxzKWeFUb/2UkMXGmNGKuylqY/krdL/0xjSDkichAxJjhqdaXBt4aeDVvXdaDtSe6XlZmbw== X-Received: by 2002:a05:6808:1b1e:b0:3a1:c841:f026 with SMTP id bx30-20020a0568081b1e00b003a1c841f026mr675089oib.27.1689222056477; Wed, 12 Jul 2023 21:20:56 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:20:55 -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 01/21] mm/zsmalloc: create new struct zsdesc Date: Thu, 13 Jul 2023 13:20:16 +0900 Message-ID: <20230713042037.980211-2-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: 77BC280004 X-Rspam-User: X-Stat-Signature: kcjhxnrwfkt9tw179r5ugsqms8rjem4n X-Rspamd-Server: rspam01 X-HE-Tag: 1689222057-186999 X-HE-Meta: U2FsdGVkX19UmnMi91CX3Xu/gwOLvdEicv1ieMCq/EZlLMy1THWpNS8993M2UzwaqqNCVcbVqeHcDtEqUugdRLyosD8M6MoDqWxWUT3u6F/XSnvHgDoiMXO57rfZTzlMJ+Izwesn1frtzUGiylabzAVXwpBJh+Ms3Xu9bFDPzkiUVu+PRK6O5aOFWCHPxtC6RFCQkQT4D8gcYa+PGq/dgs75L6qA3Dpgfy5ztYPHFrlj6s/o8w761KyqySlF5qJzp9ybQ2AL1zS0NUIjzvRQ4bolaNhyZprTQ4Og0V3wncSqSKH19DDjrWIWyYu4EjysmuS4pFakm57h7vJ6CRGXirYXlAlh7Vymax60j9XeQsVGJIBgHQ+YjrKO/OPnfaKLe5Zhb+SR1avR/p5pW+2y0MgW+WvRKNs0pIhR7YhvMlnAenmw19Tm9V+4rMw78JyAoW+Qfad7G9g5Lnjr+B3KyeXJUgOEuAterBDAMQXZ35k/6nWQFaKjQMO3U+8GBPLrzvr/EI8MJA1E7d+5JUWNC9eKygPRHUXr8Na+9i+iGAGhH1D1TC+xL8nN6v4PGm5d71Pj5qDlBzcRlf7Jr8E2QUh7TEOPaxgWk5upXfi/mmFWYcFSBBmCmNkh7REEk9BevdrKdBTg6pfx6SRH9fh2jKOcX7aZ8SRcATcfFgMAa5qFGr1UTbMbDe4pp/r8q64MM8DTD9P+Uug5AXu3BgMgkpbjePolds2vP2gD+yh5t7RTeVHhIYv6Fm/L6RwGMxWSthnjgkgAM28E2XqfEzjiYSP6XfreLoC/lUPIEZmAJAy7xSKrtnnmtGovWlxqp0DIVMRQMWErnTIHDROwQsPmG3wj1S93CcK+dypY62rqaffqksELQD8MO2E56jMcvp3BNnc1N70vqX3estKcXcPt9/m5B59v3FgZMPg4bygPkqvGY6X2EJx3NKawrDIJYTjiirHXdCbwDJ4CJxvv6xi Sp5ElUr2 umiKasyJDC4Wyg4apSafiCZQbxH7HB26w8UtEfaYYEngn2Qap3rNe+xfFxbpvJL717xv9/D8xH2iFf5QyxOLoAUt0sroJLGKUAy5PLCG/gIMykiS9XUEV1Czqp7TV4hTQBhkIlNplO0W45RgEqyIYsuG2H8wi9WkLPpMTCFXdvTqHcWeED3vG4jFOZmPvr8YzepdFp97Ec/KwO/QLQZA9S3TbTHpkKvCoo395mr3RnGZxO/1aeAWbbsTA0U3rK0URsFhOrlmq2qik9XlupGcwbv31qoNqinlEFdteLjqmtrPzDrOe2suEqRl5fr5AvdXQ3SefiW6GtBnyMhVitiBGmk/RHOtKhHtnAy0a98/zE0Dul5zlSoXs5vRB31oYsyyGN392zmThjBo65GQJ8PnO2ljwQTcJhM2GNGYdjFJ+UzoeQWf/Fq56oehOYc5P7s8Hae+EOJ6IlLtin5s7DjpmjV/kKQ2HpSxayWihXD/cX3wtbZ4+Vp8SHJBdiADVHai0FCjM0FUAAnQDt3brN0NpvtIkgZuTEyWWrHqceZSm8hNDsZY= 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: Currently zsmalloc reuses fields of struct page. As part of simplifying struct page, create own type for zsmalloc called zsdesc. Remove comments about how zsmalloc reuses fields of struct page, because zsdesc uses more intuitive names. Note that zsmalloc does not use PG_owner_priv_v1 after commit a41ec880aa7b ("zsmalloc: move huge compressed obj from page to zspage"). Thus only document how zsmalloc uses PG_private flag. It is very tempting to rearrange zsdesc, but the three words after flags field are not available for zsmalloc. Add comments about that. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 63 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 32f5bc4074df..2204bea4f289 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -11,23 +11,6 @@ * Released under the terms of GNU General Public License Version 2.0 */ -/* - * Following is how we use various fields and flags of underlying - * struct page(s) to form a zspage. - * - * Usage of struct page fields: - * page->private: points to zspage - * page->index: links together all component pages of a zspage - * For the huge page, this is always 0, so we use this field - * to store handle. - * page->page_type: first object offset in a subpage of zspage - * - * Usage of struct page flags: - * PG_private: identifies the first component page - * PG_owner_priv_1: identifies the huge component page - * - */ - #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt /* @@ -264,6 +247,52 @@ struct mapping_area { enum zs_mapmode vm_mm; /* mapping mode */ }; +/* + * struct zsdesc - memory descriptor for zsmalloc memory + * + * This struct overlays struct page for now. Do not modify without a + * good understanding of the issues. + * + * Usage of struct page flags on zsdesc: + * PG_private: identifies the first component zsdesc + */ +struct zsdesc { + unsigned long flags; + + /* + * Although not used by zsmalloc, this field is used by non-LRU page migration + * code. Leave it unused. + */ + struct list_head lru; + + /* Always points to zsmalloc_mops with PAGE_MAPPING_MOVABLE set */ + struct movable_operations *mops; + + union { + /* linked list of all zsdescs in a zspage */ + struct zsdesc *next; + /* for huge zspages */ + unsigned long handle; + }; + struct zspage *zspage; + unsigned int first_obj_offset; + unsigned int _refcount; +}; + +#define ZSDESC_MATCH(pg, zs) \ + static_assert(offsetof(struct page, pg) == offsetof(struct zsdesc, zs)) + +ZSDESC_MATCH(flags, flags); +ZSDESC_MATCH(lru, lru); +ZSDESC_MATCH(mapping, mops); +ZSDESC_MATCH(index, next); +ZSDESC_MATCH(index, handle); +ZSDESC_MATCH(private, zspage); +ZSDESC_MATCH(page_type, first_obj_offset); +ZSDESC_MATCH(_refcount, _refcount); +#undef ZSDESC_MATCH +static_assert(sizeof(struct zsdesc) <= sizeof(struct page)); + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { From patchwork Thu Jul 13 04:20:17 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: 13311266 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 1CBAAEB64DD for ; Thu, 13 Jul 2023 04:21:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B0958D0002; Thu, 13 Jul 2023 00:21:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 868536B007D; Thu, 13 Jul 2023 00:21:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 728328D0002; Thu, 13 Jul 2023 00:21:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 642D26B007B for ; Thu, 13 Jul 2023 00:21:03 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 374094005F for ; Thu, 13 Jul 2023 04:21:03 +0000 (UTC) X-FDA: 81005288406.03.CDA32CC Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf21.hostedemail.com (Postfix) with ESMTP id D2C5C1C000D for ; Thu, 13 Jul 2023 04:21:00 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=YRSuxrIH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 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=1689222060; 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=2uyb10W8xRjD9R6Hckb+QVobZc3eb265x7Mbz+pRkDU=; b=5UPujt9hEMpQswIk7YkoQBPyFOlltWZxMOWpTY120edhyvLd+/P5jNPpmw/VfCqNL0xGt5 d3XWrct8kQDcUnOUK42UsoLeFKqdNUA+o5aiHPA+a9b4tBp2xrhf2YXUDbODLPTGiFAJMz D/OaXdcsFpfbhIk5tyMoYnkl0Tc1v6w= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=YRSuxrIH; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf21.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222060; a=rsa-sha256; cv=none; b=UuSo2amjnlU9INTBgZflNErnLFAGM3PzPMJbQL5ErFMt0+SLbdTyS4iKfO91h8yrmmPHTD pQ0qR3EzgMh7216b/egES9+tHetQ5LE6VNEWLM6Kt+40+Z10cfbf2cxWrQ1InjoNCL1cJM giw5poN0DByYMDkmbIZdULPmFSp6wjA= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6687446eaccso311212b3a.3 for ; Wed, 12 Jul 2023 21:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222059; x=1691814059; 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=2uyb10W8xRjD9R6Hckb+QVobZc3eb265x7Mbz+pRkDU=; b=YRSuxrIH8XKdAW0kQO3SmDGmJ+pvEqfPMHAcG7+sFafS/d+jT6N/m/StdjuFthkODl J9x6h1BvoAUJ2/0Py77CgQKA0V45/7UT3CCDyVErHqZgssLwbka39ahmK//VnFw5/Orb u0FUM5IpQcO6CKHS4DkgDUp2nPGIBzpSrAY+ckKGMG4p38UniHiXjXuVMY+sZQxK+UZx vqyB7eU1ay5ZD3cGjO/STbrR2/GjTvwsX3rqjh6UdhYbBju5LjFgBHJsB+MbMl4166hd 6hKN3Duy7Ko+5Jjf6CxkWYuosaPbu1WsOpO+6fO+x22OsbfGPNaUxGejvj3lD+1UlVTN +AFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222059; x=1691814059; 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=2uyb10W8xRjD9R6Hckb+QVobZc3eb265x7Mbz+pRkDU=; b=haY72bpUq8VXNmKZqhGvTyAnGH2sLYvNfihoD1gneWxzB4SMyrMx0rmBm/wPneKMEU VEiUyIXCYuXN5T5CedXRunvM5qyBkQ7nYwtn8caaXuKaqtTgw2ulERrVz8LQtsl0ws/n yt/FdOaNxu8ZDUaHOuwvlr03/F/zy4DrtDXeERaEdL1hw1sAaXzF3Em3/tFN6pUHAF3Z ZAOrO1A//YtcLB3RNCCc6rhJrGHThNXS9UH6ZzPld/+UPic77HIAf+mGmSC+TXLaiCeI /wB7V51p7IqLlvmNEG0gAW/9G46TgMf/4ley8V96NHCnHnKVM4HpwACOf1aAb1vOSq3b 0jNw== X-Gm-Message-State: ABy/qLY9uS7cuXdhsb2K04d53sAVy67tJhhXl17HoIWQy/NdXjC35LuZ Y3aWUYnhwF7bHGBF6O52WYQ= X-Google-Smtp-Source: APBJJlFngfTCIZX6kEzbBCWxzo+TpDlnPYvBK4wEL/QFsnQzudRdGVDSAK30ILKKi++2X8hEX7YykA== X-Received: by 2002:a05:6a20:4291:b0:133:21c3:115e with SMTP id o17-20020a056a20429100b0013321c3115emr442265pzj.48.1689222059554; Wed, 12 Jul 2023 21:20:59 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:20:58 -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 02/21] mm/zsmalloc: add utility functions for zsdesc Date: Thu, 13 Jul 2023 13:20:17 +0900 Message-ID: <20230713042037.980211-3-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D2C5C1C000D X-Stat-Signature: 4bk9m8c5dnx9a1by3cgzxk8exsjtcaz3 X-HE-Tag: 1689222060-410569 X-HE-Meta: U2FsdGVkX19fQomKzMeRyo2r1oIePtL5kRRxL91P5OYiBii882sMT4vYgwI3cY6Q2oNK+GNAasJMIjihSr1SvimRR7A4s4dDFLcxrgOpOpma6E7GShnmB3lYaT4NIhQutumAORKcP5e7XCKX6406n9YAtU4pMhCFO1JkpANpVwOY2J1HEqpBinTs36uKwony1/W2DkF3KhWNhETgZu8kiPl1t30pR3zzbdX8U3YYqVMKWUrkA5sptGoQ612qeCVDckCwTovi/y7bqBYaZl+o4V3x9ufeoROmrTvyqjsIOJnR7UAwHEXc3JQSzMHPKCl85aqYgcGAO8yq88DPVAi748fM1I9GkI0MTbofp2RWLr57DKAL604lZEvF8WiBRj6ZmjuacqCXoLYSpLZVZ28GgZmJ2FkesuxE/ktBAgWqo4KblNAY7BpopAC2t0tcZWGTvar6pZStWJvsaZUllXZlR2o41fRHXzgD6lkQ5JEawyx9VA65xpnCXFAA7KSYQ1QRh1eOip6j5NPAuOy2xshrhhItP31cSD5p/LZxRILNdXgQY3e7/O4jOBK/VwfkUc9gr3iJ7rA4cOY//U67iLu9fIVG8LmFtdYf+XgVDZBxfPkuQtEXgwN7wm7VS9QSsAbkmelenkDZatbhG5lmHS+3S+B3oLnaNF+is913I91r2n7yNBKQyMDokrIuTRdtGxe0SS3ZcDtSpYGEs8v1P96msjwDJaVCkEIwndzbJwTqnJGPQ5CqhuTQ65EQJnemVsU2itUbsznSY65T1Gj+ajDVzi4bJVXJcLbxHI1whzMmhWZbgFw45H2E/x+NTOhPRaVrECuan2r4/6rSN9zv5/u4+yp930Zopnv2ondjyG9DcclZaEKWNK0z2DuW88RMho9cWs1BmC/2kv2Mqt0cjAJnTIF8CMqPjZFWlfs/BBvrH+VicwtNLnxL72RMzZVqlAlODdfPYErRxrL7UAmBpjr X5omKyzv Juxa9fyJLnCMjXGQUqKhsjjvzwOFuqpBc9bnJYh5k5VJSgEyUuEirmlpUzV94epD1CbifI9ecR9AHjOxDMTfkiAZdRrg6jvJhmVWo75Akr6se29tDoUkDk5JNxVkAoU9mfiozxFXUUuGegJUvofrosStinfDS/UWAPKh5c4f7TvjH1/2BEIjilbVbAAWzeWStyaVioDyb1VXztpcIRJZ0vdUsp2iKaP1Q/n+QLQORIf3BkUci/hsv3yTeTby7a4pd1KtOG/Oo4mLheybfERmniqUG1PSLQiN1WnfGEbQAILkNzS5H535V5RbKtRogFDOCXvbuk0TCmqDq0DsT8bzJjY7Fgb3ZiSAyFeO6mZt6b40jUnEilklHPgxi26bRQdgo+36NGM0X9zTqtHEuCUEadEFS2NmrRhpTdRPo5Vud0FcYmz+eUtL76coosSTmw0cNo2C63ewOX7HZhl4ahBgrtt4/Iw3vrAi70N4fI785SUn4oD4ZAJ9yvdW04G1rdfLlL4n7dnBaRqFPqoum+LZ9uPjF9F6ZqikBvKwDmI4yzqzQidY= 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: Introduce basic utility functions for zsdesc to avoid directly accessing fields of struct page. More helpers will be defined later. zsdesc_page() is defined with _Generic to preserve constness. page_zsdesc() does not call compound_head() because zsdesc is always a base page. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 2204bea4f289..11c203e79c39 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -293,6 +293,39 @@ ZSDESC_MATCH(_refcount, _refcount); #undef ZSDESC_MATCH static_assert(sizeof(struct zsdesc) <= sizeof(struct page)); +#define zsdesc_page(zdesc) (_Generic((zdesc), \ + const struct zsdesc *: (const struct page *)zdesc, \ + struct zsdesc *: (struct page *)zdesc)) + +static inline struct zsdesc *page_zsdesc(struct page *page) +{ + return (struct zsdesc *)page; +} + +static inline unsigned long zsdesc_pfn(const struct zsdesc *zsdesc) +{ + return page_to_pfn(zsdesc_page(zsdesc)); +} + +static inline struct zsdesc *pfn_zsdesc(unsigned long pfn) +{ + return page_zsdesc(pfn_to_page(pfn)); +} + +static inline void zsdesc_get(struct zsdesc *zsdesc) +{ + struct folio *folio = (struct folio *)zsdesc; + + folio_get(folio); +} + +static inline void zsdesc_put(struct zsdesc *zsdesc) +{ + struct folio *folio = (struct folio *)zsdesc; + + folio_put(folio); +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { From patchwork Thu Jul 13 04:20:18 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: 13311267 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 50892C001DF for ; Thu, 13 Jul 2023 04:21:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2E738D0003; Thu, 13 Jul 2023 00:21:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DB77E6B007D; Thu, 13 Jul 2023 00:21:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C30C98D0003; Thu, 13 Jul 2023 00:21:05 -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 B430F6B007B for ; Thu, 13 Jul 2023 00:21:05 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7EEBFA00EC for ; Thu, 13 Jul 2023 04:21:05 +0000 (UTC) X-FDA: 81005288490.26.B861EFC Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf13.hostedemail.com (Postfix) with ESMTP id A4E2C20008 for ; Thu, 13 Jul 2023 04:21:03 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=beHvFnUz; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222063; 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=Fp6PZAIRFvwp6nXKJbH8kpHOkBbqGND+2E3aTyuENRc=; b=LUCxlgI8rzGMzxGkj5L3xclN6N3Msp+ONL8CBn3jw+LLu56cJ4a4lSexoaykBwd95sWVYo HWimJNg+BM9CcBLN0yXaNE6coI6LxGFmaZKjA6BRR/QliaKWwzoxy45u7lTtjvWgfXkbIj 2bXVsudgVyDrPXMg4txaf/6IFTMgd0c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222063; a=rsa-sha256; cv=none; b=QbLFn0NkxtMj8n7niJQlLb7Gt1jFXzb2E6fuMz9753+kZGkoXCCuoDTeK4CnsurXXO/hco tiyaHGxILTFl4M6Txe5l/inPj4f/3PTe1YUqNXcFVVYMtGmOKetSR3jVztK/0MTxZxQnA7 pCk4r1YUxKepmta9BDbsUTZiEeeI60M= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=beHvFnUz; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-66c729f5618so324045b3a.1 for ; Wed, 12 Jul 2023 21:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222062; x=1691814062; 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=Fp6PZAIRFvwp6nXKJbH8kpHOkBbqGND+2E3aTyuENRc=; b=beHvFnUzX8qISZCLCnJid1ohVYLhkgcwmfXqTrvDAtYU+uy5Ztlr+SfvlDI6cKoJtE iskvrecQA0bZlZDRwbgVQ/g0J8Ut1SML5FIOq+0eqy2Ai4g2gpA5Ox886og6Bj8JqBFi sjI/ULVjLyBzR4xJcQL4vrDSQDjpBAQYJ4PhWsz/JEJdXAkSZMREN/u8JelZdypkyQyP 4GH04a4CugoAB2zIdF8O/gijVzuTdNJit+bFzqRN5hyYOdK9hIryfuvUludPF6xLzVrV nGDS9XIWOlCAvE5/ZdkX/fU2CE9ooGRBeoqkeqU/LhoRvMHmj81pl+Q1+6Hl9v4bRPFW WFYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222062; x=1691814062; 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=Fp6PZAIRFvwp6nXKJbH8kpHOkBbqGND+2E3aTyuENRc=; b=MvVLE2waLBCJZh0ShzguxmQXoChN7wbCoLqw8gluRJwkuU3EeES674pmllcxDmDVZK 8kD/xJkfqYBSAgeUpHraOqjNCPyfSqSSxlst5WBfWS8bFjyfjEA8gXTSMxL/TPLtlLeo 4uwM5+TiBBtIejYbOaAIk7sIzPU4R2Qkg2xfyEDWosvhVQsO3C1XrqdBk9xPWsMhDRap rxYnc2rrLDFIz1TF3LKJa+OFOAlkfTrOEIWwl/eWCkz1dU8pj2pZJFkKtEcraJXVfzCE Htywn8dZmlgcVIRKnJv3ZBOV85VCHCgrTfZ2Y0SGOBKDG12+fteImXXwLJ+laCVMFt7F WAoA== X-Gm-Message-State: ABy/qLbScIDj92pcU2ihcdDF/dx4ruNtIAOv5dlE07j7PapHgsPEv7t+ R6dy2PTqDAKVNJmRiP9UFGd1/8KqU7jfraY82qsbdw== X-Google-Smtp-Source: APBJJlEdRUxFFFRpu7uJbEt4B2QPnF0T3XjBRUtDhiNmPbHRgO1w2Gtj/dHOyvp3B96gwDB8K4OapQ== X-Received: by 2002:a05:6a00:150a:b0:680:2b80:8479 with SMTP id q10-20020a056a00150a00b006802b808479mr876923pfu.19.1689222062432; Wed, 12 Jul 2023 21:21:02 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.20.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:01 -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 03/21] mm/zsmalloc: replace first_page to first_zsdesc in struct zspage Date: Thu, 13 Jul 2023 13:20:18 +0900 Message-ID: <20230713042037.980211-4-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-Stat-Signature: 1igcndf1g4a8udxnio1zost9benikb54 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: A4E2C20008 X-Rspam-User: X-HE-Tag: 1689222063-795541 X-HE-Meta: U2FsdGVkX19/2iaG1wYUx48N8kgwqTSiOkPRNVZIvSDUcLYffMRbDNXFwIb+qPgPpjPG24dAqvLWMg9nHenwjniSji8sSC4D4lOrdh1NHrm3M3UfUs2hMBjHQmdrFOsIAVbHmPslC3wAStgLcfDCCvuF41cZ4qa4Jq5mAWNCUgDujqt/+ACse4xQArTDapsX7g7qbO1hkO008zvseUGxZds37pDAKiGShv9haD3HZ6chURadk811qpPFaiCkRlNXf/Ncm8H8ZlO+/Z/HtX3JnLivPExMzDtqhMokD4QjWQhbu6Dta4Fs4s5Wu1Iiji4Ib1zEFQHaF78mUJKdCr72kk6blHCeqYZDgzD7kU1YV4gk4kqKmg9TFUUtwiGRpauGQeUYc7yJSfZLewk2r1IPRe4irvnqCTPn+ixNlbmWIa5oRV9imYac7PUe6fgkEg+BzCu0ur0qsXhNYN9lJD9Y1d2qMOQ7zDlH2pq75GzBhSILVbq0vMfYR7HBq8iH0EpyiJd2s4D0W3cVuP5BSr5+PXkD+ZAGGhnOU/TluTnRcAY5OiZzd8NAl5uH9yQkuIPkhEMOLEoww+ZjJyDYCgpTHQ6CS8lOX936HLWaTJKtM/XEblO9vlQqtHQ7WBg6f7GhkpGrNithHXdjfeAv15yGIiFAX8bgxiBD8JtROUhyZWKEPbQQfRaVf6ojcPIAOv5bSEiAdMwbzlpK+TB2Bse005K7Lg2vU2BdB42pIxZf/P9wHAISCimd7MIW/ZbriHmmVyNEZ6tHvAtR4ymz2TWLcG+b8rgyi4gttgYAi1juoEF8tM8JoXjbOde+UB2SaI83DVM8J6Hu5urrrEcGSQWS2ybfqHo1j7xDBbosQlujurUGluF1H2EeRjEJzFnV66ye+Q5zh9+09gJa+I8cDZQviLuaPS0cSdo8zp/q1mEYS3XB/nivyIO2JwG1N7hHiC1jl1tf13Nk/9zIimRxshI lulPYUHe Kh4SxPCNp/i36Vqx95uYCgOuEw6wIUxUXzpSUx8JN45nyWDgY83Vc1vpyILzXFbXKkVgkHZY0M8VauawCfuw2uu8rn54jZxyVgAwxr8poM/VnwcgaVw02ujirBP7LivZB8booHr2PxfwpX1ysYFIe4Ge7hQ0WMP6Qk2NRk5OnIyHPBnOxWXVy2KSwL4HiC0LzLICkChmieI8hJtjguC8zj7Aj0G1NvQgPCt5bcBKmDH+8x6Hh4s+aPwF7PAB3Niuo8DXtmCySHnf69DDqyugTVcT/S9ccwdHBLMb4GemhaxHV0x79zL8ZmN56g1S578Uuf9cEhCumbF9ZtARif0BTJEvNbQU/jy9D6ak0/TCDE46Aj9aNj3r05jnyvKjzJe1FchA8XZ12vqEF+4yxvObuItvVLat/pd2n7uoNQg6R/WUl5cmDSCujl2FRJ03RcVSC/taIS75dJPsPjZ2gIKziZrcA4+Gx9/L4Th/B9IgG0+lmUuwQZ+Vf7b69BYtXDcFdeRC3oubMHq10qZn8i+XiGwHWmuki0IHO9V6SFaeru/mb6CuhhvlgwIs/4sgkY/XVObBlbtL+mVkrTTUTUKkBOpdbPnD+DO7IHEtmFKa5rOQD4WV0RBqslvwClXuDiXRQBLO/x+/LdzudWaE= 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: Replace first_page to first_zsdesc in struct zspage for further conversion. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 11c203e79c39..8f7d9b79d849 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -234,7 +234,7 @@ struct zspage { }; unsigned int inuse; unsigned int freeobj; - struct page *first_page; + struct zsdesc *first_zsdesc; struct list_head list; /* fullness list */ struct zs_pool *pool; rwlock_t lock; @@ -512,7 +512,7 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) static inline struct page *get_first_page(struct zspage *zspage) { - struct page *first_page = zspage->first_page; + struct page *first_page = zsdesc_page(zspage->first_zsdesc); VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); return first_page; @@ -1024,7 +1024,7 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage, set_page_private(page, (unsigned long)zspage); page->index = 0; if (i == 0) { - zspage->first_page = page; + zspage->first_zsdesc = page_zsdesc(page); SetPagePrivate(page); if (unlikely(class->objs_per_zspage == 1 && class->pages_per_zspage == 1)) @@ -1398,7 +1398,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, link->handle = handle; else /* record handle to page->index */ - zspage->first_page->index = handle; + zspage->first_zsdesc->handle = handle; kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); From patchwork Thu Jul 13 04:20:19 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: 13311268 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 35E77C001E0 for ; Thu, 13 Jul 2023 04:21:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B96C26B007B; Thu, 13 Jul 2023 00:21:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1F428D0005; Thu, 13 Jul 2023 00:21:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C0336B007E; Thu, 13 Jul 2023 00:21:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8C7E46B007B for ; Thu, 13 Jul 2023 00:21:08 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5A055C0109 for ; Thu, 13 Jul 2023 04:21:08 +0000 (UTC) X-FDA: 81005288616.08.5A67615 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by imf24.hostedemail.com (Postfix) with ESMTP id 5087C180003 for ; Thu, 13 Jul 2023 04:21:06 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=mYhOCoF5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.177 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=1689222066; 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=jcE2YmIW31bFO7IyE1TbOouyqUx4815Ufga9qggKlmE=; b=WcrwaCwy+ArLnPBVLRBVYg/ZR4LC6GaSmiJ0gchVrbvanB9QOACOkvD93SpWieKlC7NIPP d0yVGUvlSHtIOGaEy/OJ8KQ2j6SWQXDOQ84xoHbuIDD3VAglbFPRtcFtYfPw/MiDj315GR zxVsikxL9UOsAPVrs9I8AciZ5UnjQSs= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=mYhOCoF5; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222066; a=rsa-sha256; cv=none; b=BPUjW5DuRlpQHBDiTTWLKFLc6BDaE1kIouwpwvW60D0w+NBG2M4/d9nzCld6eyDGT7EyxY VLIfAf8nDF4C7YZSowrD6jl+729w78edzpThZqf5qxvR8vIuzXmf2Y1J+W+kIbXHQb1hrQ oSZ6lVlqYga/QJLlEaNmM5CPZ610mmw= Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3a1ebb79579so283554b6e.3 for ; Wed, 12 Jul 2023 21:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222065; x=1691814065; 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=jcE2YmIW31bFO7IyE1TbOouyqUx4815Ufga9qggKlmE=; b=mYhOCoF5+AgtodxdPh9hQADQfzcGGFdPKxTugVcu2Qs0e1yVg+0UkvCcRf/X3w/74s Kyz6ifXK6zTs2BFM00E8ADWIYlLRhhPSNmHbMUUZlBj8VJNziwCjHk5q1W5JoGbozIkM qI8cO56rtKm63AxeFVfIB07C8I5KBI7+H5+WeFGDdYzbEUHEYPgAoPksrpjWn3Ox9zJz BMPH5pv3QTN4UVgD9QNi87H5RnXLR/nsxOoAuPs2SRz6Ey0ejYmkLYeUBccuiFTR0Oqh q7//HZplNbzxfarT1/+PAPdpS1Cq6urRz8/Ed7OiPdOVBDo5/1Ub5DlQn/PxPVvuBZ4M +pKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222065; x=1691814065; 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=jcE2YmIW31bFO7IyE1TbOouyqUx4815Ufga9qggKlmE=; b=jCByuUS37qLJ0dTPsJHfPnAciwNqfc4ta79WhCXlZ7FrfSWUwvLIalKcbJTZNhqveN t+rOTfuNUvgm5oiql+7Au8u96SYsH9vHdzIVHEFxrfvjnmvx4eWX9xrZZyEOAvbzEicf hEIZsMZp7KQcDnBwSVJPmgyVv4lj5qOmch0EBfYHrG0yew4BfaA9fHm0ct9vMeRaIGye mT7U1PssRsY+wy5cigGsE8sATem7L1+eI8wgNqWZONlEE3q3y/2TNBR3QUa0/kc/YhJ1 mLzp5IdNfSTc6kJmXu6Lpgp0fghZly+acAWZHcqD0exFYYDA/OMnQurg7BoJS9csw8i0 iYsQ== X-Gm-Message-State: ABy/qLZ1qRx98UMRMrnsTOTBnmQEXCWfBWxU0bon31mRF7vLbZBiU0tL RQRyazliqRxupJdaPTP5xuLBK551QjJpKxD3VTNtNA== X-Google-Smtp-Source: APBJJlHn+GjEfwkeFf3et/qnGrOvXvkqgNMp79oM2A97NPAz4SPID9PPqYp6PTsedEbPVJXbuLD/Bg== X-Received: by 2002:a05:6808:1286:b0:3a3:baf8:5b8a with SMTP id a6-20020a056808128600b003a3baf85b8amr908456oiw.13.1689222065353; Wed, 12 Jul 2023 21:21:05 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:04 -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 04/21] mm/zsmalloc: add alternatives of frequently used helper functions Date: Thu, 13 Jul 2023 13:20:19 +0900 Message-ID: <20230713042037.980211-5-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: 5087C180003 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 14dau1znnprhhgum7yh1hmangtsqzn5y X-HE-Tag: 1689222066-42114 X-HE-Meta: U2FsdGVkX1/OMSKIVLWUBEA+sTE2hyZrBQyBQ1JEscjyeTI78llSa607Hih6ui5ULBwlsVd2DhQYO0Pqj5ItN+VSRduHYNGrK0Xq0ccJp9SNElAJBt21LRXs5mBhA7T8IlFykWQqXVG3WYtnpfFaNyEnrnl0HGc6KkUrZ+ymMtCh5XTKToxEOziXh5tDqfY1TIusBAsf44WEE3zvYFVWxQqsMFRNI36dMKZuN1lk2lD2Vmv9ti7aC49DMKR/aFaMPo0pEoThhOmr7BuzeYI2l6xAhu04MWHM3Eg02ffXK9fPm+kA7tFKT/VUsssd5mkvql2+ghpqQ3iCissi+cIA2cWyK3ocOUaa/srWS8iZdG9iHrgqpoyNvT5HNmEgPHbXe9LEbKL1agoeCs94yOgicdqqmX4Cu+ksyeNXXGuD6gw/TBrV+EIkyQkrIu95ysZFc9puYrQjFkBTnAnx2XzJHhC/R7was3z2a8dXm3xcx3GZKYs0ZCIpTYP2PQoqRDnLM2yIjkdIsd3Ay2ZeSTYeWQ6PTS3qfozX49dSPSzgGbfFDpGy8QOJ60bHnDSv9+GPYFhhl0twO8AMMmXsXDUdVqTMM/dePp4it0JmfxbjFmDjmHhYaQY6RdtYl/P+TXp/ajE3TlhyOwdGZ2UgseBNZ2EI5NU0cwncsQfYEuFCXtg0pys1Ks0FezaTNjM4P7HrC4g0Z/CYvyha4mIjM22AzLfJhFegKsr90Zpuqpl60+PPyukQq9ujcXdscr3tw6FtCIbVdxH2HiaX/NQngcRTmjoP/TTEm2+/Xn15PbJ0TKd5DT6FevjwiHNgo8qkdtB+jU10exNUOk8n+SuwROXFhroVHdMPs6+L6WqrGU0zeroLDUfPh9QpQotLNyzI3FfyZ19TPgBw/IDtsYPfAi9PJuDn+/53RB6l80cuVykfOJOkc6RimKkil/ZesOM8wH/NSJqapCAU+D3lTq5lpLq +fWxIwuX C9rC3U86+WP+yrFOxlYbqRq4kS9y3ZO0Dq0nHMg90UqEoAHkPaoTyDcX84P0Z1yv19jW4Rqd+6xXLLrmOag/0jEpYvLx1PyshHeilJvNTIt3mFekrGNsuxMkaoVeAcmXr7dV673r4+w0RJX1SsiVHb9iJjceCbL7w0pYCWGFhdS6a7TyYGxlmBgn7jD6Wq5Upd2nMz75dLwMmXojTKA3y8aAV9fky/Iz+DOKZM9O/TQEjnkH9hQAzgzwTlFug2BH+T6Z1pd8hO3RGvYatFCXpHMsR0SP6uUxi4uEsCsZWegXQXpEv/89jok7rXwVlj+68q/8NnFGYw2wCxE1t8HDXdKCwQw0ef/Ek70ECCb8N22Bk+3DzWQcb1jrpiyj/3EHy9HzreJcHSDBwTTD8shv2GJD5oESCvRA5xOHCRGjTWSoNndKwRnwUlJwZheIZkvy7rWzM7FpuejAJ3RjzNny5miJ06OBulnoFNHMEtmMVulrmV6GFcgeCMzrQ8DHOssJQVon07pBbvRBj5PgWR3f2ZIaz8j7KujO3JypZm3T5soQUUMM= 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: get_first_page(), get_next_page(), is_first_page() are frequently used throughout zsmalloc code. As replacing them all at once would be hard to review, add alternative helpers and gradually replace its users to use new functions. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 8f7d9b79d849..f44a2d8a36b5 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -498,6 +498,11 @@ static __maybe_unused int is_first_page(struct page *page) return PagePrivate(page); } +static __maybe_unused int is_first_zsdesc(struct zsdesc *zsdesc) +{ + return PagePrivate(zsdesc_page(zsdesc)); +} + /* Protected by pool->lock */ static inline int get_zspage_inuse(struct zspage *zspage) { @@ -510,7 +515,7 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) zspage->inuse += val; } -static inline struct page *get_first_page(struct zspage *zspage) +static __maybe_unused inline struct page *get_first_page(struct zspage *zspage) { struct page *first_page = zsdesc_page(zspage->first_zsdesc); @@ -518,6 +523,14 @@ static inline struct page *get_first_page(struct zspage *zspage) return first_page; } +static __maybe_unused struct zsdesc *get_first_zsdesc(struct zspage *zspage) +{ + struct zsdesc *first_zsdesc = zspage->first_zsdesc; + + VM_BUG_ON_PAGE(!is_first_zsdesc(first_zsdesc), zsdesc_page(first_zsdesc)); + return first_zsdesc; +} + static inline unsigned int get_first_obj_offset(struct page *page) { return page->page_type; @@ -806,7 +819,7 @@ static struct zspage *get_zspage(struct page *page) return zspage; } -static struct page *get_next_page(struct page *page) +static __maybe_unused struct page *get_next_page(struct page *page) { struct zspage *zspage = get_zspage(page); @@ -816,6 +829,16 @@ static struct page *get_next_page(struct page *page) return (struct page *)page->index; } +static __maybe_unused struct zsdesc *get_next_zsdesc(struct zsdesc *zsdesc) +{ + struct zspage *zspage = get_zspage(zsdesc_page(zsdesc)); + + if (unlikely(ZsHugePage(zspage))) + return NULL; + + return zsdesc->next; +} + /** * obj_to_location - get (, ) from encoded object value * @obj: the encoded object value From patchwork Thu Jul 13 04:20:20 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: 13311269 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 396D8EB64DD for ; Thu, 13 Jul 2023 04:21:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B49768D0006; Thu, 13 Jul 2023 00:21:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD0948D0005; Thu, 13 Jul 2023 00:21:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 924198D0006; Thu, 13 Jul 2023 00:21:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 808C98D0005 for ; Thu, 13 Jul 2023 00:21:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5A6138010B for ; Thu, 13 Jul 2023 04:21:11 +0000 (UTC) X-FDA: 81005288742.18.00B2B4B Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf19.hostedemail.com (Postfix) with ESMTP id 843411A0010 for ; Thu, 13 Jul 2023 04:21:09 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Jt6o06lR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.182 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=1689222069; 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=uhaPI5HZCviIKmkdgH7KFJDdrqT6GNzpynmu4YA1d+4=; b=Zj0M3KJYDiP85bCWX+3yG/x3ckBvfNyyh2jtjdj5P1hChiJ9dp2quD9+PHQEjoF67yqVSy VwAbnAJ3BmTpqR6Q9WP3bvfLSuOhLg46sHJEqtBurk3b5pc7xiDV5XErXNIzXQBCScbWtv a7EIerV3dutnqRksnNh5fAuh9cNjfBc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=Jt6o06lR; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222069; a=rsa-sha256; cv=none; b=pu7PStGRNrNCnToWM0TF7rHyAvfORMhTwrt4+zio24Rf52naTR5iiOeu8yRrJMkP8DU1oH 19nSsucqYD0Tu9o+kepOHLcxmsObQA79cI6XgWa0PeloNMx5LgjDWsQjU+8EbkeJX6v573 8NwyecyZ6S/6hBJ7thCsUFuurqusngY= Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6686c74183cso322986b3a.1 for ; Wed, 12 Jul 2023 21:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222068; x=1691814068; 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=uhaPI5HZCviIKmkdgH7KFJDdrqT6GNzpynmu4YA1d+4=; b=Jt6o06lRegWfpT6s7u556O96jLXuVWenL3j7rdCJMMEZJSxbKfdLZdvetPddoF/DHX PAMG0XVW/6owS3g4G4hGDuiYl5Weo+v61dNqznEhQrdjvfHaNR0Uz3Xhg37UAFAsNb7U ZH7JKwt8s7tvmf6jfRAoe5445IXGboDowduaXGoJduEmrtA/Gs04jyb+QhdGq2tCblsB VilcMo/Li/bBOTmGNGKEK+fobdvYvHTEEULz0+R5qEX5V9BHphgzBgL0oa3cqLS5uL+S wcdF4m7jBn35fTjxbHwyr18gTW56GA0WU5LMGze94rRKwRwLwPSLNaPW6F1EdVP1tc72 Ad2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222068; x=1691814068; 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=uhaPI5HZCviIKmkdgH7KFJDdrqT6GNzpynmu4YA1d+4=; b=VxeXsAiOjxSaWCD5J4PnwuKhjf3d/OxXuwax48SU8GdriSjsmCMbwfWQgSWFTQP9f2 +mQbDVOuyhNz2DHv7h6EcO9mcTouGNWnzz4rGqdnG4vNQEEPPIIw0MyM8Wh9BTP9lcPm AB1i8YltTRkHJOVwrV/iAIt1/pMP6kJg4IstMEoqv7yXZLoIFTvxShdzTu0eKAtQA4yP XrNE1R3kQEqmlI2KsEHxM4YKtJuTebVxmRQhvgwMaXRILLLFQ7qYuX08rOfwOd4mzJRd 3NTuDRMJ8NUmP1WcEVYCPHhdPXP2yjrepcLE1Ug28i1qhAYcfVE28WBKYHV+3VTyYjbb I8PQ== X-Gm-Message-State: ABy/qLagop6xAglOre7qjefBnxa6Zxj7Zwz8XAMQgm7dbrpxJ2N5xPgi l4qa5R4gPLBi0IVpVpsmz+E= X-Google-Smtp-Source: APBJJlEe7OIMuJtVjHfXHkehY78DJUMXlwp6taFHwT6PsouXRsh0IpuGtqw7vkbfdP9Ouwmze4dUZA== X-Received: by 2002:a05:6a00:1692:b0:668:6445:8931 with SMTP id k18-20020a056a00169200b0066864458931mr807724pfc.29.1689222068309; Wed, 12 Jul 2023 21:21:08 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:07 -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 05/21] mm/zsmalloc: convert {try,}lock_zspage() to use zsdesc Date: Thu, 13 Jul 2023 13:20:20 +0900 Message-ID: <20230713042037.980211-6-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 843411A0010 X-Stat-Signature: 5pycruam4u64wofqeja6yihs4tjcffqg X-HE-Tag: 1689222069-292798 X-HE-Meta: U2FsdGVkX18Z8gdCtrCngpQp/4X2wRAuFgjowyc4+N6bceba7EAVvoGax/8BIDMDeNLmu96BXYKaJB6EjksnZ/NwjX5ckhH+RtVd6FK/FYv+UrdPys7GLELTX7f3tSRkY32wNRpMNv9za60avQmQZzzw1dDwFpyWRrWAZcTuur1OiPvoZeji2a04Nr9TeT1FMjOPAh7exMGIDRL/Xz8pVMWMfaMJy2bB/69a+hWZ8vKfYbiRC0ElCpP5DtrFg+Pw5rI6dODj1JnY3+X920c2dN/ysBwE0otQTmKHyTIYldC8UZJLHklUOfFStMeb117x7+5XGCh8Y4qMgI3XPZp3jOo9fYUGLsvYlhhXwDYuDAg1wInhXUGIppmbypo//5grqZkGpxjt9rV5xJ/5EUaPblWGAE9+irlwHi0FFofUND+rHApe1h1jyoClJSzWTQ7MrSZ6+6Cu/KgyZ7unUVQOv8HkXScIUiCRCs3GdfdrzUs9yy1GLA4sGM6v4LyYZvBbGzu9w6wxPnql70pHpFGqNdtoHHSv0IjyA/ChznqFCObCFvat4xiVugDFrDT/AohRsY3VZjqQs+aDplIK5HzVBtJeCu+RTf5faI6ttqd/luFt43hsSwel40QS1hjkOoGgwkVbcH41IkQTRM0eVqTKHrZkzp9JxlOt5zHOWhWxhz18mGkQ0YFtVxBO8U8E+FUhFJdD4yEcazsZrTyPMVwsJXjQxmibPuAu+PoUWX0vV3JrwGg+Y0uEgeTDsQGKIdN3t+Ek9v3oTpcrdExbVNXuQeSoTmM7egJKnuP6szFiHZJxiwWumdkFQPV79ASnZOpIY0LAewvRXaLLDLBJRTxeTJnqtiFEyrElOh30R/nPd/+3Rol9uOhfzoR735zC+lmZQOUJvAX5k2EnLrm1kypCx7cuqOfeYeLRILqajmkg1aSjSugq8dSOO2UTxa7xuCBJaFJe1ugPrUXEO8sztq9 +eA0vuLA 8rVIq2ohQcv4E7Gs6Bxzbruu2RbaQnOO3dU4qqBaDapVi1Hu21tcbG7xj4w7HVdp24gguJntFDC3fSvPX+MtsOiOx+qioTh7+UnT7dm7dsbxM5AjHgrHEE/3rGkvospBSYMmvgJ21A3T0EOJgzx7n8TfM9S7A0Ax1rNZE3fSBmQwKFZ8BBxZlxYwOy4V+cefe8HZ44Ibc1gtiEKAUfgWbG/yjpy/wap6WSmxHtGyLcaGSI1l998AXkJiBYOkgJr769O+XQ5wKfaW79sdWEAJ4MC28QFL/pl6Ubjwq74JzVtfgtcHfOOd+l3X2cSQPXEly6xQdIFATS9f/4R4leGQSfEl0DupmfXn0x+oW54cikAdvTx7XU+5mXErzO00c02DHqAuZ0hyzyvt9UlYuUQB8AoWEvaxTkgS8OCoQF0dNpCJc2JjVgBkC7jRLVek//svt/Y2YTs50o9nj9HqD139mKB99+VLWFReRIZ0saQ70ySA3rgD0Dw9OlJqle+RQXI+vGH20qrKvg9KtJurA+kfIHH9YKHfGRcPLdAYh3wOZJrDROl6OqGNg3cB/nnvFwVyFSsIV6e0bFWoMXwTNrrnpmLSjPw== 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: Introduce trylock_zsdesc(), unlock_zsdesc(), wait_on_zsdesc_locked() and convert trylock_zspage() and lock_zspage() to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 55 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index f44a2d8a36b5..2cce76a19a1e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -326,6 +326,21 @@ static inline void zsdesc_put(struct zsdesc *zsdesc) folio_put(folio); } +static inline int trylock_zsdesc(struct zsdesc *zsdesc) +{ + return trylock_page(zsdesc_page(zsdesc)); +} + +static inline void unlock_zsdesc(struct zsdesc *zsdesc) +{ + unlock_page(zsdesc_page(zsdesc)); +} + +static inline void wait_on_zsdesc_locked(struct zsdesc *zsdesc) +{ + wait_on_page_locked(zsdesc_page(zsdesc)); +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { @@ -911,11 +926,11 @@ static void reset_page(struct page *page) static int trylock_zspage(struct zspage *zspage) { - struct page *cursor, *fail; + struct zsdesc *cursor, *fail; - for (cursor = get_first_page(zspage); cursor != NULL; cursor = - get_next_page(cursor)) { - if (!trylock_page(cursor)) { + for (cursor = get_first_zsdesc(zspage); cursor != NULL; cursor = + get_next_zsdesc(cursor)) { + if (!trylock_zsdesc(cursor)) { fail = cursor; goto unlock; } @@ -923,9 +938,9 @@ static int trylock_zspage(struct zspage *zspage) return 1; unlock: - for (cursor = get_first_page(zspage); cursor != fail; cursor = - get_next_page(cursor)) - unlock_page(cursor); + for (cursor = get_first_zsdesc(zspage); cursor != fail; cursor = + get_next_zsdesc(cursor)) + unlock_zsdesc(cursor); return 0; } @@ -1755,7 +1770,7 @@ static int putback_zspage(struct size_class *class, struct zspage *zspage) */ static void lock_zspage(struct zspage *zspage) { - struct page *curr_page, *page; + struct zsdesc *curr_zsdesc, *zsdesc; /* * Pages we haven't locked yet can be migrated off the list while we're @@ -1767,24 +1782,24 @@ static void lock_zspage(struct zspage *zspage) */ while (1) { migrate_read_lock(zspage); - page = get_first_page(zspage); - if (trylock_page(page)) + zsdesc = get_first_zsdesc(zspage); + if (trylock_zsdesc(zsdesc)) break; - get_page(page); + zsdesc_get(zsdesc); migrate_read_unlock(zspage); - wait_on_page_locked(page); - put_page(page); + wait_on_zsdesc_locked(zsdesc); + zsdesc_put(zsdesc); } - curr_page = page; - while ((page = get_next_page(curr_page))) { - if (trylock_page(page)) { - curr_page = page; + curr_zsdesc = zsdesc; + while ((zsdesc = get_next_zsdesc(curr_zsdesc))) { + if (trylock_zsdesc(zsdesc)) { + curr_zsdesc = zsdesc; } else { - get_page(page); + zsdesc_get(zsdesc); migrate_read_unlock(zspage); - wait_on_page_locked(page); - put_page(page); + wait_on_zsdesc_locked(zsdesc); + zsdesc_put(zsdesc); migrate_read_lock(zspage); } } From patchwork Thu Jul 13 04:20:21 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: 13311270 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 BBCB4C00528 for ; Thu, 13 Jul 2023 04:21:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57C498D0007; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 504608D0005; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3576B8D0007; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 256698D0005 for ; Thu, 13 Jul 2023 00:21:14 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EE4801C7070 for ; Thu, 13 Jul 2023 04:21:13 +0000 (UTC) X-FDA: 81005288826.08.13C03C2 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf04.hostedemail.com (Postfix) with ESMTP id 3481040009 for ; Thu, 13 Jul 2023 04:21:11 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=miEYIZPd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 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=1689222072; 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=ngawLjUhlg0gVz5P0h4QP2p0Jiq//HK+SFvWsbVxntw=; b=kP0PlIz3Zk9G7ZGf+gusNr/I1YtU2TI7Hfao1rA0ZjB9szdeVjxfEEEnCfhHoYnFqqwxfF s5XbnP3qE1h6AcOBChiMekOMAAao1p6WndAXQXaFfc6KaYaP67AeFCSyghko4DghEcLNYa 7D3T3wXBcjIreLjJlziPMA5vbWRp0nA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=miEYIZPd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222072; a=rsa-sha256; cv=none; b=3ZTlCOLVYbYP400SCkYtZCy68zwcU9W5ehlWHVJGcL3TM7R0T/MFd94CD+Z8ZkLyFNeWt4 z5DaYW+VsDuBb4DQhqAIKuwSyDh3fW6Qo3xkURqtozporDsmol+9r8QMdRThgknVP+rdlB g/dMFsC4aUlPtM0/HFRXg+eHPvcLTKA= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3a3a8d21208so338316b6e.0 for ; Wed, 12 Jul 2023 21:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222071; x=1691814071; 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=ngawLjUhlg0gVz5P0h4QP2p0Jiq//HK+SFvWsbVxntw=; b=miEYIZPddB/Lztm+8sp7zafciwuYzQBUl4vbQGbauqTEcHNn1gEDiWgi3y0NgODIfO KRfT+s1Unu3fijwGFRA6MVzyG+GUTrtnozO/iijdLuLlverMdvhbbTy4KwFmhEM5G9I5 6H4sT2yoo+nLtShyHPAgT2TLEkXkcqjkOYo5zSs8l+iYRqrwf6iFewKlwX+tu7MIZZUj uKbOvKvpFprsduIHAWTp/zGNXtqmvpQcnFs8GoLU8Q5hhYMS/VT3SNJrpvkAwpLFA2l4 hZJN2f5WCfZZdlO9fOSko+tMYv92fmCpNUo+GPxTMo2dQXPG6ljyZ6MIxVd4qMqUDoys U4PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222071; x=1691814071; 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=ngawLjUhlg0gVz5P0h4QP2p0Jiq//HK+SFvWsbVxntw=; b=jPexaT4FMskgvsXBbDANnGS7vpf/qz18Epgxga5ga/yF9/kFVgmUFiNhRXdwha+lQG wRm29Rrhj6RrTRI2xPFqyQ3/F84a4iydetTTb/YKTgnhWB9O8aNqXW0CXDMPOlN9iew5 Zl04amN8Qnj6dopY2Ol49jYhv6lNyrA81YkC6zDHylksbos8VlHtDDPwwHJSfV0U0ito CZt819V+pkxBhiHiSaXI6orO06FkxQ+iH913R2K8hrWjWCwYkonavK3UIXrIbWaqSgE8 +xs5Av/31huEDdt1QTouOx2Ga4R5XJoALHjeK1DF8NZS2OdRofVNchl+S3HM1VZnxliX IVIQ== X-Gm-Message-State: ABy/qLYAdfRCRgGLfeQ26ICmZYX7ym91ssILro7p/Ns5r6A+w40KFtqi DQgPk8vql4V8Fjop/dex8ms= X-Google-Smtp-Source: APBJJlGDVBDJqg7HpEytgDXKLoXjRZHg1FxttzevCADnVlsFukqWkseGrbnLv60ArIu2kkBe91QxcQ== X-Received: by 2002:a54:4d85:0:b0:39e:940c:2a58 with SMTP id y5-20020a544d85000000b0039e940c2a58mr682388oix.5.1689222071167; Wed, 12 Jul 2023 21:21:11 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:10 -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 06/21] mm/zsmalloc: convert __zs_{map,unmap}_object() to use zsdesc Date: Thu, 13 Jul 2023 13:20:21 +0900 Message-ID: <20230713042037.980211-7-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: 3481040009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: zmaxaowwqeikys5jw73bic7hyj9xuoap X-HE-Tag: 1689222071-737622 X-HE-Meta: U2FsdGVkX1/CQNttDQCQxS0pfMvCc8nrG4hToTxLOYVKP2pLqkyo5PGGaNV6SrjSM4czHDidJG59S5TN8WisnrF2JLMhVyevgS6irpm9FyafK4H94rrhyhcB7nQGR3mOIHklRaHp5mY8hAHmaScWQt3BJav6CGSe+4iB/WyKUmIspsf1ruJTWRrW/5QBmyni3+ql+XlZMXFaVrJ4ehwG8oP/kX/3nE89gr9RdS+Hjw6wJyyiUBKqeogfHCTvQD2UBAxTOvmf3ZaW1My8Vs3KdcOboiTHNUWKGL+g1E5/RiSfJ3AafFDV/c6E5QLAkhG1qjpQBjE1kCfcKA2IdJjHWxBXfxSgapJn7Hpswp7SyNjkF8Lxa1elv3uaw6WmYCIVYP9l6goIGK3Z1azcNpbzz36Ho6QZVpQXPsxDL2TNKnfHqnc3YzX6koMJMo1xdWqERT7JEqszzKQpOx+iemzXnJ9OgoyxueELYpWdxeXR/i34aJOjP+J4ZD75xeB7tKYvygTVx9yNI+iR7ov8n4f+yXxXgWAB9Ym31Qqfq81+fFQAiUVIJ6Zaq6yNr79efkkASB31FQG6vXEsgWXsVsHkEqA5jDBqoG8PRRVBvZz3+Uwd8hd8Ve+wG+g3waHk9qx09SCmt/7e18IDx4KF3vS3NcBi1Xj3W1EmnIUZ3Oxcg1FP2AcsIwjbz1GsUzAB90nmUK8OpbsOXwz1GdGwkDxGMqQYxNMVqECDmLkr6RTWPf8ySvQ/0SL1PHIM44NVUtsh73YTbFsGSWNTaWUME/2Y8yVFpeRZs3VsdkXR/nn3xpwUKOhTtBLopZHcGr+AsqvGBoLF0TpiJ85lT/O97PaGZT652XBhiPbw4BwwC39nAKNPSx2sX6h2qhquqcz+WP9Meb3f81m/hvzcbbivOUDjjSAO2L2syP/2LW1EgG91GQdfCEZvcSbTShrTiOASz3qP/88DdhtDFBaPdpgtycj rhrygRk8 bShYwwTQ0xo93O96v4wNPQHGCbbMtRGmyk0xIdaTb/T/CP8w7kRUYMjPngtc2NqsThBBm5E1Bv6JzjQ8MpYTS/zthwXWVgM540+MxfrQGEvbtOzZkSQE8ydVppTDME8NPjL6E2v/gqXjg1XxYAbE7cKwN+evcghwy7p/p2Mib6+T/mOcAp14J+SyfmpoudFx0n6LRDJ9w+YJ2I4fankpufmfN7BtAqnRRwpUbp1JDZ9fRDptXQUt13ZbdiZJUiyZ/j0g3DXyK1P5L7X2D/jvwqs7skfW5BH9HoJrnRtevIkd8q6P9Q4ijPOiFZfWUXNel1MHxucjDH+nTleifsRNxWKDUb3pIS4232EnotP3Gp8S22xLniHEEl4ev1IcC4sYn273KXhev7q44HDQ79MA1jmrcz8QZF4hFaZ/s0aDyFiXU/Hz9y4t4TPFpx4Pg9goQl4B8GpNFShs9D2Hke4HwX7pVAQr62ikPm6YAcU0s7lf9VUiD1p/ydYUv7YVbthMmqNgSAwZeTgsceJ9ISJiPvRNjxeGzZFLJn3DUh+v9nV703scSucx8b8LwvvUsVGTFV/5Nr6kkZ7IQ8NTsX5DUaauR4g== 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: These two functions take array of pointer to struct page. Introduce zsdesc_kmap_atomic() and make them take array of pointer to zsdesc instead of page. Add silly type casting when calling them which. Casting will be removed in the next patch. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 2cce76a19a1e..4c0563fce3d0 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -341,6 +341,11 @@ static inline void wait_on_zsdesc_locked(struct zsdesc *zsdesc) wait_on_page_locked(zsdesc_page(zsdesc)); } +static inline void *zsdesc_kmap_atomic(struct zsdesc *zsdesc) +{ + return kmap_atomic(zsdesc_page(zsdesc)); +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { @@ -1151,7 +1156,7 @@ static inline void __zs_cpu_down(struct mapping_area *area) } static void *__zs_map_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zsdesc *zsdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1168,10 +1173,10 @@ static void *__zs_map_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy object to per-cpu buffer */ - addr = kmap_atomic(pages[0]); + addr = zsdesc_kmap_atomic(zsdescs[0]); memcpy(buf, addr + off, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zsdesc_kmap_atomic(zsdescs[1]); memcpy(buf + sizes[0], addr, sizes[1]); kunmap_atomic(addr); out: @@ -1179,7 +1184,7 @@ static void *__zs_map_object(struct mapping_area *area, } static void __zs_unmap_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zsdesc *zsdescs[2], int off, int size) { int sizes[2]; void *addr; @@ -1198,10 +1203,10 @@ static void __zs_unmap_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy per-cpu buffer to object */ - addr = kmap_atomic(pages[0]); + addr = zsdesc_kmap_atomic(zsdescs[0]); memcpy(addr + off, buf, sizes[0]); kunmap_atomic(addr); - addr = kmap_atomic(pages[1]); + addr = zsdesc_kmap_atomic(zsdescs[1]); memcpy(addr, buf + sizes[0], sizes[1]); kunmap_atomic(addr); @@ -1342,7 +1347,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, pages[1] = get_next_page(page); BUG_ON(!pages[1]); - ret = __zs_map_object(area, pages, off, class->size); + ret = __zs_map_object(area, (struct zsdesc **)pages, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1377,7 +1382,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) pages[1] = get_next_page(page); BUG_ON(!pages[1]); - __zs_unmap_object(area, pages, off, class->size); + __zs_unmap_object(area, (struct zsdesc **)pages, off, class->size); } local_unlock(&zs_map_area.lock); From patchwork Thu Jul 13 04:20:22 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: 13311271 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 167EEC001B0 for ; Thu, 13 Jul 2023 04:21:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A364F8D0005; Thu, 13 Jul 2023 00:21:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BFEA8E0001; Thu, 13 Jul 2023 00:21:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8396A8D0008; Thu, 13 Jul 2023 00:21:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 72DD48D0005 for ; Thu, 13 Jul 2023 00:21:17 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 37616400BD for ; Thu, 13 Jul 2023 04:21:17 +0000 (UTC) X-FDA: 81005288994.17.2B441DE Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf14.hostedemail.com (Postfix) with ESMTP id 539F7100009 for ; Thu, 13 Jul 2023 04:21:15 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="i+W/NFoh"; spf=pass (imf14.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222075; 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=T5CtvWZNM/arT1DeaLF8JN33bJjE1wRpWQ+2TM1opec=; b=EdeJVmBp5ksQ0uZG7911cE+3qmZj1MCVR7S+UOj/wRQIKJu/E2ZGzp00Fvm/tSs01LkDZH buwNsCOkXkSp1Grbf1ZYsPiu0MFtdsO9AE/DPMEJApgBn/KBT9KYzGVwv8jP7JjoG6pzey YEWpw5mLEFXytM+DhikbSYKqp2p8UhI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="i+W/NFoh"; spf=pass (imf14.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222075; a=rsa-sha256; cv=none; b=i3syHDjeGFK6mC4beRxqXly21GYib1aD83iclCZkYpDdUoVHRN51yiSXKDhhIyC8rzEN0V HEsrQZTKMgY7CLmRAZ6lkSWn7rkjslhc7qUogicWFxe/h5U0k9ZjcgmH9wIu+aXLHQM2EV BSMV7r3WdCT7b1Z0m/XPAMiA67xRktw= Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6686708c986so318337b3a.0 for ; Wed, 12 Jul 2023 21:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222074; x=1691814074; 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=T5CtvWZNM/arT1DeaLF8JN33bJjE1wRpWQ+2TM1opec=; b=i+W/NFohhvOCvKpcJMP9qgQqqgnP2EXS+qk6DRkcwUUbYvBlyO+0QzIrnCeCsGQzeG cYvSyZ09QP9qbQQXIlMXW8GJC9lCe0pdff6yWizEWhJGTSkLi4FfqcLNSlrIhbSp8wXZ h0fGuGyJO0H/0xTNTKH5YJCZnp3LI+99cDo9UlXjpTtxpQq0Q7rVV340Iv1F+/Q8nHSh aOTaBulsJzrhGj0kdl84YslsnY5LBVi0yVEhoS5Yq9IlgP8hnE79x8MaMNWqPTBDzDR3 70+Pn244J5aXK8AMhsA4BKwrtQ+ItypDMjw2JTBzWvaf7nbZi/QZhOpx9etOSHV+dYxI Tr7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222074; x=1691814074; 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=T5CtvWZNM/arT1DeaLF8JN33bJjE1wRpWQ+2TM1opec=; b=Vwz+e6v3HXMs4iYKP1ecpHriStyNTfbcofyGU/sZd9+/PJJm4YAGZLRUsrb2mOM8ZV WrJ/ICWxgiQILVVDpBiGEJAvopxS43sFVg06KVjJqv+/bgL6vFZthNrWs50jKPDyoa5f ugfxgp1w9N9Y55DyyQJXNftHoV2MzamMOsO5NYIZit0djMIwHoE9hvxuzsSuu3HD5pO2 ZJ9balYOrLFWQNCaPzSVBG3k2YJo+5gwlFbLcgFsDm55ixTvzCy/mMq7UDhVX0zy1fp5 Wulf9PsXsivWkkNHgDAKPE4yuqfBLUlAylDwm7X3EkDs1Q4KVmhGzVR3rR3XzCuBaIeF t/Yg== X-Gm-Message-State: ABy/qLZam95lMTO8+skqdqSUS3nIrGm9zQMqt90mcdpDLXMA1elMqVZ0 0DWQr5I7GkD8YR49uGnaLeI= X-Google-Smtp-Source: APBJJlHjxNeh9XNM9Xg49rVHdiHhgRhHwEZjBVTmC7d2ywHYqshe0HtbWG6bkIYM6hqzf+06oaFONQ== X-Received: by 2002:a05:6a00:851:b0:668:9fb6:b311 with SMTP id q17-20020a056a00085100b006689fb6b311mr723443pfk.32.1689222074040; Wed, 12 Jul 2023 21:21:14 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:13 -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 07/21] mm/zsmalloc: convert obj_to_location() and its users to use zsdesc Date: Thu, 13 Jul 2023 13:20:22 +0900 Message-ID: <20230713042037.980211-8-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: 539F7100009 X-Rspam-User: X-Stat-Signature: iwr4m58m1xdpyyk46wtiqzf58dgqwty7 X-Rspamd-Server: rspam01 X-HE-Tag: 1689222075-842196 X-HE-Meta: U2FsdGVkX1/9aVtEwJlwlqBd046mCzJ/7476Cs6i6uQ0hKBoCKwabkJrLdUVUtP2gyyHyUnJzegcBpVlfuWgbEys+URhBx/Wphjf7wyjKZj5Qb6pWIOHwqOwTcs3XBc0IVNWcbPhwSmEcRhHT2bEB1OFI+F2UBG5JmedwHO/rDhG/2CbzziIamaW9ZOZsWjxFMbEUOyX5dJ0p2pey7HLKtsdKre2c6jZ6Yr4A7wqB7VvB3igxPeWyJ2ReiD/byhj0FdTidEuHzZ14x0pA6rccNga5ltAqxkE7m4sOI5356I7sebXpybeVEyaI8RK+nikjucDZ5U166wXHWa5d7KOGPQ5EFk1v7fgtnnj33csrNysEtjWsR/J74ziXW5Bpk6+UWmwgYgLMRlulGMK90mVyyuP5pM9UzNvmRg+PtUsienTu+7BfTiO7qpwBm0orRQZO+dvwkp68UKg3B5qwwEmJNcoLi52S1iX6v9ZLfXOZXQkWEpfTHjelXbyq2+N9Jmp9TsY6Frf2oy6mWUY6UhRVea2eDrpMQMavlWVPeRlF7eTHQBL7dDMKqWUG8Y7HkHuR5KXxoMLPkAQwmfyTPsqX0GQUIOKE6XvXDIZF8FWn0/aRlnbj2BdL2yGdmBWVpWvGlA0PSd0B+U1hCD0wPa4t2KRtdBclR8ah8RCHK3I9yJ1Y5lIA/Ql3zMImSbIAUzMbN+f15MVFDePW9bK7aXeUJLzII1K/Kyg0EZgDrgcpaOBbjB0E9klGd1q3WY1vodMZA26ylFWjE/YIfUWCw0hRwgL/gfqDYOx0QHFiPA1dhmZzCTG8d1/ZwIYWW2mz4j4/uMagNXLQXuHIikOgyxvjA+D/w+VyUvlxIlrMIuReygh2eyQXcNxwntfw1IQVaWKvhGbSc2DXrOZc1T8BCNkCUY0ef0KTIIOLHlZFO93oSYkAIxN+3c32k/hfs9KQEuENtfWsm1n1+k8RusIFWs EUr6uFck hW9LS7CXxcp2F2YbEhXOq42dhFAUkgdWAWCVs4cjdGS6EGpcSJTNNLjQrRFJTlx/QE12UiStwtA1izt/0s1LvCYtIgZvVmueJWDXMYXqw9p91UnmJ1Q12MH932e0unNnBqPk7uQENUw1TpoZrR0dAtNIEZQ+GvI9e+xFbdnlyXhzq9I2cbQOzKWjudBInDdovOdWDLjKmFgnUlaxcC+X8DYGqtwOGMjvHEslqle4MCWC/KAWPDfXQUu1PQMtJrp8gTPOELKB4uFeAPwoC9LplTX7uvw5x37nj1CHpLDiPSItqgvbNkgZSlqvjv7CLwgwjs0sAG00W/MhorZHFfreV2xlAgnWrvpXE26WOMMFouzJ4/1tLlXiIdBxiZlePZQ7A612gMdAekPZUoEknQUiRRAxTnbxj+5UDGIxLuAAr2DnryO962AbuJMhRg+k7sLoYenXdmTuwWZHfIQP8zvzviTSobeP9cx3+nOHzQzwgTBWVPj8ifRCifXGAh0t9mqBhYQtjHjqD5pBRNiHTQEj5kwIDjxiAod8PYOFkCVeNFHu3v/Wv8nEl+sNeb4v9gnAsYrAuPH1QG+UI3vrpDjfK5gr5Qw== 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: Convert obj_to_location() to take zsdesc and also convert its users to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 75 ++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 4c0563fce3d0..be9762a49237 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -860,16 +860,16 @@ static __maybe_unused struct zsdesc *get_next_zsdesc(struct zsdesc *zsdesc) } /** - * obj_to_location - get (, ) from encoded object value + * obj_to_location - get (, ) from encoded object value * @obj: the encoded object value - * @page: page object resides in zspage + * @zsdesc: zsdesc object resides in zspage * @obj_idx: object index */ -static void obj_to_location(unsigned long obj, struct page **page, +static void obj_to_location(unsigned long obj, struct zsdesc **zsdesc, unsigned int *obj_idx) { obj >>= OBJ_TAG_BITS; - *page = pfn_to_page(obj >> OBJ_INDEX_BITS); + *zsdesc = pfn_zsdesc(obj >> OBJ_INDEX_BITS); *obj_idx = (obj & OBJ_INDEX_MASK); } @@ -1298,13 +1298,13 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, enum zs_mapmode mm) { struct zspage *zspage; - struct page *page; + struct zsdesc *zsdesc; unsigned long obj, off; unsigned int obj_idx; struct size_class *class; struct mapping_area *area; - struct page *pages[2]; + struct zsdesc *zsdescs[2]; void *ret; /* @@ -1317,8 +1317,8 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, /* It guarantees it can get zspage from handle safely */ spin_lock(&pool->lock); obj = handle_to_obj(handle); - obj_to_location(obj, &page, &obj_idx); - zspage = get_zspage(page); + obj_to_location(obj, &zsdesc, &obj_idx); + zspage = get_zspage(zsdesc_page(zsdesc)); /* * migration cannot move any zpages in this zspage. Here, pool->lock @@ -1337,17 +1337,17 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, area->vm_mm = mm; if (off + class->size <= PAGE_SIZE) { /* this object is contained entirely within a page */ - area->vm_addr = kmap_atomic(page); + area->vm_addr = zsdesc_kmap_atomic(zsdesc); ret = area->vm_addr + off; goto out; } /* this object spans two pages */ - pages[0] = page; - pages[1] = get_next_page(page); - BUG_ON(!pages[1]); + zsdescs[0] = zsdesc; + zsdescs[1] = get_next_zsdesc(zsdesc); + BUG_ON(!zsdescs[1]); - ret = __zs_map_object(area, (struct zsdesc **)pages, off, class->size); + ret = __zs_map_object(area, zsdescs, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1359,7 +1359,7 @@ EXPORT_SYMBOL_GPL(zs_map_object); void zs_unmap_object(struct zs_pool *pool, unsigned long handle) { struct zspage *zspage; - struct page *page; + struct zsdesc *zsdesc; unsigned long obj, off; unsigned int obj_idx; @@ -1367,8 +1367,8 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) struct mapping_area *area; obj = handle_to_obj(handle); - obj_to_location(obj, &page, &obj_idx); - zspage = get_zspage(page); + obj_to_location(obj, &zsdesc, &obj_idx); + zspage = get_zspage(zsdesc_page(zsdesc)); class = zspage_class(pool, zspage); off = offset_in_page(class->size * obj_idx); @@ -1376,13 +1376,13 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) if (off + class->size <= PAGE_SIZE) kunmap_atomic(area->vm_addr); else { - struct page *pages[2]; + struct zsdesc *zsdescs[2]; - pages[0] = page; - pages[1] = get_next_page(page); - BUG_ON(!pages[1]); + zsdescs[0] = zsdesc; + zsdescs[1] = get_next_zsdesc(zsdesc); + BUG_ON(!zsdescs[1]); - __zs_unmap_object(area, (struct zsdesc **)pages, off, class->size); + __zs_unmap_object(area, zsdescs, off, class->size); } local_unlock(&zs_map_area.lock); @@ -1524,23 +1524,24 @@ static void obj_free(int class_size, unsigned long obj) { struct link_free *link; struct zspage *zspage; - struct page *f_page; + struct zsdesc *f_zsdesc; unsigned long f_offset; unsigned int f_objidx; void *vaddr; - obj_to_location(obj, &f_page, &f_objidx); + + obj_to_location(obj, &f_zsdesc, &f_objidx); f_offset = offset_in_page(class_size * f_objidx); - zspage = get_zspage(f_page); + zspage = get_zspage(zsdesc_page(f_zsdesc)); - vaddr = kmap_atomic(f_page); + vaddr = zsdesc_kmap_atomic(f_zsdesc); link = (struct link_free *)(vaddr + f_offset); /* Insert this object in containing zspage's freelist */ if (likely(!ZsHugePage(zspage))) link->next = get_freeobj(zspage) << OBJ_TAG_BITS; else - f_page->index = 0; + f_zsdesc->next = NULL; set_freeobj(zspage, f_objidx); kunmap_atomic(vaddr); @@ -1583,7 +1584,7 @@ EXPORT_SYMBOL_GPL(zs_free); static void zs_object_copy(struct size_class *class, unsigned long dst, unsigned long src) { - struct page *s_page, *d_page; + struct zsdesc *s_zsdesc, *d_zsdesc; unsigned int s_objidx, d_objidx; unsigned long s_off, d_off; void *s_addr, *d_addr; @@ -1592,8 +1593,8 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, s_size = d_size = class->size; - obj_to_location(src, &s_page, &s_objidx); - obj_to_location(dst, &d_page, &d_objidx); + obj_to_location(src, &s_zsdesc, &s_objidx); + obj_to_location(dst, &d_zsdesc, &d_objidx); s_off = offset_in_page(class->size * s_objidx); d_off = offset_in_page(class->size * d_objidx); @@ -1604,8 +1605,8 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, if (d_off + class->size > PAGE_SIZE) d_size = PAGE_SIZE - d_off; - s_addr = kmap_atomic(s_page); - d_addr = kmap_atomic(d_page); + s_addr = zsdesc_kmap_atomic(s_zsdesc); + d_addr = zsdesc_kmap_atomic(d_zsdesc); while (1) { size = min(s_size, d_size); @@ -1630,17 +1631,17 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, if (s_off >= PAGE_SIZE) { kunmap_atomic(d_addr); kunmap_atomic(s_addr); - s_page = get_next_page(s_page); - s_addr = kmap_atomic(s_page); - d_addr = kmap_atomic(d_page); + s_zsdesc = get_next_zsdesc(s_zsdesc); + s_addr = zsdesc_kmap_atomic(s_zsdesc); + d_addr = zsdesc_kmap_atomic(d_zsdesc); s_size = class->size - written; s_off = 0; } if (d_off >= PAGE_SIZE) { kunmap_atomic(d_addr); - d_page = get_next_page(d_page); - d_addr = kmap_atomic(d_page); + d_zsdesc = get_next_zsdesc(d_zsdesc); + d_addr = zsdesc_kmap_atomic(d_zsdesc); d_size = class->size - written; d_off = 0; } @@ -1904,7 +1905,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, struct zs_pool *pool; struct size_class *class; struct zspage *zspage; - struct page *dummy; + struct zsdesc *dummy; void *s_addr, *d_addr, *addr; unsigned int offset; unsigned long handle; From patchwork Thu Jul 13 04:20:23 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: 13311272 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 6C893C001DD for ; Thu, 13 Jul 2023 04:21:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04B3D8E0002; Thu, 13 Jul 2023 00:21:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F168A8E0001; Thu, 13 Jul 2023 00:21:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D93428E0002; Thu, 13 Jul 2023 00:21:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CAE0B8E0001 for ; Thu, 13 Jul 2023 00:21:19 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A24291C7367 for ; Thu, 13 Jul 2023 04:21:19 +0000 (UTC) X-FDA: 81005289078.28.580A391 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) by imf13.hostedemail.com (Postfix) with ESMTP id DC66E20005 for ; Thu, 13 Jul 2023 04:21:17 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=LBEyRpU8; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222077; 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=x4zzHPL0k6H0MdOKWy9H+XqQmDxwRKjupee59FsBT9w=; b=UK0jW9YZnxJTTCAuXl0RicPLp0mmb9wdkJbhoUjGnOYBQL6U+XMgRO0VIU6cpSsl/VtrA6 D0uY0AAc+pZuDMcaZJDhRkc5JaV+qMojWWBcV7n4eWvHCZQLYCc1XtGUahjAhCFWsRVRrq RFyS0VytvQEcYH+5apRLhBJ/ZYdOjnM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222077; a=rsa-sha256; cv=none; b=kBre+rOgvBPgPrMrU4PkJmNyJEM6xo486ZBkPLRlbViMJv9bZHaxfEDqEJfhU1AxwEEh3S lTCHxbTb9ocC+wGnVh7vyMIGMlOy+zr4YwxY2+KSyVTcwiikUioSwQqhxTguD36aqbnMtl ShgylSyhLCLCmZ8XeJRbP4Mdwbjv2iw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=LBEyRpU8; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3a1d9b64837so298744b6e.0 for ; Wed, 12 Jul 2023 21:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222077; x=1691814077; 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=x4zzHPL0k6H0MdOKWy9H+XqQmDxwRKjupee59FsBT9w=; b=LBEyRpU8G6PNHITLYWQWY9IyEPJyBkyQ5+FvSpkPn/XDu4Dao59DBpPH/zWMmJUshw lq0kdCLAyTLvXPRb/y+83fvqbRcDI/W+LuQaPuNH3C+pY8AU4jRsRBWwzik8OP0E5MYJ PLiAqFM/MrZKLDfuQYnYD93VG+rfaatGql8SPpIviN7wELQguFKteyX1AeorHVMmxNPn Dez/e+bAAstVLLoChOoqn9Uzy/cGstHq6rZ1lRNBHeKGx45FkUpllKlYAJDdihR1tDxk aA2G7wm5jd0vkB34MMv+IA+CCV9qlxehsMStgJw+N7ZnVOnzXTdoq5hxDAEmnVkUZ8Pj TUKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222077; x=1691814077; 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=x4zzHPL0k6H0MdOKWy9H+XqQmDxwRKjupee59FsBT9w=; b=LK/3JM7EYebjs11TMBn2eMCCohbTXQ/t+2R04QF3yXp7aHZMYq0sEEEJq7YPnXO9c5 nOWZPF8FXRGQXOgcXobhYehbrv++OYj7M0iy+VCPmUaCxG6MwxYnEjl/o1PEAp8p2ikR NxjIR1CWeBMVdY3e8NO2swdpzGl75Gx0VyfpIJ86h+S43p64weUoUqSh7S3Pibw2dRqP Kfpm3gJkde955q9iF1XbV0NVMLRwra7/fV6lmBVrch+CH7JfOkTYzLhwhHL7VuuNA/qp MYc6FYlIvboORcpZJsStaR453OD033GMiWz999/A7MntLCCf7F/Rj3HZmpzfvYOHyiXI QRYg== X-Gm-Message-State: ABy/qLY8z+SimHfqVeO1aqiC09qw+YN/7zYk69vgM7myNE8lLQVG/Y1S g5apv0S+2Of9fLiYbnBOjaE= X-Google-Smtp-Source: APBJJlFywht9zcExknT1dtSzacVpV7iePijCw8nKXr7IhX52uQwv585dT1T9ycEkrhz/WrX75xHfuw== X-Received: by 2002:a05:6808:573:b0:3a3:6536:dd89 with SMTP id j19-20020a056808057300b003a36536dd89mr525184oig.49.1689222076949; Wed, 12 Jul 2023 21:21:16 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:16 -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 08/21] mm/zsmalloc: convert obj_malloc() to use zsdesc Date: Thu, 13 Jul 2023 13:20:23 +0900 Message-ID: <20230713042037.980211-9-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: DC66E20005 X-Rspam-User: X-Stat-Signature: 9t1xf6d9sfbysbpajcjotwb3irphp4fa X-Rspamd-Server: rspam03 X-HE-Tag: 1689222077-450020 X-HE-Meta: U2FsdGVkX1/ht7DWW/GPFaS4ROvKLp/cfG5L9GYBSDtzLXcjjnNBFZej9Q2zjfWFebvU1k2Fx+E/cvDAdIY34kTeNzknxzcyPVDuC70yTve7LM9k95MwqjZZ0Rg6Ifn/Ylvbi1lhp0UREjypFQZkzHe1CzYLv2MekBZcjYkUtiOn1DZRQOKOxAh28gYcHj0k+a1a3P6qqxwBNV/I4cDOgIoomFMm68uIrTCcVEQEnQpF5/oKiaMBEwK5ZiYvVOovj5mDI+vR0KMSCnFxM8wrJ921p1bZ+f1f5BUhbYz/UatNO/oZUeEudP1Xm4/J2tp7VuI00fRpGNLpwSaI742j7x43iA8wEsbjJ4Te5tT0AesQ6tJMG90UkXHRlCE9moE223rfkA90Nq2O0/4ogDBoPWSg5wur+oP0qjoLBLXE8KsJTQzIbpuz7rLuqXsWGPNoyx/QNyvOxRJKo6ZHZNRT6h0EmVGdmBqkOCrTSIPN9QsD/IVu5ItGh5nwAn768Ucz5W9F8J/eid9M42uDHFU6mhdvJ+oSldrVlmINPteLC+GqcP44ETCDiTihTj6ChfxtC65WR0QqGruhQTqkPVIi06JL/qtlrGayDimqCq4VtajcHq0o2Ym06xIhE/5hq4CRUKUL7pEm72XtKXaZtGZGTsfy0LO+itijaMla8dXo+9SsIN8Chq0CRVfvJs+ankp/8WHGB6D27GI7J6Ob4bZz2NeZYw2jwv9h9QlZwIv73fV3+r7b4uDKhz78A6YOPFnopmsYFlYYRTV3RxnoeZ/XAOVfFNE8hTJ4xabcaDMEWjKUWujowAhGytA88znR7Ke5wL1sFrxY6amyeyKKXUKheOE8YmGGARp7QRnI7o117XUrEVMxgn21saJb6dGj2L14q3Xon3reintHT36Q+zSqjq3KWRpUI1m0DBx1VcYyIXh7neaYmaMibsO3eTRVc3MfNBBpE4QkJnPUcCv7TUm MAz4s993 lmx3KUEWjaahCrqezM08r+sGjZIFE3YYCjD2uEHvD0ERNFvAl9WuW/mqNYHjvCrWi1qlXsBIGtcCZ17mtM5bw1Pi3lR9USeGUWslcCLSe2mEXW/ishLUaNQWnKPhvIEJM9VTmupMaVFsTyPzR2Owu1u+ABLbMRGj8i4PazYuNSbi4xzWl9wMJ8khpDrmqBKF8vTjNVXAO90+zot7hvPki1iWXR32p9ipFmLULxV0pKNP1dcpSX56P7M816KJX9Y5oEt9tLvSGNQQdveNL4N9Mn0YpSgmykUYMIlZ9RCcIbWBQnz+qG0TmSFth0JmSHV4JaLxPmR/BlGkLQDuyO+b7hHVdOtJBl1fPBB3Y6rZ6fV+EziRc5QVqj25Yr8Q61/HUGPZ2SyujXUlkZrvBFcvjshC+qebrLHS9YYsBoWG/fR9heeHX2J2l+w5JCSgCR0T7Y9jXxk8dBzhdPfLUCUx3LDQsisiW0g7u3rHyQiquPlbxQNbVG6lwSz9IUZTiPt+/VHSBygzg1hFRN5pgplQMFSs3WXrMp9rk2+WWvQJFKA7xFJdbf+WhjqixRUJUl1ODInXEO8WzbaMyZvHzUZhOorUrzA== 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: Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index be9762a49237..06227da86afc 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1412,12 +1412,12 @@ EXPORT_SYMBOL_GPL(zs_huge_class_size); static unsigned long obj_malloc(struct zs_pool *pool, struct zspage *zspage, unsigned long handle) { - int i, nr_page, offset; + int i, nr_zsdesc, offset; unsigned long obj; struct link_free *link; struct size_class *class; - struct page *m_page; + struct zsdesc *m_zsdesc; unsigned long m_offset; void *vaddr; @@ -1426,14 +1426,14 @@ static unsigned long obj_malloc(struct zs_pool *pool, obj = get_freeobj(zspage); offset = obj * class->size; - nr_page = offset >> PAGE_SHIFT; + nr_zsdesc = offset >> PAGE_SHIFT; m_offset = offset_in_page(offset); - m_page = get_first_page(zspage); + m_zsdesc = get_first_zsdesc(zspage); - for (i = 0; i < nr_page; i++) - m_page = get_next_page(m_page); + for (i = 0; i < nr_zsdesc; i++) + m_zsdesc = get_next_zsdesc(m_zsdesc); - vaddr = kmap_atomic(m_page); + vaddr = zsdesc_kmap_atomic(m_zsdesc); link = (struct link_free *)vaddr + m_offset / sizeof(*link); set_freeobj(zspage, link->next >> OBJ_TAG_BITS); if (likely(!ZsHugePage(zspage))) @@ -1446,7 +1446,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(m_page, obj); + obj = location_to_obj(zsdesc_page(m_zsdesc), obj); return obj; } From patchwork Thu Jul 13 04:20:24 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: 13311273 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 B4FBFEB64DD for ; Thu, 13 Jul 2023 04:21:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DED88E0003; Thu, 13 Jul 2023 00:21:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 468248E0001; Thu, 13 Jul 2023 00:21:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E2018E0003; Thu, 13 Jul 2023 00:21:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1C0CA8E0001 for ; Thu, 13 Jul 2023 00:21:23 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EFC20C010A for ; Thu, 13 Jul 2023 04:21:22 +0000 (UTC) X-FDA: 81005289204.13.5D08AB6 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf15.hostedemail.com (Postfix) with ESMTP id 1D4D6A000B for ; Thu, 13 Jul 2023 04:21:20 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=lf7AZa8e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222081; a=rsa-sha256; cv=none; b=b5prkYI4otc09wv4/2zNeWgpqSh3ILGp32ikekggvwJ3GbFy1eCEKVbKM0c2rMEYwHrBVy WNor0lpeChnz381+OBsw4TDE+KyY7wAMLISwF2H+x8aVS0z1F3s7TUR5wEiA7vgs1ijeDY nIEpi3G1dZDyB+k/Dslg2Zo4UWNZ3F4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=lf7AZa8e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 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=1689222081; 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=LP5xQ6efjwHS47Oxl1IdTrKCp1PjMTJw03NOJIq6Awg=; b=gcfzDSm/KjJ+MMaWgz9UiSpgsql9pt+/vbhUcj91pkyc/WzDCmAYTA3hTDFYdHQyE92ZMq 0aPW9uzUF3kU80ptR0sp8na0+Q11sOzU5QDwJ3iSDdHOS9G8M5TwFbLSuDDO6AYOT5+NBu pEcqdAgZLINcmhoGcBohlxlpg6c+Pog= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-666e6ecb52dso168168b3a.2 for ; Wed, 12 Jul 2023 21:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222080; x=1691814080; 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=LP5xQ6efjwHS47Oxl1IdTrKCp1PjMTJw03NOJIq6Awg=; b=lf7AZa8eID+bpbDGYm/7QEvzwEHh6v4zg3kNCWj8c5QyXrfMVbJVNMyjrKhdjmIr6t n+bP+RtxPOH6barvlyqo1EADq8+88sVBaIXeOtY8d4CbOu4dvt5MEfQrfWMNcwou+DGu BXBA5OPPHaMvCSejIv4nOX2PVYomkk7yshU0mCGwH8csmbEDebanQEvkyDqaTeKh7PmL WB1wJ275RzFYYecOIfu9U+tkcobqAn9P1hmhpJT+SsJQ0oOKgsbBJwoL5Ar6zPV5RJYh 9iaCciIY2AOdQZIpIVAH1JrqhDPoAjY80UBAmlXDDID8R4efwMaF9T5xCpseUc46O13L rxjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222080; x=1691814080; 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=LP5xQ6efjwHS47Oxl1IdTrKCp1PjMTJw03NOJIq6Awg=; b=RMdhpAi2BKJRHl6Kxu8siL8aEG8Fg06Pp9BbJNG4fcVC01d1G7bKfJXcBjPH3A6lJ/ peLE4+qTgSu2fFfuKQtmOYV+XT9ehTWRDrkuNpnE7Etz9cMnKbKYrG1XK6vgIRuGfZso i58UBU9sO0047ZWeI2gSOu/uzPlos3lW7+P0wJGekl/2j6U1//2dGsQplo3Fc1CdNpWx 2ohJ/23Ro4i7uRde5mn0VuEk1x/Kg6dy35jaD7/efX4n569LIoyIM9VveCq2gRnWgftz 0sSSYKoKHpVrYmHJTsAecQaoEtypp231bHeJCCbMRIGC+cB8YCuPxrXoL5dvyJuZiYLZ BgNw== X-Gm-Message-State: ABy/qLZCMVR6WBrvlp5amRy7G3tH4HUH+Ccp9M3LTXKlq9Y6zRS2aEXB 6Q2eNEabZ9X97Lw9DCm6Bpu5+uvyjn/mfmDHI5KyQw== X-Google-Smtp-Source: APBJJlE3EDMrVhGu2+w99ghcjkXTfEgbRvc6vMguhTPtHAU43UkedDKKOy9zY8oR+2dKf2q4n7r4QQ== X-Received: by 2002:a05:6a00:2401:b0:666:ba76:eef5 with SMTP id z1-20020a056a00240100b00666ba76eef5mr364274pfh.8.1689222079876; Wed, 12 Jul 2023 21:21:19 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:19 -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 09/21] mm/zsmalloc: convert create_page_chain() and its user to use zsdesc Date: Thu, 13 Jul 2023 13:20:24 +0900 Message-ID: <20230713042037.980211-10-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1D4D6A000B X-Stat-Signature: bmyitgbf5m3i8z3ssysz91w5wzn9bafq X-HE-Tag: 1689222080-564257 X-HE-Meta: U2FsdGVkX18YsHvl3fcyA/Ob073oF7NoILOta0tP9PiX7+L2MxSIZ9aUdgVlqF/fUNt9K6kYgzWER8EB/LtRWY8vv+/YhmSICaXpMblahttp7yNMzWqbt3DcxclhnH6Td9Q5uYwVi60G36nkAJM4O4TBMEWNwuBgnrheYk9Kt56rSYJgnTKmZGvDywbJNdXc5RJWBYB70XgzXfEQ8hiGypT5Do3NhixnK9DoNrRr2U58vxowG1t9gkCr8q9ejd3eihL9Z8Z+o/Ylp7Imp8ZhaChsUuiAEc3mSMkG03N3+DM64VTC31lGDfffkm1n/k06KAqL0hhCVL/Xfgd5d3jPCEkUGtUEkRCKfc2PYfDRUIScqVztR43XQC+Q7dUi31QVtSp3ha2eZN9EuKAtKrHZQ+xk4kSbI1zXMugDoKke47lQ8o2yIidUA7/6Iye+b8EGWlbqG1WjKsEGze1exDQBmhbjAC0lPXoZtCnNKPx4SMCB66l+Hrn4K+JMba+1Le/VHjwmkhpGprF5oZffzNBepobapk3sO4x0vVckPALBxJ3B+accEVq6M4YfcEsOqkAs40sYsgcjN66QuuDeunb52/bBwCJzjkpxG67dhtyJb+NOJ4TRnEMpVlgWC5iZzxeiXaxhQwiQ2JF/hxFoQ6LzFeql3biAQDTIpN7Q4L5UrwyLaa2m3bttftjTmrOR8VHdqz+DDYtJp+Tn+TMINwIqoZNykg3QDH045Sskx2MjbC8NNRFhqD9F8MhWzWDEhMhFHlZCXuGIIgrpAlTIvTGMxlMrsJKPsq1kuRUD5nMmSgi5PrlFf8QfQyfxguS2V2Sw6S5u3+eut4syJpflCk/dNs+J8jUJmTrIDVYpWr2MkST+gYlrIgH73GUSUW+P9mh5oXgCzWFYzP+TOzDc+wOAnvi4ZkNPmoP4Ycrlbf7xESLN6PHK6bEz8EHnQaG5LEwQm7UHIbk3LlrvSFkuYVT zRVmpAbF WR8f3+6Ca8ABWtGPBo2gY1Z9sdpnu7xye9AcVugYIX5ILZ/qGdgWcf1UOavsjIUbMkpihRsrc93r7fNFRJNk++iSaMRG0hGmsEsgOFUNJQm9ZttRBkHYbvJbAVTiIdCZWsJlZYubgSWTxyvCfZ9+8/mCOa9J6pJf0gTWixcRzIk3MbMuAGaene25VAX5EoORtXZGdxbAO3Er4LZAp8bOK1mbiUY4O0mgKu5S2gdkOxYrTxKvzvXljQrtX+4YMf7n1JjZyrroaYnFDaHNJ2h/gtInWjUBLotWkZm9vno/lAA0KV1ut9ekfMZH5MxhnaBI9zBB4OjQTm2THLbPAS4LgTiX1h6sKBAajkBlqTpax1X0vo2xhI9sZkYAjpNUNstkgqLvW+82HXHbIZEKMy4+x+I9Aub8lPF4FRbHTwkjd1unGM8mWBCldOtkToRbx7nmqE6dxwFrSXoaMbb2uj8UeGTBh1OOwd64Yn/eAhf2Kir3xsqYrmfTvUdaj7kHKv9kv1gL8FhTaB6GkpFsowxg5LnmxO2RghNuzLmv3auEOE7rU9/AVHQuYCwly+01/Z+qutuNfNuoQKeF5c8dC7hMjPz1wx2x+x4q8XQp150YVS4ZROCFzNN7kbPoTPjpaIa5eLJNu 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: Introduce a few helper functions for conversion. Convert create_page_chain() and its user replace_sub_page() to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 120 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 81 insertions(+), 39 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 06227da86afc..48bfdbbe3b1e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -346,6 +346,48 @@ static inline void *zsdesc_kmap_atomic(struct zsdesc *zsdesc) return kmap_atomic(zsdesc_page(zsdesc)); } +static inline void zsdesc_set_zspage(struct zsdesc *zsdesc, + struct zspage *zspage) +{ + zsdesc->zspage = zspage; +} + +static inline void zsdesc_set_first(struct zsdesc *zsdesc) +{ + SetPagePrivate(zsdesc_page(zsdesc)); +} + +static const struct movable_operations zsmalloc_mops; + +static inline void zsdesc_set_movable(struct zsdesc *zsdesc) +{ + __SetPageMovable(zsdesc_page(zsdesc), &zsmalloc_mops); +} + +static inline void zsdesc_inc_zone_page_state(struct zsdesc *zsdesc) +{ + inc_zone_page_state(zsdesc_page(zsdesc), NR_ZSPAGES); +} + +static inline void zsdesc_dec_zone_page_state(struct zsdesc *zsdesc) +{ + dec_zone_page_state(zsdesc_page(zsdesc), NR_ZSPAGES); +} + +static inline struct zsdesc *alloc_zsdesc(gfp_t gfp) +{ + struct page *page = alloc_page(gfp); + + return page_zsdesc(page); +} + +static inline void free_zsdesc(struct zsdesc *zsdesc) +{ + struct page *page = zsdesc_page(zsdesc); + + __free_page(page); +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { @@ -1047,35 +1089,35 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) } static void create_page_chain(struct size_class *class, struct zspage *zspage, - struct page *pages[]) + struct zsdesc *zsdescs[]) { int i; - struct page *page; - struct page *prev_page = NULL; - int nr_pages = class->pages_per_zspage; + struct zsdesc *zsdesc; + struct zsdesc *prev_zsdesc = NULL; + int nr_zsdescs = class->pages_per_zspage; /* * Allocate individual pages and link them together as: - * 1. all pages are linked together using page->index - * 2. each sub-page point to zspage using page->private + * 1. all pages are linked together using zsdesc->next + * 2. each sub-page point to zspage using zsdesc->zspage * - * we set PG_private to identify the first page (i.e. no other sub-page + * we set PG_private to identify the first zsdesc (i.e. no other zsdesc * has this flag set). */ - for (i = 0; i < nr_pages; i++) { - page = pages[i]; - set_page_private(page, (unsigned long)zspage); - page->index = 0; + for (i = 0; i < nr_zsdescs; i++) { + zsdesc = zsdescs[i]; + zsdesc_set_zspage(zsdesc, zspage); + zsdesc->next = NULL; if (i == 0) { - zspage->first_zsdesc = page_zsdesc(page); - SetPagePrivate(page); + zspage->first_zsdesc = zsdesc; + zsdesc_set_first(zsdesc); if (unlikely(class->objs_per_zspage == 1 && class->pages_per_zspage == 1)) SetZsHugePage(zspage); } else { - prev_page->index = (unsigned long)page; + prev_zsdesc->next = zsdesc; } - prev_page = page; + prev_zsdesc = zsdesc; } } @@ -1087,7 +1129,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, gfp_t gfp) { int i; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE]; + struct zsdesc *zsdescs[ZS_MAX_PAGES_PER_ZSPAGE]; struct zspage *zspage = cache_alloc_zspage(pool, gfp); if (!zspage) @@ -1097,23 +1139,23 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, migrate_lock_init(zspage); for (i = 0; i < class->pages_per_zspage; i++) { - struct page *page; + struct zsdesc *zsdesc; - page = alloc_page(gfp); - if (!page) { + zsdesc = alloc_zsdesc(gfp); + if (!zsdesc) { while (--i >= 0) { - dec_zone_page_state(pages[i], NR_ZSPAGES); - __free_page(pages[i]); + zsdesc_dec_zone_page_state(zsdescs[i]); + free_zsdesc(zsdescs[i]); } cache_free_zspage(pool, zspage); return NULL; } - inc_zone_page_state(page, NR_ZSPAGES); - pages[i] = page; + zsdesc_inc_zone_page_state(zsdesc); + zsdescs[i] = zsdesc; } - create_page_chain(class, zspage, pages); + create_page_chain(class, zspage, zsdescs); init_zspage(class, zspage); zspage->pool = pool; @@ -1856,29 +1898,29 @@ static void dec_zspage_isolation(struct zspage *zspage) zspage->isolated--; } -static const struct movable_operations zsmalloc_mops; - static void replace_sub_page(struct size_class *class, struct zspage *zspage, - struct page *newpage, struct page *oldpage) + struct zsdesc *new_zsdesc, struct zsdesc *old_zsdesc) { - struct page *page; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; + struct zsdesc *zsdesc; + struct zsdesc *zsdescs[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; + unsigned int first_obj_offset; int idx = 0; - page = get_first_page(zspage); + zsdesc = get_first_zsdesc(zspage); do { - if (page == oldpage) - pages[idx] = newpage; + if (zsdesc == old_zsdesc) + zsdescs[idx] = new_zsdesc; else - pages[idx] = page; + zsdescs[idx] = zsdesc; idx++; - } while ((page = get_next_page(page)) != NULL); + } while ((zsdesc = get_next_zsdesc(zsdesc)) != NULL); - create_page_chain(class, zspage, pages); - set_first_obj_offset(newpage, get_first_obj_offset(oldpage)); + create_page_chain(class, zspage, zsdescs); + first_obj_offset = get_first_obj_offset(zsdesc_page(old_zsdesc)); + set_first_obj_offset(zsdesc_page(new_zsdesc), first_obj_offset); if (unlikely(ZsHugePage(zspage))) - newpage->index = oldpage->index; - __SetPageMovable(newpage, &zsmalloc_mops); + new_zsdesc->handle = old_zsdesc->handle; + zsdesc_set_movable(new_zsdesc); } static bool zs_page_isolate(struct page *page, isolate_mode_t mode) @@ -1959,7 +2001,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, } kunmap_atomic(s_addr); - replace_sub_page(class, zspage, newpage, page); + replace_sub_page(class, zspage, page_zsdesc(newpage), page_zsdesc(page)); /* * Since we complete the data copy and set up new zspage structure, * it's okay to release the pool's lock. From patchwork Thu Jul 13 04:20:25 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: 13311274 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 8993FC001DD for ; Thu, 13 Jul 2023 04:21:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26E118E0005; Thu, 13 Jul 2023 00:21:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F8B08E0001; Thu, 13 Jul 2023 00:21:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 098158E0005; Thu, 13 Jul 2023 00:21:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id ED7398E0001 for ; Thu, 13 Jul 2023 00:21:25 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C3B28A0101 for ; Thu, 13 Jul 2023 04:21:25 +0000 (UTC) X-FDA: 81005289330.20.D1835EF Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf26.hostedemail.com (Postfix) with ESMTP id 00B5F140017 for ; Thu, 13 Jul 2023 04:21:23 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=J0aXa+kt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 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=1689222084; 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=ItG8ksrwK8WHStX9MB/fUTZvwyuLsvIlM15e1efhXFY=; b=wErU01sU3gfiTCRbnAWCaGuTIF15jp5/N0fbb23VDVR6kenk4UMpSAAinh5AezGxDv5Krh zD0Q1jnrlBm8Pz86G7L/pWql+s1E/8R3FJlvySWWmZiseIwXwD8YOZq63eF9OsAtz55P+y MGROOfejJftiikXCuJB7/gimi2SrAmM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=J0aXa+kt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222084; a=rsa-sha256; cv=none; b=KZVVFDycFdPin26qIG4K7errm5eK433MUuCphGITm0G7x0zHc5qBbeJ0ToFtyz8jbydVlP e/s2e+msRpeoi5MRREoqZFFRBIRo4fkCXrHvQV2K8jOSF9liVCMqFS7Ry0v358WAyww+8C +nZkWo7pHLXodunoT/ozdhAOWfbXi+U= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6686c74183cso323136b3a.1 for ; Wed, 12 Jul 2023 21:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222083; x=1691814083; 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=ItG8ksrwK8WHStX9MB/fUTZvwyuLsvIlM15e1efhXFY=; b=J0aXa+ktFUJkOdgZrLc2eH6P3UkQshHs83zm1+lxcabnZXxw2S3zbeIJMrU5IqnQpz 9OWtyPzFeDJ4eBoHQ5EtdlGXLMuCMCuJ8hWmDjHw3Uq+mwo18ozEHn2PrQm1PwV3zKQQ oewcfr0RJEamddaDOUGXzRu7FE+s2Eos0q//ZjWC5KNiJlFWWdXzJuhRR8/St6pZAkdK XLqCjS/iraG+Go+7sFNvQk18yZkdFi53LwyuJns0hwEG6WlIUi7gf2eN/K3k1WI9sz+x YYH3R2RtRgQq6xMHMd9aTAiq4LdFyBW1/+DSz99YmQKagn19cx4MSPATRiNhSbI/I0ag 2gRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222083; x=1691814083; 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=ItG8ksrwK8WHStX9MB/fUTZvwyuLsvIlM15e1efhXFY=; b=EHiV2SqpG4Ehu3LLKGzbK1WGU9TNAwpndQy7D6F8k7rugIf+PDUxdZjtxQ/a3jEXpq LC/JbppR9qlTu4UCpWyoHj6f+oz079WZF2O/tVsIpQvQhCv0Agisrwbj8ac8N7woSIop 3Xqxfg2w0tNRNEjx93bCPE8MTh43O1qF6YzDSjQl0yrVIMLDi//yuVVBpzJLxtHUSqCM K+n8pq/euKi6ncWxCxzoldrwyftkebUCapomVWhA4Og2+u9hvfHzrC5caku/q6O1a638 2svjSG/NYOO7s8S1dXEdXvtOo16qe1AMxtnmkXuG/VVoL1Tvd/1PqD7GwCNHNPlbGJ8r pfqQ== X-Gm-Message-State: ABy/qLb99y07Lkv+qCTbI2WkhXejXvNfxTAjjyppYRIURHjG+muPWTfr prS+PlID898HXSxqgBGQp18ECg7u474cBMMHEZUlJg== X-Google-Smtp-Source: APBJJlHv1tRh9q0qQqBjcFbXSS+jcB852joeQND+bRafSNcpiomPGfwhEemort4fhA+14tH0PTb7cA== X-Received: by 2002:a05:6a00:ac7:b0:674:6dd4:8337 with SMTP id c7-20020a056a000ac700b006746dd48337mr934769pfl.12.1689222082858; Wed, 12 Jul 2023 21:21:22 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:22 -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 10/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zsdesc Date: Thu, 13 Jul 2023 13:20:25 +0900 Message-ID: <20230713042037.980211-11-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 00B5F140017 X-Stat-Signature: atzdphojnse5u9n9jps354zda98dwn7t X-HE-Tag: 1689222083-215168 X-HE-Meta: U2FsdGVkX1+iVcFCa3HYGbH24flaTnLuvq62hJ/6IrIzYag+oV+J4RWkUH3+Zm9YDf4wjUn0VG34x8pJ2/UEf+Zo4EF5U5SIbVNoXSQ63c4hAIxj2SGmdNnPVELQFVs8P1iLVJ8NbukQZNmaeUa/Jl9RXii8NniF/Rr/v2py1aFTDQzWH+kpUefDBGKBnc8Ya+Bm5mVIA9HhRG/Q5L5qciI+KPA02SbnowFiNxkYCoDDe9O8ojqTcke4NuYmpNOfUvyZCRNsZKbihrxDKQD6EK3OvX368VwdRF3XT6uOTEdxaaSwHsIxgLoVcpgFlSpLA62UqHOtsZmPhBu3+K52vtux62pVL+VYetLoso44wW96gXqxTiK6hgg7zsiGgJLuAMDr3S6Kug2xifiogOIrNyi/tPV6Q8tYvtYe4WPIIKYsqt1LJB+1StghQXEIBz8GL2Y9epXYqHCNYImmhf89SUHNcZm1Gs7OgHA38z/nIJVZLfqfHlCIDgbuHcxRdCv3TbPod80bGDcfqT+E8IDHwYDG6rsvI86o0kaPrqtHcTPTLHNhJn/3IuhAdT/ajbfG5PmPMzKWdDwlwdGyovKzY2jD6tu5IVofFPRze2r9vsOu1SMs2MJ+lg5r5fuyyWhLTOc/f8tooc6nXvSyQ2IQ6srAbQ905aZ8pKpLj8IXzgPBCwpI6dUwBRFhOcMAiKNcTJGXFQm54QRsb7e4fWBNzoh+hrWxR4hstdyUWCQL1nFv/UspqumsDZ5HP3ZgyKTWDZ35JckBPXw7jBg6RyrEjvtdGvjf6Q6MKQfPSnVL+g0hsUVhGT9uVl39wuRJjrdaMINCIftr3lJ7of2qsbE5YlTUX5L+oN+U7hRDTKE5YtHekSe0OBBbSiId1x1246jydYKv4dp4hOEuzlrg/gUtBejYTDkK8kd5tkokm3qcSVhHxLJGfsrF7fBdkhbkttZRhY68z5HLCgPSGchQvYF ZxMs3Uj5 Gcn4GSjFDRpEy+eHNLJ3LPRhhKUW3POgoZWu/eYumg0nI1yxdxjXSCU5Wt2v0+8/VVkOieaJrLbGUEBakZGQWu87UfU7iPrLlfUrgiiS66JSQf0TNGB7aiE1UPNc2XafH7/OoHPHPwtCOOYIFFbJ3O42ry0VLSVZSZBAOj4xNvgpF1C6Cc89B6l4kYDkZHAL3ulBqXdq7JYI8q8Mu4pxCxKbwjwPxKlRX31IW8YLxOfO9ZPLV5cOee8XngCy6NEwfnP3lZvFzkgBXR/gx+R4X2YMN32kUxB0IVu9F/3hEYS890v77LgNjPGXn3b/6Uv32LPCtDoZkaEAD+zgf44HLsezdXvjHXufhKA0d+gHFJe0275c/4jVoKSRfYRKcCdhOJQqRrqOPclOCuJxDkCDgEzJ1y5/RCfYDdfqmBY+hZ1L5EcAKRYcwVSKxT39jPSdTXf0qADe3Rrq51aWUBt9+RoNgQOH4lsaYwDdMlGzC5hJzfDCtcwIKOHmdE1n/w7vr8RglWuxeZNIaDnLZksAO8dFjLLC26N6QIcWCxeef9VetafeEV/c3Qc7S9FNzAyiXPAlEqc6rjCA9Aqzmetjjmu87lJ/PRmEQoWJj1glWXM4RJHL6Hp+R5xYCGQ== 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: Convert obj_allocated(), and related helpers to take zsdesc. Also make its callers to cast (struct page *) to (struct zsdesc *) when calling them. The users will be converted gradually as there are many. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 48bfdbbe3b1e..efd7a0f78962 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -942,15 +942,15 @@ static unsigned long handle_to_obj(unsigned long handle) return *(unsigned long *)handle; } -static inline bool obj_allocated(struct page *page, void *obj, +static inline bool obj_allocated(struct zsdesc *zsdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(zsdesc_page(zsdesc)); if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle = page->index; + VM_BUG_ON_PAGE(!is_first_zsdesc(zsdesc), zsdesc_page(zsdesc)); + handle = zsdesc->handle; } else handle = *(unsigned long *)obj; @@ -1698,18 +1698,18 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, * return handle. */ static unsigned long find_alloced_obj(struct size_class *class, - struct page *page, int *obj_idx) + struct zsdesc *zsdesc, int *obj_idx) { unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_atomic(page); + void *addr = zsdesc_kmap_atomic(zsdesc); - offset = get_first_obj_offset(page); + offset = get_first_obj_offset(zsdesc_page(zsdesc)); offset += class->size * index; while (offset < PAGE_SIZE) { - if (obj_allocated(page, addr + offset, &handle)) + if (obj_allocated(zsdesc, addr + offset, &handle)) break; offset += class->size; @@ -1733,7 +1733,7 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, s_page, &obj_idx); + handle = find_alloced_obj(class, page_zsdesc(s_page), &obj_idx); if (!handle) { s_page = get_next_page(s_page); if (!s_page) @@ -1990,7 +1990,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page, addr, &handle)) { + if (obj_allocated(page_zsdesc(page), addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); From patchwork Thu Jul 13 04:20:26 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: 13311275 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 6AF6CC001B0 for ; Thu, 13 Jul 2023 04:21:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E77E8E0006; Thu, 13 Jul 2023 00:21:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 04AC48E0001; Thu, 13 Jul 2023 00:21:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E062A8E0006; Thu, 13 Jul 2023 00:21:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D24458E0001 for ; Thu, 13 Jul 2023 00:21:28 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id ABF291C7318 for ; Thu, 13 Jul 2023 04:21:28 +0000 (UTC) X-FDA: 81005289456.06.9AD8277 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf23.hostedemail.com (Postfix) with ESMTP id D5C0814001A for ; Thu, 13 Jul 2023 04:21:26 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="QaglxJ5/"; spf=pass (imf23.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222086; 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=KN/0UQ5A23ju1GQxKe5y1Dsl+buU4Kky6wfdVIYQXVw=; b=IlmGT5yys9UdFRiwzAJOAXi+/jbmPDfce6PxmwL9kxifWpwPQYxE2vWY0+0EPlXAVZuuYX kOtWtDtys5fg45tbIjgr6E87cP6K/iNFqhQHWsFPyLit/2y5UVpabrDDyRsC1vVH8BJr3D nxotfwNrowJYy57v8fICHXxdaBBLRpc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222086; a=rsa-sha256; cv=none; b=XYeWlUt9eo1vaFGK664Fg+dnNmRiKWWgJxHn7sWWA2MxsKJDC3OBb3xjbzZDEKxvKzHMix FENyYJDExgssgHXZyz9RXX7kB/bqrUxUOpsmXQjDQd4aO6DIR6SUW3xF97Knw6K7DpAgDk 68EguCODcWHsAiivcEHTvENHZhFf60Y= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="QaglxJ5/"; spf=pass (imf23.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-66c729f5618so324279b3a.1 for ; Wed, 12 Jul 2023 21:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222086; x=1691814086; 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=KN/0UQ5A23ju1GQxKe5y1Dsl+buU4Kky6wfdVIYQXVw=; b=QaglxJ5/4DXjaQRW99wAX/gu3nfKdLqbbfoLZYjSPiZByNoZNuaSdKjd3TkB7SCXyb 9ehVOxCsLkwO4vuHp5ToaaXKVIGUzxQ0Xc9BVAejByY2cbduYp7MEgSHy3QXB14VaKJu /dQ0TVVhsehk0MF70CW/lmLy+DXRf72UlGYPhjyvFIavnPXAU9WS1TRF/1K5Tegr+t0I qYRZaVa02qwoX7CwbvkyUENFWVyK/X4roOk9f3PKyKmrpS0lq1ImDkXWV+rL6BZWGEta hyb+fgRMQ//JMKjUB80tVxa0Ad7ciBFGNKOG/gFD0rBbAhL4VGHGMzWqsWVYi0c10LpV wOBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222086; x=1691814086; 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=KN/0UQ5A23ju1GQxKe5y1Dsl+buU4Kky6wfdVIYQXVw=; b=N3SX3HqsOaXcc9+B/dEOG6QUi71pj7eF36hB4z7vsrxPIZmQZ4CYo2oCzrLodyxdJY kp0zf6GyQaeeq0Egg6pYnHC9Wo8qoYWDDLGfwVliKzOZ0nn0M6SjRjjdR3+OGpduWj6c frahnIoxIBp/r7CAGo5oIiFIb36f7cbWltMkPwoyHJiLh1WNUspfHVeSgbis+bNLtov6 8IZT2OUIvfjdVkJ/hyGSiYNsh+BjdFnRVIwKMjtLmkMNaDEavVI9Ol92jvtitXEyNOKE hBDC0UcciFCMb7V40DPdEOuJ74z5a3UgGuxlpfNVKPfcOs+5KN2ttbAG0trAOswkZ11y T1RA== X-Gm-Message-State: ABy/qLbnBf0nRSVd7Q1hr8/u7x8osQLHCsY+MO39Cs6cvYFB6w3j8LWZ AfqfZ0sW+57Qa/Wtlx/x0Xo= X-Google-Smtp-Source: APBJJlG8kddUlSs/CeJcZNRjhBskayUfvYWIuJ8jWcHhX3qWsCgb/Vp6nYOC/llo4VEovjRzZW4bzw== X-Received: by 2002:a05:6a00:b51:b0:641:3bf8:6514 with SMTP id p17-20020a056a000b5100b006413bf86514mr775304pfo.10.1689222085708; Wed, 12 Jul 2023 21:21:25 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:25 -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 11/21] mm/zsmalloc: convert init_zspage() to use zsdesc Date: Thu, 13 Jul 2023 13:20:26 +0900 Message-ID: <20230713042037.980211-12-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: D5C0814001A X-Rspam-User: X-Stat-Signature: 8u94hdgbp8u9gpikbmcmdao48c48ukkm X-Rspamd-Server: rspam03 X-HE-Tag: 1689222086-943637 X-HE-Meta: U2FsdGVkX18waGn6UPDh0wAErGngfxYpurlJvEiIrQvGjVL1KPgHBDonSnRv/msQ17izTG9Ljo0gckUHe+/LVkUAkdIrBviNU5A/Jx/MY7WT7Z33ItFEcJIeaXmqa8ZIoPxfW5XNAcymnps2762F6VoOOUMFxOhKU4L/Kx9XHa0Yx36ApFICXqHxix5As293TT/bJdM9DxkeJ8Li8tSSYaldbvWdyi1Kc+hM0xHaLdW3SDvWRig484IVmseCynjUuG1D528ZDxkft7NHp4eYEkqrcaxu8aJ0hLOyeuG4HJFFV7fBk/OWo+R32qAOIe9PjAa+DTsOV85fNXwNKPQwdazNK/BaKC1Jhqr41bEHANUW3E76f7PuTWzK3qdCzRH6rleEZmHUie9X5ZktYn3iNlVU11m0E8WGbiM8WqbqS9LjJnch7wF6sCDodVdww8xOa70fPaQ4Ip0w1QGq1WE70AQriEEe5j5eIC09mR64gQvSwGjgZnmwqx+tw8hBfLwoSmRF75utNGpVVuVKjJHny/5cfhCbYj9EUYwY8uxqG2PjqzrtpklMbZsuh3wtNkX7sbKvHovNRRCQfdWtnt0hY7QCczhu+EkYmkzTIWRn3ytFNVmaLHAQZAyOSFxMLu3F8TmkQopmsEOnxR0odangM5caFNWcItKjd9d+mTZCOZ1y/+E5L4TSn70QvDSyqI2Yz1Jn2AY4ijJMP2SfFkW+GZ8aPf1tw1fT3SkEHn89eReTQoqcTS/HeOJxtxkxpKdQDJu/6GXgb3cDZ0wSIijtVnedJf71uoJkWLtzuIsNKuidr7Ofv7BuPaf2UdzRZLGs6Fw9A5CQBCVWA13uTsGhL53SLBik5abhDnHUcA8CrDQqlZktx05NQ8XtYQpMETowjRcfXFsMUq/nhO+/sObaG2BkgW18co1f5OMrya8qVEDvvbopWycgCNfXno1OEjT4OfOOnXqgoJ3sDRf/biW C/KUCmES gyejw4V37ZDy8yJ7pEhRHLeLxFJijq2Oy/y5Avw8fMGcX8LwFVMnaD1KZfDg44h69JAV0JoHy4yzRbAUiAbHQu54JXJpQfCcqjRgJQFyr1+EATeclUGj/JqzEtpOFOVf6cYbaHchBuCK9+O4PL/oasZJarT4LbxB1ve9K+vXgD0QMvOl87DXovJlXlaYbM8d+7R8tDkW6oxyH38ptmmLLcH5T06U5g67wV3k+S5uxbduSrF+KkCm44B0fwIMNONt93oEioxhuHNlm8hgDz6JQNbJbBwAl/jnVfA70JRnqTtckokrB9p3Cmw9UxPW3KexJCa0YbEUqHmnILm8+gIsOJzThTXSWWthPROHGTWz7LamPOLbaDpMZHSywW1Pt5V/aalwnprHUi0eoXFwr0Eqyyfyj8GBj8NkDownctSNL/lDk9s0vU6gkQ6xP5uSlUm/lXp7kI/p6Lw/GCyO/oHQQOGP5JgJnQU6r2CYpkBAr/GaGSoOgkvaGsHdhCxV7rtkJZKB1eTprECdIkRT5ZEny43QtaGctjEbKFceJuLwl6gOIdQucjThypueQt4uZb+OuGXK8ET6aObTlX3p3SJepnQ9sQg== 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: Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index efd7a0f78962..c8c3039a751a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1048,16 +1048,16 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) { unsigned int freeobj = 1; unsigned long off = 0; - struct page *page = get_first_page(zspage); + struct zsdesc *zsdesc = get_first_zsdesc(zspage); - while (page) { - struct page *next_page; + while (zsdesc) { + struct zsdesc *next_zsdesc; struct link_free *link; void *vaddr; - set_first_obj_offset(page, off); + set_first_obj_offset(zsdesc_page(zsdesc), off); - vaddr = kmap_atomic(page); + vaddr = zsdesc_kmap_atomic(zsdesc); link = (struct link_free *)vaddr + off / sizeof(*link); while ((off += class->size) < PAGE_SIZE) { @@ -1070,8 +1070,8 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) * page, which must point to the first object on the next * page (if present) */ - next_page = get_next_page(page); - if (next_page) { + next_zsdesc = get_next_zsdesc(zsdesc); + if (next_zsdesc) { link->next = freeobj++ << OBJ_TAG_BITS; } else { /* @@ -1081,7 +1081,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) link->next = -1UL << OBJ_TAG_BITS; } kunmap_atomic(vaddr); - page = next_page; + zsdesc = next_zsdesc; off %= PAGE_SIZE; } 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/tbcFFEC4xoO7EWKJ6wJoNR9O6LCsKQRdX9AJV1NNOf2D4vEywbGEFLlE+KqpIbyTi/osPtaj8rxipCAE9yVpedpFCmtFi8OE5lEpPwm0/5EKMKoHiqbbmeEYJUlsP1E9f4pxMqhyweM5H8UoAcEPOm1OV0jhf/nzbg9CT2siirnabmaZPaf4l051GsxbKsEwbySqsL3V1LUiJMT8GWBNdxGbmQdv/1qQIRmehRjgsJkuz7w9t3bOreMeNJAUSfzAH2vLq2tcLxZEPtuiYW0xQgm6CunZGu9VccPywb7FtIrsbvmIcOidGZUhDCVoKQVkYLlCfMLVgFLTAj1rv2ECWD+BJ2A41qjwuGQlUyf/xYkQ4z7VTBLYK0z74asQldWC9yXmlzplAzZOFPxSJLANlWBFiaPfnpe3VHo10sAv3IcFHvYbWnzXTgGQiP2OLCP/ITCivCilsPL62erNg1oI3plgaAt4hZ8guIegh/hq5CCbDC5ohCq8jj68G8Y4eawRMOdBOOimSa/xGTLpIE+mxTpmmEYbmPkQsJUIbeJmtsaQhUDQ/dBPTNBJWybb3k1FTPMsyN5KeD1533k/p4d4tGqWWZcMtOdLoQfsxJp6edFU303R36/JibfMNZco/ECHHUVhKnParqoTfvBoKnJcJuTYnoJ62n 1i8SJNsc B6ASIaiI134JnmGz0UlO0PLWYUH2SPOyiXSEKxoinDHxI5XlWxpK3yfpUw9w1/uqnHLNXVNpqAgcGT4oSkVf/y/bj34NWR2ZYOYGoxaVWgPNAtJKjX9q9KlQlDJnIQUBS0sGx0I/9NEQC7NxCGoAL8ipL9nb5YsRF1uMXPTm52eX5fOWW5Lzey6h4OA1jQGi7WSYFwqxtU7tQUBqB+XhxXIgvxcr8Sh6ip+nFv5Xe9q+0uo5wXttRLH3UVLgTMUeK4C59xOzJkKDtEPhbSyIinxqHh0M50NdaEVtEtoZc+OxcvCsmHy2dAC5yrVkk6+IqniRLBvLshB9Dvddqwd10vykMOfBAUoM2CkNksOldLV6hMyrxM9EMEux+UQHDAA56s0KhYJwoGQa+yrGvSkTctuRRrkyeaj0ZKIoEUnjhZcfyzmCbYs2Q10HA2krbPCyU+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); From patchwork Thu Jul 13 04:20:28 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: 13311277 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 4F340C001E0 for ; Thu, 13 Jul 2023 04:21:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DE3668E0008; Thu, 13 Jul 2023 00:21:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D42118E0001; Thu, 13 Jul 2023 00:21:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBB998E0008; Thu, 13 Jul 2023 00:21:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A8BF18E0001 for ; Thu, 13 Jul 2023 00:21:34 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7ABC840010 for ; Thu, 13 Jul 2023 04:21:34 +0000 (UTC) X-FDA: 81005289708.07.A53DF1F Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf13.hostedemail.com (Postfix) with ESMTP id AAFC820008 for ; Thu, 13 Jul 2023 04:21:32 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="SOG/K/Xb"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.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=1689222092; 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=/AkKYYKmxj7TQUeJqlTJNcjNKZ3qt8jEQhquu79OlOQ=; b=UI7XmIOh0mqdNL1gcnYx2K85rqjXGActgfIhmbLX5dxOCUwam90PywY1x5/BdBRHY1PAKD 33vh9wiw9vAqiFvpKf2AGAra+ruKDADcQtCc8MAg7aU3aVagrxWe20cvYxqcrP2VPMMVnO LWrFWnt6T0D9mqkcbO/R7Y357/EG3Rk= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="SOG/K/Xb"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf13.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=1689222092; a=rsa-sha256; cv=none; b=ggzQSf4Uh3a2En/RDWOW6TvTCl+TcC1TwQlU0MiV2r/79GkJdDDW+k8ggOJjFGpcLU1Exv fD1Ui2mFe7FGJ88hVIO2vzzwfXw24vHFRHvVjdwDThby9864o7J9G3OpVNowAl91H79dVB ZdDv+hodz8A5J6FV3icIzs/t2Pzo484= Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-666e6541c98so297320b3a.2 for ; Wed, 12 Jul 2023 21:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222091; x=1691814091; 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=/AkKYYKmxj7TQUeJqlTJNcjNKZ3qt8jEQhquu79OlOQ=; b=SOG/K/XbNRTO8yeNVcrdEC9e85SmT5W+OelcxVnc+JYMVci8hbXGxUYc9gd4vbQ2aL xOYh108uhhE78bp3NscDM2bw1DQiku+bU2BJUvJwhf/cLuc89t2LiJ99VfukWcEdbUUM Dxx22mtv8Q6wYTu9gryeEOpcL2K8Ed+Wysz6APUHSMO/AfNgDP49TuqaGCDDqcNvngN0 aCs+TpmkeOONH2ObDHcVHT7ixWldKRp5t9CINzRwaO5RxB7E2aRhf0+ndlCQXbbT1iqP 79ze97f7s33kR3eBFqX4rM5CpMfOgksc2n2rzkSLzFC2wlYkLTUZ7OTkxbkFZoS3qWDr RlDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222091; x=1691814091; 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=/AkKYYKmxj7TQUeJqlTJNcjNKZ3qt8jEQhquu79OlOQ=; b=CS5G1AeY+fCY3pHWHMCzIE6Ph9aKT3qGP5hqknbSO3evldewd6H4Ai8zDCmlHfrLtW jndT8J6P8KMMQwpy+aFFKHhO5UXyID/rmHoShGfqbesiBf1OGSwunmYVNDPyBAekK1Nq bF0GWCtCmk7lk+OpjgyK/UQ7a/F6npr9DBT9+sLrtdPmKjA8YGFtfr6BJiqohw02B72E qYP3mgo3dpiHcnQjVDNvzaJ384Tnh7ae8frlK3FP9Mkj5SVliWWuHj8VDgA424Xqdut7 w1QxB5xrgGI1JiyDJHJGqY9YnPlYwmgn7QeT0TpmLkwEH+/4bjIH7GPJJ7fIlX81Jx4J OByA== X-Gm-Message-State: ABy/qLZYXKNQrOP6BSzVapbWaWAagvn9XlKnLp+6SLN9LEKGEuemiejm i6cMnzcNKeZD0Ug+5Hy1J7g= X-Google-Smtp-Source: APBJJlEjl5B7pAx+psP3HeXUMoWINVPRy39+miBs80ttFtJlPDOsP+1gCYRlrL/q07+KyucCY6JJCQ== X-Received: by 2002:a05:6a00:2d8d:b0:680:98c:c595 with SMTP id fb13-20020a056a002d8d00b00680098cc595mr731083pfb.13.1689222091506; Wed, 12 Jul 2023 21:21:31 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:31 -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 13/21] mm/zsmalloc: convert reset_page() to reset_zsdesc() Date: Thu, 13 Jul 2023 13:20:28 +0900 Message-ID: <20230713042037.980211-14-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-Rspam-User: X-Stat-Signature: 8mkhqjemn73xzp5rtpegd87cyx5yn4fc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: AAFC820008 X-HE-Tag: 1689222092-55668 X-HE-Meta: U2FsdGVkX19c3cqxIgbKZCfQJOBAWsDxl6NIDyDFZauoZI+ZrdkEtmOF4MnqMk7boPknSEa9UWD90qOW1YJoEH18Tqx3TGBh577lCo8CBvrxuycgdvcsq/uHdPVrSdeve73Tg/6y2Z76trhkr68nTvZYNcMyOTPTIkm26nT66ADqGs1rBZjeRkVaGdCNb9YS5L4y4sqf7RkeID2FVWje33KCe36ef0YXp6xrw51gkNdcibUs305IDBgGyvfbLVyTgkELHDyGXfsWetris8lGubMk6xEU1FGQ8ic/eKpMIngRTas17Fnp8hzZwRbUfsS0nBAqoduTZB7JjXq6yafH7PGTf/q176E9KqtBELRwHy27PtBKCOSZA0fsPvN59kBwFqU3wOQzXHMhJwpSfUHO/Dhpva4lG3UPiJ4eVCDFCLKf3TkgSaIjdqiQ/pBq/cMlYiVEoqP35fjLXAFvh0Hu1OGOAxdJ+m7gFIW0a78An0MrABBmcXjDxUxynBwXIaUsWDQc8v64KtlpUBVZMfKhdrWlzyv6ypG+fEkFr136LAfRY+nkZG1UlEYufq2CeYdqa92w9cj2zkH6ookpnnoqT4XIUmWtKFMHH6BIdjWSPDIr0W77p+SqHMKItcxZl12D/kj/Qw0lDzhKu/jpRe4BdebdA1lMVV1Mz6wT5JxW94YSwDNB6LEKjfzmhMOak9Z4FGcebm2dpQN17uzhHuduVJd1Mz5vMQsYzgYBMZ+O2PKeUPcxAoqAQBPMHlB4gASQ6f73881OylT8iCzJ2iNGCe9ZEHwSSq8hidRyI/cqpOWMfI6qkP0WrekhfvRHPgRc3g5OQOlf71tezSntHcPDLLf47FZuy9f71TI+zymDUWFXgxt6AoaWkVjSA6iJtlUGgdAV8BBeVwgn7rk8aNMWVhzFFuqEtGjRBLl+o6TXMIUCWEkbieNTHpKD2/UXx/x0zjQNdmzrVPD1wg8jv3Q f1t2gbFj bYAdqnsNdKLLlfZ/ShVLw+0G7zlc+PUN3THilVaGJsJVjICGuHlswwT2vRcC3PS+vqpDSNvC0P7dkWXYb1YvO0xmvGHuXK9TUwU7nURyAJqZ/xFTHYOwDY0TgXuomK0RHvNwJNJ4bG6nmsCZ8A1f2NO0mT5u+xmhjhWCP9lgb8PpZxh0szgOQ50GoFZBZQskuSR7e52phMKyz8snBdvcfn2/Dn2SDzLs9Qmg6AKIW1o7p35CTb+Ur0W51XSQe8kdokJldzWdoxU64K0W6nQaQ36LBLJeiHDZFYvHBuCK5TNvuitzViKf9Mek9CqbkMC+8S7OWnL2Mh8g8ZP7Dt2EDt+/3r6moVl7zSUK50hew5k1YBgnKN5fnJc/8feCMSFESivaF7TrkKGRPMqoQQXt+BHqFuIVhs0/fNv4cmCvnYIZXuGGuAfXD1jnTdWqexl351+W3C9sZDHzABxz0BAZOltigG05Z3GCfOZwf7oRJxVa1ZBQyjOL7OYhqHDFiNraI6anuL23mSXPhI6N4cmhEqzhVP4IW0OP3o4xGgTYhGqWq/1xWvHpKtsrvByV7se1VhbknJP2W5vC4tP00dSW2xf6mig== 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: reset_page() is called prior to freeing base pages of a zspage. As it's closely associated with details of struct page, rename it to reset_zsdesc() and move closer to newly added zsdesc helper functions. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 5141a0c72c61..085f5c791a03 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -388,6 +388,17 @@ static inline void free_zsdesc(struct zsdesc *zsdesc) __free_page(page); } +static void reset_zsdesc(struct zsdesc *zsdesc) +{ + struct page *page = zsdesc_page(zsdesc); + + __ClearPageMovable(page); + ClearPagePrivate(page); + set_page_private(page, 0); + page_mapcount_reset(page); + page->index = 0; +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { @@ -962,15 +973,6 @@ static inline bool obj_allocated(struct zsdesc *zsdesc, void *obj, return true; } -static void reset_page(struct page *page) -{ - __ClearPageMovable(page); - ClearPagePrivate(page); - set_page_private(page, 0); - page_mapcount_reset(page); - page->index = 0; -} - static int trylock_zspage(struct zspage *zspage) { struct zsdesc *cursor, *fail; @@ -1010,7 +1012,7 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class, do { VM_BUG_ON_PAGE(!PageLocked(page), page); next = get_next_page(page); - reset_page(page); + reset_zsdesc(page_zsdesc(page)); unlock_page(page); dec_zone_page_state(page, NR_ZSPAGES); put_page(page); @@ -2016,7 +2018,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, inc_zone_page_state(newpage, NR_ZSPAGES); } - reset_page(page); + reset_zsdesc(page_zsdesc(page)); put_page(page); return MIGRATEPAGE_SUCCESS; From patchwork Thu Jul 13 04:20:29 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: 13311278 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 32501C001DF for ; Thu, 13 Jul 2023 04:21:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C80E08E0009; Thu, 13 Jul 2023 00:21:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C09708E0001; Thu, 13 Jul 2023 00:21:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5CD28E0009; Thu, 13 Jul 2023 00:21:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 92F938E0001 for ; Thu, 13 Jul 2023 00:21:37 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 617EAA00FB for ; Thu, 13 Jul 2023 04:21:37 +0000 (UTC) X-FDA: 81005289834.22.7CEE320 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 8F064180005 for ; Thu, 13 Jul 2023 04:21:35 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=ZwLsHKCM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.172 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=1689222095; 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=/by1wk+lV1+/9owJgKTgxMHTJboWG5CTUy71o+eRxGw=; b=8UBByQn+4otEmc7wGmy26o1YWog32/04E3p5j7EtdNrz1wzWHZPjnJWQ2XyqGoSNYWgSU6 n6weT57sJ4/oaI5e/cZX0U5UlfTKyRlAhKkDhEV6XglNbMbfime5vsawCL3mCaVUC+tPSf 4gdj5+iek3DLfEJW3O6unS3fFXsm8lc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=ZwLsHKCM; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222095; a=rsa-sha256; cv=none; b=y4hcES1x2Dn0yUU+MK3BAgSvSuN3KmDmlFlIzpP+dXV2wSdLtaVXDRDUm/jFIifvQsqWsn BrsdvhTPXTjdOFZ/xKVQXpTpOUdHl9ZOnZmhJRXoGeVCs0am7pgdbHck0rGmfpAB9WNZLQ ++mFwyQEcEm71ji+0CuSEQGhGYWpxek= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-666ecb21f86so296580b3a.3 for ; Wed, 12 Jul 2023 21:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222094; x=1691814094; 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=/by1wk+lV1+/9owJgKTgxMHTJboWG5CTUy71o+eRxGw=; b=ZwLsHKCMGtSfeOwsjPa0Ht517nH/Y0IoWXfzkMMAR8zYkK/vu4HdAF46+mxiWe/roe 8EelYNkbLmFMwUTu8yqR6eqjQQEZELmkL0j5hPFs2j/dvv04mhUiCuF4GqCCxNQOvHJM 15lB1o6EhTt8eXMOEcjpqczfk/daeZabPbwWkIh/3bBXdpM3MSLYmmp/G+F4XIechk3c igz9mrzUUga5BdUJq8NrakVnxKm5sOPFoBF1tD+fv/XrIHaelaFD8r2jMn2tpTxX8icj QP5KDdfRxq+vtvLqAVuOREzSHDU9V/n8VLkX1DfcInOK7adg45jBcWmgh22ac8mHhHZI qZtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222094; x=1691814094; 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=/by1wk+lV1+/9owJgKTgxMHTJboWG5CTUy71o+eRxGw=; b=kOB844ca1IWjKmVKi0/fvrco8eDvlOHm1DsIu9HLtl6k2QRvKZ1ySMDQDUkx7VA5Qu lDpjW+9H1ueizWohAGLkuGj4JFsAMXYZpYYNTQNppp7/2JBLiiJc3hiwjb65wFBPBlCX Qo+hxUB0GhJvgm1vTRc6CAVmNdiPd+a/lCdFc74Xeh8WqGsGeIABtzbQ+xNXkZKYaeLO PzlS2kXnCONkREq4o9Fkws8IEtHBN7qGUvNWSaTnqpZn0mksVqR2R/9ZDjO2C9jOe06Y 6M63e4NSaBnaU7yoqrtz1u/JkXgsh7sDtL2i3FTlhOrYbIDKjQu7ASt9t0iezW7XYwXV +/iA== X-Gm-Message-State: ABy/qLaqdpWusaF67fwvQEqejrnnPNWQa/Fn3AqzTohJLbgcrHTP8jUU M8fHr1YhL8gc3BRPILcZkSU= X-Google-Smtp-Source: APBJJlHQXaD+zIgZjEwNmV8ncpgx7dFNmq4wW4mHfF3i/lYKQg9jn3S5Evn9lGjxsR9uHDQqJZv4fA== X-Received: by 2002:a05:6a00:14c5:b0:668:83b6:bfe8 with SMTP id w5-20020a056a0014c500b0066883b6bfe8mr621472pfu.9.1689222094431; Wed, 12 Jul 2023 21:21:34 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:33 -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 14/21] mm/zsmalloc: convert zs_page_{isolate,migrate,putback} to use zsdesc Date: Thu, 13 Jul 2023 13:20:29 +0900 Message-ID: <20230713042037.980211-15-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-Rspam-User: X-Stat-Signature: nn6g4uqwnyuzbcrsnhsmr5hn3qfbfqz1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8F064180005 X-HE-Tag: 1689222095-581601 X-HE-Meta: U2FsdGVkX1/GotvccbmPqHxCTCylFPNlviOMExBiI6txfHNocT0kuSOW1Y7Z9R98gbJz6P4DhwDl+JEQHDt2WrUsQY15U6MaEcGlnNLtN5b3KQjExBSpaD1S+mBs4DYw7nrActPR02hnIWc7cbkE7VmNQn5R2wRmVDk0RZfUyv0UANGRS7mD2Jz4vgCc7umM7lkrJ7n7HX8/p6bMgiQrJomKSpuAQWXY0N7kiH3riT4ahWsHeZLoard9ySFu0xfzZC56tvzPE00pjDxUevwTPivVqS7j91sVl6+fJzfWI8vRbXhZp6b8tlvWa5XJoX8rS+ptCZnudMsmhTmPNXDc39/Z6a2TxcjdPld3IzLC5aCG4pr0fIe1wnBFgk7gcncFwZrlYagUJ0pSUn2yBkv38XxkmPW3wbjwpjrBIiXUfSNJDuMclUn1Fe8shWnxbHsBEGtcr5NTx1eS+aqE9/eLitd2TiqCVOIqcmu49Kq8pF87v4E1qayJDqJBgNjkE0k/DwfQNKkahB5BUhoYI0DyUO3SKivIGbcdv4/OJfBLwnxjk0FOzd74jwapFctD1SIOzuyMCUf2QGx8y/TFo/BHupHoxf2f0oJNF5W+7CkYygE4Q9Gl3zKHjTyK74gRvO500AoZxrvtONP+wlcXJGPd9RwAeZsnNhua2IE0hv/R92JxmpYYq6hgwr7Q2uMyMBcCvYhFKlgdYp1vhA26lqp3n49dqb9IMbiKYdgBDluqpDxWC+0/14t0cRWP+wKL60o5o+7rCaShSWWAK6xZlUkXPPo+3LTiFQ6JWBcQJXBlYlaB/HJEfOZTTcmugukOvneoU5UcqfD/nYS5Mt7zTvQ5lJqnaPG1CiAM0pIcPmmFO0zLyEGe6+EdGQtR0HQzi0xYh7BaVkgUQ4wqe6gutbfw9BQuOHzb/RLyCT4cE9+FTL3ybyyO2A66kpAD9+o29nNUS0idsT1vp4lnOPOYW/3 ME+XTOml yu6EimpEPQDu7hBHIfI7Sp6amyvFtrJhXbCSQk2zXOS29D7Mm25IlTZSPXJZX38irCq92/3w6yQ4/E8u+seIxO++TsI4yURFrbHmFz5lyPojDjtVTQt4ySc6ThsJZvSZgFFy1faBmnz9XvKJxOBsIisRqTTu5jtFjw8TQzOAm9b3NDu5ygGSyNTMFwIGbmm3907yevc6IB1yT3ndF80WsTPdrU366mzwy0e309QjhVCeheNuUtXpW1UaZB8WHDjQPuVrLb3evkxCAc9U9n5uxk8IyWsad2iu2A0FajotmjTFynK3uVhN6jx0OdmJMfyPJgqbn9zsU8WgKPdqwzB6W5B2Kb5prFkPAHUmuXkMo+k0p2+qNOsk88qCgZMMJiqUze6HsEavWqiCwDAGOzMINTcjBlx+Ey9NLybgNo3U/vxjanY/nS5e8SToER3XbNuUvUqWOyfVJT505nYprT0SYPHxMlkawCMXA7OMIuGOaBIM7yd1YU5ARkgbTdMwGGati8uo0thI84QKJQQ5BIHKsk1pobdDMLfJ1M0ELRYjTD7IiuXtZle606rQLGxR0+FJiKP4OJVfP72xEYmGpmuMT2/ZL8A== 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: Convert the functions for movable operations of zsmalloc to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 085f5c791a03..9e4ced14e1eb 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -399,6 +399,16 @@ static void reset_zsdesc(struct zsdesc *zsdesc) page->index = 0; } +static inline bool zsdesc_is_isolated(struct zsdesc *zsdesc) +{ + return PageIsolated(zsdesc_page(zsdesc)); +} + +struct zone *zsdesc_zone(struct zsdesc *zsdesc) +{ + return page_zone(zsdesc_page(zsdesc)); +} + /* huge object: pages_per_zspage == 1 && maxobj_per_zspage == 1 */ static void SetZsHugePage(struct zspage *zspage) { @@ -1928,14 +1938,15 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, static bool zs_page_isolate(struct page *page, isolate_mode_t mode) { struct zspage *zspage; + struct zsdesc *zsdesc = page_zsdesc(page); /* * Page is locked so zspage couldn't be destroyed. For detail, look at * lock_zspage in free_zspage. */ - VM_BUG_ON_PAGE(PageIsolated(page), page); + VM_BUG_ON_PAGE(zsdesc_is_isolated(zsdesc), zsdesc_page(zsdesc)); - zspage = get_zspage(page); + zspage = get_zspage(zsdesc_page(zsdesc)); migrate_write_lock(zspage); inc_zspage_isolation(zspage); migrate_write_unlock(zspage); @@ -1950,6 +1961,8 @@ static int zs_page_migrate(struct page *newpage, struct page *page, struct size_class *class; struct zspage *zspage; struct zsdesc *dummy; + struct zsdesc *new_zsdesc = page_zsdesc(newpage); + struct zsdesc *zsdesc = page_zsdesc(page); void *s_addr, *d_addr, *addr; unsigned int offset; unsigned long handle; @@ -1964,10 +1977,10 @@ static int zs_page_migrate(struct page *newpage, struct page *page, if (mode == MIGRATE_SYNC_NO_COPY) return -EINVAL; - VM_BUG_ON_PAGE(!PageIsolated(page), page); + VM_BUG_ON_PAGE(!zsdesc_is_isolated(zsdesc), zsdesc_page(zsdesc)); /* The page is locked, so this pointer must remain valid */ - zspage = get_zspage(page); + zspage = get_zspage(zsdesc_page(zsdesc)); pool = zspage->pool; /* @@ -1980,30 +1993,30 @@ static int zs_page_migrate(struct page *newpage, struct page *page, /* the migrate_write_lock protects zpage access via zs_map_object */ migrate_write_lock(zspage); - offset = get_first_obj_offset(page); - s_addr = kmap_atomic(page); + offset = get_first_obj_offset(zsdesc_page(zsdesc)); + s_addr = zsdesc_kmap_atomic(zsdesc); /* * Here, any user cannot access all objects in the zspage so let's move. */ - d_addr = kmap_atomic(newpage); + d_addr = zsdesc_kmap_atomic(new_zsdesc); memcpy(d_addr, s_addr, PAGE_SIZE); kunmap_atomic(d_addr); for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page_zsdesc(page), addr, &handle)) { + if (obj_allocated(zsdesc, addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); - new_obj = (unsigned long)location_to_obj(newpage, + new_obj = (unsigned long)location_to_obj(zsdesc_page(new_zsdesc), obj_idx); record_obj(handle, new_obj); } } kunmap_atomic(s_addr); - replace_sub_page(class, zspage, page_zsdesc(newpage), page_zsdesc(page)); + replace_sub_page(class, zspage, new_zsdesc, zsdesc); /* * Since we complete the data copy and set up new zspage structure, * it's okay to release the pool's lock. @@ -2012,14 +2025,14 @@ static int zs_page_migrate(struct page *newpage, struct page *page, dec_zspage_isolation(zspage); migrate_write_unlock(zspage); - get_page(newpage); - if (page_zone(newpage) != page_zone(page)) { - dec_zone_page_state(page, NR_ZSPAGES); - inc_zone_page_state(newpage, NR_ZSPAGES); + zsdesc_get(new_zsdesc); + if (zsdesc_zone(new_zsdesc) != zsdesc_zone(zsdesc)) { + zsdesc_dec_zone_page_state(zsdesc); + zsdesc_inc_zone_page_state(new_zsdesc); } - reset_zsdesc(page_zsdesc(page)); - put_page(page); + reset_zsdesc(zsdesc); + zsdesc_put(zsdesc); return MIGRATEPAGE_SUCCESS; } @@ -2027,10 +2040,11 @@ static int zs_page_migrate(struct page *newpage, struct page *page, static void zs_page_putback(struct page *page) { struct zspage *zspage; + struct zsdesc *zsdesc = page_zsdesc(page); - VM_BUG_ON_PAGE(!PageIsolated(page), page); + VM_BUG_ON_PAGE(!zsdesc_is_isolated(zsdesc), zsdesc_page(zsdesc)); - zspage = get_zspage(page); + zspage = get_zspage(zsdesc_page(zsdesc)); migrate_write_lock(zspage); dec_zspage_isolation(zspage); migrate_write_unlock(zspage); From patchwork Thu Jul 13 04:20:30 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: 13311279 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 22D09EB64DD for ; Thu, 13 Jul 2023 04:21:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B21448E000A; Thu, 13 Jul 2023 00:21:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAA078E0001; Thu, 13 Jul 2023 00:21:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94A298E000A; Thu, 13 Jul 2023 00:21:40 -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 7B8308E0001 for ; Thu, 13 Jul 2023 00:21:40 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 52E5716010B for ; Thu, 13 Jul 2023 04:21:40 +0000 (UTC) X-FDA: 81005289960.05.C752251 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf09.hostedemail.com (Postfix) with ESMTP id 79A6114000F for ; Thu, 13 Jul 2023 04:21:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=gDl0JF5e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 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=1689222098; 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=uEDSSIP+zt5V9XvZT+ict1746NWdOpkIhk/ClYlbKG8=; b=TzDx4ijVKPMjDnm4JZ701iVvIJrz8Fr8oauNKFNfUBW4WBQIeLomwwp7+OZaoGCRsc8jaw kHUb+49CG4OUafuAVptk6T7UASmwqK75WXxQHQ2UuljSAxCEtwHPcyL3qUTSjSGgXbwlJE YkniQwXYooR9H5KiLrvQiU1bsCTimUI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=gDl0JF5e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222098; a=rsa-sha256; cv=none; b=Gy6wjlSLzoPX9ArMT2RcgG9mw1qpYPSxnp10QVMClzPLq096v6SAvfjAAd8dXI4BhNkHe3 8aiITKthEbB5+Wgnxr2WaPq6pz80sMPugiYotZPO3Gxz2xUGpfpqgwLGicqdEA6E2wMgFI IOjRL2hLSXNu0/7+0pdyoRES8NgOBXk= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-668711086f4so152261b3a.1 for ; Wed, 12 Jul 2023 21:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222097; x=1691814097; 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=uEDSSIP+zt5V9XvZT+ict1746NWdOpkIhk/ClYlbKG8=; b=gDl0JF5e9zGpLRmEVQgEpzZ1YDB6JYSyOV9cQpeI18V9wzgjkAQF1WTsMsyU3VSoLf 2e1cTn7O+bGR8vWOg52VMo87dUBAfJiYwc2XktidpZUMY8OfM7ngVE95TQkHX66SanQW dgpC/2e8PppNekV6zRbcREFOHsjqAgeaozdTGFKKnnpBYoeg5Fx0fhAYs2W/ui/9MoZh 69aAO90DqMUuP75JGEeTXuZFg0xeVjbCPiw5v3qygq7ShgW2gTRi1GIszh84o4kPH8Qj 0sUZz+95DRgGUeST8VzIXP7PSo/0vTH8boyycYF9NPSM14W03PRBlwUQO6t6BMR04X3p PekQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222097; x=1691814097; 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=uEDSSIP+zt5V9XvZT+ict1746NWdOpkIhk/ClYlbKG8=; b=FPPV7srKefL+FysxJ432LRHYPq9baQMyPF5835Y7sU8LxXaCLR3slmzD8uH6p5jlVA C5LmoaT20nLyZUWfBB/q7Ktxcl/bVa15/EDhIWBnkXEHFCQ3PlVq0H/195H5UmyNgoB0 93ox0kAy0Sctu9RUij3XHDWyDM/7ineIlGBnzr4svfmbGzDCvzNhXnshg4lhngdvfb2a iiYB2p9Xu1VriiE0y8KrVIqzRlrUFw1divO3qpdXkcXRze0/1Pa+pxDHrjfZcET8n8GM 3ephLvIdKmuxiJIHW1CobQyNkKWPFqqDA/Shed5JfRWffD++ZokwTQzLqMnOjZ4FfiVJ jSIg== X-Gm-Message-State: ABy/qLabbChOhtcnSg5bjnBzpKMx43nb0Jvbb7PWYlhTp0AMtCZtVXTm TreBbWdws7qWR3gfGMRu/Xk= X-Google-Smtp-Source: APBJJlFlwg2pA2K3WdR4ybI758//TlSODxXQDA/TxlawtEXWCY8PW6IRxuTtLqAcqkjZbNPwiFTClw== X-Received: by 2002:a05:6a00:1a8d:b0:681:919f:bf69 with SMTP id e13-20020a056a001a8d00b00681919fbf69mr1060619pfv.0.1689222097302; Wed, 12 Jul 2023 21:21:37 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:36 -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 15/21] mm/zsmalloc: convert __free_zspage() to use zsdesc Date: Thu, 13 Jul 2023 13:20:30 +0900 Message-ID: <20230713042037.980211-16-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-Server: rspam09 X-Rspamd-Queue-Id: 79A6114000F X-Stat-Signature: m39t9xugztqaoea87p5jqn9yafc64ct7 X-Rspam-User: X-HE-Tag: 1689222098-161236 X-HE-Meta: U2FsdGVkX19fe0UEUpi9HuEQiMp+uA3xYZYWX1RRCkRZN3bwJiiol5ERRT0lYK4zrzr9gMkJixa7b7LDgRuOcM3kWxTUSy4xedhEsCDDMoytWy5CLdqCcwFYVVw4B9YetsWYoEYbajOxjkmSYIGdzaXDpCLT9XcAIX3ctsvgRlFhI3kB6SZycSknbMCl4R24qNGgYG9SQZLdb/0w2jRGOvvDggxXr5RXQVlVrHhCbt7aroWkXUwsu7BiST+j52wpfhM9cVch6/RCD2xM/D5HzBiJFsqwJdoyLkJhUeLdUz9Flcf1jvC2xugWRFaJlxP5kj9ILGxlHydsRwhtgAZ5x5chisXa2zNRykTCPBKpTPxsMAAy0DNGcDVl6Tgz/7nyYaDG7zk2vq9RGmgMcGTMJiu90fDlMs6YW8k/fXa9c3rPslkdg9jeR7eblSIh60u+dqHxi12XGXhrRCInMx/K7tV7Nz3nYdgcLqlo671Hc63723z7GkBht4825XldJUqpo0pLBf8Q30qTaP2sAs6BmDXRCcpUpa67D1egE/yLzw5YQcjj9Bp3N2PF3Bu/iCWduDAb/5Xq9kJyu053dms7Q7UJh8QYb2KLsGYa83/oR6wc9yqYuWXIRmiXrbd+VCue4dZdJubcm6CdmGUTp16wqR9moS+j+AyVoZspStaZM6BWu2VonQSk2kLMXgtEJTiACXA5G6wnpxaxa4B2PlXP6M2bi/Rzlk2uRJqLfENXrqHaz2+eZs72QvIWMGNrAeCZE2ou0EAOEElQwxslf8pbiiM5fgZtAY+WE+H0elG/fudu7rQm7Cxxtu+m6DaZ6/8LGtB+4ESeChMlqUF7zcxjXYTpSlevuYggCuMk7Q8ATpASnDilg9USv1UvgAfgWZtiBaYXrEt94ksYNn5FdvdTd8cQBdqZgYQS0M+tkq1lHP6SZy7QWK3GbzEtXEKhfFkZqR25HHKDWNGgkIhhMXD dtqyP6ZD a2jN8HkA6BYpotEjVGAXYDTXwrM6JzV+23SVueI9+Sd/yGqH/k/q0Dn7qYmESEKcan5dcom8x7VohhJV/rqeiuiuTVqkmN2QyZW9SHoRaXEkYEf2hydlYNa9A8ZmlI6SssPeHenS0a//34ReRRvJdSkreC18NbvTsoF8eNUAjCMFnG9pr3rUC9n1L46uh4CrhlAilwVKXaxyL9Mc0s1kUrpbOf2qfk5fI0gSgHn9227Jx9ZD0K5/9YTe/CYOZrLWcAnSrVF0PMsvzFtOdql778197lDPaWcHR5tsaM1K8CqwaHZxAKk0DeD+gGy0BzlCOACYhYuID4wz5XZCZekRo8aPDxR67dMrlymaHPL9KijjNndy5odGmUdGQNM3JJwdMKPbrTX08JN6tUtZk2UQfcsxCxNJqvWRxIDYOqlPECFy9sPeDK4RzWpiCyfwQ2VbIFv0lRE7pxdWe9iArMt8+ZiYOE2gxSodpQ1QKF589VTpAdSDQW8O39lJ2cMhP4e+TtrnBZaxgEp8dfF35aFk9Tav+/py0C/hkKqwGcj9eUrzbt3JsxE/0cLS6NeRt0llGGbMiMCD/LgOEuFIamTgxAxVzNQ== 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: Introduce zsdesc_is_locked() and convert __free_zspage() to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 9e4ced14e1eb..69bd497de35e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -336,6 +336,11 @@ static inline void unlock_zsdesc(struct zsdesc *zsdesc) unlock_page(zsdesc_page(zsdesc)); } +static inline bool zsdesc_is_locked(struct zsdesc *zsdesc) +{ + return PageLocked(zsdesc_page(zsdesc)); +} + static inline void wait_on_zsdesc_locked(struct zsdesc *zsdesc) { wait_on_page_locked(zsdesc_page(zsdesc)); @@ -1007,7 +1012,7 @@ static int trylock_zspage(struct zspage *zspage) static void __free_zspage(struct zs_pool *pool, struct size_class *class, struct zspage *zspage) { - struct page *page, *next; + struct zsdesc *zsdesc, *next; int fg; unsigned int class_idx; @@ -1018,16 +1023,16 @@ static void __free_zspage(struct zs_pool *pool, struct size_class *class, VM_BUG_ON(get_zspage_inuse(zspage)); VM_BUG_ON(fg != ZS_INUSE_RATIO_0); - next = page = get_first_page(zspage); + next = zsdesc = get_first_zsdesc(zspage); do { - VM_BUG_ON_PAGE(!PageLocked(page), page); - next = get_next_page(page); - reset_zsdesc(page_zsdesc(page)); - unlock_page(page); - dec_zone_page_state(page, NR_ZSPAGES); - put_page(page); - page = next; - } while (page != NULL); + VM_BUG_ON_PAGE(!zsdesc_is_locked(zsdesc), zsdesc_page(zsdesc)); + next = get_next_zsdesc(zsdesc); + reset_zsdesc(zsdesc); + unlock_zsdesc(zsdesc); + zsdesc_dec_zone_page_state(zsdesc); + zsdesc_put(zsdesc); + zsdesc = next; + } while (zsdesc != NULL); cache_free_zspage(pool, zspage); From patchwork Thu Jul 13 04:20:31 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: 13311280 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 D1408C001B0 for ; Thu, 13 Jul 2023 04:21:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68E668E000B; Thu, 13 Jul 2023 00:21:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C7B68E0001; Thu, 13 Jul 2023 00:21:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4434C8E000B; Thu, 13 Jul 2023 00:21:43 -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 30BBB8E0001 for ; Thu, 13 Jul 2023 00:21:43 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0EBB01C7340 for ; Thu, 13 Jul 2023 04:21:43 +0000 (UTC) X-FDA: 81005290086.23.B8F2F40 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by imf28.hostedemail.com (Postfix) with ESMTP id 4846CC0017 for ; Thu, 13 Jul 2023 04:21:41 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=X3NbDx3D; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.161.52 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689222101; 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=3gkqWMyo7b2B7ewPiOnxxOYIhM7JQ5HFP6zR7XlZTck=; b=hpOu5V5HkT/LN4PQ8ujmMIiqqoSJJEgl91KnLHFN6JzccOLcxgI75eXeZ1AynLPAGBOfDi 8kIOFHIBBjVeL2cvQ4x88znqyNFJpnekp3lks3OGLiYE01S9fL9lqBuZNqprwKIfVZjGYw RCjK9h8XymoWyh48TmpcMW1yVz5zR1g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222101; a=rsa-sha256; cv=none; b=nUaWXtFG8dZ1vrs/EM5B93hci5k39XTUBXT24NREXSC3Z+zthiXLd5k0K88HuuEdUXyBMH GeUGr/0x/Zcc5dzUC/Dvcdczcpci5fjlM3FoPxIv/RaAxLxoIIqzV/A8mL4Mq25IN8r04b NDIiijxQgmnYkUA4BbYmYN6rYw76ESI= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=X3NbDx3D; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.161.52 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-56597d949b1so294903eaf.1 for ; Wed, 12 Jul 2023 21:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222100; x=1691814100; 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=3gkqWMyo7b2B7ewPiOnxxOYIhM7JQ5HFP6zR7XlZTck=; b=X3NbDx3D8zqD9lwl2kii6f0ZcuwskOzE291MA+sqwvMG8ec0/+DCydE9arTynZ/hFV llNcsSyZINjLssmVLJhR57Gb9x7UOqBRh1WCnSKjNaGY/3+T1C4weTBTwLITapuddIWQ w/vZUGgdpa57Dotq9AB4QF2tiXUq+VjAJfzEOkNe8FxdJPM0yHkxP/8v9NSltQj6Uzgk Y0zydf1delIbaOOERiR33rUXICwirbWlvPSRGV3fxy8pYZuod/K46pv+voF0EYvcEB2J DFyIOGSSKXOkWmUQq5m3V5W1DxAHFb/KZdTzT/6VfC8EOkBljvhCX7zIpQF60wEnzop7 UlaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222100; x=1691814100; 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=3gkqWMyo7b2B7ewPiOnxxOYIhM7JQ5HFP6zR7XlZTck=; b=SrX4/PvhulMRwEne9ACsXLCnMtNq1rnb4fprxjCznq89ZF/5QEvezxna5wvUOSBCHO kPFbtwiAaWjDQ0Yf1kiPDNDnqd2ASz4acZtEpxXhfLuIOnxNfX0q7y22mPsZy+x1Yhks pP6T0bBTn8qXc9b2LmQ3ICTv2xBuLTP8tCkIrftYbgAe6M8/CJGOiCri0kZ7Y90uLZIc zIAxSwhKeOo/u73h8FBVvouLQ57OQy6vyxR4Epv9pAQBzU3sxi8IfFUa6IozSiccGgIc C+jE5mNEOc9snfIBEz8ViWsTwUNDs96VF0wx+1xGRPNylThLt3QQhsIe8JGP7ua2rFRX 33iQ== X-Gm-Message-State: ABy/qLbJSr7/U8HruhWWXfov2k9oB/xNa7yoKXq8Z1ahUQojRB3cV0/U zF/j7kAZdlhKVD64G62cVVo= X-Google-Smtp-Source: APBJJlGiX7tftXPlnlj0r6WSZjzexhUUuLF83JtQLTrkv37u7pJOZ2k5ZiTxPcckOR51/J4NcCaw/A== X-Received: by 2002:a05:6808:1719:b0:3a3:bf6a:ba55 with SMTP id bc25-20020a056808171900b003a3bf6aba55mr682088oib.3.1689222100219; Wed, 12 Jul 2023 21:21:40 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:39 -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 16/21] mm/zsmalloc: convert location_to_obj() to use zsdesc Date: Thu, 13 Jul 2023 13:20:31 +0900 Message-ID: <20230713042037.980211-17-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-Stat-Signature: 1gmo8fmy3crkao9sue3dfggaxm4mzr3t X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4846CC0017 X-Rspam-User: X-HE-Tag: 1689222101-730730 X-HE-Meta: U2FsdGVkX1/PFx75lN0QCegANrOYwPsl+7VVUX59DJOdRAhZpyQlreN81GtsL4y0Lv7+aVaOruu51IhX99i35eHWGeGV+9lnhCQB5vwkCCCaXJzVfd5udyuIUaXBhFjmKC3TMXrWH2sZPS8B3hzDjojpO/vFajBSiHLFl4invaXFjyMyHEFlyk3558bR1iEbeYIRykTMM1Y1S5aqeiImX4keig3L1X+iweMAJJcfnT+LWGN/bM5gLccoATWmo2T1Fntdb1P0dC2fimWCg5eOyYByWk7tl97VHl8c3JQsjGJlm9fucV9u0jgwxHawIRhaSFNnI2sHwZW3Kt5SJr/E7gSDsYv1S5Dcyr4WysZ9CYaatlIirNxoo0IFKfSzfQaNyPtcaMy8y2gYkvJviDMhvqDoFHdkwObt6vAxRe1tnXOlgHNFIu0Jan0wX5nVXWHp2Sn4kXP4h7x2/zXy1J8X3ROrEN8+jG+Urv1Nnr6+BQgEcfqerF7cZS0ZFnqJ+Ghc5nQvYu+1oUkextO8WshyGnSqIyI7pl0Ya1TIasaEIbAWkxTYVs+uhqjpSkzHkpON56WNsk1rRY6LLiUTfpnSf/bKZhVNRo0RWQ0nENLrXPHgU6dGo167kqlu2W0t46PD5FdZ8vbqfCFpbIQI0opfUsiZyAV7eSlCbwyn3phr3X8pAVqgGTZy4KtEP6J2b0iTkTZI1hIeG7lliPIzYpfjabjLLfkoa472QGksmsR5xreNqv7bDfisiOhBfFzW+KqPowbmRJP9Z/v/s7fre8Us/F74IqHrbJZs/v6Tjh6WKYVUTcen7N/2aK9hlZbPgop4ZqtjQ2j7qo9rFyGoQ59CLrifv6A/flt7ULIDXx5ZuAWBGlNIaLhYaBi2Wctsk1wdV0LJWGi/spIfh31fdaSvBwyVCqSVEgEgvr69Y+HlOKek2aoc8eO7dKioEUhUlH7SO5xcv8LcH5Y8svxlE35 aU7yBJOX RR7xp8UMOq5OWSlfnxM6q6ubpJS/1ICOf5N+bET2GGQ5srdV+IcWnPiOz8Rw82fzac1TjhJwueI32KzaKjtkOiPV6Bbep+VXlUL9JoQmM/oZjidRvt52Uak7HihwHZvjo4aNnDTLVKYtx47i44xcLSJV+goNJlpZ/CPfe5J0IjGqHDwcsb2fceUaenL44PcB7xsx0N09nA6TmyCbkF34UdI+vfGy128yjADmJRrAjE/LspOxuRMehsK1AjspYimFQnRxIF8ID5h9u2COCdOnFT9YP31q4Icv2bG3rBeS1i5YypaL7/yzpGFGa7FKDd/KXClzBvKNkRAAvqqV6BEKwhvSiHocsC/NKNkrBsTNjzdKcyNxn07BBeOuxNPhiCa4wJGJpiRfKTZuocCTh0/bVuy5DEsA87jeCfetFMW6sMH7zBtSh5uxn57ZB0L28BAmr8SUQzb7Feeuw68YF/q1Ug5GyQh7UjsEGNm2AHFaEfwACFM7/OhutUfxN1aGw1oQBl92lwR3Or7ufaIMSs3kZu0F0mvQXtYVQbHxxz8NwIKLeQZHsJnxt6Cz9E3jILi87jhQV2tLy1cqWA6J9oF4uDronQA== 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: As all users of location_to_obj() now use zsdesc, convert location_to_obj() to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 69bd497de35e..fd920b659b1d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -948,15 +948,15 @@ static void obj_to_zsdesc(unsigned long obj, struct zsdesc **zsdesc) } /** - * location_to_obj - get obj value encoded from (, ) - * @page: page object resides in zspage + * location_to_obj - get obj value encoded from (, ) + * @zsdesc object resides in zspage * @obj_idx: object index */ -static unsigned long location_to_obj(struct page *page, unsigned int obj_idx) +static unsigned long location_to_obj(struct zsdesc *zsdesc, unsigned int obj_idx) { unsigned long obj; - obj = page_to_pfn(page) << OBJ_INDEX_BITS; + obj = zsdesc_pfn(zsdesc) << OBJ_INDEX_BITS; obj |= obj_idx & OBJ_INDEX_MASK; obj <<= OBJ_TAG_BITS; @@ -1505,7 +1505,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_atomic(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(zsdesc_page(m_zsdesc), obj); + obj = location_to_obj(m_zsdesc, obj); return obj; } @@ -2014,7 +2014,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); - new_obj = (unsigned long)location_to_obj(zsdesc_page(new_zsdesc), + new_obj = (unsigned long)location_to_obj(new_zsdesc, obj_idx); record_obj(handle, new_obj); } From patchwork Thu Jul 13 04:20:32 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: 13311281 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 3131BEB64DD for ; Thu, 13 Jul 2023 04:21:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE50C8E0001; Thu, 13 Jul 2023 00:21:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B94F1900002; Thu, 13 Jul 2023 00:21:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0E3E8E000C; Thu, 13 Jul 2023 00:21:47 -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 8BDCE8E0001 for ; Thu, 13 Jul 2023 00:21:47 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 68183A0100 for ; Thu, 13 Jul 2023 04:21:47 +0000 (UTC) X-FDA: 81005290254.08.330CD90 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf24.hostedemail.com (Postfix) with ESMTP id 98B74180011 for ; Thu, 13 Jul 2023 04:21:44 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=HhBiTuA3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 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=1689222104; 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=aqbwv8O+lxJHxid3fsI/4aDUJzUIFl2vk+EDGGzJMlE=; b=ieBYVpSwlC2pVVttmBac7DDNn4tPQe0uArPsWttyX+1OfjW6ynCBi92H2UzxRS9rR2uGQL Th9IS4JvKtqZUuXZDwPxuXzmLqxCd4IASQ4//PON0WZr8ql/O64JITigEWCJI4iZgHQann e05Q93SdHL0CcIUp6ctsy6lMeqnMGKQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=HhBiTuA3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222104; a=rsa-sha256; cv=none; b=ABT4Ib9PjgrIbVPLyJKOODW3Cr+cHa1VcFeJBijVYp/BrnNjgPsOJSrC6RtNkAm/xgzQsT 0dXbY/noSTG7OhlVeFUZ+FlJLvRoqwit2zWGUpM7OQkB9+SyGIkSDyqj5Teqr/NDodCHXs +WfiNScfxk7INOop39CSiD6sQhvEo5o= Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-668711086f4so152300b3a.1 for ; Wed, 12 Jul 2023 21:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222103; x=1691814103; 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=aqbwv8O+lxJHxid3fsI/4aDUJzUIFl2vk+EDGGzJMlE=; b=HhBiTuA3YRFVYYtX8/M0YJ6lb1HKlwUn3kN2x4yXQkPMRexnTuCNWiRQsxPM4Z3iot K/7cVMrpdqnXwqA69sfPQzAirtFx3g33cYzX2PZR8LeFPkVsNkqyf3a+CqglzU6PT7VN lzTikbIsFgelxLz6BdKj+2ew5u6NbqpOO3A8TU+aT+87uJAmc1FaYlwxI7hX4YIecnWB 8MrcygZ1GUYj35Q/AdYZJYSlQ55TU5BtSv5zHrWoTbOL/rt43IIq8zzrExczRxc1Chwm VN3KzXoIEVrT5+2xolvk0RaRzKulzYpRW+TbtM4OQXgGLLRrFe2PG8vfUgcZH9O5BTyb UqIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222103; x=1691814103; 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=aqbwv8O+lxJHxid3fsI/4aDUJzUIFl2vk+EDGGzJMlE=; b=lhhkhw75n4sXfRFbyffKAMOZmhYtvZ1eFnKAlvWsFpJi59GIogl0oLPBdY5yB5G9cx WclknhtFnI6rynCwnXU4asuEj1ZSVbHVHq0addTs3d9H804uZhFnSHvbVzHrUktpy0wC C2f1nx12pW3G8tQElJ2ETl4UVVkQDneZyj+oXg5ztm6kswFirNvGGlwZKgCbPthSrRen Wy3R5enTtJ1DSWa0xjDISJudYkZscPaM4sddGbJD8h4Eqvd5utrrJnWxt9dK8FIxL3rI UKBHlujy41qax1elDDIa5yZK8PGnIFKcMubHMU0WLcUv/NY3F/vhLRpWdexUDlD1X/X5 RQow== X-Gm-Message-State: ABy/qLaT483ShOkMtYapJ+sloBbQeL1MIMSkJU2rvPQJoJ+34xsMCTzc pU3UkOo9eBDVyNbYEehbk8s= X-Google-Smtp-Source: APBJJlGOrtV5hOsHEJUq5S+q2K6dI2JgqQtu82o3Vjh0U5YJbxX6e/q+RqfdVpeSjj/rqTPUsXDwYg== X-Received: by 2002:a05:6a00:1582:b0:681:4274:eef0 with SMTP id u2-20020a056a00158200b006814274eef0mr1212636pfk.1.1689222103209; Wed, 12 Jul 2023 21:21:43 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:42 -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 17/21] mm/zsmalloc: convert migrate_zspage() to use zsdesc Date: Thu, 13 Jul 2023 13:20:32 +0900 Message-ID: <20230713042037.980211-18-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: 98B74180011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: xjo1wytzm5g86p78n3e1k7fqfomt4k64 X-HE-Tag: 1689222104-55510 X-HE-Meta: U2FsdGVkX1+AgIhA2tzxfEvHJs1KnFzYggvWWXIMjhZ0XvRP7ArJ2oT9Bqx53eyCc3Ey91hMl7swIiik7/ciWllG1singyW+MUuSz9zk4/iQa5vJsdPYGySIrgZ/bphyOeYtzNFn8LVV78QRz+9FnU+tVxOSYZMsKkla2VCwNTazLUm5SbahwUXOyhYOjlcVD9pbakQYcnAVk0p48OdzfMlSsotfVTg2nExu/vOkk1oj0P43POm4xDA6t0jRRtnPs4aV+HDOcWPpg/J8BaKXj4/uKflNoy5N9Z7zwdeoQjHWniY6gSx1tATBchAgTBRzVJa8Ze/AMXOQzZpzUwsAYnabhodsPUayHwfLtpBanZ2SU8RK4j0gKo8g8W+hWfe6U3pMxtG/l4YLMNAVEZs/yii20GxQ2TskefR36ktClUdLuImRc8vEhnIkP5qY5zqf+o8u1ID1Jzroyuba571+RPFV3aSFzw98EnDs7ySw7a3+g9G3GlroYEOFD/l/JcZ6efc1C2xpx5QTxJqOzPbfY4xpWkEj5u6HFND0s5+1QyacxU3n/bE9sgDHbT8dLVYufOBur+Ghg4i2xDw7RjyleDl8yfaT88Z+cYbbeqXET+FGuWhGiZcxDxs9KPZfPOwijKKBDGEXS/+126vkp9G+mslqciUxKJB6c7btzmELMOF1JotOjC1DXwGDxZaGbANIrXKv60CdBw83ST43UMwyNGmdj+iZvBkjElyrVzoshLQ4zvZivGGJkBszJu/9nHWm8yyWwZjnY6QlWGK9rhzisNAza6zz+dDTq54DsxNV0S4Fap7LzSyU2kSG1yPPvUyIKUxkOWW+lqOcMeGLkv7iYcQb1sdYKNHBCzBFzZmHTIMvIyfrMRmZe/ZYJ+Rtk8RCj7iCukYmO/bVJkpvY0J+7VF16XpQMq5BT7vzSpyjZ3mCPf3p8UcA8+ciJFoI6vuVg76upM3K89cjlyLAkOW SBFaTKUB rQhEaeaL2jIdkG/q7Jxls4DWGUpFqzlpvnK1YfYrbcufNgUB6ZJDDPas/NV6PihJxF9qoHsSlKJ1fLrdN63J8dLrZGMvhWEZhDPizth6R40WEWkdv7M6Bao91En5VkGio8ds6Bkrsjo6k6u3RNkwIqKmpqF+aX69ZlpHnwLhqnYtdGAJL0gfK/c6mkpmOAQ5pITDaSAsOueuKGVHB5DChF9aUj25Sr1S7tZYnzogFuW+kqYkZg5chlomiFhZ6DpzbF7Ad2bay7LAwQWmoPbwBM/G7jflzpeurLSWo9t3hnb/PtnDHRQjKfy99KMTcgq0yTUdpfZS9JL0it4zKYC/JCZQZNKeJ/c8yJgWfV2NbTZKFFCBVTB5/NcU3hRSmSJTF3kY3Crg6ap1yhUUIZHklOqV/0wfjBYM2VoKYHWPvZJDEuCN17NKflWgKHhGkE1xeRd2w0q8WChOwSdiiCMYiF1oCWGmzLMT8funWuVazk1AS5z1303BUx0bOr/E6xhfaCcj8eh2994sALutpeLvndmJ70oTu/PgtSL3mIabmdfmSIHb62B939BEjckr1mYtjrjdco8crmaa8c4ICbV7Ys9YTKw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index fd920b659b1d..db43a5d05233 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1746,14 +1746,14 @@ static void migrate_zspage(struct zs_pool *pool, struct zspage *src_zspage, unsigned long used_obj, free_obj; unsigned long handle; int obj_idx = 0; - struct page *s_page = get_first_page(src_zspage); + struct zsdesc *s_zsdesc = get_first_zsdesc(src_zspage); struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, page_zsdesc(s_page), &obj_idx); + handle = find_alloced_obj(class, s_zsdesc, &obj_idx); if (!handle) { - s_page = get_next_page(s_page); - if (!s_page) + s_zsdesc = get_next_zsdesc(s_zsdesc); + if (!s_zsdesc) break; obj_idx = 0; continue; From patchwork Thu Jul 13 04:20:33 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: 13311282 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 B8E77C001B0 for ; Thu, 13 Jul 2023 04:21:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 508688D0008; Thu, 13 Jul 2023 00:21:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 441D68D0001; Thu, 13 Jul 2023 00:21:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BACA8D0008; Thu, 13 Jul 2023 00:21:50 -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 155AB8D0001 for ; Thu, 13 Jul 2023 00:21:50 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DB704AF4FD for ; Thu, 13 Jul 2023 04:21:49 +0000 (UTC) X-FDA: 81005290338.30.11CE31F Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf08.hostedemail.com (Postfix) with ESMTP id 0E333160006 for ; Thu, 13 Jul 2023 04:21:46 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=M64LK05+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 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=1689222107; 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=eXM4L6ATnQ4xrg8tTfTjz4QRtMoQblLyPPhiA9zDD8E=; b=o2moafi0PKmZQ0NnjvkCwqkaPxF6ODyjc3GMnmvrSkoDrDSM4yRTpAyJo4fxtMjCIvIm+C cHVwYWDIv6QpSP9bfrYBaGDMPXankQifWQ95GCHH+sbbS3e3W6KasbhS4dJiqwmgXXie4C wERcWIux2jVNRF573pdngOiFkovm9wY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=M64LK05+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf08.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222107; a=rsa-sha256; cv=none; b=5JgqrhzMs3ifVB7jmWm2dBxbJfNf3VNjJoypPWP92YfymHeHvSdZsxWdTqIdWfj2JSg1zP d3172O1Sr9uNCJnyHOZqajch6zdGSIFzYuNTrmAnl421/XbM1XZ2ib/HxfbA4H4TBUTbsl 8oCibXkD3/YoVJDfMwcHAH9l15LZHys= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3a1ebb79579so283885b6e.3 for ; Wed, 12 Jul 2023 21:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222106; x=1691814106; 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=eXM4L6ATnQ4xrg8tTfTjz4QRtMoQblLyPPhiA9zDD8E=; b=M64LK05+hua14coRfSAzgdWbmeWOfjeIcnMe8zHhEEq6QZfU+wicBwfhOlbx7f712p MCCVAAWPzNo3Qc49xeRW05dxjBSHHqRcqunGvYK0pYS6L+gPbY9eAfRpW+PEVWOnMgwm mRuybE0qcPvJWT52YiqJU/z4k9UphElNmJ66v6/+Wy2VTIZ/VE+ED1zF44gtWuANKLX7 OL+nN4m5Z7XRCwbQQdqcMQ3ph1yGrn7MUeyQDVo0XCnzFnLf/zSV9e5SxA0vBgl5vXB/ j/SOEuJk4oFEFhmM39sbUj2Sk4Ip6WU0A4Fa6blAp1QbYef/HX06f5QtVIbQ9YsoBg8G /gVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222106; x=1691814106; 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=eXM4L6ATnQ4xrg8tTfTjz4QRtMoQblLyPPhiA9zDD8E=; b=iaZ7d/RavbDmsvhJw6/eo+hew6ahMpgcsyPuQL8Dtflv5iZVEEOYjNLxjz9L4a2XQS 6IKTNXlKpfWb/LI43+JrHjrXplS8Zqs6uM+NqgK41HFWJLX6BPQwWvHPrZYvDmi0Ed0w e5pXyrNV261JdpqJ5GAa755RnM8EEug/xjgwwPK/CuolKRHJhRXpdGm9NFcvfj16ceue YRdyxWwSrsh/zV4ahHrl9o+dGEZ9pPNYT1t9tKfVx3ao5v4MgzWiV+JSPKJ4gWux+o/O 8GVpFyzqSU3afOpOl0qVgr+zYmyxFvY0fINbcxtbENBuBLhXy71WSSbiyXP7SLyR7MXl wrEg== X-Gm-Message-State: ABy/qLb9bgcJDc/oDCj/HhH+kh8FwOKVD+lp7BZjtWY2u8rr9V54HgPu jxQ0pMiFgOArtQE3wmy/xZU= X-Google-Smtp-Source: APBJJlG+h4Yqni22gjogscFoMXfmzoSDOy/WAo/NSF0NWCEAbsC70HXke8WrSb7H557DGFEUsgq9Pg== X-Received: by 2002:a05:6808:1246:b0:3a4:17b0:2b12 with SMTP id o6-20020a056808124600b003a417b02b12mr628547oiv.11.1689222106137; Wed, 12 Jul 2023 21:21:46 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:45 -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 18/21] mm/zsmalloc: convert get_zspage() to take zsdesc Date: Thu, 13 Jul 2023 13:20:33 +0900 Message-ID: <20230713042037.980211-19-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: 0E333160006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: nubbh8dgrt7pcee95ifxu48rq3uo6957 X-HE-Tag: 1689222106-664223 X-HE-Meta: U2FsdGVkX18AjEvJd2JwwZV4PFkVMDOcnz7Ne3HqLW+rq42O/niI+tsleuYtoVJpZ7DNFKMs6DM3TOOtl4MAovh4IxNEInQnmBAtWs/yk0547SKMycOpULeqEB0OzqafRrEnfPKh+mUOdRXSJ5SrvneyVzNa+/90l8yLEWyr+DPRjOwygrISRR3hklbbLbkoNv66E+vtJWemVLSDa7/Mg1u7Zt/XsrwABBOgTL3UHpQBDnDOX+3Lh+6Q5YGh3aDGKlKgulpJ4afMC6px5c7sE3TMpWxjMRSnooSzaeN2OHuqMfDC+Od8j/hbzpx/33MpLEL0SGd7jKCwXHHIPglJkNwo1ntaVSs9HdnwEHnlm3UyuKcXJ3EzZ16Rpor2r2u+q3XSwqsC6YDCtJZmV5ZhOSJIuLBsrdLxzDFIfWk3F17IQJwobCqUzy3oPHUWwx1gNRIUmSF4lGZ/5D2cMNRVx5YabkA2OhnzP03tmxuEnVDkgmmnNZN2f5Dc7WpN78N1h+9ceQJarD+A0gYGDhCLM5rsm5QH0TizyC1niP3OIJoazfErQF403ByPWaF7Ue++/E583f8VTZY+wHQ+6EWDynfResWzkHNKCmgYoNBq75YX/ofmBDcARxnc/QUL7GQJMRI+6LnTkQF2lCTmPqdxHYAsmw31DvSnDJUhxeQnztSHEXCJRF3WrOustrKo4UtD/2ydBGbkeWIpRwZ2n+6VTDv5BU03sQvdriLxsbPDdo8WN6jL9FtUtTAZ/X5bGNgTS0SknbeECvFXyFzCMR6SxDNCJqKxbTWu5gJEX3l9YmLxig16ULtOIF+ipimRBN84XIAZn2GeBLeawg8YPhCsLa7vDVdZKwDkIhVja30+ozKT5aOAQnCL1/3Qp012JZEpWbn/Cznkl2FVhbJQIwEgPcnaV3YVYmGOVUcznDHTnATRdbpLHk/iUITSExS/1Jo2T6tHmeo8TchzEeBPwGA bB0GL3Sp 2LikykwlKFBYa55ZaPUewVfYEGTMT7oMUlCQ4KF3/jgRM1xz8LZA3bFh4gjnTN0KjLJ6UHikNcvReT4EnkSLtwf4TAYJCTkE8OjewQmPFoDsAy0K2bhvnS00LPNM3Zt7tfaAimFxyVvAT9vWIJYC46OSU3gTEC9xAJJdwDMK3ezBq5vcUHrZYuYe0rqsjbZRQ/jBFLY09Q4S561tyupXooPWDMeuJVt8WUcEvnmlr6zaoAbKUtSyVJ+eDtsZWqzzkg/0l3W2iqXLNaDmgbCtVnC8++Cquh22sIIVAk7QRjUVBvV2jZuSaeSiyJ7L1DKlOwwQz2wcW1oFKcCwu7+zxzT83O9SpmfX1l+blePCnH0yhdM4LOj6k4bF9RJPGOeXh05j7926Ww6JlIdGTRGCTkZRLdtCEW1hIondZPVBxJuTmdmXY+7uN01hAFp122Etcne6kGhAWZm8i7JHW6HYoyiE2e2dB2iUqtoJ0okRl08tqRuoREBp9F7xqNluOib6FyWhOs1BbuL49Fsy3QbZcaXYuWHmuC8QNczgqNpVmAkpMulNATcFQtZrQi3QqdLm4kQ0Cv/FiUBe1IY43ibDznG85DQ== 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: Now that all users except get_next_page() (which will be removed in later patch) use zsdesc, convert get_zspage() to take zsdesc instead of page. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index db43a5d05233..6cb216b8564a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -899,9 +899,9 @@ static int fix_fullness_group(struct size_class *class, struct zspage *zspage) return newfg; } -static struct zspage *get_zspage(struct page *page) +static struct zspage *get_zspage(struct zsdesc *zsdesc) { - struct zspage *zspage = (struct zspage *)page_private(page); + struct zspage *zspage = zsdesc->zspage; BUG_ON(zspage->magic != ZSPAGE_MAGIC); return zspage; @@ -909,7 +909,7 @@ static struct zspage *get_zspage(struct page *page) static __maybe_unused struct page *get_next_page(struct page *page) { - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(page_zsdesc(page)); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -919,7 +919,7 @@ static __maybe_unused struct page *get_next_page(struct page *page) static __maybe_unused struct zsdesc *get_next_zsdesc(struct zsdesc *zsdesc) { - struct zspage *zspage = get_zspage(zsdesc_page(zsdesc)); + struct zspage *zspage = get_zspage(zsdesc); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -972,7 +972,7 @@ static inline bool obj_allocated(struct zsdesc *zsdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(zsdesc_page(zsdesc)); + struct zspage *zspage = get_zspage(zsdesc); if (unlikely(ZsHugePage(zspage))) { VM_BUG_ON_PAGE(!is_first_zsdesc(zsdesc), zsdesc_page(zsdesc)); @@ -1377,7 +1377,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, spin_lock(&pool->lock); obj = handle_to_obj(handle); obj_to_location(obj, &zsdesc, &obj_idx); - zspage = get_zspage(zsdesc_page(zsdesc)); + zspage = get_zspage(zsdesc); /* * migration cannot move any zpages in this zspage. Here, pool->lock @@ -1427,7 +1427,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) obj = handle_to_obj(handle); obj_to_location(obj, &zsdesc, &obj_idx); - zspage = get_zspage(zsdesc_page(zsdesc)); + zspage = get_zspage(zsdesc); class = zspage_class(pool, zspage); off = offset_in_page(class->size * obj_idx); @@ -1591,7 +1591,7 @@ static void obj_free(int class_size, unsigned long obj) obj_to_location(obj, &f_zsdesc, &f_objidx); f_offset = offset_in_page(class_size * f_objidx); - zspage = get_zspage(zsdesc_page(f_zsdesc)); + zspage = get_zspage(f_zsdesc); vaddr = zsdesc_kmap_atomic(f_zsdesc); link = (struct link_free *)(vaddr + f_offset); @@ -1625,7 +1625,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle) spin_lock(&pool->lock); obj = handle_to_obj(handle); obj_to_zsdesc(obj, &f_zsdesc); - zspage = get_zspage(zsdesc_page(f_zsdesc)); + zspage = get_zspage(f_zsdesc); class = zspage_class(pool, zspage); class_stat_dec(class, ZS_OBJS_INUSE, 1); @@ -1951,7 +1951,7 @@ static bool zs_page_isolate(struct page *page, isolate_mode_t mode) */ VM_BUG_ON_PAGE(zsdesc_is_isolated(zsdesc), zsdesc_page(zsdesc)); - zspage = get_zspage(zsdesc_page(zsdesc)); + zspage = get_zspage(zsdesc); migrate_write_lock(zspage); inc_zspage_isolation(zspage); migrate_write_unlock(zspage); @@ -1985,7 +1985,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, VM_BUG_ON_PAGE(!zsdesc_is_isolated(zsdesc), zsdesc_page(zsdesc)); /* The page is locked, so this pointer must remain valid */ - zspage = get_zspage(zsdesc_page(zsdesc)); + zspage = get_zspage(zsdesc); pool = zspage->pool; /* @@ -2049,7 +2049,7 @@ static void zs_page_putback(struct page *page) VM_BUG_ON_PAGE(!zsdesc_is_isolated(zsdesc), zsdesc_page(zsdesc)); - zspage = get_zspage(zsdesc_page(zsdesc)); + zspage = get_zspage(zsdesc); migrate_write_lock(zspage); dec_zspage_isolation(zspage); migrate_write_unlock(zspage); From patchwork Thu Jul 13 04:20:34 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: 13311283 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 090ECC001E0 for ; Thu, 13 Jul 2023 04:21:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8138A8D0001; Thu, 13 Jul 2023 00:21:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79C4A900002; Thu, 13 Jul 2023 00:21:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 616308D0009; Thu, 13 Jul 2023 00:21:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 47C8D8D0001 for ; Thu, 13 Jul 2023 00:21:52 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0D96CC0110 for ; Thu, 13 Jul 2023 04:21:52 +0000 (UTC) X-FDA: 81005290464.11.3700CDD Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf25.hostedemail.com (Postfix) with ESMTP id 401DBA0009 for ; Thu, 13 Jul 2023 04:21:49 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=DNDzJeH6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 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=1689222110; 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=Xtrw/YzOEDonF+rRVmBrlDfCDCMTeOToGRvD9RY+bgk=; b=fftVpACZRFqpC5OM/Ku/3E4LPPp60y1L0i820DbRpIA5aS2UpYrA7wXjjAoQgccR7lgcsb Jah9o22NL7cs7C7ABypGUfZg1TS/MCHPuxzYl9naNBwVpvK/BGIpgwK5QZ6r2GaUCvHIk1 wXzPpK80H2eChk6ce8J+UB317U/F81g= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=DNDzJeH6; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222110; a=rsa-sha256; cv=none; b=a26Eu+LJ55eKDQ7KzWw7ZN7P479pT36qVGE8G7ghGzCqRQ0M9/JKm7Rvtbc21wWRPr82wF gxJAp7WUYuDm9LcYC/GMlyURmYyzmzR9gc9hJuvoG+U8528qASENMKbO5GTWPFCWA/4HRR whMVkdQlUNU8eEEeOn2cNHbBgRZmccI= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-666e6541c98so297482b3a.2 for ; Wed, 12 Jul 2023 21:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222109; x=1691814109; 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=Xtrw/YzOEDonF+rRVmBrlDfCDCMTeOToGRvD9RY+bgk=; b=DNDzJeH6+uO2QRQUtNKhlz1aZsrdHRQc3v19UspNEVteBUbKa34CxMu1dDwP8iKgHU 8KF0nWm/6lmyuE7xNphIGmx+lEgQI/KoUbLErDlzkhdMtelyMl9ecW/RcTK1ebr6VO9h WLouJWDpvzbelCRzOX01QxQExmmdG+26259mTxI+kZ14UISGq5hYvhWEt10B4jTr9Y8S E6P23Iy6hI+jrHrFx0fKwUEJQj40SaSOGcqSGfe3z9n/47iE46lajWhiuXM0lGeG7iM2 7WUKg2qQ+SjwVM/EDeGVwxsBI84kTuo9LnBmXX1lcyGbwIdXJ3ckrlw/RMp4VBjFps8m S7xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222109; x=1691814109; 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=Xtrw/YzOEDonF+rRVmBrlDfCDCMTeOToGRvD9RY+bgk=; b=cG6zcEeywIIlhzn8RnUT711OiIb+egRQdvYCZp3+yXfx4DbsvA29Aqj+AGYJaNSep+ cwmpZ7XtjTRSGCWxSdJrzj/0oAHqAPqyVkyYpgsGZV5hD8YhfiGiWhvVIuHsresWti9q yAGDOP2cHmOaibPzSmYcPZtu0vVW046V7bGP2AmWS+NJqdE+j0gnSfNS+ZEGbm2/k7DD orBz9hbq7Mpn18rrSV9uQXecg8BQ0uJGt+8JtpKeXNcV2f4iHH5UPV7NDSGqMdAfVfvi KlPNUvR/EdU7bNh9EnrdmGP1YNIW79iw0cmAMFfpW2Zi8CMoPl21Plw1uw8OMknKKwRz h4Uw== X-Gm-Message-State: ABy/qLaNZ1TnQLuQJJj49uAbr6zB3M/Hi4ShO5/cR5qYUeXajVO7lv+F hqNKkMQWabGNgBkGuIUNHbo= X-Google-Smtp-Source: APBJJlEipD62xqeH0pCFWBwE+nqF39ivhCrGaqzTXzT0L0e7T5j9i8QrgvKnwAX+1UqrENQc5Txtlw== X-Received: by 2002:a05:6a20:2585:b0:12f:aac7:6f83 with SMTP id k5-20020a056a20258500b0012faac76f83mr419599pzd.42.1689222108958; Wed, 12 Jul 2023 21:21:48 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:48 -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 19/21] mm/zsmalloc: convert SetZsPageMovable() to use zsdesc Date: Thu, 13 Jul 2023 13:20:34 +0900 Message-ID: <20230713042037.980211-20-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-Server: rspam09 X-Rspamd-Queue-Id: 401DBA0009 X-Stat-Signature: 9oa5sngwi7smmaret5y656zudi67jody X-Rspam-User: X-HE-Tag: 1689222109-337218 X-HE-Meta: U2FsdGVkX1//pcW8gkkXw0Y+asQvdtjwOn/JDHNAqHovC86EJmJdmlfn6LH15NnYl0LpHNo5VTa3WZrLbI5iFTbsPu9tTFyy0am2lw3qncQ4ECVP1IUT2J2jotS2rsjVP9eB9ZVpF9buOEK5kwFiljI3O7ONqw+cfk/0cnm8CRq8uCVsWOF3MhSz6DU+VuQ8B7LvByI8AZD8bKGSgblR4rNq7i1iKZ+X1lhfIIkrjUaMrHY4d5sm734CClOQqWFHNIgrcfIHur3/rKlJURAo1q/eypVSmPbaAfdA/WkMhKfHwmtag6Fg8LRgetVKr86GWI1fevcgEI1/6or1msmiOVtLaF6ltwFQqPbmMaDKJwZ+qBcocvwEcdJoi1S+YRgZuJJ+5bzrsl3zVlnH2ikWTnyAxUZzaburmeCvxeRl+m7a8ERpTJnY7k4h1eJ3sZqKElSm9eZ1RVN8EQOfnOPsvHt3QFA70S+UrFO19OiXeT0H+VH6TIgZfY1K2ZkQWoZTOUKrVCWvyWh8Mx77hNlt48kiIo0Sa9WpvakebcxxTL7CYfKK4jzdO9qLRqw8BrrYvTFvE2KrmxzR1io7TOsQCMfkcyBSsKGYOFdCvBGgc3RydgnC0ibjpdR7DIo1Poq0wmjsvEsdC5zBqwX5IauMd9z6BWZofm5ZTLnYlxDE2fvhyFezYyuVyOhkkL9E2QQBCcGaY7BY9iy5HkQjYDQQDfmH9OOaMhb2hNUEoG9MKa3iiOu2HrWoFCC186DbHiC9rcpE7U9QNSjOBCI5uunLjnn3rfGp66eve5YHwKNxyKhKDGnmV7mmasF46eBBiIHfDSUZ7KuqpgjaQszuSi5nOTfSfBHFgAPfCEXQwRDy5gLJ4TgObkQrZ9IGrcqeVe8Cxbrd22ShG9RQSfaFd0OoKDjRZcIjn78ytoRctnY9s3vl/pCOcDtq59dFGLRMuDQcrIm744HnK7PJpHsv2Q9 VNwSltZa 3Jo03DxVswlHjhZbACxyuM0Lzy7WFl2SkLsxfGsBrw66komFHUqN1nEBq5dD+/OZt7iLsooTM9CVja2izFDA7UOZMooeeOwgIbJws/Z+j8M7fa7Ln5IVk43vCFa86Nc9djlu9R4byquE8MwE81rePitKOkSgVGpqmzgEFwqAHE5bP7I6wd6fxdm2U7J9a2X/epDJhFo8sqo7lV5ea4QpukNDdbigEwnX4KKeBB2ARKq2s6/KH2+bXQT664h1by6LxdyLPSb5TzT57a9z9CL13vZjfqtrCapLgunc0Co2RLdqGUG9RXOu67ph2XnQZ8xkqTM2+olYzgFKr9nxn6+W8J4QVs/Tmx/jcD1oT79dYiLo5N7wEFrM+BSmrw1W2QVf5dnygwusQhtYgpRrYX/B8ibWiUBQzW9PvTyo4Q2NK5LLr+qqlG4UoBI1jJoW1e6EMEUSZCxWKINMwaEy04jnpfX8k5kmx8L3dDHlJHqhlc0dRMnrTubWa6wxOy0SiltseadksNLK9fAMGvo3RYAHDI35MO44w/mlU4c/65IL5F9Hl2a4= 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: Convert SetZsPageMovable() 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 6cb216b8564a..5f07e3d92a99 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2117,13 +2117,13 @@ static void init_deferred_free(struct zs_pool *pool) static void SetZsPageMovable(struct zs_pool *pool, struct zspage *zspage) { - struct page *page = get_first_page(zspage); + struct zsdesc *zsdesc = get_first_zsdesc(zspage); do { - WARN_ON(!trylock_page(page)); - __SetPageMovable(page, &zsmalloc_mops); - unlock_page(page); - } while ((page = get_next_page(page)) != NULL); + WARN_ON(!trylock_zsdesc(zsdesc)); + zsdesc_set_movable(zsdesc); + unlock_zsdesc(zsdesc); + } while ((zsdesc = get_next_zsdesc(zsdesc)) != NULL); } #else static inline void zs_flush_migration(struct zs_pool *pool) { } From patchwork Thu Jul 13 04:20:35 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: 13311284 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 8E4AFEB64DD for ; Thu, 13 Jul 2023 04:21:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7CC0900003; Thu, 13 Jul 2023 00:21:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E066D900002; Thu, 13 Jul 2023 00:21:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C580C900003; Thu, 13 Jul 2023 00:21:54 -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 B0B1A900002 for ; Thu, 13 Jul 2023 00:21:54 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 95E9C1C7404 for ; Thu, 13 Jul 2023 04:21:54 +0000 (UTC) X-FDA: 81005290548.01.3AF26A7 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) by imf05.hostedemail.com (Postfix) with ESMTP id D3CA4100017 for ; Thu, 13 Jul 2023 04:21:52 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=nSXeqS1v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.172 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222112; a=rsa-sha256; cv=none; b=eS/bqm9JoserQrZBdFvl1TNTo08j30X9gX9tfqonE9onNp987ckiY+NuqQcLZqI3ESdlNc Q3HNBR5lLZ9SzJLxW5K/vHWp9DEwdiIr18MN3cO6mP/z6Emc7mzXfr91Qj+uUF3Rm6j8mX 1hXExLI2ZlrAu7vrD6Jv6wrEntDMMyY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=nSXeqS1v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.172 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=1689222112; 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=4hVswznnlp2brrsm/2WMROw2zFXU8NWv1b1UdYi0jsE=; b=auKcOMjMr7XMRVzgx48SVFSiNzduyRekHYDYg9EmYUm3gXfWbN1jRFsE/k3MWeqd0DWe08 RF6ui7jaCH5zlQJVOS3Nez3YhHZ1WKSmDpXdMZ4AAgg8kOJDg1xYYQd6WyuGkyMbxRzXg2 RsKAqGYwDBBCDdfkKVu73vcbO+8vJEA= Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3a1d9b64837so299108b6e.0 for ; Wed, 12 Jul 2023 21:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222112; x=1691814112; 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=4hVswznnlp2brrsm/2WMROw2zFXU8NWv1b1UdYi0jsE=; b=nSXeqS1vrLvki3hjRv3NHB0p0a6UYVrNvFV2Ii6YiscGVqtFX14ZQ7AlPeB7kVWfuT Ge3ZUTVOIbie5qSVnUIDRYK5ZuZRUShCVLtmwACUe12u+/VK0t8Wp7Wyie//lJZ6R3P3 ATBNfotR8SP0Km7iZBgdEp7E4T3Q/MMP79/aoXMAyAaawvkpdXL9NDHFTJv4mWqtWThH OXQNsrsDF8u9uBkZ6MjB8IRe64HCUUOxL1HZfUNT4M+aL4cre5gN9Lnsazz5jvXtXeIq rnP3AWKopqiW/8n5yl4b6sivZEy7PdI4jDL8+0SxDcQChTGYh9PyxFfUWVcjO8flw1zE QaPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222112; x=1691814112; 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=4hVswznnlp2brrsm/2WMROw2zFXU8NWv1b1UdYi0jsE=; b=B+N74+VpUqdN2SmbOdlS8xCRl86Bt4tmAH6lGFMaVWWYnl5cXh2O3zWHvgEmlGh1Ns cYsb1XtL7D7NYeqlAF/Srq+CP0Gw2TNDo4WJca4PhMNlBUCXZrQKaC/iDMOUX2uvBWVR ljCKmUGEtngO9OPes9ZNwGtblhsMBCITDGX4OG5phFT499RM7RUDqhVkAB+xkCFBNcLW hySvqG4WHBwRhpH7ezxQLPQMAgSfhdhUX1kls+oeUMxMGdBU/xtrs3+UokJ7yhanmwYy R4FNIX9U+JGmpB24FFa+0g2dH08utiUreAQxqnhoKUWfTZB28+gwRZP3wKOvtH9a6rQb 1/1Q== X-Gm-Message-State: ABy/qLap5nDbLD+qTDzSH6ObZHe8UtHDEbtc+rqto1qXwkuEObGicR7d DAphwzvH8QVLIFFvdTlJXKs= X-Google-Smtp-Source: APBJJlEsoCbaP98J11wpcHR6OQ0qKz+6eqfKR+c0anBTnosUkA3m/LCnjzPgDTpVgsvmVh0LYSoiSQ== X-Received: by 2002:a05:6808:1802:b0:3a2:ee9b:4262 with SMTP id bh2-20020a056808180200b003a2ee9b4262mr595232oib.52.1689222111920; Wed, 12 Jul 2023 21:21:51 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:51 -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 20/21] mm/zsmalloc: remove now unused helper functions Date: Thu, 13 Jul 2023 13:20:35 +0900 Message-ID: <20230713042037.980211-21-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D3CA4100017 X-Stat-Signature: 4ebpbpr3szcsroc5jz6xthd7xmgukdbx X-HE-Tag: 1689222112-19766 X-HE-Meta: U2FsdGVkX18TTPK8t6YsJCtOczAixV6Rf7S8KC/Z5rl83vd/oYu/qz4FpvZ/NT80pZhgP2ye5S5io6I1KoZVDKGQhX6abM7LHMS1qWZNz0uWi2IA/Fx+Y2iTEzcigoOPTBxt5FmTnqwF6lak/7yMW6TLB+34ZxxZf1wkjc3bhMDdzKEM32aEvZ4rvceUNtn/Pkgv6GMRK5EWtNgES9gKsndcweqToeQuCx2El0acJ2W+CO+scuSqE63pH13UUy4PGrLH3gplcr8R8NMLGzAwVnIgB6U0NzgxWoMhgbe5GbbzIJNxau7hdvC1CFsvZfPHqdFSGNInlnNPAzyUltUekxTUxhiFFNJQ3Gg7KTkfpWGmVsQu5E19uSSh9+qCJa+XMCYyTY1Tk+fULCgpRTTVuJLFhVRz+K7uI2v48vY31oBN4LPaiMbQyK8QX7R1GId36qlBxl+dtdHMYW63TTjZ0Y+ff0ENSIaDSUw+cqK30kmrlPMWH++pKhmdrT1Y4CDtRHUAkQjH7Q727BtOaA2QDvOsDFeQZ9SZaWgxTkOCa0ZeoQZj0r8JejT81hurbez1GyhotmUC0fN1xoWfYdf0Z1IHBl55Ts7VqiqZa22tTln85G6lsjLmzwJY6rg5ymDzvHF+lewevXtvGIAR16rh+874xfnnTgL/l6YqMBiKN5J42REdOfG2iaxpnVZF5Fj51S0H5nPwOtwSbPJuIrXFiD2rq8b+D1fFq2rYTxZeWg/tBxYOR528qb8W7R2qfozo1rQoijt4JoelxEVYCNbbSEY9Pt7Cy1SEhjJTwVJwrmuTQuxRIAdF2nXKVdfn632aEM5ZDEriGIwtzJ1OMr3KBaBSroqNpv6CdsPDSrq1lCUSL+MOOJLInqX9wm7x9faXPOgCVHo1rGPvmPKv+3zzm1bJlznN+/LvlmdonCHqOLeBIBTTzlfttMDfbLo7vZ60opQ7TWRiu+03ZzkM2hq kBIeTLM0 afU1VJRBeZBLzC2qdLNnM66ESqGIqTd4U5DtdYruof5IIetwlVL2G1Sp43i1/YKpsGRdmBhwt2ZA33llapemNsHIvu7NdLS/23pfg0NGUMw+XB3SqnYqUft5sxYgyFwp77sM3IFvSmW6qznOPmN4PYQmp9MQ+YjRfrWBqR23qAS4AN4/f1fPRkQU8fXSm8YRwKk+LWyPBNwN0qsjMB9prH5knHIhWWY9dT6lKN4Th7fpx85XINwdNpRfn3NmdK1J18YFekL7tiaYxrLTvNhiSHpng0SecO8kvdSuJ3pMEdr1OT9SkDzSnHZHWj4q2CEhB8gNgpIVu8b35oGinTsVbcUYG41uVFFsUNzOSJA4YmEaTMyq5l+rAH8qpfgHJXNJDgI1ugYr+5dBFTQ3/IGys6lh4kyGtbUi+gZS81wZGa6OGZ6KLdd+v9U2EivYQaNNQKmi/Ui+m+gJYegqZCMOw0GYuiHEdgB+9laNM+s83582WZiklch/xG5R/W1RB96TaHwuCOTYaEHd9CUu5+BVF92JGLvTSViLk1i3VEVw5b0eqBFY= 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: All users of is_first_page(), get_first_page(), get_next_page() are now converted to use new helper functions that takes zsdesc. Remove now unused helper functions. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 5f07e3d92a99..3933c023c3c9 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -581,12 +581,7 @@ static DEFINE_PER_CPU(struct mapping_area, zs_map_area) = { .lock = INIT_LOCAL_LOCK(lock), }; -static __maybe_unused int is_first_page(struct page *page) -{ - return PagePrivate(page); -} - -static __maybe_unused int is_first_zsdesc(struct zsdesc *zsdesc) +static int is_first_zsdesc(struct zsdesc *zsdesc) { return PagePrivate(zsdesc_page(zsdesc)); } @@ -603,15 +598,7 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) zspage->inuse += val; } -static __maybe_unused inline struct page *get_first_page(struct zspage *zspage) -{ - struct page *first_page = zsdesc_page(zspage->first_zsdesc); - - VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); - return first_page; -} - -static __maybe_unused struct zsdesc *get_first_zsdesc(struct zspage *zspage) +static struct zsdesc *get_first_zsdesc(struct zspage *zspage) { struct zsdesc *first_zsdesc = zspage->first_zsdesc; @@ -907,17 +894,7 @@ static struct zspage *get_zspage(struct zsdesc *zsdesc) return zspage; } -static __maybe_unused struct page *get_next_page(struct page *page) -{ - struct zspage *zspage = get_zspage(page_zsdesc(page)); - - if (unlikely(ZsHugePage(zspage))) - return NULL; - - return (struct page *)page->index; -} - -static __maybe_unused struct zsdesc *get_next_zsdesc(struct zsdesc *zsdesc) +static struct zsdesc *get_next_zsdesc(struct zsdesc *zsdesc) { struct zspage *zspage = get_zspage(zsdesc); From patchwork Thu Jul 13 04:20:36 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: 13311285 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 38D74C001DD for ; Thu, 13 Jul 2023 04:21:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCDDB6B007D; Thu, 13 Jul 2023 00:21:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C585E900002; Thu, 13 Jul 2023 00:21:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAAE96B0080; Thu, 13 Jul 2023 00:21:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 946D86B007D for ; Thu, 13 Jul 2023 00:21:57 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7586D40010 for ; Thu, 13 Jul 2023 04:21:57 +0000 (UTC) X-FDA: 81005290674.17.62E911B Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf26.hostedemail.com (Postfix) with ESMTP id A28D914000E for ; Thu, 13 Jul 2023 04:21:55 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=jiG6Jx8v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 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=1689222115; 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=9MetfO9mrNUCPlQ/wlpQAjWG2Omnt/Jwf7TCm8Zb+zM=; b=xVNHI6KzUSieBejNOV9A8BP9EZUBSzPayfjTX4pBNmMtDMfcaGlOXgV18oCClMFjLyiXOn YYIwsr5zeEmbMA3yMvYld84+QhEp/kU3Bah/RYK815wdv187A4nHtDiucwfsDLkMaXg+uf 4sUwHj5EBg0kvUdWlKyVbg1pchXfgKA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=jiG6Jx8v; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689222115; a=rsa-sha256; cv=none; b=ktbOYi5L3RgHklOAKWHJsccZDK/SojZpL+tkSbCNUAvVUVF8hLlr/JUwz7kgIlK1wHTNgE LM74gPXqE+G+CqQCYHiaWMlqausdfdKZ20/5S99mpt4uxjKhhExQFI2urVtN8X/1HmnFzq 1Usq4tLKJ4owuizn200nfs+QWQyNunE= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3a1ebb85f99so321654b6e.2 for ; Wed, 12 Jul 2023 21:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689222115; x=1691814115; 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=9MetfO9mrNUCPlQ/wlpQAjWG2Omnt/Jwf7TCm8Zb+zM=; b=jiG6Jx8vCgsZyWAXe3kUGl5Upako6/0pIT2NiUYxygtCnwxrcoeYsPV3i5Gcl5cn2t Bzlf8SSWF8qrdn0f6obQVsRY5ZP7XeiJBPkpH3tvqKSyZPX+hgjuIywu9/nb0UHxSlrM +t5R51ZUMPBPupiQEifFHmBUsv7jqUbvokHGWc8YSWLZ/w8v6wzdSugebG2dLgAC2fTR gztdBFEUkKIoFlpMBPGExShJppDw7+m4z8MBK9yJKnpWGCzRKA2L+50cEp801RXqbY7O ze9c6SdR/EdhnVbqyTexU4Xl8Iqju0TNwJhDPsExbp0wBwSXAFj9+GgZHHn/67yFKj0Q YajA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689222115; x=1691814115; 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=9MetfO9mrNUCPlQ/wlpQAjWG2Omnt/Jwf7TCm8Zb+zM=; b=QaFh28lbR3kotW6x+iBThHTKdJ3S6llawZVMOvMGCaRxsNzEQ3PBAyeCoVPaSUlt2p cqyviEZdNTM/XH6GpTCfPfLxFcN6VDrIiSfOyPpoiel6HEFIwyyai4P32+5+l0gv4QHd ttmlcJ5RaFOg755BpIGB4fqeD2+OgBgGvXHfjqYovuoSsRYr3xM+u3IajZtY+iW0utOy IbZjst6q5LFUptLJRlXFJD7H8kYMqD4B0G3FJQlKKmh9cd5IMKqwQFLGhVQo44AQiTOP GC9aBeyIS7Qj3fHG2lC0ohaBlcXANtgpRVpcI6u0IrPCu0uAdsUZ/ZGyWRH6dgtY7DZ7 ToDg== X-Gm-Message-State: ABy/qLa/aE+cVfBYuibc+JOY2PLPIKG3a5KYck7RtnlImQmMQx4q5qUX m9uAcvR3IcjNqTm+TugKBuQU60cpCHGHoQ+AwUM1Zw== X-Google-Smtp-Source: APBJJlHRPVrgCMfgSTQjztNxsY5F6JRQM00POfBtGVR98CC+mRl/WjJQjXMYh+PyKxa4hTDWDnelOQ== X-Received: by 2002:a05:6808:118c:b0:3a3:7248:252a with SMTP id j12-20020a056808118c00b003a37248252amr904978oil.0.1689222114767; Wed, 12 Jul 2023 21:21:54 -0700 (PDT) Received: from fedora.. ([1.245.179.104]) by smtp.gmail.com with ESMTPSA id u18-20020aa78392000000b006827c26f147sm4346601pfm.138.2023.07.12.21.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 21:21:54 -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 21/21] mm/zsmalloc: convert {get,set}_first_obj_offset() to use zsdesc Date: Thu, 13 Jul 2023 13:20:36 +0900 Message-ID: <20230713042037.980211-22-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: A28D914000E X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ynqxnyxmyony5k38o6k55ygbqr5sypip X-HE-Tag: 1689222115-56897 X-HE-Meta: U2FsdGVkX18+M5N2vBBis56CLk8n4eFwnfGAZLhTIFFjgN3UQVc2uczxylTPmI+LzDdP+VhaM4wooi2z9UCBP3W9DV5sZsMqFTItPmYnNTwFb+HXhF2Hv1CV5kcYovWPbaW0hERpFPjY1MfOeuaaDRgBGcI1oSmvB1I2urXjmi3wt4SRqVPnlYc0zTjsDV9fPag3f4IyZ/HGEiaAN9ZmeJ+1niV3iWvX3K5eVAHnkcML2xBtbGxN9TYyk2HhvS4ntddAJpfkKb0pdvXk6R/NFAlCt1lsTi9vBO/D+pJhRTQWVwe+/W5nZO7yZtM8B8puN6KiR5NGSJCZx1PszQVJGeVk+QP8QzrTR/PrZC6YQzUGSPcfGZ65YbfglN8KpLy4Y4OkpRZka/3lVpgWjfiwA05cWKSvgHWU0jUJqVEBWbX3Ld8DmRtP70n9DF8+Yz35CjBrFwrvfmyV/SqtRJvulT3uUNHgONIIgcbRl7pV8201F+EXg1/Pfp6OjNQUWAUlIINtsiVulUF1lm0gtkBJ9yR2f39ZVDmlPdPNswWgmYUVMJ95kDCeKpwv8Nn83wY76lPTy2mZWmYtRmopqm/ZUdYIXKsZUzeJHoKmfTYkL3mOHNUZjZzU6NKe/fH05600OcVGbv6nFQWFqflpJ2t1inI7JM4Fmjuzo1PZHYC3RE8skY5t/AxMbcIQchgQ35IcTGcWbH7B4QFBOkDLB8+uq1lPzuu92PZAPzQJetyJ4qNW9OZU23TQilkiUvzTxdFS0OxRjWsq3NFCOivpZ6GdmeDJRwbzW9fI/NbEKQfj+nQKxgW41mV3i8oeFnUOcsA64mX9vXim39p2cwLfR+PgHXT6f4e11l1GTj6cxK3aF0YsstVQS2hx0KMRKtFfSC9mjcj/fGG6JHOuCTh10/Kqs8axY4KHjAT5aQTZmhvZlsS3U7gDFl72whfADPkPwAGFa5fdN1alIubzmFS+BlU 1LZ7mbUt ipvUE+dxD2Qre/lqtm/DXRDNBMn+Ixmxc87xs9rc6Ny5HwTrnYpUft/T+Ae0K89Zy4sJYewYLrIkA7I6NjL4vEfuJbR+jX0rP+ORNZXph3Ynil5K2+S/LWcrlgtgUGcLunoQBiaDaIjjp14CXDre1U1wh/P5UMt+1lLCMQ9MPD64gv1GjJQD/p9w9dyN6/PK9gVDiX0yzsM38Bt3YdKLHhie2KksDXiLQMXTOIAl4hNEAKEZSSF49fye4usChpzK7Lu9ZT/WiCtJUFyIbBjBLCg/QMl4k2h7F7ew63/SYx5IHaxkXFB+uWesfeNPIlFydnknHYmRieHMXTYC/TTx5bdt0I/dh/L+ENzx2Nj0InHWDD9R6qYUBdXj6TSCf+g39PtkIFmVY0CSTyXFCy4MPMRVHwCl4v+ZzhDYeIdzz1zef3CBzl90ASerbSimmyCWsp1yDOFeohn5MZdF2oAGgMsXeXdTJ30lfhR7f9B7Qg3Xz3rS3jvLa6xUcEip1a0ORT17lA5YB+KnvDQxfRsFzorRvRGGt3h6LrwRf55eURgoFdXD/FNxiOl17LeCF82p1hEWZ/Vt+f7OfLza1sJ2lJ2QElw== 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: Now that all users of {get,set}_first_obj_offset() are converted to use zsdesc, convert them to use zsdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3933c023c3c9..7ac5d63e10a5 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -606,14 +606,14 @@ static struct zsdesc *get_first_zsdesc(struct zspage *zspage) return first_zsdesc; } -static inline unsigned int get_first_obj_offset(struct page *page) +static inline unsigned int get_first_obj_offset(struct zsdesc *zsdesc) { - return page->page_type; + return zsdesc->first_obj_offset; } -static inline void set_first_obj_offset(struct page *page, unsigned int offset) +static inline void set_first_obj_offset(struct zsdesc *zsdesc, unsigned int offset) { - page->page_type = offset; + zsdesc->first_obj_offset = offset; } static inline unsigned int get_freeobj(struct zspage *zspage) @@ -1049,7 +1049,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) struct link_free *link; void *vaddr; - set_first_obj_offset(zsdesc_page(zsdesc), off); + set_first_obj_offset(zsdesc, off); vaddr = zsdesc_kmap_atomic(zsdesc); link = (struct link_free *)vaddr + off / sizeof(*link); @@ -1699,7 +1699,7 @@ static unsigned long find_alloced_obj(struct size_class *class, unsigned long handle = 0; void *addr = zsdesc_kmap_atomic(zsdesc); - offset = get_first_obj_offset(zsdesc_page(zsdesc)); + offset = get_first_obj_offset(zsdesc); offset += class->size * index; while (offset < PAGE_SIZE) { @@ -1910,8 +1910,8 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, } while ((zsdesc = get_next_zsdesc(zsdesc)) != NULL); create_page_chain(class, zspage, zsdescs); - first_obj_offset = get_first_obj_offset(zsdesc_page(old_zsdesc)); - set_first_obj_offset(zsdesc_page(new_zsdesc), first_obj_offset); + first_obj_offset = get_first_obj_offset(old_zsdesc); + set_first_obj_offset(new_zsdesc, first_obj_offset); if (unlikely(ZsHugePage(zspage))) new_zsdesc->handle = old_zsdesc->handle; zsdesc_set_movable(new_zsdesc); @@ -1975,7 +1975,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, /* the migrate_write_lock protects zpage access via zs_map_object */ migrate_write_lock(zspage); - offset = get_first_obj_offset(zsdesc_page(zsdesc)); + offset = get_first_obj_offset(zsdesc); s_addr = zsdesc_kmap_atomic(zsdesc); /*