From patchwork Thu Nov 30 10:12: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: 13474198 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 C847FC4167B for ; Thu, 30 Nov 2023 10:13:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 127106B0456; Thu, 30 Nov 2023 05:13:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D8446B0457; Thu, 30 Nov 2023 05:13:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E92666B0458; Thu, 30 Nov 2023 05:13:07 -0500 (EST) 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 D72A96B0456 for ; Thu, 30 Nov 2023 05:13:07 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A0FB1A0112 for ; Thu, 30 Nov 2023 10:13:07 +0000 (UTC) X-FDA: 81514207614.06.155A539 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf01.hostedemail.com (Postfix) with ESMTP id C2C394001A for ; Thu, 30 Nov 2023 10:13:04 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W2UuxcIB; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.173 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=1701339184; 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=AFLDlKBZImGeYvTOOkWXzANWKOiczdwVYdjtu1l9KXI=; b=5ErNFfHHNLJ4WB6EYaCZOX4JXNeLScQIX0NmllFuNkLw+OMYXmiwt/PpHV30hh4QOLnRu2 Z7XcNLrBPBhcvxeUk3JLSbWE8Ncbg2tXtCnNj/FkptFHx5wWbw0ENL+CPC/odETr6RvaqF mF4FLFU5trilFzbCFOIV24FfoINe1jQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339184; a=rsa-sha256; cv=none; b=RrligbAEkM3ijoSRKG6tmF6owQtvO76+MDB6H1MqJRIswLSWweF0g0GdEWqszfNZKLjmpX CWsOhgs4e3UFintJ6YviZvGZdDFtS0DEHJPpQ+5dehMdGujAjWlddF85H1pMXGhkwq/vpF Xy+NeHSt7dciUxnxaRBFrLaEQnk5DeI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W2UuxcIB; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6cbe5b6ec62so745982b3a.1 for ; Thu, 30 Nov 2023 02:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339183; x=1701943983; darn=kvack.org; 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=AFLDlKBZImGeYvTOOkWXzANWKOiczdwVYdjtu1l9KXI=; b=W2UuxcIBBAD/gveklOiYWHmtMQ2qy899Hvp2NHccVSkNQX/v09fhxSYIG29nCLFuin bRzLq63lX+4WLrnWsi8cMxWVhmm5EENnPko6G13/M9rwuE7m25wiT4soeE7POZ9ac1Um 2+T3mZGijqKCjj09qfwSkkRL3QmGTo1eNH1Q24UoMmkt7uSmnFIXMtxOmxQ/Qko9knHU soJV5BioV2FQVKm48Qs18NZmy1SGUmfaQRoPvb6tBBwcnZphm4Sz/kukKsYjF//8isqw 0VPFutUBNF62FY3B9nwL9dm16Wry6OWWEtOdB8eWYD/A2JMb5kRPMzjc/FipMMdrNNKV E39w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339183; x=1701943983; 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=AFLDlKBZImGeYvTOOkWXzANWKOiczdwVYdjtu1l9KXI=; b=kZG/j5OgvYFUX0DDRp1ojrk1O+WUnqbcxEOacNlaJHOH1+1E3ykjE2CvMFLsp1pNtg t89xB0/6W4Rv8NAsCJLSwcx1PO9T1cS8AS74XI7Gzg1Stk6l3ClAs8lv05+eTh4QiaM8 bJznLE7KR6vSttjGbhb0xeosfVldj8V3wl7S222zi5dMlanzZuML48nnecF2erqhw8rk b844Ar/iQb65pZ6qZHsljxwRwsOOdrb+8eEvQ+URBQ5QcTZUxGLDQknKJYSYLMBBcS+5 nkOrgi3d48Zmnld5GANkFTqt1Z2Ca+D7+Dl/QD2z/Q59qUYUUXFoO+ajfqvykj8sg5yy NAsw== X-Gm-Message-State: AOJu0Yx/W/hZpkq1uHQvXgrIDifqrdGeE/opwxtpzp8P1NifE5xYVhpm 26Fu+Tds604Zwhz/lIwdYZE= X-Google-Smtp-Source: AGHT+IGObcMnYoNsBAZwY10OxxgNLh9BBg0u8VMJHj8UzkBGa+NGHjd9Tr2PQSL/C7blmd6+EQ1crA== X-Received: by 2002:aa7:9a87:0:b0:6bb:8982:411c with SMTP id x7-20020aa79a87000000b006bb8982411cmr20447348pfi.8.1701339183190; Thu, 30 Nov 2023 02:13:03 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:02 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 01/21] mm/zsmalloc: create new struct zsdesc Date: Thu, 30 Nov 2023 19:12:22 +0900 Message-Id: <20231130101242.2590384-2-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Stat-Signature: pxa1yqxagydrqigq7oqcyfo58ks45i4u X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C2C394001A X-Rspam-User: X-HE-Tag: 1701339184-206869 X-HE-Meta: U2FsdGVkX19aTTpD2YHiYJPHU/5IUPg0V4iW9Yk7KzKBVSVjRCo+YZfOyXStEdie87Wk2sIralvoRA5ohZE76yLxLFOCX8TCx6wxMx4xcDBUWvcrIQ0dJy48lQngKM0qA0vm9d+9pKZiV/yMe3rw3DFTpkwwIdzBW/j/opkJnobumZki7cATQKvjjIcam+YdpteTOAwomKqjbSjU/92Dr2Y688KnPqWDFWQex7F74c4g93vE8C8u593gFVvPuGqoyqIhY0IuShWJeUpNHdGvPR9AhM1F1+2iQaWB3md0izJQstjpS0o+OcuMBg7MNftN8poZ4xQeTdSo/na5dLbJvOg6xNCMfRfUFO8BFvM3+JXV+0lawcqHTV9ESpZ9XDU8DWtQiteqjxvazkLe5o9+IkhLnYtbkKoTcay/v4RMe7ZwoSbodEahsNY6XFC8N6DUoiY4z+shXX4W8xpTZxDfM0bKUDgFeqmlM/iA2x3RX67o21sG7pUIx3935z2b2/bYQLkopumQ8ijgW6u0hpwp5bSZbufBFO21uVmbZLXO6GJo8pTxGWqtzIjBOmnSXvrtkoLYKysXe3rwvmz2fwg/6sTsPXe3pAaMxGnocpxcol+o+xjMD+Tyci7vmwQHzeOLOgnHyJPdJXai9PjoNRwsKE7evI712YLaMUThHoo9nN1p9lJgxLsZp1ne13kLEPA0OyOMB7tEyxcxDTVGJkXR8SyyhpnXIRx8QAzOsU/lS4c9d2MzvxScyWpV3lvy7H/9O8l7ltPPYyr9fizO5d5ydVlknd0AXNog0b32cFdEXyCQnt0FK/BJ+LWjbl/F8nTkcsaHrYBeKr5uBMJAf9fyIgmVNDFwDwzZr0z4WBxVfb6txs7WKxi02p0NSF3vhdiazhhoerWEa9x6s/xTIVX/eZ2fPkaO113kKkIWRWEgh4k5JyMdf7gJNaAifdP+s2asanzyXRA/YjWETbQww2C MdmNI/4b 0f6rar9pZ7mSwAckVpEupx8AJ8kBc6LageusjoEYz82ldIGbl516wCfvE/0XHp69n47t3U8n6ZatPrD9OIQdZe2w+b41RU1ncdIcsUhdYTlcRU4vJjmcm8XW0ZNFXLsM3F0vnHEZ+l5b2zOGO0n8I89CNirThMllVNn9deLq1JFjG0Pu6bE0D1Hkn1isABgWQHwJISDvT+1kd7/LgEj8tTGThu1VFVxDJOfCazu5u1kgZ3VonzPcxODU2urTW5Hc/j/RQpoMkul9CUHtmbA6JcGxn0NxOBAWKirtY5l/+hjfed/e9gcsKCJUteHetdBDx+a5t2xtI1mWOl7dpjQvrpzmtDBve+sb/h5qMlY7xkOTdJnef7ZigzevRfXfOqWUCLxcgLpzU9BOaXVIYyFTErzcGi0juLFnOhbdGczMyRPHKfuaG8vS7mg1oJ1El1Fa/NdF7XYpdbPEkfZ3deFKXCajjMgs7lCyacNx1j6XKcUKLSG8QRU2zNDgnA3xbuTt8wD8y92hIYlXnCANunNMk1b3ddEr6m+AppGDMwNyt4K+0qTU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 | 67 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 17 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index b1c0dad7f4cf..60ce2a4dfeeb 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 /* @@ -241,6 +224,56 @@ struct zs_pool { atomic_t compaction_in_progress; }; +/* + * 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 __page_flags; + + /* + * Although not used by zsmalloc, this field is used by + * non-LRU movable page migration code. Leave it unused. + */ + struct list_head __page_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 __page_refcount; +#ifdef CONFIG_MEMCG + unsigned long __page_memcg_data; +#endif +}; + +#define ZSDESC_MATCH(pg, zs) \ + static_assert(offsetof(struct page, pg) == offsetof(struct zsdesc, zs)) + +ZSDESC_MATCH(flags, __page_flags); +ZSDESC_MATCH(lru, __page_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, __page_refcount); +#undef ZSDESC_MATCH +static_assert(sizeof(struct zsdesc) <= sizeof(struct page)); + struct zspage { struct { unsigned int huge:HUGE_BITS; From patchwork Thu Nov 30 10:12: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: 13474199 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 4857BC10DC1 for ; Thu, 30 Nov 2023 10:13:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AEB1A6B0457; Thu, 30 Nov 2023 05:13:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A9A8B6B0458; Thu, 30 Nov 2023 05:13:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93BBA6B0459; Thu, 30 Nov 2023 05:13:09 -0500 (EST) 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 7EDC46B0457 for ; Thu, 30 Nov 2023 05:13:09 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5A9A5C0132 for ; Thu, 30 Nov 2023 10:13:09 +0000 (UTC) X-FDA: 81514207698.19.96E2ABD Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf06.hostedemail.com (Postfix) with ESMTP id 76765180008 for ; Thu, 30 Nov 2023 10:13:07 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FlbUfkIh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.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=1701339187; 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=2h/f1F9fKvv2WfwxbmzHcgOXSHro6vTsEKLDmgFNvxE=; b=KtdrJA7Z54tjmKCMSepvxmUfZkcANd9dJItMUY48KEm15ptUFRK0D+XOD2MhjJaogTq6m1 grABTg7cHVw1PaWAD2j4V3jNQRSO9G0qR2UrXJRnX71fTVtRhAq6ICib0En2mSpXhQQQ91 dwZK2meQgXj3ZBe8/CURpe35KkpQfzQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FlbUfkIh; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.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=1701339187; a=rsa-sha256; cv=none; b=nMx8+Nic8klC0Jc/iS/j3xe8yqcO3Im9Cdhtc63H4oL0uSf7fETx6bKOCOy8Th1eFZoSQY cKUkruFwGeR+h7H33jBf+RvoI7XSU04D/TbQqsYKlII9QkJLmjbGmb/5cY1zjnA8Bgrv7i 2rJ7x6VlWtf4zPLIf//9BMfH1xyPIFE= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6cddc59e731so685324b3a.1 for ; Thu, 30 Nov 2023 02:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339186; x=1701943986; darn=kvack.org; 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=2h/f1F9fKvv2WfwxbmzHcgOXSHro6vTsEKLDmgFNvxE=; b=FlbUfkIhdzHiUxcTkTEbVCK0lcW9JDwE79hGqrS2kTD89qPFF8vhcqEOjw/K1R6Lk0 dlGQWheL4L3IY8Fs0AHWKjMaINBuNbOCcQQpjr5fykltn1voUgDgOJMmuGizVv3pYk3e jG5BzuFMmZLv3ubXP3MaaFBt98giDAyap9YHdhwPdTh8XkMGm+x4sJ2ZDCHFW3anPsgI COEu8WnJTIQCMolV6rBobsq7T00Fy2jht4jS88NpKgDtoAWnBUEa0fD8y/AKYeX281vk bBpNpGavmuWf4MNgOFcD0TJt3PnHFiQPfQVBUC9oFnQlz/PmOTset+PntG1bOL9nzim8 wy2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339186; x=1701943986; 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=2h/f1F9fKvv2WfwxbmzHcgOXSHro6vTsEKLDmgFNvxE=; b=uSLCBzoCOVyqkRVcM1DbLVfUNFMtWBTPOHfJpuS+4rv0huvAMp6Tl3RuCTO1d2GSHG P/+gcur843iOotPTmqFpStJIJ0PQLP1cQfK8bWT5mqBmjYONc8eUt3Uer4ohOj1R1TJS EHFDrn3dDXTkVjRgOLwROfIE9CvqBHF/8eHTQxFnsDnR3ARkXTHV+8t/kkMyjLYzp/8M CrGVMhvKO6Q9bJmrqYIdhO++5G/HKZfvk+kmnRSPA7bWd/SyTlCwUbZZoEFJkiDSiBAP tBga1aa0BFLAloAcPQzFRtJooHO8AKWcuUtjmOTg/12wAT4xunTmhAKNbhVQBLaiM9Sz C73g== X-Gm-Message-State: AOJu0YzetsEsh3WI99pckM2dXU93u5PXNAdzidPDWEyb9ewcuzOAqZlG oZVYRfiFJf6WoK3sIzRq04s6Y7j1px4= X-Google-Smtp-Source: AGHT+IGyrl4qadlT8BFmM6NervDzr5nWt4c2GSSWUXePbBbF7UCO53Hy1sMP5F2FrQJ1h5Yyb6Yk6A== X-Received: by 2002:a05:6a00:1d81:b0:6b6:7a04:6f9 with SMTP id z1-20020a056a001d8100b006b67a0406f9mr20989074pfw.28.1701339186247; Thu, 30 Nov 2023 02:13:06 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:05 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 02/21] mm/zsmalloc: add utility functions for zsdesc Date: Thu, 30 Nov 2023 19:12:23 +0900 Message-Id: <20231130101242.2590384-3-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 76765180008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 18d5hqe3oy9q5hftsr4bmo3396rj3uto X-HE-Tag: 1701339187-23730 X-HE-Meta: U2FsdGVkX1+xFmzBCnEiudjf33fTcCtJPwvMHDD/WtxvWDEtryr4Os6q2nlAt4HT1uSdXKpCNguPhMgAWQ/ImONAJA3YxyBWeS012ECfrGW4/dwQWU/mumje/s721dDZF0WxLNTN4+v5HoIvcl7YBonqy73L/CutQR2AmM8jL25aLaybZy4m9aqrfvC6YOjH333p/4PZG8XWX2IrG4a7KjtZXXUrhyiQUX0CgxNiEUt60SH0UXDCICy+x+Ht4spnPzkhQeJMLcNLTfSItaHvxcDzFqzYsqYupoZLNOio40XXOr+JI229HN5DB/V/gtjj6WYbbYKlE8O0F1FPr6ZEe/m43IT9BVQ5suMAamQ3d8Z488GZxi65l9ZYH51DMDKBUwDH52pCl37niOXn+bh1XXaCaIJyOYow+TDExHKjWhbcrgAcJtSzES+0Xqhw1HbPcaKALHbngbD5PNygIERlBDJGVAi2QBlZ/GDB1hx2KaUGCsimto678UYWKtXsO02Yn/FRee6+IE5/rT0UE06cH69KlxCF1o6TrUP+FtpsvuEcemTT7ltCPMlh2wg6E137boPTNRXBZOvz4rs2ic4vGu8A6s2MJ7LJee8cYMaf/i+4eN7IfnzsSKw2LEczw5LambErGK6KzIhLVKfse+tFWaqPdzKSMMIrRg7c+ovvKcyTIEeLtykBqMgiUJDr+2JXi5B+56IPCYaL8AZ1SpZyug4NxiG23pIOAH3ZVsNyblJHubxQSUiAUn+cucIRxUS/JLRa7hLsF/59q9UqvmiACxNIxZJhB/EZwglMNUcJSXCeL/dU/tek0/9JU/CntRlqOgtoYdt6mmhbvUCKk9mfrw+a+1T/EKU/m1yJrBR5kOTQP8F6MKzzFqZsNSwhYJ0pxDlwG7wuExuMy/mcz53Fu2Y0X1Fd0CBaskt+x06Mxh391XjA31S0v0oNQVDPk8qE4Q4lKsLNBJDkWf6bK1R 3VFuYsls 80AuWNrPiVGKjyBGUmPrM1p8td3BroiV6gUFVkM/fBGiuUu5Jfp6oyzseEZMxumKvpT3re1i+NIh7aXjk9jhYmbJGiaeZgKBmuCknaOqgM8iiLZbo9uiSQTQEopfWm/cUJhH4MVnkxjHe8tg4HW4ArAEAedvMTSD1EPXSp8hqztKBaA0ppIYNS+Ej0JHoGJPRnfuCNnJIxxDDSoflkJS/O6VTF7Q7TDnxv3g2MTTWqcotG2zNaVnuJOZ7O1ZEdbCAxuUq/UFWizKZwl4a41ixxg+SmCXwUfpNttubJcGNaXe+Q/k3f2cDjRC8qHwf0cdYgBUfEpj5cVPEo71mWVGh0CRo7o9dxnpzFY1CqPB+ySkXTSxIqe5GZdXJYTps3xRRYBlknv394dSc4GfQsudtgoEdOSItB25RyQuTsbtpj01Ih/qfL8HvzV6Pa7W287B5LphaQY7e1uzyj4hZPRaK5o2nEDRenKkSRCkzEuub6TtZUZHAk5FBEWZK3YuZkZlMdK4wgOfBw9d73xK2E/fiexP+bS8Qp++Ip5vdKigddkDq4CM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 60ce2a4dfeeb..47df9103787e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -274,6 +274,39 @@ ZSDESC_MATCH(_refcount, __page_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); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; From patchwork Thu Nov 30 10:12: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: 13474200 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 23C33C4167B for ; Thu, 30 Nov 2023 10:13:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 658C26B0459; Thu, 30 Nov 2023 05:13:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 606BD6B045A; Thu, 30 Nov 2023 05:13:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45AC66B045C; Thu, 30 Nov 2023 05:13:12 -0500 (EST) 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 332046B0459 for ; Thu, 30 Nov 2023 05:13:12 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1321CA0165 for ; Thu, 30 Nov 2023 10:13:12 +0000 (UTC) X-FDA: 81514207824.23.D8EFB61 Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by imf24.hostedemail.com (Postfix) with ESMTP id 2028D18000D for ; Thu, 30 Nov 2023 10:13:09 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CKVhQa2z; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.166.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=1701339190; 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=0QRwjIDBZfH3KHXQixzfUgriCEY1OpCqJmvwU4YsPh4=; b=ELyxR95oUdwkcm/Hg9MYaRt/RkUQC/wbuX0N1u3L40zMMK6i+liALkk9l9XkGpivSobqUH ockXVUu1ebDuRvVN5vWT7ibMzS8g5xk2n6nMcBVpqwtLK1ELnQMTUz0twiHokmB4qTp5NZ Kcc/S3pJSumyEPidO/6kX6yqa81cfGw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=CKVhQa2z; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.166.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339190; a=rsa-sha256; cv=none; b=gcwR1PNT0cST7TNwYAGkrVaXR86We0dcxCmFfq8o4nQbGZLzadiQpACmWgjyvSwqWiYgZU EdXKBCY1LADJ0++KP5SyCp0WX7ervnlKJP9XEWtdS0XR5p0E/Hpf7s9zec9K/oLz2IlS3C d/8kv/Wl0psRkSWJ8B1mT8THNCyH7FY= Received: by mail-il1-f177.google.com with SMTP id e9e14a558f8ab-35cbbb308e2so1846155ab.2 for ; Thu, 30 Nov 2023 02:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339189; x=1701943989; darn=kvack.org; 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=0QRwjIDBZfH3KHXQixzfUgriCEY1OpCqJmvwU4YsPh4=; b=CKVhQa2zHeuSxBK6Bha9ga1rvso349Pb1rN5gOGc/o+kTf5/4lY0h9oSqJxIFCGlpf XgU92TVxSxnetUmLZVCKVxZDT/CDBKB1lliOtHO8iYBIP9VPM2+LnTkL+Ahd1fihYzbQ E+ANYoIW1WyBdU5tqUibDmQaRZsS5aD52CfCkw+pJM7PZ1bYJoDQvKwWt+maiqioOI7i yrXj+YYdYr/mtHLYQmpVqCg9dqyeVEeIqZVyymJbGDH5N+k+0yy8vHzrV5Zk3DY/0nAt q/0ebUYWwiovh8anUKMKAczcGym9ES5gZJAZTBcnhKDP2WaPe4qWAzDgi072TiGdaxS1 blBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339189; x=1701943989; 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=0QRwjIDBZfH3KHXQixzfUgriCEY1OpCqJmvwU4YsPh4=; b=KvIkts31dfwpjN++zBQOrjLXr639Dm92vCycMQBGZYTL/jO/tuBGWNbtwtOoms1flq 62/dX8h7PdnZd4H0LsY5aFbyELRELWzuR1AnTlcF5Abq3NtEBrsd+yCDhKx2ghTnt+Ng y9J0Bc9D3L16h869j2PE1LIdJj0/spAFngCUMLbIi9WuacKAXATusZl1skU8cuEBM/HB jfYwBP3dLJ/SyO+Wwbj4ss267utysLYC7T0eSZZsIQ/Go8xVtTcXvx9YKXg2VCxp2LEU 7jU5t+0o04Y5frx0F+I/DRtQlRS9bzALRenwJiY6GmlHb+1o4ruTl670gJVNI5Yjp05D qi6Q== X-Gm-Message-State: AOJu0YxtOFE9upfI7qOMSF1G8xKs2KEHIFFx23LXrPJG29Om74NusU7g wHSBudy9Nf/eAHEsBRwIISk= X-Google-Smtp-Source: AGHT+IHbebPkjUiF9mNqY2J9Mw79ZmAdS3WmWlNY+8tFKTs2TjE7U5B18tiwviQu0Fnp9m3ckXJqug== X-Received: by 2002:a05:6e02:13eb:b0:35c:c47d:f58e with SMTP id w11-20020a056e0213eb00b0035cc47df58emr13432878ilj.5.1701339189129; Thu, 30 Nov 2023 02:13:09 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:08 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 03/21] mm/zsmalloc: replace first_page to first_zsdesc in struct zspage Date: Thu, 30 Nov 2023 19:12:24 +0900 Message-Id: <20231130101242.2590384-4-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2028D18000D X-Stat-Signature: e3bhfxq99iu6x5sdukomestocr8jg67p X-HE-Tag: 1701339189-768182 X-HE-Meta: U2FsdGVkX18FPwIhn0uHyZ0nPdASfhBL1jhdPr4d9YDes48AcLcleRRirw5PkObMbmS1SIlB+UjNuZ0HnCbkfqT1JvzVXIfxdvNQWMnEjSHHLkUAAPgmp/mKmVLpFkzoeUFFar2CiB5IPSPXIFHa000VAk2UdHKu1f0Pa82GY8xO1uX/mVky0SbW4wPs8AJPkHEugaZ6IctqeXMPEd2y1mHkfR8BnnFhTxdMBVn2yCVxb1jf9DYTOOPLNu0WCiF5FS1/v+HSM9P8Nv01+k568QOLlExVICBqYPJz58SFIpZdRq0wlhyBFWwX3rSgjHfahttPGk/EVU5lnb4mVTJ9Yp1h6BYcnTNL8mQrXvCbNWGMqVRbjyUjwjTzVQI7M0EE1nD/fjlA8AnI3/wXPBVqy7kaW9Hu0396Tl0urECEjKv2MZt/pLJb0K2Sr05qu7UCarrgL1LEO8jDu/vvUaHdfHr+33tHssAl8U/EtVSIvf9fifO3Wj8pEjk3ljHl7ILxIScB87gEnu8MpI2eD0jYVEMaDINooU0xQD5UOPlY6hRn0Ntl3SyxB1OikxsoYCUKFc1lHLuZ5/p1nnmHxyNuKFfdOW1BLfPUK3GF6qXwTCj07d0H3HH5HWPVin2wyHJTVMdZ0+UjaTZ0mQI9RhKFXdZrLvMhY4ylZVW0zevX58yuPOoCQr0g2vhJ+AqwZB/AKn/r31lL5d05m5io5keo1GxYejxuDBnaLGW3RoC9TAIwYR6wl9zD5ooqalqwSEg/WjQxwkwM2lZm3naOWwJxLmJTPeWxKTAUjLePs52UNRddwCnCB7uRXLradXTsTUZwD/gODsoVd7mLIPWpy+cy+Vu+061+K3iRJe+A6Wo+TRwk8ieYRsWRVfOqJHcsQRhKxMPK+g1xmy11ZrUADwIpCpeqVeSW8hz7glckZhfVr4WW/Xyn/mjInAd03rmVoF9PP82T5tZ1XX0+6WLrLT4 gW6Hce5X +6Nk1qXS44VxvwcBq6ZTSJEQMcrXK4ynQC4yAlIjS+9L5l6NKfYwI62rHuR+4HKySOWP9V/J8Amf2QRXMLZ4D6n8x/2ycwzqheTPeCS+9Y9CCgvqhEeV7yhjRGcNGxjWZskxUr4ABwx7ngPLT6jebMCzR4kBboRUUbwiej5heaIbGJLk4pKVTI943BroD10vbIW7MEKrzPIYnCv6i4rikcfQKPONqVBtlbCKXDU+fDWpB/XDoiP0/7uug86SGkLxDpsYF9q1tSJQrLWgsPaKo+jrGmDyQORjeQn73oMtg26kvgIqCDHHJoOtPqXdxMndXkhQkXORPoxj/2sFq8ZAfwVLlltbOB9wNE336AEDj16CVOHoPAoZofXg6dKfHlvrlq+bdapXMUuJuAoz0Iy2F/nAZSFikX5lS70zpWb9pdVwPFHr04rulacQC6PCdoNzAULtp5kg1ZuD/0Gv8xau2VPvF8Lx/j7Ea8VmYZslYjm1Uz8J5BQx/B8ebmz1ak+RopLhfN1CANoyDHUIURVLc0kOmMLwjunJz1/Vn/Q0kOTjcz0uYZM2bX8EQd5ALMx8hjDTQpzdz2OYnm+La4cduy+UDTg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000098, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 47df9103787e..4c9f9a2cb681 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -317,7 +317,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; @@ -516,7 +516,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; @@ -1028,7 +1028,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)) @@ -1402,7 +1402,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 Nov 30 10:12: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: 13474201 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 BDD58C4167B for ; Thu, 30 Nov 2023 10:13:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 520A26B045C; Thu, 30 Nov 2023 05:13:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CF6E6B045D; Thu, 30 Nov 2023 05:13:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FB296B045E; Thu, 30 Nov 2023 05:13:15 -0500 (EST) 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 1AA726B045C for ; Thu, 30 Nov 2023 05:13:15 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DF518A0165 for ; Thu, 30 Nov 2023 10:13:14 +0000 (UTC) X-FDA: 81514207908.28.B94EE5F Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf04.hostedemail.com (Postfix) with ESMTP id 0A46640022 for ; Thu, 30 Nov 2023 10:13:12 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=B8kUO4Fd; 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=1701339193; a=rsa-sha256; cv=none; b=6JxEBgDh2Iqn1vHBBf3DEWKPmXcOZ2Z5RDQQkzLwSbaEdhM+XPM49tJETCuJ41zIBChWPI +gkEhaqTFY1oMruU5bJjQNH+YoUGxarTZ10xawr3OzDDGnWzpp9irKcG2qxggrUKay7z+p y03n23DWfKyVNl/H9pEMcsnwAr7dOCQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=B8kUO4Fd; 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=1701339193; 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=7hZ4QEa6qbbemjVgd5G8BNyx+l3Y0ydBKsZ1v56EUu8=; b=5ndDJ+ktL2ljFUO2M1NIMUEB572YkkjgHqiA1Btq/aCygpCA73zU2nDjcSBnQQ2t4721hC TdTVzFrGjLH7a8uDwwIom6mzSfr++nV2UG9uoPZjMehbcyIFFF2AoZ3xyONDEEtxKVUDF8 W3bKBvGYSW7leQd9Jw7E5+rlw1/IN8c= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3b2f4a5ccebso407405b6e.3 for ; Thu, 30 Nov 2023 02:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339192; x=1701943992; darn=kvack.org; 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=7hZ4QEa6qbbemjVgd5G8BNyx+l3Y0ydBKsZ1v56EUu8=; b=B8kUO4FdmLVuub6ZONRlPqpdmc4+wpItTkLgvTZPDSZMe0pFcWqys39lB3QtR1T10O O7wf498X5MRyR6NxDJ99PELQ0J7j3u07oWZ3ggwHVa/RzOYNCbyCH3NLVYtWKZR4Wn9Z ZgW8H1NHupoubQjZkAao/p93ypoUiTqIbGZ+BHOhMexF/ofUkIm7diR/ytWqa5RsHmnq zBv8HR6QqWidud9WtL7C6wP62dgT9NuUQM9CHSp4KafJzbt/LJHwHHo75bfspCUml0EM 8Pg8CY/mA0Nkp2/7QVX4zTz8qWzhesYuCTgB+0cDZU+ZWhgxc1FO9q/566YxujJLtLYZ EzOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339192; x=1701943992; 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=7hZ4QEa6qbbemjVgd5G8BNyx+l3Y0ydBKsZ1v56EUu8=; b=Ee0/yTN+3GcFb1HlfQhAFiwjMwvsBq3at7yhu2otbYdzgS0Ri8o0u2QmRxUO/VgXdx eIecMEZJX3iZE9HGF30WfH9/nQwf3LUoa3sHZnh+LnLM6j/iuX3RpI38lP/b2wGP3Qqg THb3SbvDbhDCytQWxc+GVoCPICV5Z4V3k6NLXrEqRlfxU5AlD+3aQZUlukKzz5ABuGjK LlJ3olXrskGbrlDN/U+Pi7c6fLWu1+HrJSTocVuNbla1pZ/Figo1A1GLJA6q34xNsQ4S eKX2Pwpq7/AWMZBIGVRmDWFQiH9+nJtOJP3nW6xoliaEIINETBpvMp3RRSuXU/5BJppM fFfg== X-Gm-Message-State: AOJu0YwCufHpMsIe2iORiwmy34W9Y6ry9VZLLefllEBB+PnSHY8wCeXf xCQQ1ehRLadARWSMlL91osw= X-Google-Smtp-Source: AGHT+IFcnzB21TtPzdY3IZ9ebd5sJCgNo9mdoC2Efki1ra/Kpjx5LiOuHG/hacNR39WaENx55nDQiQ== X-Received: by 2002:a05:6870:392b:b0:1f9:5e26:9509 with SMTP id b43-20020a056870392b00b001f95e269509mr22795530oap.22.1701339192028; Thu, 30 Nov 2023 02:13:12 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:11 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 04/21] mm/zsmalloc: add alternatives of frequently used helper functions Date: Thu, 30 Nov 2023 19:12:25 +0900 Message-Id: <20231130101242.2590384-5-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0A46640022 X-Stat-Signature: my6mtsmt6dkmaxawr5x4ohnha6ck81mz X-HE-Tag: 1701339192-742007 X-HE-Meta: U2FsdGVkX1+jAwqBLLsTS2tmvDNZvVd0k0I22jzW6ZY984lBBDb9JDFYI49ewW4xUylN2s1IpToUGbuB9ky8h+J3jmHFfTemqa9OWawCFIt7mFOUgYzuQT6U+4L7/pF+aIMJSKWivK2OeHvty6sho2qFodSp2HlAlJIrI1opMUcShGExB/KWv6RC/jUfZ1hwRHhfwGNvrDKd3xcdyh2TCi+HNIdJm8Y5LxlCwHfXlfe5gpffIQ9D95XvkUH9LhxXorBmMKKqsiuY73C5PygGLWci3LxBC+3Fqm2oiVPiLosRIM1gi/y4gAFemawSvmA0qwVimNaIVDzfSWRuL7FWEAmx984wzfQ6REq/guOaErLlMsLvY7THGJ2Cvj95nUWTAgOCDjaOMd7QDvnspHr3E6wyU2y52RntvJcEB6JIS3Xn9zDgGm/8sPzc0MQp9NNbA6R55mJ92LHixWoq7tZLqiuUjgaVFiNprfIIWT7AhTCB9sVpFwIWbheYX5uBmwTHofdDGSaci7g0boqrbxjaNQCZA5sfOdIWHTtybbpvbuyGlLuKZ1UhlqDAAsMX2SgqnnoUzYm3LTuFdp/oz719q6jcEKwxw03q8Kj7FkTFwB/q4VaPKIcSNh5MkcxZKgkdSOMCXZ7bcctFkMX3lUaIcdvIGfWa553/0ANqJaM2ZLAK7czJnMGicOjmIhZc2VO52VCX62TSj52FKrOBcXikkgNCeuuftFqXejsG56hAe08gKUg4QODv9SCIAxi1dE4eghpGrQVciaajcYnEt+iOIE4becPLfanIkplPS7ytwqeXy9XTUc8aN52LWUgp28xXXn1ES36t5imygrIwlsdo3/WpnsAl11dXrJyYw7UWFbKTQK++Ky8vdnBapM5vYStYMAGObBC82TDEepSVihkGx7AfqWlLv51n4fxTAoRcEn45FgEpTajGSiYl3mhlkapSb1j5uCYI9yVFddkpVcZ zSFkYChH HFmry+N0W8cZogx7RLHdwLRotzwqTPoWtyIDExz5aLtOyidToXGojnl6GruZZediUeEFDqLl8gAuywpHDy6munHpOnALjfuTsnxacppO3nOLtZJxKeyo7QMnIzwA2rXnSG09vCDhlhAQJKMV5f6DNu/p1eE2Wij7+Jfzyer+pZO1UmcV3GjG+SPA4igKM+PzO6kBdHkRdgBPQdc/PQn8T8mMwEplCeO5wQWuTJBZj5tSKSxqz2/jYpQDlFZYbcNMAK/G+IapDd2A4BHVyBLaTKlnqSmJlvM3QhEBaYc94Jr6gPcJymU5cUS2tcxPI1X7mVBBsXePWR6IXBi1rXaGapb+UswnVwc9kx89ZbutAXrY6uq8w84r7/H+0/sdZ12etKU8hbNNCxuYBMP3NkTHzl0xPLiDs4NKDfzq2VQFh2oOdgI8eUgDbW81AlvHA87SXsymdEdgNBW4Dxgvu2F9ANORlcg1eX6lCMeZ4dHx1dmiftG+bSYVNT9wj7boWAIFORXfH7OobA5rAtRdAIFYVWmwvjImJX8205/78YMj82FER9Y8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 4c9f9a2cb681..c511539bee8c 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -502,6 +502,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) { @@ -514,7 +519,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); @@ -522,6 +527,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; @@ -810,7 +823,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); @@ -820,6 +833,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 Nov 30 10:12: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: 13474202 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 BB6A5C4167B for ; Thu, 30 Nov 2023 10:13:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F85D6B045E; Thu, 30 Nov 2023 05:13:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A8506B045F; Thu, 30 Nov 2023 05:13:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FBCE6B0460; Thu, 30 Nov 2023 05:13:18 -0500 (EST) 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 1902E6B045E for ; Thu, 30 Nov 2023 05:13:18 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E1A7D12011F for ; Thu, 30 Nov 2023 10:13:17 +0000 (UTC) X-FDA: 81514208034.05.2C77847 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf16.hostedemail.com (Postfix) with ESMTP id 1ED33180026 for ; Thu, 30 Nov 2023 10:13:15 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GZZZJEfe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.173 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=1701339196; 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=efBNSdYQOC9rF9V+LwGnExMI9wJh+dms2ODwKHp/3kI=; b=F5lP6gv/uYMC8sbNkWwm3kQKRfaMLFmDqnodAMNdchPqKNOQkmWXAA64eAlmDPsv8R+N57 4kjY+iUaDg0Hz2hh04aqXnoOEQbEuvu0JDiwOyy6XZW6rjofsYh1s4kmjZ3WUY9yg0A4Gr 7lL7W3KNZ7zCwlVebhjM88DokDhd6KU= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GZZZJEfe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339196; a=rsa-sha256; cv=none; b=B+id3rT5zdPZxFsbuUUxg69YsMCUOFpqoJOKkcpWZsFs12eoDeASnNvIvhBOSm9FU/mC3S m5h1k9d6mxVFIRMza4GgU8himv9I4CjJ5K6aga0V0yDd0Ox0NsoEfZ0SU/qZa48Hc2c3lK yvvv/uThRL51LlG6XLNik2x+cDq/Xo4= Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6cddc148285so753451b3a.2 for ; Thu, 30 Nov 2023 02:13:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339195; x=1701943995; darn=kvack.org; 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=efBNSdYQOC9rF9V+LwGnExMI9wJh+dms2ODwKHp/3kI=; b=GZZZJEfebKf8G6ppUFKQum5n7AmhC3GDSRHTqLWE4KfDzRYytQtWdmzOkWYY2PYxc9 9M1nwhy666iPVklcGLfjz9KcWcHFuaq6LlPJJoCbj4bYbmCiygfXFD4LaOVIPQDQJ2h7 1xhaarUEsqP3UiWtz6xB7AJqkHVIALbqx5gZkKiudkWDh9sYNhSVv+IXn2LeFiIRuwQM JDccycaQ2c1H8QHhcHSUZAzKzSP+vhckIihFBzeM3tGMTZV0uy5aZtncMiBuvPcCFzpF 3NzSUsX+Mk0qSpBjjSSMqvLHaBO39lBNbM6namFUCLXR5w5CawIZGf+6EVyDis+Dk2Ag IMdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339195; x=1701943995; 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=efBNSdYQOC9rF9V+LwGnExMI9wJh+dms2ODwKHp/3kI=; b=RozYefgW1mUm2waMcK/a/zH6rHEor+Qyy3+N+PSB8LKjodpqQeAvFzTTYHL8cJdMlP 9px3TMkVMGzyO/Vsfl+fXwTcWaDENB65HqaNXnMOzzYoV6SXHvNGl2t19Q769/W60lPk VIMRbky3GedaBVzF2g58BQVz48Z9sz5AZja5US1XkNcYeVGp+lWTCIAnkMVjszJiW69o 9T9y8GyHIrf44k+vK8jtfc1RBjydjKhbMwTHo0JltQ1V/0IJqJSaav8tjiElLBdjPlS3 Tq0+w7Je+gCcYpu5iXbu1yssKIEudcUw6RzDUOwaa1kQZ7aw2ZLSGv3FyZZQMhcC8z7J 7yHw== X-Gm-Message-State: AOJu0YwJiJ9rHkBj/2JqanU30s1HgO7toItZi3YgcEpvS6dtBopzLHa/ ACt7f1VYO+fR5XzVvyOew1Y= X-Google-Smtp-Source: AGHT+IFzrTweuqjiYF7pKKdE9kfOSMjO+2vK+G1yRQBKcPwB9oDlie0JFqMh8xM5rAD5uaonO93oNw== X-Received: by 2002:a05:6a20:12d3:b0:18b:d3db:7048 with SMTP id v19-20020a056a2012d300b0018bd3db7048mr25946917pzg.23.1701339194873; Thu, 30 Nov 2023 02:13:14 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:14 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 05/21] mm/zsmalloc: convert {try,}lock_zspage() to use zsdesc Date: Thu, 30 Nov 2023 19:12:26 +0900 Message-Id: <20231130101242.2590384-6-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1ED33180026 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: o5p4z1wuyo1ydbppxuqtb6czxhobwc73 X-HE-Tag: 1701339195-151028 X-HE-Meta: U2FsdGVkX1+o6EJiE8WG7Rh8o4O3PXWnU1RN/C6C5u6LkeIYxbxjuXk/Jch0Ot/xRrjopQi11axKg6rbMWyFUJ1eRsdx+oFQxzcOjnXyH6u1qs/qwUSK9gsP81CkCqXwzkrsdWp6DeLFX8m2stPRITF/OAdjlzAM7vrPvHR2lzrrO8gDzYYvVkmhncYAxxU/x20LRRV4FP5M681sCFnsm/dUFmtHZOMIOnwuYskFa7eAQDsoN1JVYEZjUdlxeFvkF7b/OhLdD3kxjKugIxLvHo77ywRG2PDOzgkflN6DWwWf8yLjwlqJnbaFifd0aerGZujTSsUzQeo1Q6QUZQGO3Fksj9nEfHey5J6PzyN7d+lxixLCSwXVoi/vzqJXXVQNU3AofkWUqKRSf0hQ7+58FxxcG2RDdmTIrCqsL+pSz0ynyIEDEC9zslRFGMpS0awcl7ppna0VDO0uNj/7NGwffr5nhqaCL5bUIjfM5Sa6sdZDrpzZTafLPUx8a/OIhuHQ6tGK70+JDv/pKVAnZW5fz7WSKVxK2IjDnJiG4xNC+9+0nR6aVukx/2aUlgF0g9qXRljArdzrCY7mpWpKStYrw2bcllkBxbISNK4f6dZfPVxWL57t1+F5cY3m+RFFe9Ut/3C3KD2fHYzumku6nozO59shF/ngL2xdGcZE/zV+w1iUbP8uffaQL5L0NgnnLcQd/gkLAzu+s4/YYTaSTbJMVdXWPcOO/HMrM/1bnPom6D54YJKGEJISplYzxnbS7RrTY24kbXRItzaSVVl9FYO17v62gzJLFvv+66hLsIZu2X1JXxzfoMwTiKkClo/We6c/mE1Ve5+HMhiwLEakqGusLTeT+E8lJrWLIXbn885ltFm98AEcUVrpQd1JZaKPAnoO7Vu/NnLYAO+Ia9x5cl6JG6No5+FsNBaQ8VlTU5EvZrokp24Ogf6tEmSwfrbbNJ4jiQPRwXf3rbjIJZRXVIj pZ4FFZuW eYyGH6e2FMe3ugKjpoHgUS+Qhhr4kmj4ukkoGSsjYjEu3jDf0wH6Krl7fRvg8wepDigNd5yCHCU7J5A406xAWhX3rj91u83SyNGnYlfy0jWDnMDJjuTNBb0+1w5hVwclnF1r3rrgH0ziUuxIdnWr32RrF5h1D24FPS4L7ZXaW49QBUJaHtJGrTXTpMdnynGrJDbyHHrwDPfpm+BLTjwVzkyLOU5yrlSDJnVMdZIkLJ82/oJ3o4mdxoKcXIC8CCmwmDPG1cYEfWqgstU9EKaWNncZUve7/Yl9qu+DvcNQq5+c2FfN9A562qg1MMWQExPxQInzpAgG79paJrbp4ZGfe8iT+NdYw0ZsqcTC+2fJFCJU1LP2J7tSTo5BOvFnII7y69Oivxw3dZv1t7aFGNJh167aBbOE7W8qaE3qPq70QAuNB7ZL3WNZ/kEzsKDTMzSQek7iZF1XLuDYKrg7ejsWJBGShmC0vYOWZLWdDssrRXT9HVxzicslMoUemsw0XnSXxQ5kUncA8hcnVuaeYsF0uNaRNmqiV0zXXUcba8s3I/BPI3kclipTFTqJBqm7L5AaE+TZ5CeCHjUiXPVIveVV++gWGYQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 c511539bee8c..91fccc67185b 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -307,6 +307,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)); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -915,11 +930,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; } @@ -927,9 +942,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; } @@ -1759,7 +1774,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 @@ -1771,24 +1786,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 Nov 30 10:12: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: 13474203 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 C25C2C4167B for ; Thu, 30 Nov 2023 10:13:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460C96B0460; Thu, 30 Nov 2023 05:13:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 349AB6B0461; Thu, 30 Nov 2023 05:13:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C3086B0462; Thu, 30 Nov 2023 05:13:21 -0500 (EST) 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 01D596B0460 for ; Thu, 30 Nov 2023 05:13:20 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C830EA014A for ; Thu, 30 Nov 2023 10:13:20 +0000 (UTC) X-FDA: 81514208160.29.A4ABF3B Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf28.hostedemail.com (Postfix) with ESMTP id E8010C000F for ; Thu, 30 Nov 2023 10:13:18 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ao710wkc; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.169 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=1701339199; 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=GZ5+k+xZdrGcARQj7U5lpnB1y/2JIFVjU4+7cRgD1WI=; b=WKwbGsVQfaqZLSqycsNusNdR6p7pUaVAuzzLq4QAJtA3Tb0Z7qA3iQ4K7rMjnQHO/H5DpW iFo/NiCXJi67MVxt5PW2Wt1+iTfKDi2OFrrByIc4Q+11Pq2dWPE/THc5i1SpjSckXMoo9C Da+76nKxh1TcYBTHfLooB/izH25TfFw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ao710wkc; spf=pass (imf28.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.169 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=1701339199; a=rsa-sha256; cv=none; b=N7OkQVo5DnKLZInkKRQytczHi2+WIMfsisjYHhGJSenp3w1Djqs7loKoijnPUZtbAuqj/N WAwsxdXQz4MV7d8M/6YFA6b6x9DcvUApYdYBciZNfStr/b+vNeY+ZcaylafSqxFCf4QU0i 1LUt4C0vin9lusIlNlpjYjceQwIU+0g= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6cdcef8b400so760900b3a.1 for ; Thu, 30 Nov 2023 02:13:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339198; x=1701943998; darn=kvack.org; 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=GZ5+k+xZdrGcARQj7U5lpnB1y/2JIFVjU4+7cRgD1WI=; b=ao710wkcLwTsthlBayTXcSskV1BH/9WZifwW7+k3ctdzxQLh/eGIWiEX84yrR8gE7v MGSBcGARhTKpBKgWcOpMvTReDV85ZVTvnFhgyDv9WRFIDxW2GS0YGAOj55AB2ERLKU7o hAw3eCNLA4cLAIRy9pDGICbt9kSVX4yuXseKtGuhadPUpg7BADHefc51sgeHfkGRxrfJ uh+0vsb/RGt9TtLth5kwTg/O5vvX1nLt+X2EYmm80iyvBaniVe+4LZZ9/IGYqxzzs7kr VzOsipYjOcz/Q+6Amr1QQIjw5C0MiH/tt7QgXoa4UchKTWP1tuIX36ck09xDfr3L+JvC VMow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339198; x=1701943998; 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=GZ5+k+xZdrGcARQj7U5lpnB1y/2JIFVjU4+7cRgD1WI=; b=ESMUuR9G6WubDqw0CmP1X43WCNXopkSpnQNOoNtEKD24CyPc7UNSadZj4uANZEsXbZ eK4Fxnx4m6+86Xkmu6LcpXvKJD70lPi9qJ5s26OmjoCUvW/aKWZi7fKtb5eNUautc/Dt I9OZPRxoyiXIEHB9tkqzqUm7oM6GwjzNE53P7XAku7tkRX/l9IOAutA2Bfw0cO/yMJIB Q80f7LVJjun7GFZwbKaMDZXTaV7Q0zao0JYqy7Sp5zSc5HmBlyv5A0GSwu48jrgtOvjH 1CHR2Z9K9qVvCijNsmhqAXFw5O4C+AnCm8EIxQGVKdCusX1inR6SdT/O8WtiC6A8x5ei hMIQ== X-Gm-Message-State: AOJu0YzHthzHMVcqOycogrIUhlmQ8suOBl7NB/I8OnK6EvVf8VZ2Hw9I at6Ngk+S/uZojnkvL3JEXRY= X-Google-Smtp-Source: AGHT+IFqBPVr7Dm/UF0I0z1hPcAYdJfS/T9vLKX1SN/kDJaPGokzN6o6Gk8be2WPH7/E0wIcjljZZw== X-Received: by 2002:aa7:9a49:0:b0:6cd:d0f4:cd3c with SMTP id x9-20020aa79a49000000b006cdd0f4cd3cmr4494832pfj.23.1701339197684; Thu, 30 Nov 2023 02:13:17 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:16 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 06/21] mm/zsmalloc: convert __zs_{map,unmap}_object() to use zsdesc Date: Thu, 30 Nov 2023 19:12:27 +0900 Message-Id: <20231130101242.2590384-7-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E8010C000F X-Rspam-User: X-Stat-Signature: ufg643icta1wgtcwne4sk4xuycnkkd8o X-Rspamd-Server: rspam01 X-HE-Tag: 1701339198-295513 X-HE-Meta: U2FsdGVkX1/ZvYyEW+tKAkIlBah/NtabrDddG7izn/waazY36Qm5x2bJ1vzTl04wGz9ZeeKtDfVPLb1B7RZf+m4eCBgDbpO1cnjafIg94WRu1NZGZX3D/yJHAUPRw4S3LjYII+cuA1rHF07IWOt3xvxdWKuCnEnpW0Z84DKkL6R/7Wd64NkwWzvq30ZMD8JMEfOIrMgnQKKihywiY1FzzpepVPYkkULNQCCQYie63GUeuL3UEnR14mYT00OBsZYSTi3KrR/HQzrtP272T9aNldi7VHP8mMb/+1aJZFS2R2udWlk8C8ZRV7hBOnaxbWBpS2yDPRC4p+lBuDtY8/NGnaxO4VMAVwsrZ3ZWyBbskqxDS7P6UPlVw+QWDobusdnvBmNTSRXebdr35Lv8se4XfqaI4olr2i6DWgbUY3RDeTUUA+d/cXn4nEvwdI6VUVlvmzg4xizAXC4INNtbKiNtV+za9pRtv4dR3op3ElkTe1v3qEiDjQBzO8VuLjUlrmCljpGUwTHgeEQDo1MjwLDTah/tHV9CTsgV/vvrvash1GPvFyQsW9yCBMMFyvZwRa8Fem2sVXd9oyrX9rbEMMZlZqk0/XM88SmDungHuhMQDqGYReJpmXhHpnH96Wohw7p80GkhFoFB3O1T0b/febcx9/h9/sQYNy5eGf5xH3ml03PlnAtl9K3uLuG63vuirw60yZw6vumOGAzfJHBmsBlQYPfdArlM1EzikvnbuvNWzliVJGlU436bUyoIzJicF/ly/QWrPIhl8rQN510pNzJVbKJgoW/V0HdnRod/6R1w6Gq9N7JCzMfDdaWzVXzlPxTvei/6PydcbxhCTRBbBnO891bq3Qda+CpWtfI1EvgwKSjgdwDrKCIkg4dNW/DRt0y5TLaL5VA1lyMT5wMg7e+BN40Kd1Ma65M3F84Ng/Ve9fe82MMXGQSpTzysHgUQhmpFWWV1uS0Ap3GOMgvrxnt WKoYb4TU MpWNwFVhJXh6PNb1B20wbeoAWCxtH9NMUW7sYG5UT+LHCcSx53fEC9j1fLNz0A03dM1izhRHm15DZE+MH7iXRiDem5JE6fKxKNIrZkyF/6BOGrVC6hCyMA/LmwLdjlQKWdSghxnEVKhn/C/5d65kTa7bv+SYhMFJpg2GdG9yznqWk1k7JUI2HoKOjanccIg+gXS/QL06rxsWvAxYXAEuB9YodzkzsnoeDIG3I5Uzd81rgFRmvp5l4ucuMF0gJD9Al537ltl/0B8tnkC9vQCmhVUfC/EtQLAauyeIPrtIryI7GSJW5QGM6jw4N6su/r9UtbM8GVRrUbgXXljLtEk5ahiEFA7Ih+fRAdNpEsvvMQnD5LTG7h4s8wKEi95+hw0MTFfu73dZDGsOypoeX8+/seMRt0xFSz/TbVmBEH8j/kSq2N15kM2b50HsxyO3xvI1Zphe2IfLBOaXN1aQdeH+jZLvHtbHGboMqeeFaAfMXB/YUjtC40xWvLXT68vIyAW4KwQLMAlyOrCy3KLEJ+ZVsJWFtgC5FCO298aC8ZhzFoynz3h1Ji4QUVbTPoAIbnxZpKYV2yvF3g10VYMvrIeG+J7kxLg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: These two functions take pointer to an array of struct page. Introduce zsdesc_kmap_atomic() and make __zs_{map,unmap}_object() take pointer to an array of zsdesc instead of page. Add silly type casting when calling them. 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 91fccc67185b..be3b8734bdf2 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -322,6 +322,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)); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -1155,7 +1160,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; @@ -1172,10 +1177,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: @@ -1183,7 +1188,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; @@ -1202,10 +1207,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); @@ -1346,7 +1351,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; @@ -1381,7 +1386,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 Nov 30 10:12: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: 13474204 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 8D114C4167B for ; Thu, 30 Nov 2023 10:13:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1EC796B0462; Thu, 30 Nov 2023 05:13:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 19F7B6B0463; Thu, 30 Nov 2023 05:13:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 015AE6B0464; Thu, 30 Nov 2023 05:13:23 -0500 (EST) 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 E08146B0462 for ; Thu, 30 Nov 2023 05:13:23 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B8581C014C for ; Thu, 30 Nov 2023 10:13:23 +0000 (UTC) X-FDA: 81514208286.30.526D941 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf10.hostedemail.com (Postfix) with ESMTP id DD969C000B for ; Thu, 30 Nov 2023 10:13:21 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zj6XWtEm; spf=pass (imf10.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.172 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=1701339201; a=rsa-sha256; cv=none; b=WUuxItBpWWrpE5U1EJokPPf3MyAnHBzi7IffRD0/7Rp8goXLCjCDYSWiYa9F1JQfrUzv9I n5gBzMKyCAuPgRgdzR5+WfgJfyQdI/vw8sHfFkC8sUsgyeKQy49veQBE27bgvNy0u/3Yqy 5X5uuhq9LNKBh+7/CtizRmEuVltDPTE= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Zj6XWtEm; spf=pass (imf10.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.172 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=1701339201; 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=sN9WK9gt3M9tH0088FFqUlWMS1+EeVFdkh7yWGn+zTA=; b=ECGk3/LXurwwtpZNHGT/MZG3zZ5pRJMWjnxPoKt3ZS5GMRCvwwjjP6bODEEHdvQ3/y+eIf JpK4KnDRs+krivBrF2nAoFZCzxSdZbD578glybNzcvhMwM2z9DFArJbhstWWHr+oWQGvWU qxNPQXNWTS5607BmH45jkubItoL7TLw= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-5c5f0e325a6so627358a12.1 for ; Thu, 30 Nov 2023 02:13:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339201; x=1701944001; darn=kvack.org; 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=sN9WK9gt3M9tH0088FFqUlWMS1+EeVFdkh7yWGn+zTA=; b=Zj6XWtEmjziQGJFOaUvnkkomWgW6VcupulW2LOrc2Zok3FAwxuRBwtN/tf3Q+JBxGV MxwEstd4ebUEUi7m9KkuccLE0fBSwMdD2gVAkj6V+O9lGRgKfLxV+cEEdgqoCpDtXKYn Z+FLUrD0YltCevVuJ53n3Y5ZLhmUhxYgGXHhQ5Nn6D04kHxgROnI0Ba1N1R0/OjeKJ3I JzDGKFyphBU0GRGsrQORP7ZVTkD+SPLcDyhKdN3SfegrFvCegU8c3OB30amiA8Qve5Vz Zl7S/+CFUh6T7g23vDK1WobjLXhhlpNMhcOlnixXfMtVw/s860QWCkwXmmJVkvyi7n0G WYzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339201; x=1701944001; 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=sN9WK9gt3M9tH0088FFqUlWMS1+EeVFdkh7yWGn+zTA=; b=lIkcCRgHyxZkeP23aEIC89ry311+QbG2BBSse3MspeUngewmv32VdU1Cl+oLxQyUKG jJGzA0czfyx+X2yKG2z2O+B25Agf3QQbNG1ltbajqDtALFuRvabHS+Yd3StWxf+Q2/07 1QAcn/FYRq3u/OPqa1SOOXh7jXxvu2MRBEGIcQi+0jitVvr8cFPpz+JkoLjo1JKXq/w4 WBX2Hi7ciErFgI43EzlN3DMinREqywgoqzLNGs34OXHycKFUfsjzRcsHy3yS1Tl1oH6G SIZTGpeWt78Oo8v/FNq+7ETxX5OPfdGItbRiyNJ7TZCCNpri/AFkQxGhxvMgmEgUcPbE Cfzg== X-Gm-Message-State: AOJu0YzSZ6dDynp39iV+OVo/Zo/JUgEbq/Fo2JjhY1rz3fjb+7XX4vV2 CSOj1XythlyBK3+7hJ8i9kw= X-Google-Smtp-Source: AGHT+IEwFMzcf5tYd6FjYnBLPQh0f175hnZdLkui0O9Bmt3oQnmtyBpIi2tN4qbWfiJCd0Rr+uiMgQ== X-Received: by 2002:a05:6a20:d48e:b0:187:3b1f:219c with SMTP id im14-20020a056a20d48e00b001873b1f219cmr25710613pzb.10.1701339200517; Thu, 30 Nov 2023 02:13:20 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:19 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 07/21] mm/zsmalloc: convert obj_to_location() and its users to use zsdesc Date: Thu, 30 Nov 2023 19:12:28 +0900 Message-Id: <20231130101242.2590384-8-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: DD969C000B X-Stat-Signature: uii3phmryuke138ftupcb49o51o5e831 X-Rspam-User: X-HE-Tag: 1701339201-545139 X-HE-Meta: U2FsdGVkX18hqKEojBBwwZkVoIlaeqQwTNxcU7Y9takoEV7GQryERTRSzIDP7E46DmAn51yuMcCw07m8JoX0MIC8V1Vnsnz/IrtNUzYYTlG37+3uESyk7OZ3fezqMjMIMuERiB5kdLQfWFV7JM25KWvFSv4WgjBbB4BU4CsoK02K84GIeKpaehe5BeEihDXW9d6fQ4trTgBTMQSLe4KXMCWBZ2RceAX6xteJocCxFvv/uR6oTIZQuS4Rh91SJlc5bVw6Bt3umgSuAdYJ1tr3uhhj3AkGCMzMZ1JjtswMPbK4E6OZA52V9Tt0PBNt5ley14UuL5zkIlEM4CE5UcygcSG7rL5EKc2DzxUeqv1CEpdE0FSrl3+IfFXVM2ABHP9tPQRXPf9DCftTx68dqdO98s/QacDFOtial6Ff/JOEeDCDbeGqfwgX40cGMGfe1gB4gIjTzGnajWKPKhGIL+5+FqVih9L2Fp4pdplMFBSuvtGlqsnsMyhvIDBnsaZ3ozHzBsSgaIEJ4oxev2sW+Uc5ffWozfxlhYuo8N4Kvlq6sm45324vXVtHRLRMF5zWq9B1DiE5Hh4hCTRO2R9Oc95Dv3h1lVsLx+yfyvgBk4DeLDn6luWCu1U5KhXjiAiPZNyOpoBMtn09Q3Y+02GgVrs31P/cZJIWAcl5MGl2cpvP9U6vbFh4KZ7hIgHehc2td4k9RG+GbmE2uoL0jRF+3ZsusGcJ1e6ctf00NhEyKCJckrwg+NOXqn2q0nRI5baxjAzOb46bk+uXzrA7LHXpsRiVRTiqMwckwCiCIZlZpVR2+Bm9gebLKLKpL/020G07LJA/JRbg911bu1GY52T/CuQ4f9q+TC78CaHpk2KBAQekgjPuZDaE7nylv1qGLyamx3SVXCFNNTogOfb3d8lF60ohQUG/MTxG6bpa0n/e8uGCZtDUaTr0oE+Y7dSB+nz5FHmp/6qYECsz0tk7qBANDc/ +3WprW04 lRp0jX4/fYBguLO5Q9XWXos9kJEIjEOX6l0eGp+6A/akbgSP5EN8K4a4DiTGAGLyfcE35nWaTbfVgyd4DZXrUW14n69D4mCR6tBjBG1ermis/Au5Tu9dJ6bCqhXACyX7DavLIWBa9QtackyoS4Du4w75y3HJWlMP8deUYl0DjSU1jgyveZ2GiVDHqkS44vBZhOClFfTjWzn7iVJAVh+dbvKwrsIQe88vLijhZjXWrxiDBpfbXnJM7YbxyAcnavmcGIcJ12ySEs6DaJ5ioB9TX7BZI3GN0+9uhPjYYttV/pIpD4sQCEr4/4MaJeuOIv4k5Tc6fIKnlWeicSLUEGu8bIkmYuex5VmgFR3hZ8oSWNISG1mbOU7JyT8GXh4UsbtGRnWM3gnFc2wEOVolPsHMck9/zmCclZdCNx7avlKqwyiFN+7K/jvN67Erukbjwphv0s1g3HXJubOoxGIfJpjeehqddfcx6dG6D8PYdKY/uL5lNKqp95U6ricPtnMnU0R0e3K+sNAqr52bruUYzH0uifGuQBUSo+rQY3STAtJhCRKJhRoLeprgSul7KyWDahttIGS0oMmWAYBgrJKqmSiat78o2ng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 be3b8734bdf2..f5a20c20ec19 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -864,16 +864,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); } @@ -1302,13 +1302,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; /* @@ -1321,8 +1321,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 @@ -1341,17 +1341,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; @@ -1363,7 +1363,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; @@ -1371,8 +1371,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); @@ -1380,13 +1380,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); @@ -1528,23 +1528,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); @@ -1587,7 +1588,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; @@ -1596,8 +1597,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); @@ -1608,8 +1609,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); @@ -1634,17 +1635,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; } @@ -1910,7 +1911,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 Nov 30 10:12: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: 13474205 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 E22FCC07CA9 for ; Thu, 30 Nov 2023 10:13:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B8196B0464; Thu, 30 Nov 2023 05:13:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7690E6B0465; Thu, 30 Nov 2023 05:13:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 608626B0466; Thu, 30 Nov 2023 05:13:26 -0500 (EST) 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 4A3BA6B0464 for ; Thu, 30 Nov 2023 05:13:26 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 228AB12015A for ; Thu, 30 Nov 2023 10:13:26 +0000 (UTC) X-FDA: 81514208412.13.CFA950F Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by imf01.hostedemail.com (Postfix) with ESMTP id 528494001E for ; Thu, 30 Nov 2023 10:13:24 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ViHEWkBJ; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.173 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=1701339204; 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=Kjc69aPDfRYct2ssOKqED0XUgPxt6UAzqNQ7B6cYebU=; b=RsWq1gzPnEjl85+PRZVrEm69sbEeqNzMppNqefipYiCfFHGNESi7kcAZOfw7rqf9mwWaVT Sknv4TrIc5eT4LzafTlCKkJnIc1+pjvFZEn6mXLg9hxml9llQ10BoZET9ggSXiOcUESIhw xbITrhK8Fs8SOrWH743GwTlKxofCfNU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339204; a=rsa-sha256; cv=none; b=VFfNQRxZbaaatGWf/98oRDML6Y9d2a3566HNnEN+MfLmmhFrQhK9Fl/JMgWfgZGmaG7Amf p7TWStSYQEciXDnWugUIdlRDbYzM/z5juEahx0D2VHoXh3RKlHgY4uvqv16phsk49/bhbA qcCvoIqEeqWEGfp6GkHNrSf0QMmfDlI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ViHEWkBJ; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3b845ba9ba9so435911b6e.3 for ; Thu, 30 Nov 2023 02:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339203; x=1701944003; darn=kvack.org; 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=Kjc69aPDfRYct2ssOKqED0XUgPxt6UAzqNQ7B6cYebU=; b=ViHEWkBJbyAiSjes770OzgTHPRTYQ4RJVc9JKZCWLcb+uV2FpcBrhTY1v6EVxnxlhN 4v6/hMTcuL1G3YJVCH7LXLgrMorc6UOMAdgTrfruWJQdbaDbA1616hHYG5wU+JOL3xP/ BGeDoAJzTCKS7SMYCKHEaUaPX5B5spHYTmXApOp1coHsM8PWpkHlWPPn7CzlUzkHhjBO AtggiEhPJZcZB1DC4Utm+Pcpo8V9SD79NnWFaqTMKiZHlCTVKl/AoDC36Rm38V3kEpJ/ GOpJ+r620es+80iCaBqak3vzMM4l4xCKVEkCQ5axdKaJ8Jgi0JqHlRqT/L6K4SUEcIFO M+HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339203; x=1701944003; 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=Kjc69aPDfRYct2ssOKqED0XUgPxt6UAzqNQ7B6cYebU=; b=IFWKsv/B4+PngSP5Y80epcF5YJpE2vMQeBa1pwHbCOkpHP755w+q2QRm8hztNPwyit 21DKYV5Yh3ZnPv/nvDTAmG75sOpoOtqOUuy47KUsM0uwIP8V0C7U4MrFcjYSaOhGpwLd EV+x8LOkB1OTUpZIx1yffI7CdX+j7oklDdTik4Ix1cLYRg1lJw2e/QtWb6inSwxD2SvP bL+/DS8IrKnyMm54SJA18Pf6TduHK8SeEGkky8uZFvI/3fCsoui8V9nbYDUIRlGzR3aw WtVscwTAwKNrurP0oQln+upX0gz1aoMmW7TkhzM0FAfnDAnVcJwUTuzrbw4rXt3LXziS ryAA== X-Gm-Message-State: AOJu0YwlOMZqkRqUjd2g1QOqmuSzGW17rTPeWJe8TWP33DmXyFGgwZjE fxfBjLuKZSp4gLqIEWbnA40= X-Google-Smtp-Source: AGHT+IEWkVmBU5JkEIZWnFyE/VXLr2LB5Fw15ND7dNbbGbUYfuhXURtapglhyxY9Nfd4s11kLj9D0A== X-Received: by 2002:a05:6871:e7c9:b0:1fa:306f:60d with SMTP id qc9-20020a056871e7c900b001fa306f060dmr21590218oac.4.1701339203405; Thu, 30 Nov 2023 02:13:23 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:22 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 08/21] mm/zsmalloc: convert obj_malloc() to use zsdesc Date: Thu, 30 Nov 2023 19:12:29 +0900 Message-Id: <20231130101242.2590384-9-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 528494001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jcpzhmpzg4mg5pzpohz68m19pgq9h3wn X-HE-Tag: 1701339204-109657 X-HE-Meta: U2FsdGVkX1++xGG//kRsWjImkYsCevKf1tQ4seGT0ZUlspFH+QTOLqpOUu5spMVOvOHKlUYUuPIyrG59aQgWbRcdWtYrlF4hCksH8GZ0jNEoxV/0CTWMGe8nQEssO6s12a72xCcJbZTEcMsqrMfR6DZw0d0ShSA5nhV9XBDBYrPim4XX1m8jUg0eWuTK7s/k5vOui/cgKnumPcxS6g6rmmSetTgpgobg5RI4tmqL7kbDyPFVdICT3gB5NsI2r8uc6XY0rMRlyPWIfgbowzQQqQjtH/lKkAcaeB4WtagaCoNs4vSjYGS3jzFaYDbVVvGRTlRj+dKhRRIQzSxJ6IA9cIeku3XizQSq7b+Rt56b2isNqn+uJOYErZo9ksI6TO/dDktJSfNd0+G+t4byJN6BdP3YE8pBV7f8cKcyt1IH6kfBpYEhwthiAu1fap+7cWWKp1FowYNRh3Uwgopl78qKWrxf5wCYtLI0niQ+zwyw++87rUch23MUCuB2Ttx+SltQWbCXfd0StBteCaVsLgTLdMGRJ+CQLsFICA9Xb/FmNtc+V1NWcGjPDzwKvJacoh9drjUfGlEB94F4Oj8A7TAvAFCDNgEGCjHMwcLG07991eKegCSEvJc1By8ergFajwoOgnR6pfs/6vX0TQDOMtRCuNanm0Z0Njutk3UDsw9NwCBAnOSaOEQKyx7BV3kyb5rz+z6mReRLRhnfWwRG70DPWwZkb2Eho58G/JX6pECOMIBK6CwS0zkqiNvFBywGGZJFzvlneKDEFhMbg2QuI1XuXW5/OYyX8VyxZkGHepPoO6IfMu07kHDHUOUVjxB0UQpbXYxceFjDql9eKvjVy8Ua2QifOP0LP2eh2AXI8L51b5azbxEGsYrQxtw4XOMAxXTS03EhgK0GNIfNdCPk6gk2owE6n8x+4TAk+8K/X4RyJJ0f1fZMa2K40KuKVcEGY9gFk6s2wSeg9W0c+pVIzqA O/bonOUc l/hEsqhMARlRykYOgoMFbz1/59f7l9Mw84f4i8m7YFL6tFKOv38BkRmifOhwQqLA9iNsTpe1PyoOrD7Js0FgdPBVSPOWe21MWhRblI7CR7R84/XFTswP3alJRLxd52oO8/0q7xZa+L2YnmnwdRT+WGhKm/hggRjmYtX4boEY6GLBm+zr+kxUrYppQl5eaE1L6/TthXfd2+cACm++NN3sOGlBcFKXAoRAuxAYhJWRIeMrs3VBtXoslRrlKeagxo2j/dEZtBlVQtojRUQx1FRzl3/17SdTKKikF/W9h6kn8l1JfIacGsfuLb1GUBOQnr8MXHjUf9C1qtzz6jSuPQlzeBfnHUxPlfYdJaYKNtgFgyn94suPU3QY2c7A2mVGIOBUpt0UWVRPNtg37iZvSMSTHzXxTqVBNWwJWybdsoSE6be8T1lC/OkTXR3YlP9/6HcT3LurMe3o94J+3Xv4tkpt1npfTj6eqmpViTD+s5KQxOGV55izGcAqEoj+dKebfis5e+0QCPSKSxQSxzxvuA3YTyZd9qBuU+GlzcolEB03qU6foZYtAj0+q64L2oFAcpyVdgxnjjnG/PYMf+FPs7CdoaVBXsg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 f5a20c20ec19..74ed0477f40e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1416,12 +1416,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; @@ -1430,14 +1430,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))) @@ -1450,7 +1450,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 Nov 30 10:12: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: 13474206 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 4622CC4167B for ; Thu, 30 Nov 2023 10:13:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D36F46B0466; Thu, 30 Nov 2023 05:13:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CE48A6B0467; Thu, 30 Nov 2023 05:13:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B915F6B0468; Thu, 30 Nov 2023 05:13:29 -0500 (EST) 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 A22AF6B0466 for ; Thu, 30 Nov 2023 05:13:29 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 811E2A0168 for ; Thu, 30 Nov 2023 10:13:29 +0000 (UTC) X-FDA: 81514208538.12.9DE8729 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by imf11.hostedemail.com (Postfix) with ESMTP id 943364000B for ; Thu, 30 Nov 2023 10:13:27 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=g9gomZSz; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.176 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=1701339207; 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=uS3iDho6P/vCdQ1q75iaR0pr3ux5IXne/kUUf4KBVRE=; b=H/STMP1Whr+iLSSyF7UN0Z0y/eoymKcao/OWZ3SrGZy9jfALSjw0aRr5VBVuVYM9CDY42m k/fxLgNPsaRP4ZaD6J05h25Zxyntlt6ky7ByajE2lR9oWzk6U54+rMKCIZB4KBK2FINPUA ITAOvygaijV2Dw4jj1hdbrZPJp+JujU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=g9gomZSz; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.176 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=1701339207; a=rsa-sha256; cv=none; b=7padoZkogFEwdo+ngtr1qCypTCP5iVsmhHI8WC6dmTvIeMSdBddfICmAej5O9vTWMtrNRU rFX49MNLJXOEgCEFt4GN/VnBsag6wlASLRz50/56Hq8qc0ZHuAlCl/87zwqqoubW7W8k72 0TnOjsvJjhORe2FsIAOkk/uZnX80QQY= Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-5bdb0be3591so610170a12.2 for ; Thu, 30 Nov 2023 02:13:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339206; x=1701944006; darn=kvack.org; 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=uS3iDho6P/vCdQ1q75iaR0pr3ux5IXne/kUUf4KBVRE=; b=g9gomZSz3zalfDh9lyQt2hiDrOTM2ny+OlQgAXv6QMR6+m3S9EwEZzT1UiLw52Pr+V Rp44fsJVrEFaqViFSRoAgATF7r6ZHW3hatlTX9a392CkukFLbF8B/F7Y56VGpECvUfpZ QSCG7OV+0qUZvdZvrm/UGzjnTMSKyS1Pb0fcEb0qaQ2h2VM2PDFbh6FeKC5mXKDhugJ0 QNwccb6ZrmeHjE52NMpYk8Oa4SbKGNnKutt2fGAvNGxOz10EJcjOspIV76g8ppAX4qun UuyPexUwQmr0++V6xlqWGvhA/SL4cQxgQA2A1mCXjtc6Hbdl1Z5r2Sc/qkkNq78ZC/Qm Ajqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339206; x=1701944006; 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=uS3iDho6P/vCdQ1q75iaR0pr3ux5IXne/kUUf4KBVRE=; b=DWvdYCS5O47SzKPQ11z+/xGcH0FaOZGJszJK2pIt1Hl9Iug9Zxo8FqF6e7FNODNP7+ wMsGheIG9KwciJRdfSsljqWIKoQ02LnCdMIJPPh2v6/GZlqgbOJh1tbeUVzbQLoJgq5z sY+ga0WygSFzvmYLf6G5shaMJq1DBg6r1iciss1ijpiZgo/jr8tBX5hdVyu11sDd0nkG 1FVciidBc3VuFXaoGLXcXZBXEC6YiNmi6h9Iq/qPLFZToqFT+hYpiO9/FJIwPS+Z2xht MlKLaENBvrJpexThh/LHP+iDLz+VrHiR/ppZXFYplQgBHADV9vkKt24EIXlayIaDSPGM CUdA== X-Gm-Message-State: AOJu0YzXFt+Un4h2GGDCEh73IoZ95z3RXXmwcl//ojKrgdz6IRKY0Fzq e9spJiy+LZxuaamBnuIfK6A= X-Google-Smtp-Source: AGHT+IF3DNy59mcHbuwsXrz0BX30OCL6//xSDQgckfW+hFwaYy3O9GK0VJbDAZH6EXT9wPfwaBzNJQ== X-Received: by 2002:a05:6a20:3d14:b0:18c:18d4:d931 with SMTP id y20-20020a056a203d1400b0018c18d4d931mr24409041pzi.34.1701339206235; Thu, 30 Nov 2023 02:13:26 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:25 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 09/21] mm/zsmalloc: convert create_page_chain() and its users to use zsdesc Date: Thu, 30 Nov 2023 19:12:30 +0900 Message-Id: <20231130101242.2590384-10-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 943364000B X-Rspam-User: X-Stat-Signature: s4hhgxps6mih1p9ku58mjg6z9ahyxhm7 X-Rspamd-Server: rspam01 X-HE-Tag: 1701339207-586006 X-HE-Meta: U2FsdGVkX1+/sjcw9/draGR4Do6k18wOqvIqg5iL+6UEdOHVgc5vHphto2oWmO8+LV6zwVcwJ0g5jp1mqvyGPtD6CdyBG0Oe+NxY1I66FjzMjAs441xhtMhEvY8zCGH+4vQppNatwmJpFn23dMAWxApZQaDI4r4H6enJt/fawPHdOUj9+52+Xd/uHHgXi8QukXcru6ISs2c9BS8rSulPw+6aMZ6KlDsrrpqUcGN1zpgBWvBoB+O46Mmr7VERZSrrjPVmjRfcq5CgrpYDo49uNr0NODAztBwKI1JxupWvvPNj+JwXdex2vUjDzw2D6h13b9aPwN/c5BBkOjAUJVA/8i0QyfVU3RX3M3N1bjyZMQoOFHIBCe2aqXgURsu5JcNqkVYM2ZcsA0bduGwGJRXDJIwkYTet9y88PHc6dowepRnpgIq+fTLoZxaLhRHvZPyB2GMno0N9srn2FCpp9beln3z1WMf8K9M58AH4xtAXdnn3DDILTLJG8u3kvAOnKybgKI04kxv4m8zkW0Yf5IO1Biae2uOH1+1a+BeBiZeDZtUFzBSfUTEoaa2v8NLRHVAAe7/3bVVcuocH3jhK98dhjekwXIRusCycQD4IUKPXW27AUXhw+QC48lTFi9uJhbXAlZnDtxZzvmPPooVTrsN8pI6oYapUZAFaz8HH8OapsUvhnDx5EGxmiX8Eg6p3X96Vm+WmYOxQymz3sihNsVXR/G6Fw3Efonwduj45jy5PZyNnkkOm5qVWz85uPv7HijZ3cnzHKeWyWGYuxAMP4dNXXhIFbCcqqMPWZCLrRyF9cZP4cbBAD6SidtEHD3X7ohPi0DFr6pa6Ye2u7WPec6wKdLmRKbJHTBcHA87waZv/sM6ZeYGP16YJ9oqKC3t46bxyMRpEGuYKhtkFI5ND3JYtWm/lJVKmSMPIR/2v2S9ewMptUXA3+4f6L3JHrQN4lfgZzCz3qg2ALwWbv/I3T/T LyJxTKaf vBLSg6rmfUjxHIcwbsgP4Tgdm8Nz4nlt231flaAGauE/8yLxIdcjBTQHYcTvEdj8sxldSWUx8DZ58V2BvX/fwyxu0gCHtnuFsCsREHEnouBfNUAni2Qix58BQ5kX/VrvRCQAj2nxs2lKyfTpMKZvXEeYiXZqT9nkaV6NmhWYhBoy4ubYMn1Cb078bvNBcJPXj8Q+ZoisAcRbmwTpVl63u5kCNArY5AwvZNir8+DCn8FBJ7YK53OqpNUvg1fCUsfkVW1bcVV+EQoJYapWbHq1O5ejEmWmD7nqRsT8C2luELNdjDjFzhmnETDtfxSyZ9F3Ie+V2DadhIc3UcI0sQgvOrte7RLuemaGaq8HzUcXrWWA2Hiz/c8T78MrIFxTXJvk/Cueb4Y63TIq5604YJQfwHyGhtZ6LKngW4MZIG63pqbXA4owEp6he7QHGqyj9/k+cIoN8SGUb4O8ouGhiF2De7k+ynAJdcnVkml3zB2yC0Yrwl9jJxjawMbm41ThAviA1CcYY7cQ6U31eGErlHemiMiT3cc8bwMpKJmdNj8WqMhGtrTpfS42L4gctXo49V1loU2bP6uiDPqq+tgE8dA6q93oYEhD4tcOVIUQKELERSQnohOMUXZxzwrudHy02dvnIT9IL X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 74ed0477f40e..1b5b9322ec21 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -327,6 +327,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); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -1051,35 +1093,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; } } @@ -1091,7 +1133,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) @@ -1101,23 +1143,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; @@ -1860,29 +1902,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) @@ -1965,7 +2007,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)); dec_zspage_isolation(zspage); /* * Since we complete the data copy and set up new zspage structure, From patchwork Thu Nov 30 10:12: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: 13474207 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 CE9CBC4167B for ; Thu, 30 Nov 2023 10:13:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 631C56B0468; Thu, 30 Nov 2023 05:13:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E0AB6B0469; Thu, 30 Nov 2023 05:13:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 481686B046A; Thu, 30 Nov 2023 05:13:32 -0500 (EST) 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 346466B0468 for ; Thu, 30 Nov 2023 05:13:32 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EC8951A0105 for ; Thu, 30 Nov 2023 10:13:31 +0000 (UTC) X-FDA: 81514208622.20.C4900E4 Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by imf19.hostedemail.com (Postfix) with ESMTP id 0EB841A0014 for ; Thu, 30 Nov 2023 10:13:29 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EGeIz0ku; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.166.182 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339210; a=rsa-sha256; cv=none; b=SdM3K2rhOO1Kvz46wy874EYP4AXKOpGW0G05j4GOn2b7BqFN33nZxdBOEFdwtWbRiP5pGz uv3e6FgnvIi0xmuWmYi/wLyTVmnzz80kvDLJTe7U0SX5Mv5VDBKsU8I+L7WZSdcSJJbh2b kAYU7QFYlJ1oURQQFCUTcQu0ZWV+5gM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EGeIz0ku; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.166.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=1701339210; 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=Alm4Uwmfg8k4l9xZX4lYF39z1/lXjIuceVYYdGDrSHg=; b=TwAuw3ph+jFwMS2NmIfu6tS9LddXqf9qKQIwWLqwl2JrzcaG9f3ukUXF1PIqIyVhgPRdRf 5e4hOZ2+HuKRr0th4VK6s7mQ70CbOAh+AsVgk0reWJl0QLmprt2PVDTusKZUp1txo8k5qc 7Q2/4XQ6kCYTwuqsrK0Bzy5Nz2UZ12E= Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-35c690f6e00so2023785ab.1 for ; Thu, 30 Nov 2023 02:13:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339209; x=1701944009; darn=kvack.org; 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=Alm4Uwmfg8k4l9xZX4lYF39z1/lXjIuceVYYdGDrSHg=; b=EGeIz0kuxpSPcUcYyHs3jcKCeajNquzfMc9rptYy/UZjmtfRPBT21RQyE+peDt3q+W /0GIsNNYQKNRDiacfNC3RxnOi8GgicmU+DO4z1hAh/RQYzHJXKssn/AUewj5JCiW4uIj 1X8JaQ0GhW7Z72aiHEzYfQnqyIsuiLDTTjXo+YuHOanwuavWGHMyp9pfz4zBn00RaKsp HY4js4LtmMzfIMWWrGdg1SYQQaZCvdRp/3WUm4KAyEMEVb3lSFev9Bxv/0C9zgQXsZoj s1lOloDS80LSDKjJdxaSRRFdAzwc1gkgW/SepwXYpIpXBUtBq2QO0WAMofkwZlw0qDmy UUow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339209; x=1701944009; 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=Alm4Uwmfg8k4l9xZX4lYF39z1/lXjIuceVYYdGDrSHg=; b=TF/esbt/vEV+JU03K4gVw36N1Llq0YaTTuLdxlJ4WdOzLTzNLmwm3WEwt7ihHpxiyW U/D48yVXLb8fcJ7+RWfLiFGZD2IChqWAN20xop8ErVId6+30lpDOiNEaDBviPozjdROD vxb5D9UkTb6sxv385bwqII+kZLlBg877LBzYLSWr1aWg+cY4O9uUYd6Ku+2jJcVjvUL0 WC23esn4uCf2lSB+voTJVuNaJmNPVvpRXMGw6UsmFuofqdYWu/1dzIqyqjplziLM6fS+ EjeHhBvMHVutF0kYinASaE3Z+H2jvCb/iqeHo6w+IichKv7Bw9SAzrfRphkXIBnm8O1M CifQ== X-Gm-Message-State: AOJu0YzAD4oPPGRgNVf/idXUlAIJ8dwjasUNwChbGFpt5iJ4dupGBnni V/lY2BSIHlgA/tmh0z/BCkY= X-Google-Smtp-Source: AGHT+IEkldX3LH8USjAq6RqcqBA9mVaJhfibAPk/CkQLar7kV7XzoLuUQo1kmMTNe3O+LbfKqEuT+w== X-Received: by 2002:a05:6e02:12c1:b0:35c:c916:892b with SMTP id i1-20020a056e0212c100b0035cc916892bmr14929126ilm.4.1701339209129; Thu, 30 Nov 2023 02:13:29 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:28 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 10/21] mm/zsmalloc: convert obj_allocated() and related helpers to use zsdesc Date: Thu, 30 Nov 2023 19:12:31 +0900 Message-Id: <20231130101242.2590384-11-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0EB841A0014 X-Stat-Signature: xc94fnk6kgmre48as73fjn9gq4mwpghg X-HE-Tag: 1701339209-145730 X-HE-Meta: U2FsdGVkX1/apu7tJKptN4UfKVn0RXlaL14E+qcYlhQdZrhJJSd+r6YKxl3seNyQeBBpbWVsPsUy9UF5IqoXNo391HJvBNflLUMvS67AJBblc1nP6yDVxZbD0LGJGdqksw8qC8SGHM4vrPcfwOwIIiaKOMwNK1vYvbFbxJYPz59gguasFU06GjoQHl5IJD3IqP1jvyimXetOK6h91HMKVhVPejj6AjXHbUNKz08iliGNIYX8vh2KzLdnAVvI5HLsgbDMOKcLXwO2Bmtf7lRrh0mu4aM+PKFYW5lj3aIXQ3FKWzwfCk1FA32x1ahC+Vf7mtWC5K1nGF38bWsdIlneiflSKsCY8AQXWH960ddb3leKd/zGQc9h+l0/YBUIJAJ7yKEIAPM59EUv++GxEkrOTvq+wqTRV8OMSAgJ28z9ExNh0qw88eNmzkUwRZKBAmD9okwTEP29LD9SE6WGdEunC7mR733Kk/9dhftrPNOT9HMEiTxthuZEm/W3Px4vII6IPX9/LPgMK8230pF3PdeK/PvbLVp3vBhTYuiCP7TdmiBsAY11YVXxd8wzXAOiipS2lvYNMVu4kjdhKQD1HmGTCxV7cjsUY2SZf5Efucf7iTsMZx7halGnhTZUbrlXJnGvUm2soec0YMc/ZqM87I6nuIfoeSaR9VBzKCpFcrHWrJPGQTMsgjnA1m2DNEa1A7ZxpMsENIlBhMdtLV8ij8SSoxdoEUX2qqKOcropM6YAOwtYlAcUSbYo4AFZDB5ca55JCP0K/NaS/S4JttdrWllYWUX5Rh9gVIn7XDd2Wts79MFw4NZAq8X25xb3iZQk3PQDjzUy/uFZfCfU4G73qw+yh0VjCwtLwBLaKBTpqSPBcrnLbi4Dy680fyBdQtU+qArWM8TvDFeFZWJnpfsSzYK8y5Vi04BruwVizkteYKNeyj5RN9k9W/oYE5ujwGuShS9xNpkeK9D+ogOVZyrpfp7 ymASerSd fB0nnRtrEe08Jud+PrPDwTG36041UfKttnvMPbutWHpWlKA6j114V5kNUyAkivsigCE+PpGrgS6CILlyBfcpZJYx2CCi/8x4YXw1K5H4FUJewEKt++/h+zOfqz6MHZ3jVfsbcaXFPv3gy021Av2M9b3OGpeZyQHfRcttQrsnIXxFSHmFFUD42MI+zDfTyvUFfP1gUDYOjqTIlcGPB2PXYuFB31KA2zteEwDTEdARQmtV2jtHO9dwrEVTvAwS/5tKzAmJGL9CDYiwHuTQyaza2C+qzBfyrZ1NTYnYonFqasy34XgpclCAgL6lAAUrrngBXU+zVJtAPVVSFREi0t02Cahwk3Ri8rXdu/67caSgSeaDoZXM2QqrE1rEL1P1KMg8lPQ56aifAu93vpXzSJ9lJ9hUQkKpuzONt9sleX+tWSUHZENwi3J/zl4zQOsTyADJxj5Z7330J6v38NDIFkpyOkge3jhnjL5DFmEpxhfq+oackMrAQnzZMr0RPcLHAN2BDjY5XFCKHxUr98hE2+6pqIIcUGypMLxz3RAJuGau3I5Uzz6g0PBk5WZ6KoeyAjSjRvhbb+e9SAzq5pOuNnu7k+d4sa3vWUd7OO06MH0XcPdA5k36Ty8d3rq/ZVbC8N7CddKhh X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 1b5b9322ec21..f625d991bab1 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -946,15 +946,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; @@ -1702,18 +1702,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; @@ -1737,7 +1737,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) @@ -1996,7 +1996,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 Nov 30 10:12: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: 13474208 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 BBD98C4167B for ; Thu, 30 Nov 2023 10:13:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FBDC6B046A; Thu, 30 Nov 2023 05:13:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 480E66B046B; Thu, 30 Nov 2023 05:13:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 323928D0001; Thu, 30 Nov 2023 05:13:35 -0500 (EST) 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 1994D6B046A for ; Thu, 30 Nov 2023 05:13:35 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ED96EA0128 for ; Thu, 30 Nov 2023 10:13:34 +0000 (UTC) X-FDA: 81514208748.03.DC0D06B Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf25.hostedemail.com (Postfix) with ESMTP id 2675BA001C for ; Thu, 30 Nov 2023 10:13:32 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=R11RO2gc; spf=pass (imf25.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 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=1701339213; 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=8jWeGi28nfNGy4wvNOSN4A3IkH18ay24ClD0Q+DNHkQ=; b=TTvZzoIoI0R5KWXD/kvmOfgDwNSZBBtvgcBGq/V7i7bmznaFHRT8JMydj5g/p0h9CUu2MS E9xjW1rPNzVNV0ZoStaaQu3kpB06KaI5LT7BgXhIkAHRRuc2iprDMr0klTq7q6Kn/ypCaL TX76XdvUbf2/B2Hw6JxKVqgCP/8RB5w= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=R11RO2gc; spf=pass (imf25.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 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=1701339213; a=rsa-sha256; cv=none; b=QTi04Khzax4+Nd8mQDuvrj0Q6qYtBi6McSSThmj+ZsKN36E8gbGuzvbypbbre43gthBIm5 B6so5ot6SJBKGbc7Jvw+Ve3aWq0xBr02ebisJw4stgAkX7PxESLykleM6uBv94GouNhLSI g1HL+SElNad8SL8PLQpcdJkFO6O1bHI= Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-6cdd214bce1so749598b3a.3 for ; Thu, 30 Nov 2023 02:13:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339212; x=1701944012; darn=kvack.org; 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=8jWeGi28nfNGy4wvNOSN4A3IkH18ay24ClD0Q+DNHkQ=; b=R11RO2gcPLP06yGDCgwtTQ6av+fALaoTB73FwEkDfA8Ft5BxsuYw0t/v0GTd0toC9S 2r5UNIoYzlpx9EwDcv7QVzpg6c5gntO8XtMxg2Wxzc+Yii3Fxzbb6S7VsvPIWTpEvE6D trEahjQra/3i3Gdbh7m1N8f7ydZroj/bldS5aM+hMIsauNkMM82wyRtbz7Eb2PMWRyAQ L59NpHdGNW8k8TZqKHmcxPOsVV2b+Nod5me7lnAqPHe/24VtqYde1M7oksR+3PgrdhL1 9s9EpD0mMN9lgQBwrm5GNiUUEeGpoA8o3gYr0MtZ1sqFQ+jtOGQMOMLtz9uD2WRF8i3w RAOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339212; x=1701944012; 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=8jWeGi28nfNGy4wvNOSN4A3IkH18ay24ClD0Q+DNHkQ=; b=bG7ACurRr3B/FK3dhoA8OGoNfznXV7R3aLQjsqFYvBf09xscFJmA/dvn+FG2C58wlB IF8vs3ALHpMhgfYCEkwFWKo4DjZFm6+06cX0fKXzcrWhcg4fwJe9wrAG7jwQ2UWr9D4m S/yzbKahYVGM5lvGFX28c9dP8RdG+6R1hpQrNICwXZeF1817AQokUxa9H7LYXYm/xM2w b0/bgZycTT5qtawF/51X/vWXVMR4FlMrs1jiCIUuzth6xnd1NdHtMouM2cgF8hukcu8s CnRw4zE0KFipcWl8hB+5oJRGSuZZM7cClSt3unIfcPE1qcvF6XRGybs6zLAFFArlHb3U tRTw== X-Gm-Message-State: AOJu0YylBrcnrfzq2YmSZqz/GhcfqBWRtNs6QlWd3OzKayMQe6ww551q aaqUmI/hgfS+XrlzPz8kakk= X-Google-Smtp-Source: AGHT+IG5pQEbla1Kb8DJw51iiB9xJFHgIZQTEhcTpEJwyv9qKXaA4smwJQqouZQCyjNQGiNxCnUKtw== X-Received: by 2002:a05:6a00:1d83:b0:6cb:8d97:3df3 with SMTP id z3-20020a056a001d8300b006cb8d973df3mr25523758pfw.5.1701339211946; Thu, 30 Nov 2023 02:13:31 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:31 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 11/21] mm/zsmalloc: convert init_zspage() to use zsdesc Date: Thu, 30 Nov 2023 19:12:32 +0900 Message-Id: <20231130101242.2590384-12-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2675BA001C X-Rspam-User: X-Stat-Signature: 15pj3de888canp3brz5x7innuo4pipf5 X-Rspamd-Server: rspam01 X-HE-Tag: 1701339212-460027 X-HE-Meta: U2FsdGVkX1859MP9r83S/OchFoQE7T06EV3377TzqwTovzTj9MmVawgyE/7j4gDNGZV0BRzuEmtWHfOb32wvRz31DcnjqJ2590TI7ZL7V/O1v/Hk5MKzQfCc9hJndDkSPlfk9JzUy+zU37f3z2wrna7Wnamf2vRpPBnW+fKWR5pWJHsc7BWHhJfp8amZ9y8KwMVGukIOqjbeBsnvcSJObpLcaAwOJIPV7RXfbu4+4PPjykbk3ZumGNA6GN3/TqmsoOMxzqMpGd3pJP1h6HCBVsJN/LqwwBVAMBSy9r+izmJdv5tenOdCWoMfEMfjPqYPNU9QrZdnfE2e+8yZgqvnYDRBOgIm21pbSfzNr4jwL4n6grLXhirpMO0OEM3xJ/8wnjbfOMUetQ6zeeYtqXDL5l3sGyw/sucNll4M8LI9xMdD2JywnKyxfbQF8hu6Krk1cPK2yT3yiy3vPML1PjSVdK/fYWcS3H8EyUxBpXLaOh35BHBO7XIE5uR5n4p9ejp/AtbvSxQ+AjhDQ0vGhDkcgIp+qwCAJ+Siy03nc05483AU4mO+ouDEIMqbVvNbVo+bisbm3rZq4HgVl04oaZHY8oVe5Idl/V+b2/GYfQ8K3wrh/bNQ4NlE8LNIRPqZ9dYsZlomSMKxwcIzYkfRSKdYz11k0tydCOkMQgruIniN9NCyDyppqO+ouatjOxnXUv6s9LHrpa15dqMd49EWXI+NAUThRyh4NM1ZlkbNpDMXUya8pnYQh+FgFynN/8eKrr3HWUy8wRdK80pU/V2ALpmNrUjrjQiMOZ+P/p0FnomcLsKm/hiELtWe7qxX4Ld0tDMmnHlA+iOt3FRWghNvZ3GR1GnJxNvZbTL6XwIlSBLNp8b/27kKkCnI6GKD0eAFcC1FP8fiD0saxgWvwTJoWRHIDKvTufqikjb3dP9+poH1aMjf9pL5QzmieQGvyvePa2KQd6JS1C9DABMohuCKebx 2Y+QdaPJ fVsTZbo/b84kBMJHqq3jrkF5bxNgJYtRnKrNPEdMWSLOPl0M385ysCIfncivQVZaAOWHvln/9/XgWaFrpou8Rzk3aki9P6CLQe4NNhODcF6IEPGEg4CAdh8SzzAC5Z6mfjkKQkn/VpJx6H4hGMJcLP4J0SEI/B/NEZ2ie8y83nVwvQxu8vzGeccOZ1Ax6j0Gg1+WKtwTJvLImEnaybedxCWsNEtOSP4UQ8pqhaMBNMSdTlSSNfc8lDx5wXm3nHOf8zJ5C3nu3bVXxIYB+H3R8CM8Z/cia8D6YJ7KmgV8GLjrBapolalK/r2iiix9zYKzZSYpJl5JRlsu9LAJZS0WNCA6Z6Hi3T/badlbB/t48J4OZCDmcHTc1IWEE5r6KR0xSwzEYZpKeAzPU7q0q0ZxuAlTy/C28QI0EU4wN/dM7Pp7rkYDeBTKd9BTGvufATIcNmjwPSyMyLdzEhYYDT5fsWin6J3jh6Hipoft/EeP75jpoXSG2SF1sS4istCVq6LVE1cY/+t3DF7dO5YmN677magFDbvWl1jCAqoJ5GLdyJPn6V7gAYvGeYPh5tTdzq9+dk4oM3uePhjEtW65HGlWxZeWvhw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 f625d991bab1..8fe934df298e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1052,16 +1052,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) { @@ -1074,8 +1074,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 { /* @@ -1085,7 +1085,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 Nov 30 10:12: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: 13474209 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 514A7C4167B for ; Thu, 30 Nov 2023 10:13:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF9C58D0033; Thu, 30 Nov 2023 05:13:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D82FB8D0001; Thu, 30 Nov 2023 05:13:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD99B8D0033; Thu, 30 Nov 2023 05:13:37 -0500 (EST) 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 A96F98D0001 for ; Thu, 30 Nov 2023 05:13:37 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8388C80168 for ; Thu, 30 Nov 2023 10:13:37 +0000 (UTC) X-FDA: 81514208874.06.C1DF978 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by imf02.hostedemail.com (Postfix) with ESMTP id BFF8E80019 for ; Thu, 30 Nov 2023 10:13:35 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PGY3bqwU; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.54 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=1701339215; a=rsa-sha256; cv=none; b=GO/OKfS47SuEX07DXKFvrAmqEidRDpm7/NjOErCHJW9jZ5ECnCUmVgOQ6BEyKl2s2q99iE PlGGqpW/2xuhgsHznClITiENM/kIQvjLFv9eF/ntuU7ZK2e2wkd/zvGPillbFn51Ijbrpq VYYC3NmeG3poumnaVG15HXb8SgObTdg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PGY3bqwU; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.54 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=1701339215; 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=vdihqx7B7KLgar9YSAGyUX0LBqL4R1+4PYzUkM92hCQ=; b=K1pTpZggHX6vZOHmuNaR9Sv5P/Reeu/CkupMJilsGXoKHszfKTHpEFazas6HGOeZzqOZn7 ZoW3LnyNYF6BZnABwJbCFNhQayuFPBaGzMwtPjz7WlABRZ5Yv7VU9gqoQRBem1w7zz6h71 AjoFavtVqu9tIeR9tsQgU2wCumxD0dM= Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6cd0963c61cso480506a34.0 for ; Thu, 30 Nov 2023 02:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339215; x=1701944015; darn=kvack.org; 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=vdihqx7B7KLgar9YSAGyUX0LBqL4R1+4PYzUkM92hCQ=; b=PGY3bqwUrI0ol2QZMFHeRkltxogRpSRPvu/FNCtJCpIJJ8kioPYd7WhIJEIvEQvB7e dZPIqI69IC6/h4A3l9siRDQsIJogf5XJuTzeelwIJFsG+/J6kstQn2K/bv6RRLELjvZ7 RgsJEQy67grThGt9dByFh6emj+5AXOfuzpC00hEbxp/gz0LwxzQG9AgCzUyr9dc57P9+ 4EeemSEgek8xCCpmLnTAG4rf2akB97FSq8QADUXoE/EzRHZryWexGF2ibe5ioQMw4j4x DkKzKcxJm9mVbW0PFlaoTvy7kzZgCQyVyeb1UlCkIuE3yd/LQOavHVAiuBxUZtZiiCs9 BjTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339215; x=1701944015; 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=vdihqx7B7KLgar9YSAGyUX0LBqL4R1+4PYzUkM92hCQ=; b=rxYkavoSvFcLMkCW3k0gSygdvYDL6XdhMTu7WtRVReydT2E8iMsKraDaws3epsCfzu beyckGgL01Cl6IF5Y0YX7nknseMr8FqJs0EjW6y5anO/21nlGWLSshI9sGyu9YpOrLWj ZA3YNDj5pbovEU+zIf/R1Iv/3mYDeH1HrXPW6mvpAuBTgAZPF/Qal0BAqeeic6MpgsZc ACbaHKc67AKRXAkoo7tFq/G2m+3VMdlB9BNK+/tAAcV1UAJI+4DkQ4ilBGu4EWu7yhm2 7z6H2RRF2k1d+iU4cQGqtEmQxMVN//jg2g3632AlUQDqxKZt64DXPGctqeIAqFgKkceS Y40A== X-Gm-Message-State: AOJu0Yw0Jb5LE6WlWRI13Iqss99fHaDq9aDvluGJoG2qLUA/tKhJjB7h 3i6ata6HDsHK8fuaCTnWVUM= X-Google-Smtp-Source: AGHT+IE34+5OA4/fl0FgaRCmUxAwP55nM0ufhZGNZb3L1jlWRJdswT+L2DOUH6n6RMKqxXfN34vQzw== X-Received: by 2002:a05:6870:c45:b0:1fa:345e:5e15 with SMTP id lf5-20020a0568700c4500b001fa345e5e15mr18230739oab.13.1701339214817; Thu, 30 Nov 2023 02:13:34 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:34 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 12/21] mm/zsmalloc: convert obj_to_page() and zs_free() to use zsdesc Date: Thu, 30 Nov 2023 19:12:33 +0900 Message-Id: <20231130101242.2590384-13-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: BFF8E80019 X-Stat-Signature: u9ij9ysz4xccwrdhwmibrcbiutjxwtmh X-Rspam-User: X-HE-Tag: 1701339215-469366 X-HE-Meta: U2FsdGVkX18OuclU08mPvH7vV53qCnr+sjbIjPRctHPorTtRHBiGTx5sh2yfyfZJCCbFkHuPnZ0Lrqa2w4ODffhP9dxYrDtIIGzvoEH1s69wpymp1GQ+69tzZU+C/wXpkSzIfBoyQqghGK3nsbb18KdzV39yXb2lnoPgdI7gSfaepBOacucB6zY6U9/IXN2gj2wih9Rtz4IHE1nVfYY6+LhfUe0q5lzbp0/7CLzhqOab/68xpsoE+xsW3362PHIo9j9BEBZe2+ltkHWv9YbsRAL0mvdhNUayevp+FcLSNCkD3h+gB8i9vRkFrLHPgAQ11H/rqEWq0TG/NXFHU7jI7GQu4OQgwykkWAksK08F602GOlxQOAN07aosEl7e4cAvJjQjNhM5Mw1JfCeJ1vGf+Q5eF7loxFhK/Q8qq+IK484pwIQUIUEimL0UVfRH0cWk3CRnhp5bJG5dsHFSxMK/Jzxh1SLb9crFPxAVp2qcmsBME0gTqknDKCQdOLo1nkts4xb3Ud/0Lf5oWzlTVuAnsRFb/op48ZcnsxBCMQQRI2Nnf+VFliwwMO4X9Cqx3yPLJ5De6hCLVBWQH095cqvvYYPyP0xoV16MP36Cs/ISXy4AFcoyS8zSbJ/YI3CLZ4nY14OfewDJkoDqU16bA1iyxEybK4WQldsinT2r4UCwy6i/loOgxbb7QXXhQ2bhr/R2UlnLR5uvwE4TXPcZub400EU7VO5ED111E9Xojwk35qWbvN1hBU5CxUopFC9t5DxJkCIDkJ5oRv8XTeeZ2aAyGZFkXRNsgWBgmt7YvBdSbxlyoDF4ZvCfaFqIQpHn61mB1GdlFHDNufqe9bhGOowI4B8YKDZrk832bgKj/8bxbeWAtzdoqzFKaH9wRgVX8MAv57iSLPT/p6RXAIKJctIt9ebFzymIQZRgihM8CkiEJx00CvBsJGrgaVXlL8EJHzdz20I1aV2/gyBNOysiYJI 3JcUr/Vf xyfYEw4qtacAZcWjNQVF8WnpIFCTgjfstOgGv4khqzcAvn2HShtX68vuDYyktZkj3G6sNHPQH04KK3xOLrMyXJW8OoU+K1iXoBeUbXjieRFetGZjYtSW8jZ46Sq/tUoFrvFB/ugXGG0uAP0bae2l8mkaD4/FHOs0dTxzEvG8ew8rtfjCTgHIVfmCg2JkghVBZS0XnNO6rozlx5H1VFCsg2TOIQaPCN6Z+6UAAPuQhxdciXL8GFpMRp/AHlWPU5WwvUb5CuqJhVWzHwW9eEB2jZDLAyhl9jpAWu1qV4F68gyKR2blDwWticgOIMteJh7Ve/rT8h1DZ+40mU8ZYkqbqX3N05asYUGmltNDGPyz/bUb8eYj26uFHwwUSfSAmRKroUtrhdZWxMNapF0SX8PLF+U5ZI6zpTZJSJ1OWsUuCOPmjfWMTVH4/P0Ddfwy9mO0hvlhZ94I7Rv/4RJK+VxJj5ShDXHyc2A15JOyR8iF+S2CYDTfOU40gSa2eFKxxuSQA8IVVzRGX6jx3ywXRuPg/xn+Ja5BDkxf7oRtxEM+WCtmJ1XXLj0c1ydGaLIVOpebda+1OJmxYMjW6VJV7h0/UxUGZUA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001926, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Rename obj_to_page() to obj_to_zsdesc() and also convert it and 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 8fe934df298e..1140eefa3a1c 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -919,10 +919,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); } /** @@ -1597,7 +1597,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; @@ -1611,8 +1611,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 Nov 30 10:12: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: 13474210 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 62165C4167B for ; Thu, 30 Nov 2023 10:13:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0C778D0034; Thu, 30 Nov 2023 05:13:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E977D8D0001; Thu, 30 Nov 2023 05:13:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D34FA8D0034; Thu, 30 Nov 2023 05:13:40 -0500 (EST) 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 BE5118D0001 for ; Thu, 30 Nov 2023 05:13:40 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9B7D84010C for ; Thu, 30 Nov 2023 10:13:40 +0000 (UTC) X-FDA: 81514209000.13.94F976B Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf11.hostedemail.com (Postfix) with ESMTP id C2CDA40019 for ; Thu, 30 Nov 2023 10:13:38 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DHJcaNn2; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 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=1701339218; 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=eBuykPjz3vVnLwQWjGnbP2ZlQua+B81WA4wZj6NzF70=; b=7c3uOv9ZQP4eTHCFujEoD3V0xZ+vq9SiDk0YYbktil8dYYyiEgYirQpv5j4nDlDuXx4asl vYVie9hLfWfGWLQA9kCw+7zJAlWoyd9WF4X9cw/S99PyqgYuQeqoHtMrCS8/y2p2R5v0Ct 4tkB79wr+dAMKiep5DEP0YbBHI5/E/s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339218; a=rsa-sha256; cv=none; b=KxuOd1ZiunafA3Uu0qP8+Z4wXpLpZfR5DNOqza1svO+CSeC4+A+Oh2YDF8iE/fT88hJjDU DYoFvJldzrv1rvT1NqO/7WTy6H7OjRs0FgWZGupkkD4WfgFyVEgdAUom4aCe7yHSPCW/3g GIY22U3tcrbasITZY13wqyi+XbnIBX8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DHJcaNn2; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6cddb35ef8bso735723b3a.2 for ; Thu, 30 Nov 2023 02:13:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339218; x=1701944018; darn=kvack.org; 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=eBuykPjz3vVnLwQWjGnbP2ZlQua+B81WA4wZj6NzF70=; b=DHJcaNn23proWQOSU/FbyH5vjPekkHwMK7xUjwh3jpfdwVvURR9i4s6LJcVNEEw76V trzrwtdZujO2HynzJCLS7I6HpmohxRfDEqJtYFt+je10HQ7t7GA38zrPzbE1fH8CrtE1 ug+VdOrXq+EIW0/mESpLUu5KyC8ZXocMa1cQtmrxujVJUvQqBgESiE2hEZFyI2JqVYRS ufHEwpbN0S73oUgcx0xE1MCCacmMmVZtyA/IhrgcvzR+ow2rbI02MIpnWMtcgwwqf+JM 0B/ypFmqVqH+tGiAWQeaf2oz+o+STqDfxL2DpX+Re1sjQ23ocgsCg2pzotGrdHP0eGVV ZrUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339218; x=1701944018; 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=eBuykPjz3vVnLwQWjGnbP2ZlQua+B81WA4wZj6NzF70=; b=MthL1M+xoA0ly714cpmSrT/ajEnqppuCnibSEOmFpx4dQq0BTX695z1ZXgbeQWECOK k9846tIAJakDvlVslQnEoz3Dm4cPey5Jza65JvpkVzQ62L91yUpFkdH/AY2NK1bDEZNw vkw+XY6F1HhhBS/ih5+WOLy3dSvvEiCQhdrNnRXxcokkNdce3OBGAwRNBHbcGiO9Fn4s hMHOrGIiyqJOlRcd/6+Ucc+vdl0otdw2B03ImkBmSQObHsIU7lghv5QaqGjoqks6Fnwy eJWRu2oI1t59Sommq0YSKgqjZTJcTZoO0AjicHL898Q9so7YecN7cjWb8JOdSXbuOtmu Fltw== X-Gm-Message-State: AOJu0Yw/1nHAQ3hDOcoGheDyHBm+sxVK2mmoqTYuXrOz3wzi1xDIlXQf +4ZJ9FX4pIdGQVZeSEVIeVM= X-Google-Smtp-Source: AGHT+IGFtTtuoeoafGm6dGuoU67rcySjIsflHS/zx2u0oTttotwXEkWYyEw2eE/ntqH0Y6rJqY3NbQ== X-Received: by 2002:a05:6a00:1387:b0:6cb:67c3:9c6d with SMTP id t7-20020a056a00138700b006cb67c39c6dmr24263730pfg.25.1701339217645; Thu, 30 Nov 2023 02:13:37 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:36 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 13/21] mm/zsmalloc: convert reset_page() to reset_zsdesc() Date: Thu, 30 Nov 2023 19:12:34 +0900 Message-Id: <20231130101242.2590384-14-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C2CDA40019 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 9daug9idnydnsjuxdbcb4uyybkucwfds X-HE-Tag: 1701339218-144794 X-HE-Meta: U2FsdGVkX18fcKDOB3CF0UsY89OPkeK5NqsykuWYVvHWVbE2//0iIuSylEa+ErkltszkKHW+jRsnUIuhFWcl1FY9M+d7KXJ++9Y1p3DQHpoudOxA0b+k4uFnRXaHL9s8JEpjg9ThMMSKaKxXmENqW2HGDYGYomkjB1tOq1jQPhLiT6nQ9it4oU7A3HgtVayDAZ554gBxDUVHe5c9hkNHdyYC1CLI9GTwy+2kIAGrdApDx/UG/CccI9hOnSBhPMH78uLxg5r6SkIbn5ATTo6Y9jRdzkPlgtLeRhMHCnKk1EoA7Gzw0tXlpE4DmaeEEjOysbhHLStJGZ3wUml8RKaICXmUwdOERHyg1M+5yDQ4dccjjKjFghEq6vxIQ5ugsN3W4Fol5CY0WC9axiAnE2gkgxFrHc9z+ZV32CpzTx2QVaU3naGJNpFgtobTnprVnWJKs9wQExBzMPTKiPLZX4e+T9SdtRp9DC2w5Tz1GeWbzm9UbhAUuuC/rRnp9Cg8l5nyydhqbvyfctOxdIjpt9S+Nra04hGRnDeAiQXyjnGxH4IJD4wY80esPK5Q5as9ie2skCOLOa66gEqU+tMek93yuRFhhxQ0HU1IzJw4btt9Wl5QcYzgV5VwiCURusO0X88tEx5r1ia6le7yOsC5qFbIbZqCUyfXevDeOwBJW0zXe876igCV/DYtImfFv3miAUWlgdqK50QXTIniByaMl62OX43DXWUfMENuI+hwklAeetnrSFOLbIBvJqGY8SZPR9kZik2g7mdr08YQritLrcXm98R9tb2kbcX3Fs08aB6gvs4A8YfoLLR5NiMmakIaarhQS4T1GRREH2R+9gSzVE1oGUP1fwKdjxfrVS3GgEZwuqQg2byt4VR16neF9ikyNM564uL9bZvItdQSCTt5cU2vhJ2fqRnsHn2owcIZyEZUZpT2wOltogKUangiLPwm4oXf7V5dC6InGAAROHeER+b vsaJIFfL c093+dMoxBvwcRRMUS7GusTJuT3/cYpesu2Hgh+9OK+TuPZgcF5xDl8ZofHnu9tkQSSiTKeWRZhZ2o4MIeZFlfm7hvQbPezqk21YAccx2IqZYsIfBXuWYquk7pb8J5U0H3WK5X+7nv9VvFTog8T2JyLoA4YtyadsMKbzUp5Wrn15TLoZr95BfMwk0+f9roPugp7AKEhJlyyF24xi9btbTO+PEe46wQ0hhk8IbzQmcKvD9uAOgljrM0MrIMm04BwrOXHNgXxkq81tjK2csDQTggcG1uGoMP0cIMlrtaXlQIhM1XySWkDf+Xhzc+ncVDw80YMHEonqjF+JoByQcR3aZo9xCVti7t0bzeNik/1OXgVzVJtf92CzS1ozF0Tav/ziRegMQ9TK3U5RsaG+y16D0cXyJ5BJWZp2pU8gLael5LcyfXS+10xiL5kcYc+oCNAQhGQnVP1kmGhp2oMDAy0wsxUy8iwR+243MTn/hLnYjYwBkQ6XLFRiOxKozXtAPVthQ5u0ws13sraqpBcgHu9cH4k41Ir8obv8oxcyPDFExxYnxbgOqX2Jri0O346QRrV1WAMLWLbgjT4Iu7AN2Q24iJKMmqA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 1140eefa3a1c..1252120c28bc 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -369,6 +369,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; +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -966,15 +977,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; @@ -1014,7 +1016,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); @@ -2022,7 +2024,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 Nov 30 10:12: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: 13474211 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 1FFC1C4167B for ; Thu, 30 Nov 2023 10:13:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A51658D0035; Thu, 30 Nov 2023 05:13:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D8DC8D0001; Thu, 30 Nov 2023 05:13:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82B1B8D0035; Thu, 30 Nov 2023 05:13:43 -0500 (EST) 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 673D38D0001 for ; Thu, 30 Nov 2023 05:13:43 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 47B8114014A for ; Thu, 30 Nov 2023 10:13:43 +0000 (UTC) X-FDA: 81514209126.15.B16FEE0 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) by imf11.hostedemail.com (Postfix) with ESMTP id 7252240011 for ; Thu, 30 Nov 2023 10:13:41 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W6SMhXpF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.43 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=1701339221; 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=/e5l2dXqHayaHruWo9RQrUpw6Q1W4wtar29KNaAiiUA=; b=zWMJWkSnGnAcCW2yoXKYdyPabKMO0AgUi2Ioh3+1Ao8n2m4pQcGjQq6opGSonFNcNmckfY kaqkXB+vtrSFq4/SMiOLUXmEufD1R7c5pRA90WsA5MEcEPnMfURU1+R+EQ+I5d3FINYgUf KGlM17j9X3G6JrrKNy9nru1izXPxIII= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=W6SMhXpF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.43 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339221; a=rsa-sha256; cv=none; b=lmGY4JtoWBCP6l68lAiXuGZ8LEqT+v2WeYVt+Ins0JZ6jY8yI8xNM4t5aGnT728srXMznE 8CrlU8EqMuiebwxclePcJVlTkDktWSv/Xc79GC1k4uV6JlCDod77Bo6lhE9qT+gkw78L+G XqVdGJm6Usmx3R5k/H3q/uGeqvZf1UE= Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-6d80245b6easo447530a34.0 for ; Thu, 30 Nov 2023 02:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339220; x=1701944020; darn=kvack.org; 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=/e5l2dXqHayaHruWo9RQrUpw6Q1W4wtar29KNaAiiUA=; b=W6SMhXpFtPGhwoSMNu0uFc5UlHPeqtSIcr76by8qCPJw+bfp2PgxIP5+rarmVw81AS Me/7DVh0FbzonCbxxHNO6tP1ppYuY0lzyLfp8ow+fzsahQUF/eL/u38pXiiP/nwbBh51 ejRlMGKE4uwcjqt4qECgNPIQcrKOcVQqHO84eo/apSsg8oAfISta6/5B3L1uj46GV/rQ UfZwTWvuwYk9c+S1aLrEwJcJIpfsyoNXbmQuFczHpcVe6z/JO5PmVHSmaJsp8JRpzL3f 1KnWwIC+TS0DkdM2Z2qQd8Y35M2//0/v5Ghbc3/0/xcYfPc/t9jhAv+wmeP43+m1GBZQ V8XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339220; x=1701944020; 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=/e5l2dXqHayaHruWo9RQrUpw6Q1W4wtar29KNaAiiUA=; b=YVc1pU0VSQy5Frj1Q2SFmm/1ZwIRfLI/YxtKPsF5GrA8ZQdmmPrT3vzX4Zf751kQRu dfJrZY78/IfPHFPpQnA/CT2XcViUpSfWQFuJYrrlPUKTHrEOCde5Ob1GHdKTYn7kinvP sXlARrD0Lyj05e7fPjqWj4TWwK5IkiVJvco1FgXRArMshnBb2Yq2qoYOvoggL7QyBvLo BgTocAUkRjaFf4eaDOSkgJVV0dzIRekcYuqLq766kkRm2/plpLeeqrR3GbChFMbLgUWo 4pD5SvvhQDMi4KGVi+MdrYfHDWTjI+AiBSvmrEDbKPitjYHMICuVs6Tfpz97JTVoTOiE fEqQ== X-Gm-Message-State: AOJu0YwK7/MWtQUhw5mCLkN+b9Vr1Yi98XCSNkPoYHRlD/k1d+tzNI2R oaZ/9R8BYXmYj9bueiwRE+Q= X-Google-Smtp-Source: AGHT+IETR1NlufdrUSgFJMvtG+dAI87A/6d57BBFerzgb4wtwONV1yX1F5zTgjOb5u/gK+LOby/JvQ== X-Received: by 2002:a05:6870:6245:b0:1e9:96c6:e04c with SMTP id r5-20020a056870624500b001e996c6e04cmr23707871oak.32.1701339220482; Thu, 30 Nov 2023 02:13:40 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:39 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 14/21] mm/zsmalloc: convert zs_page_{isolate,migrate,putback} to use zsdesc Date: Thu, 30 Nov 2023 19:12:35 +0900 Message-Id: <20231130101242.2590384-15-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7252240011 X-Stat-Signature: znt6qfnhw8czmmrc9nyatgmjxgdec7z3 X-HE-Tag: 1701339221-793348 X-HE-Meta: U2FsdGVkX18UCxScXOU2+pupBEDJhpX6mkEzgdRHGPmHSxyNPCdMqgVDvm4Kwa+dEUpJqODqoFEAO8pTHCNbdDpIX5BWRDWKuIvwwzfGu6zrzyuKjUuXLuR70ZmNC4pIZn+CE3pyca7rajkiMFYRZ9jR+8DioHm3kKFv0EnHDBsVJh60Sg9tbMDhlQfHqPw7CM1ohKsYyiaNOwgpRUIQJCiUPuiYEYy1FenEQAMTBwFpvy2oMHg+tboQqkDm1+mZvBhicdhf7WJCIweem6EbN3JpHdq6c1zNeqOo+f4tj1XSQoaE7qvx15+C6wOH7GRvLDyFaD6rcbh8/ZnhrEwskrSPS/As9VNGdLiW3fjrN47REOLuP2g1oQZHkrTASiYxISKK08ZDG0DT06PMquUR/EfqWE5ZivUw/XPn33e5/ciXsKNttrDKQ40lrT1TgFHsZuIgKLJRTExv5cgqMowgFmI14Zar1MnL4FOcLhd6zSoCI2T9dglFFaHjXnvnwLnlj5nul6Dbn5jcOHcdD6Yrb23dOAUfmQKB7qQmm6mvKXa9Egfjh0gAXdtt69hDgJJRLo22rGPSeTK/KCBU+T8P97nEBJ4FtoNZ8EfS5RR5aIXD4fi7nS1/ADuBF+BLVf4mo1QJn30TMdF+1rP+LtlBOzG1RYkh9g3MtOsRB2cMp0kzC/1sMaXUgP7+Fub92Mlq4kbyROH2tFu0oq6/+Hw3S+2FNzfpIX8zzjN+BfnkMAHyukWa9BcXB4IKcRpHtNbwyC6C7pFAs77pi23fAH1vIV4lWO1CWXiJu34KnnT6vcIooe8I4rV5weApv1RVzbM49vDL8KXw3aPprw34aHC26U1LRauWtgur82G1KVa6pR7naxtlvFA1gBuAwOPhtEENtRFjQRR3+MDCV8d3YT5PNUX+yFIpigfFbcKIhM3p40MzIa+4DA8CthvJAoyBvvr7VSMYjDrVGCJPGAuJNxm lXXLZDZU nHpyJrfPYpH3JGN8ZhVWoK2GMTLH2VPc1FdDs6WHKAJKTGH6QgJblA9My+BQC9ejLfF1/LyxIptCpTgE/dkS15SMZUJdtX5yRymQNbASfoCdGp/kx3qrwC9fEGbV7bhCWrCXQOl+grxKtWCIdRCYAZxK7mMf20Hx7HoG3MhY3+fpuEehBg2StJZI0LzGxjjG7Zfg7vhfx+5TN94TyzCvLoMAEZk+HGE4u4BocfRO1f8+TKgalJe3A+OAheDwt5D+06W9T9dJZWVND4aAidSoEYJHbX0oP0r87rgiIwevYH6R0DQgGh13/1Q4Y2oZ9do6zBvSfKo3+6uKAD2yqTShjGMEckeCCk6Wm52PKME+t5/UHPNplRiUzKPoA+Xuby0OJqlCqD4MhL/Cgg9EpyUoBLVky6bqLOPRdAEJDsl8FkXqKn3Dd+SMcrtzQMo9hxAHEwnAhhftRPBJN+FV2pXE9jA669Jt5RnJKNmSfOjUlLD/K0KIaAMyX3tdSe9KXuDJOzuoH1NrQgouQ+h++U9UPKQ+Y+ZaNg8L7ceCIvePdGNPCtPOktoKiXCltd1JkzLUwPey4R5GjU7y2Ek+PiwTO51/TQQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 1252120c28bc..92641a3b2d98 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -380,6 +380,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)); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -1933,14 +1943,15 @@ static bool zs_page_isolate(struct page *page, isolate_mode_t mode) { struct zs_pool *pool; 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)); pool = zspage->pool; spin_lock(&pool->lock); inc_zspage_isolation(zspage); @@ -1956,6 +1967,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; @@ -1970,10 +1983,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; /* @@ -1986,30 +1999,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); copy_page(d_addr, s_addr); 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); dec_zspage_isolation(zspage); /* * Since we complete the data copy and set up new zspage structure, @@ -2018,14 +2031,14 @@ static int zs_page_migrate(struct page *newpage, struct page *page, spin_unlock(&pool->lock); 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; } @@ -2034,10 +2047,11 @@ static void zs_page_putback(struct page *page) { struct zs_pool *pool; 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)); pool = zspage->pool; spin_lock(&pool->lock); dec_zspage_isolation(zspage); From patchwork Thu Nov 30 10:12: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: 13474212 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 A32D5C4167B for ; Thu, 30 Nov 2023 10:13:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3244E8D0036; Thu, 30 Nov 2023 05:13:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D3BC8D0001; Thu, 30 Nov 2023 05:13:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14E2F8D0036; Thu, 30 Nov 2023 05:13:47 -0500 (EST) 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 EA7B58D0001 for ; Thu, 30 Nov 2023 05:13:46 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 87A2516015E for ; Thu, 30 Nov 2023 10:13:46 +0000 (UTC) X-FDA: 81514209252.13.D15C304 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf05.hostedemail.com (Postfix) with ESMTP id BDBFE100013 for ; Thu, 30 Nov 2023 10:13:44 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OKGFBr62; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 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=1701339224; 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=6s4/GinPwmjXp8PbuqsM/ouukWTYhIWhNNDkfCgacts=; b=7n4pDqKDGQLNHI10vfGl/gvLe7DfudWLSOkPAWKWQCUwek24+c8bzkP8VnAAmNBKxhtKk/ rOBxvAf2lqXcjPlPDi1MovmJO4stCUA+/YsjTU6668Gme7qJcB2uKtdNh0KCPzc30oHzll cQYe2biOCiqLZgyou1m8N9s6Wt5QhOc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339224; a=rsa-sha256; cv=none; b=HiwWfGErTy/t1qHPx58lvI6AN9SPx0nkSSXwHyducfvi8D1CFMlNhfXY6ivLx/0akVtVu1 7g7+Xv6seV6f5fFW+HMy5vB/8f+7zVdnS4ofELiL+OkM0F9tQBzpKypZROczl1dxSJJ7SF F2MEJe7yG0FI/3IuuhecxKhUPl4Q3T8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OKGFBr62; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6cbe6d514cdso706047b3a.1 for ; Thu, 30 Nov 2023 02:13:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339223; x=1701944023; darn=kvack.org; 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=6s4/GinPwmjXp8PbuqsM/ouukWTYhIWhNNDkfCgacts=; b=OKGFBr62hvNvtGA4bfdU60htw1yqPj8KfWzUF4uN/CQNni3rEffTMe9aDp+EO3oi/b cgb+OqY8/xL+FYUyPLpHIhd09OGEBeRLPG+KjseeZLICWqEHo0C/nED3pcdB38VwcryR pESH3osJiTZa4Lwws5WHefjbOXGSypm6W4p5zgbKWTTzCZ5M++Z2Y4Cxp928+xNSXCiU WlhDYmtE1qsA2qHA9HV3FXh3jdA4n348kivTE/S8Ki59yx98cLQgm0iOAGCJWLvgqO7r IlA+hHuheKxp1RTM/ZN4r8vKQPX0yHUouz8BkZE4WyS4jh0XztkSGS1trM2Ckek2gJmO Jsvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339223; x=1701944023; 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=6s4/GinPwmjXp8PbuqsM/ouukWTYhIWhNNDkfCgacts=; b=fdlM4ex2luOyzcurNsBBpwCaoB/EkVhV46eRbgfTaRNdR4xgFsSo9UJ2vjnwANvNeP hKjFrt+I7T+l5hxT4KtoiKCyILmNrSOVU4/l7qybhCnCAlryDNV82bgzhhhEdXl/LR1a vlV/iQ6exLl8+jaGXGoQKX2YyJcJOMUgGVn6QpjQZtuEbYL8AXip0Nrh6toxcLg6O0xn i6HR2BldCckAnhJaPAupEiTqiDl8grt+cpEBUhuas+1EmA7EZi1zDApRo6kAs25YVb6S jfhqQjbW72yqPO1Q9qYqiR2jeH1rrfdKKD6mQw0IV++ruKEBy5FuRrrlNb8Ar6vicFtV +wWw== X-Gm-Message-State: AOJu0YyOywo6vVZSLf3GavxW65uRZIVKVyCuA0WIXepDMoFxPnZPOHAB rcXvKhv6PSnxpsaKSQbhE5w= X-Google-Smtp-Source: AGHT+IGErMaw7pLwEkQPvsLeicTbR+t/oVEeqeV0rqcgbCDfrSFfgzMQ2nl0OvW/1207sCLUvGeYaw== X-Received: by 2002:a05:6a00:1496:b0:6cb:4d36:5d07 with SMTP id v22-20020a056a00149600b006cb4d365d07mr20752770pfu.10.1701339223391; Thu, 30 Nov 2023 02:13:43 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:42 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 15/21] mm/zsmalloc: convert __free_zspage() to use zsdesc Date: Thu, 30 Nov 2023 19:12:36 +0900 Message-Id: <20231130101242.2590384-16-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Stat-Signature: yxzzf8o4t6d6yk694aasokq7318p96qh X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BDBFE100013 X-Rspam-User: X-HE-Tag: 1701339224-581968 X-HE-Meta: U2FsdGVkX18k/AM+bzHx6+LZ/wEgbxbMoX7ns4qztZZCOMcsKTkZvy4w2GgvR29AgmzOwDK0t5JNBAqcNMYAsxXVNI+teyrTEk8vlxSEBQCEkV+2VqTzsfl0FBxPhbI4hcwFa4kejanA9d0F5LCIdhzSN1jpwg1/XZBZB/kv6xd1/kefGpAcog/Kct+aVGFpIzEkjFo8huxNGW6rjU7hIhd+WAK7ITETwBu4YL+GsTsSlyy8YPfcYGwBq+oW4Wy23S1F9rn8GQGYcumKYQR4X8FxXxC6+c9YH59xSld72JW5u8vip4CJY/l3o0gOs2PDMrw9Lqp6+4k/5lApoll/tN4mqjPPOQxZHn6ybGvA4e68U5MTcvG/3c7BtwGBerH7guPLwiwk02Xl36sd2iIwEcSH8YclF/O9vxa5XUrq9a/RyuFpn7EgysjA4xr3trigDct/Pjr6dg4Qv8K77Ja80QfI4ZR/965N9sefDAWln29Kemr66Sr1rNJHvyYfiBLNB1exMX3z0i+llxFC4288Mi7HwKvYc/BW7TmmiIzWOzZV5wIlsUkdCvg5j6mBJrftRjGI/OuRYk66maMgLpgZYBMROKA4JHkbdDJ69GvymarcRUvglFgfWMtE7c4aNM92f/0EV85sQhxQ4biO7TXLanQUTPvqX+pE0FGYVU/aUi9AZE6kmeStkmNdfMfneJi6SuHOILCk+0HdeLdXffZh4hzfyTRBvunGoXSS7meLWu2mXCfUcncKGUSjlTkFN0TNtlVsb1U1fVJUcHTq8UdIaWoW17CSh/Qhx3/0zFQ8b2DyLQW8ZKlhr580EgR6WTlWpUqH+DwAhP1CM0MPrJpGXbLYlwiz14AV+6fvGuEMM4VwrISy9P9lylNL9FXSEUe1Rbmo+Wre8fjCFjfQf7lOr0+fVIXmCH80e35DhwbB4gIFe4I4HkNQrjS/nINzVKHvhtoixIM2eRYSwdXhPXx wpEOV0Ze KeJauk7P/qo4oq7t+sMRGqoSTcIOnjS5Jg3soVKwQ81rPZBmWP5jxZ0Pv4ReIgi6/Nf+Vc/ipPUSTdT5IpmZEAWfqr+YA5EgYEQF0yJd6QnknBNn1Z/jSoZb0QpNL1grwLjhXD+PZ/tKtqO90vUI8tLmFQoUA5T4WYpHQa+wU2w4LiNZoOGAgW2VZkqHsdzw17HVGBcztWjcAeElUeYpXeiUY/0a+WzcLUk8HijCPSBw8bBOFmyPjJ7dcH7aOwaO4LhJFI+/Nk7+ygKk7IQsWNWoY1GeYsbThyeVYhQADomW4LnIDsEIvCTUmnoImplzZTjv+Sc2qnoauu0Q279Konuau6N/tfwcyapSQkdvMpuNkzOrXVI+00pG4J/BKRg8xM5uVjgg15AdkL8ZPo90up/x4c/lisLeuasbIsgj3kOBnNZ4sqGcAoIWl1QgKcQDY8sGLyq80gF3WRvoN8vcwC5ldt+I5uaWlI7DDxSzerzInJ8CRVM8Dczpk28qx5AblVUiK3/+4WBOjlOgaKPSyJkoxnEl4wJaMG30T8pp6Dhc5CxwW5Ifqn7e6OpiPu4l384xqzvVTuKGD+wfms8xCsqbk9A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000020, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 92641a3b2d98..fdcc47569644 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -317,6 +317,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)); @@ -1011,7 +1016,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; @@ -1022,16 +1027,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 Nov 30 10:12:37 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: 13474213 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 22A84C4167B for ; Thu, 30 Nov 2023 10:13:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A769F8D0037; Thu, 30 Nov 2023 05:13:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DB548D0001; Thu, 30 Nov 2023 05:13:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85E0D8D0037; Thu, 30 Nov 2023 05:13:49 -0500 (EST) 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 707E88D0001 for ; Thu, 30 Nov 2023 05:13:49 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 456B280179 for ; Thu, 30 Nov 2023 10:13:49 +0000 (UTC) X-FDA: 81514209378.15.8335B2B Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by imf17.hostedemail.com (Postfix) with ESMTP id 3A0B340020 for ; Thu, 30 Nov 2023 10:13:47 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P+byPcYL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.45 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=1701339227; 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=ZL22QKK4nXxVYgGVD7neKWpp8x2kVRHfKcr5jDKusDg=; b=4z8O9c7rumlcFvUE7reDx4eLcAXIdWDJjX/SEZ1YdIgcHIcpcEVS/4dh3QEXKdcV0RMGKW Kspd0xe31RhMIQvM4tlaGB2CjnFL1n24WuQ3NTtvJstXh/k/SQp2TGn/zrCSc5phOVrG2y PxsXEg9bkR+5n0uXyuTlb/sqHTBziik= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P+byPcYL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.45 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339227; a=rsa-sha256; cv=none; b=AZF9/9Ze85qcRaGo9iGJsVNTZp6yHmgVERzajBeofHryBb7grtJKHVajWBVyNm723DCZQv o16Ul9e0hQTLuCud+k8XXJnrDhzXwpEMnT00IO1fpw8dZsWLGfeQBYVFEAkIWouFs18MbP 7qOO/QyGFahzkiDWauFOz5Q1TQQpoD4= Received: by mail-ot1-f45.google.com with SMTP id 46e09a7af769-6d7fc4661faso440717a34.3 for ; Thu, 30 Nov 2023 02:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339226; x=1701944026; darn=kvack.org; 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=ZL22QKK4nXxVYgGVD7neKWpp8x2kVRHfKcr5jDKusDg=; b=P+byPcYLWw/TYPQuCMt1PWQ5ASFazjMEptCQbWFIkqO9neJw+lqh+abX/QJIipKyzS W1DWxhfRel66PcrNM5uN2aQceTT+jLCJImzKpyviH9qgwER1UNmvaNI5RP8h6yG94SKh ivOXh3gQlAglT1LlClJ6aV7FZVu4LFS29y2OGztA91io04W6hqPiFen2Hz+lXMmZTjL+ hK5GxALhixBWLj86oK2DxJSxfCa6wChG67USEL6NfGaxIUsJtkvdyv6j2Iza/xij5vSg 9PKjBwj4zVapT/rBkjkrTp2z5kMsAnkQ7YBqIfVSf7DNoD/G/f7lOT5M4x9K5J5aS+6F qlnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339226; x=1701944026; 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=ZL22QKK4nXxVYgGVD7neKWpp8x2kVRHfKcr5jDKusDg=; b=cV8rsnZvB1sERX1070d7SjVxQd/zyzqv3Dq2/cjB0krWEDn72bAeS7hp5X8R3mvAdg r9hw4aEhI9xUImqAveE7hH3Cpi+Gh2YO3UIx40vVT4/oSg7J4xlZyPHmH7FahDs8iZGO QczuBzle+robT2k9ToDqlfQziZMdrWNLhF4/U/6Z6Hm1SGM6/+YWpdauHEpqJf5i3Fh4 fLUmifnrkh2BfIY4I+//4AQ64Ab1tVculne6IB8VO5wcTnMnydr2IG27u8zxQY1r8hnh AJYmIIImaJUWIpJtajQN8bYtZINrgaty5wDWr03NGyQy3zsFHwh8dvtc0OREqduNaW0T ZArw== X-Gm-Message-State: AOJu0Ywhzb238rJjHaBJK59mpTCDQRRJ//3/HeVn/aVXPqVwfwpljBCr gKnuhIYsg7ahBuMpeVSC1tY= X-Google-Smtp-Source: AGHT+IH5M77JymonPDY3XhsdbxOK2PjjaHZPKLSVAv5L1xsSrPqO0yeVzHbJ2hgDEgEm3O7rKd0f5g== X-Received: by 2002:a05:6870:75c9:b0:1f9:9003:4164 with SMTP id de9-20020a05687075c900b001f990034164mr27306992oab.35.1701339226256; Thu, 30 Nov 2023 02:13:46 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:45 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 16/21] mm/zsmalloc: convert location_to_obj() to use zsdesc Date: Thu, 30 Nov 2023 19:12:37 +0900 Message-Id: <20231130101242.2590384-17-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3A0B340020 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: gitfn3yxw3hp4pf4gc6qx1kayb3gao9x X-HE-Tag: 1701339227-795279 X-HE-Meta: U2FsdGVkX196z3T10V2+3kQ8qe4krE8L2l2+UU7mIPx7TEw2/HjVYdYAPGZ79UQvni+UVH+j1J41n3Xz+tpNTM2Tqh1eqVNxh1cuMSPUqSogoDyulQt98I6U15udkQ1DjZEQmIw8FIVxb6TFmyU82AQOq6qYOZO5xY/wRvq0HKXeW60gOhbnsQYPu51uu00gvL63vru2mHFC6Mo6HVLq5BOHUvMgTlQ7b0foiuxb6pHrSS31rqt1BLgk5geejhIb/jkJ8O5AZu9bmB74V5rwsgPzoJbylpEXzjAdKCfALg7jgaYPou4C7Z14nzNqdJ+AVpdBbJrx/AvFh7cFuSuHW32SB1Khc60GtycdabvvIukiTo4jMeBDlftB8w8Nmggkiqtk5GGhUyvoX2oIDqRSfl8NRYXAXM8qZuT5eeK8EnIy7K7upU+ZUfFUe46EhXrdCWnCnBzfcxyFzVUylGGls8tmCqvsIIJk+y32uvtFPZvzRA5HN3skqoHoeT6lf3m/ZV6wP4j+1+OZmFyzn0VBWOY9qBImiuWH1f52xlSZa/s3I3xjYHzyCo7bkYy/w1GtrU0xOrkwJgvzYWEp4QCsMyYtGCEIULU7kIXoB4GQVJESln8eAS34I4febwPoThaTZsAW3OYuMSbMdgd+hTR+3IQkujwOdezKH3eOv7kFUQRyQjOJHuMlWAmnht3cHbR6D4FMxHJQTomNnJLVVR1GQJ1VJDGTXMAcabaOvU0We0Q8beqacg+WQSMFPsUWwlrI1l6htuOXRTvcPorwJdMyhJEPOXm9EQFLPaOxKKOdtr32QUi4czxkgAnjnhMIiD0TSWa9dy9WBL9zzdOQJB6qWIHz2Clw8KOWZL89yp4YWd6XpXIeKolLwNnzMMijoKb1qN5SbV4A8s5fnjL7P99ArgqNJ9ArPoAfi2kN6Ize/ziorpC1XVH5JdAS3NAXnFwXHb8C5FyOTHdgB77N6cE zZg8DF2H qRq+qPiisKY9fT/p+udQpckof7sGZ3pTtSQElJe57n56MMMmwkoC5LO3aip9JIQIyrPAnZSDr5/nrRJamLe3xuCCGQrtlNz9xhkVYVR5Td7BenaQyseceqEjjAiGEiw0BLuclerhRrzirSpfc3SPsn5V/Z4rxDKici7/QnFDjasclgIRED9kwyk0iH1ySD3v/6IUZOkeksboXz6R3YA8mPr7b2ssk+VNgqffhUYKas1a+XRyJPAykQKJciejI03XRAFldF5MGo8tuy0eE+rwfmQKy63qaf3J2DHMSBEPwqBjKOHViNmSVzVKNeicFl0W91m4R/8FxOgn0p9csSnOI9ZdFh0qWIFurv3RynpuSPgwc6gfMJ5LiIfpiXPkIjIibVCwxzDQ7I4F+ooRgm4ubBibmCwzhTd19JFc9aKqHJ1WgAw1jNQ4nxibKsXO5vkePPh8RMGESQFr4ChJTp3KznVxPRlYuLsdOIJPvgIgUzqFwBK9SjJa4y44xYaq8c7S3hcRxHneSKv1/4jxDW3yXRKXIlNfik5bM+9xpBnNUNrgeGUBDk6sghvLJqEM88dChcKkUhYIhBiJM3AwcLcq18KyTyQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 fdcc47569644..317bb0e8939a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -952,15 +952,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: 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; @@ -1509,7 +1509,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; } @@ -2020,7 +2020,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 Nov 30 10:12:38 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: 13474214 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 1327EC4167B for ; Thu, 30 Nov 2023 10:13:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2A968D0038; Thu, 30 Nov 2023 05:13:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DB6D8D0001; Thu, 30 Nov 2023 05:13:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7DEE48D0038; Thu, 30 Nov 2023 05:13:52 -0500 (EST) 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 6A1D48D0001 for ; Thu, 30 Nov 2023 05:13:52 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 40B7D1C0081 for ; Thu, 30 Nov 2023 10:13:52 +0000 (UTC) X-FDA: 81514209504.23.BDC22EE Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf01.hostedemail.com (Postfix) with ESMTP id 702B440015 for ; Thu, 30 Nov 2023 10:13:50 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FswxOfwq; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.173 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=1701339230; 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=jy9auwkflPmOczZw4Ui3jCyKMI56Rp84VrWiQ/DbUxk=; b=r1p8ExhdOUBGG8SU59dznbATe+d1Qpq6sxBRXJbYH5jb0BULnCQrHGaFIG+QtmhquDcA9M Q7b40LIPQ1ov12ULYm5M9ygBufs20GU3XhXiovLxs9XfYUIysJI4f/tEWXw+20sAlG9/Fe xUYgS3YjjSe/iSxNBj8JsHQjTq/fhcs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339230; a=rsa-sha256; cv=none; b=pgj+wZI5vtx4cmHCIhSrwh3uidfFKYO8rgQWrqrE+t8pXRxgnScTI8UVOsC15G/o7RIVWE uuAOsxMw0NoEFPSVw1gL6ACCe3vZk7rIMk0nhvVNpIr6XKb9LTEC9Bq4fMm/OE7HCHGrW6 KRzbSHHlw/SfK+bEdhPabcKW8OspCYQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=FswxOfwq; spf=pass (imf01.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6c3363a2b93so704062b3a.3 for ; Thu, 30 Nov 2023 02:13:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339229; x=1701944029; darn=kvack.org; 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=jy9auwkflPmOczZw4Ui3jCyKMI56Rp84VrWiQ/DbUxk=; b=FswxOfwqjQvyTS2IaZaxU140jBJwxVoq2RScBGsHWZs/loFdS3LTm/riFea9Ri5ha6 in16UaTdl7B02lPmS6AA+1OzGyaIfWdiOa4uAV/9++xt42CSOtGLDc+wa+1erUi3gH8Y PojWZU9MeGPZoIhHAlwuzv7CiC4keistO4xfqNnC7XSij5yhdmND7m7CR8acojItTeIa v+qgTs7/NnCOzU1mXv4Jrnd/48yJ/HP5wi3arpQEzHyP9GM96heNWD6a8OHHeTfD/eAc uteh8K0JA3aukXpmxZRicyZwCiMaReo23zh0Wdzr5fnkB4yS6k5+7XHy41L/4PqnZiHo LcTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339229; x=1701944029; 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=jy9auwkflPmOczZw4Ui3jCyKMI56Rp84VrWiQ/DbUxk=; b=wmVNtQhkbvj9j4VDS+QeYRNO2LdDi8eFfFFzfcY0SIIQgy0XIwpwYoFqX4FIBDko8j 3/slvpARkcakA0OUDEabcu77TVvDxMpo/WExFxXRTZ9Eo6CPbp+PdbgyC92YgsT2bMzr 0iZZ2dK8icaoNqpA3SzN3fXzFDim/hgOTSsntQ65MLcJmPDNq7hjUZ/muCuElSB9Bc25 mGF/nTmQD0UDq8L2NSKL5Ihbta55nhyduWeqn5fFlrEjKJQu/8DTBzCdVtxm6MOZ5Uit l8K8jgFk17noBAqSbMsD8PuIaN6UaXTILdDanUPlQTKaQwzBSeOG7aQPeCrKaER28YUZ d5Vw== X-Gm-Message-State: AOJu0Yy3/M6PABY5v4nrj5LFgoWnYM47YsudaWxVIFv7pevKskZfiElq Z2vAYNqGDofA9njSjfoHLv0= X-Google-Smtp-Source: AGHT+IHL6Jh3rlmAl49NW8CXnxehlfI60yhGcQ5hvU58pJRbDpI+sx+Y+pUqIea6TG2ydnUmae+ofA== X-Received: by 2002:a05:6a00:6c8f:b0:6cd:dc54:f757 with SMTP id jc15-20020a056a006c8f00b006cddc54f757mr3755498pfb.24.1701339229280; Thu, 30 Nov 2023 02:13:49 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:48 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 17/21] mm/zsmalloc: convert migrate_zspage() to use zsdesc Date: Thu, 30 Nov 2023 19:12:38 +0900 Message-Id: <20231130101242.2590384-18-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 702B440015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3pj5peaiqn6d5azy5ni6m3tz7w4e4pnn X-HE-Tag: 1701339230-740266 X-HE-Meta: U2FsdGVkX1/sBpblbeW2Eb1WubydSisBAzNL814HU1VAJq0BtZmtoz+C+z73YgpXTDiP3XRmJGRPC1NgZARWlV2NW7mA5CwkgT6LnRIrKWnU613nqEzkD4fjUnvqLDUYpv2GPjCSzdVhnYzWiI4F9xIDM/Ssg/O9PymJZxBJvbcGwCqQhcDU6AazmJac0Juvj8gKs4cKfnmV5wBD/MnsZ6xMarPsKjOAIOTxatgSMVgCiLiWbkqrF0NHWW9qfftpewqfS7lj00pa45hfBs+bCZVM/RXxe8sf8QnKx7uBuAoWoXXZ8hT2WLwjxUFgCHLbmDCC5Wu4ne44qproE6sZ/lwVBSBuWwTmFMGy0i2FQLPTetpFLdXucvjpi92/XZ9l9PEJlx5nYRaJiwAeicI7DYBnzw5R6rIurzCxcxwiDhOjho6rJ2xQjdftlj85xHlTT9GOPXFTAojIli6WCT7+51/Jk5d/8e8XZKdrLdKCmihRm56id+iNKxcSeoz9tU4Wmv/ibYHgSW7DTkvuPlOesmr9gf7ZecpnPmmhF40qTknGg0KkHXbGk2hR3beMqwTJ+OyAg4NOFJbhOfKrXmh1dykLn7EHPY0VtDdSvdUPHexhD0AlccnsaM286KufcgZCAOvOBeYBxhV5pFlZaRtA6nFPEmszKmzkmsZW6pwfZO3PGlBDCMy9pjPw+/q/YhpeYvTeugwiwthGTW2dfeHiPL51RkmoEP/PSvWRYhBU8KTyaXG1aGTD1NfB1agRVoiUkOQZfZwTBIdeoVNFFsYSHrnQn0UyIr7Owhh3kJ0D7bdOjlOU/OldyJ7X+IaUIME4fb0/YoOG+FrcCg9RsuCC7b7i+eAG8Oi6L+OenzIHiBFuv3bAzbmnrbM7ZjBWprkmyqlhXB3D8KnRBdOy1wyFHIKUTfSdJ3zB8lMaxZdryypWHU0JuTX3nT/pKbt3UjBpIe/iZXMDbCqEx/aU5mi XkayHVm1 7qAy93ZglS4fxBnNVn7xo7hjx4Da7o2sG+Png3qe3ZKuUT6rqxkRJDgVe1I7hyUs/LVHTn6NcNGt0ZMSUtOFuaaTtDf9UOPLUlWWQnY1zrq7c5kAG/ohriIz01ydjhQzVFlX01zF8oDEflxrGcM/AZP5pG7v59RNjtDrdTQOd8D3rIvt1tNbm1K9NOg2U+CeKNrpenIWk53YMNRwvTmdb98sBTSv9kDHL3yaHbikcrgNG+5bkG36fzbhn1HcTqMNExHTKXQlOIGrZnwy6fxJ9R8Q1IS9KLs6WYjXOqQq2qs+0YIb7/3/XDSi62C9LWlydLHuyU7VE8uAs0d5Sz4CnvcKXZj4aI3QyqkClJfM81ByKifDkR7y8/EGjQr/jXTE/cfEUL5ZFlIDC2AibIortFfUR7plzBzIdoHiZTNGfi865r/16j/cJXt05jjI211ixFSqhGtOiT7SJnxr6sWjmZg6exz+udDGvRVmkIQn0LXX4h5PEZpC4jesQdM6y91qy4Vt7Cf6hhAdkec0AA8JD8xc9BIte52wWRrltFL1M4Ad0EpxoX6NKCvZp8wH91xptnpUAG3oA05OrIqjyD8Vz8d+2jg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 317bb0e8939a..91ff1f84455f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1750,14 +1750,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 Nov 30 10:12:39 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: 13474215 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 79C85C4167B for ; Thu, 30 Nov 2023 10:13:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DB778D003B; Thu, 30 Nov 2023 05:13:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 089B38D0001; Thu, 30 Nov 2023 05:13:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6E728D003B; Thu, 30 Nov 2023 05:13:55 -0500 (EST) 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 D1AD28D0001 for ; Thu, 30 Nov 2023 05:13:55 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B0CB5A0129 for ; Thu, 30 Nov 2023 10:13:55 +0000 (UTC) X-FDA: 81514209630.24.E8DC81E Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf14.hostedemail.com (Postfix) with ESMTP id B7EC3100005 for ; Thu, 30 Nov 2023 10:13:53 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=by2Kkczm; spf=pass (imf14.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 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=1701339233; 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=mMaNyZ3L+HZw8TE4qwZHztb69egV4WdyDY+KH+9nP44=; b=ntuQnV/P+RHeawU9HccoKqOj8tQKwJS6A3X1TUaQPxmLG3eR6i591zpQ+44GFkUDZSt1rk 4bWvGIUexcT9Nu9r3ua2Rw5r7EfWsvs7nYgC1uYMh0H1YpcBA7b/yJTbxrcAWGfUElqzri n2/P7pP61gumKmNNAjbRl3ma1E2/1Tg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339233; a=rsa-sha256; cv=none; b=gdVikWOlL6OfNiEJi2jHIaorZC2tYgp7Xa79eISZQnYS85IPpfZDc2bHy5Nsx89T/G3QMH EUGG6DInpYj+R0azGRqfHXmdtOAJWbb72+RBpgcJFGb1ZQpK0P+sAbhw6TOnrMY7q+Y/v/ 0mK879ESPujsNCVg58ZSdBRvO04L4eA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=by2Kkczm; spf=pass (imf14.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6cdd584591eso754764b3a.2 for ; Thu, 30 Nov 2023 02:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339232; x=1701944032; darn=kvack.org; 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=mMaNyZ3L+HZw8TE4qwZHztb69egV4WdyDY+KH+9nP44=; b=by2Kkczm/LB3vDXmGal+wAsYTlhdn/23rvhrhu3d7DmPSi2QAYI/doLauXl7Si2Fvp 7pjRpEdZU6sH9nvNmWJK3e1o0OLMCeoPNjJ/70QxIyaZhjxs/kU/h+5nbwuAFPU3nxZE fhCoEPHTw38W8CZ4+guIpzvuWnSW7rQsLmTLoI6s9tt6wH6tt6b1wqcs82BCTB97zBJZ zwxPn4HZcOEmCExdvjIbzhAXMx1CT+i5Hv8eG/IylTa9PG+ha3xQprTJ3Vo20AkkAD+S pVaks62KSFCPe7JnrBEQX3pCrFf+UN913fs9wkYpTReBeRYiOF9tCV5FQzgbhTNSjRIY Sayg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339232; x=1701944032; 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=mMaNyZ3L+HZw8TE4qwZHztb69egV4WdyDY+KH+9nP44=; b=VoD0Pu7LA6C5tGV5GEWyjQ9go/kj9jjnpcV9SNIOrtGLWKc2/Y/CVknxlvy8xDyiZF mwKqs95JGRrWIOp9eFM/h8lx38Fa907mrKdUNFqrGSNua1fVcIKLb8nrbP7HHuJcQLhq jkNur5yfHTd7CxBMCQMuYShHNNWBy9xnz4XkRU/LJtWA8/Dr2MYh/mg+x9U5IvxnOIFH PaJf23WcxBSXEggxkEo5ynH/hnu0FSbqyjNw+pKdfCzZHlbJfECFdYworcGBu3PVIE0Z l1xDdDnxxpTYAAJfdNlZ+uu4CTFzIh0PxNoTTHqnqxRDh+5pSDMNH7NmyT5BV55iWKB/ GllQ== X-Gm-Message-State: AOJu0YxRBcQYsMN6OP98hJ/q/lLwotI7TcoUKmDEI9rPrBEzJfFYJx58 6jqomcuKB00tONXkz8kqs/o= X-Google-Smtp-Source: AGHT+IGr54Tvv7uxT9fmYn+OarTAsfngkaoN0RH027eQiqR3aFqNa9flCesmMZle+RdVtI+9WPQ0lQ== X-Received: by 2002:a05:6a20:7350:b0:18d:4821:f754 with SMTP id v16-20020a056a20735000b0018d4821f754mr656115pzc.55.1701339232480; Thu, 30 Nov 2023 02:13:52 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:51 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 18/21] mm/zsmalloc: convert get_zspage() to take zsdesc Date: Thu, 30 Nov 2023 19:12:39 +0900 Message-Id: <20231130101242.2590384-19-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Stat-Signature: afyspisw4fhy1ahjy6kz5p3hz85u1we5 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: B7EC3100005 X-Rspam-User: X-HE-Tag: 1701339233-763837 X-HE-Meta: U2FsdGVkX1/z/1UGnMwTKyJ3uTMzr0yW+FI18JGGu3jDjfJhAnHscNtTzW3aOSTb3K4uHGWdhaiNxDSPrkKa3F/5Hx3LZJYCgjSh/1mrVztaD4nfqk/wWjvqqwcXFUNT8BtF7w105Iq4W/38c/bAIMhL9qmarkgx5SmVpiO5xZpo0TpOvhm8Nq5IbrFVe4OER8//tDmL794xNJ2BtDNMLf5swZ929UKeJLM2+vpQF1XkmNXm51KuwObZ416M6+U1h+DuTBrShGgbc8HF/OyagrJp/Z0tlK0TOVMa9CLURCNSxvB7Mw/+g2cYdj0O8mIGC4fFhq/FSaV21GkrWeRYXLfNTlUQfomcU2xqpoVgm/7/CW50GJo0mtrtxwOrjNzALD9owMoCmRVRwsOl7m2e+cmp9DTE+Ku70Vpg2+E8woS/YNAsN+ZzpYvN5p8+L5beW/jQHV9WpV4rG7qCuZaXRgdKQ2LZ78e52jwEHKuXOc4+ITPEkVGGOxwgL3S/jaOkXFseQ3bEn4/1i0zHltegh0f1A1YFa32PTidtYpGtVI/U06iLddou2YkZxA32EUkfjPWkeSFBHDdwui/sYU/2oJ53n/WMrsOZHOkaYxs9xXkbjGJiXjfTVVNVLCdIwt1ZhVFKAesSp6m04UXsGHyr5SWfQlJ+1aSfnxL5GToYAuvPflgSvIXGEODw6wxu591P15p91t4j+pXqLgR/RLuWyo8o8o6Ny9VdsWlz81vqeMEVDI2fPPuY64qTO2KIfnlCqCMsY07SED8eGs7sQJvU0SGi6Fjmk+tbcgXRRA2BkhfvhoCHwELLZu1ECPewgoqeTmxbF9XUjkDIa1AdKNOG+Y8YC0gO5nThJ8aJPoiULWqx+EwQ5WqxZnWE9h2BwVo77yEd0qAw++Ey3xEDJ/PHaMNRottW0IVtCDGKMTyjAC/RKFPUTtlyeRSkGqB8qIqrn/Zh8qFU4WGK1xPwHAD B01amcJp 9EtTznvB9DWHp7KlQ4ZVubdq2cuBkHbMaNYU5Khs1s6n1W03ooPqs++Ne5rwlHxtEx2gaA9LeygjnGmESAYiJ+hTdWH/Cq3b+nwXnwBEwdkdLHgBcZ9/UmPxYl62fcgF8U/I7n1Ql+ZJfWwqbHY0ujIyV3bMfT6W0onxsJCxb3comRxnRYcSf3EB88/dInUGVDx7TQfHyofklNSvdL42M72NK/gEIMXrtlatR6WOQgRXNpOP9iGkHB7hn0FNitjPxOfTjeDT1WWmv76rFCgNAtsUvOHlkNWSVRsORqLGL4Lpl2lunnMa7W+k/29oajZOAK3UB8ebbNgotiEUz01wGNn0VHcSyjAkjOf7NP6T/REWHg+znKNgbKO0FPb+mhoDjtlnQSZwp++C9tJstDT1vYR06qHfziZZRPZk93RZhi5zWLmfnjatKszcPaiCV1dDBHNR9RhqP8w52LnqB0GdenaqiUskhAHNR27X8ZGFCMIHphhrNRlaFwk0l3CltcCyMD8KL17CY9o5YufZ25TNVj4nE+clM8sy+5QSFRT5BcLKwd3gSvgKgkx5jY1+ICt0ou+uGtIuZsXu08tGUZBp4Z6r2CQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 91ff1f84455f..828c45eba8ea 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -903,9 +903,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; @@ -913,7 +913,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; @@ -923,7 +923,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; @@ -976,7 +976,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)); @@ -1381,7 +1381,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 @@ -1431,7 +1431,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); @@ -1595,7 +1595,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); @@ -1629,7 +1629,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); @@ -1956,7 +1956,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); pool = zspage->pool; spin_lock(&pool->lock); inc_zspage_isolation(zspage); @@ -1991,7 +1991,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; /* @@ -2056,7 +2056,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); pool = zspage->pool; spin_lock(&pool->lock); dec_zspage_isolation(zspage); From patchwork Thu Nov 30 10:12:40 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: 13474216 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 32B82C4167B for ; Thu, 30 Nov 2023 10:13:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD9098D0040; Thu, 30 Nov 2023 05:13:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B604C8D0001; Thu, 30 Nov 2023 05:13:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DB4B8D0040; Thu, 30 Nov 2023 05:13:58 -0500 (EST) 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 877698D0001 for ; Thu, 30 Nov 2023 05:13:58 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6F73BA0129 for ; Thu, 30 Nov 2023 10:13:58 +0000 (UTC) X-FDA: 81514209756.02.D7B19BA Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 93B1F4000B for ; Thu, 30 Nov 2023 10:13:56 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=K2W4HZWA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.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=1701339236; 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=lMK1nh356VR2FhvAbjoFdNBCqsFSEHW0471/Eww10n8=; b=UO8b7IV1kg4OJk+iBC2+GXbAOLhrN67/TWRJOH8rzDltAW5t9lW4yKCoMZNX1EHj+HWMT/ tJiI4289RkT86w906PGtMweOGGjNo3H++sUFCaZOmIgmBhP27u3vxlDemnnZeIRrUJnOHM uK8NfsWThYZKDrIeuEW9Wg27Wy58hew= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=K2W4HZWA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf17.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=1701339236; a=rsa-sha256; cv=none; b=YUvJAJYLBwTqX3UA54x+E3lRS3HlXH9f7JmzpSd98S6y2nA5B5J8hs+KP9LtKJAHLCCglB QLSwdCIhMpsEI82EKnN//TbAaRUWUIDwxA4YRq0hD3ZYSp7b340JbPM5j8qt55ofObV9VJ /YK4DpDnnY+DMkaES0f8DOY3T+Ukt4g= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6cde104293fso756139b3a.0 for ; Thu, 30 Nov 2023 02:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339235; x=1701944035; darn=kvack.org; 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=lMK1nh356VR2FhvAbjoFdNBCqsFSEHW0471/Eww10n8=; b=K2W4HZWAlGIRlXscvw90a7VoowalapqMvHHdokNVojDtqTOUkusvYDMq0QeMnOqY5E 21/26XmbFIWOoWb9ParWOv7Z4TGnhwLCLqarxzCMQjy+JiVnAd6I7TAT1b7HVyQnpG+1 MegkTYGxjVZZLCWn7EfbaoyvmVaVPzbhOSzVkhjiElxHvKGNTZo2zKlyEdSGbepY9kuB tAS+XEnW5QbRNGMDLOx4o/Zy5RDJlnFgX9Cu+oWa9AaxkCkYWBIrrECb4+FY0RvZoFM3 w1bH8t5N24G7SQ4G9sLk15BCb+vOOoYx+mlV0ghA2/8a9ccNayDMG8PJJZOOp1aUVmmp shxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339235; x=1701944035; 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=lMK1nh356VR2FhvAbjoFdNBCqsFSEHW0471/Eww10n8=; b=XAK3223Kgo1MOK5tmtHEC8AaDefzp1sqtmVRojo1fQzJaZPJkvCtBc6ws5bcKm8do3 HhpqV9WwsLRSkypeswZg6J1bd9BRhyOBKn+fc+DyQ8GOIYOvqMDZfVyV912PUX3+KeMk GUbUcXGpVxZd08PSaSiDoBY7/NumVLiXx8tXiXvel3qu4Myyo8GkjpUWPj75wEYa6wxC fXlu9wDVydl6/EGb0m4wQK6gq5o6Bu6GrGiK6WlT3KR3qgTiqGtDZiZFCoQhxEUlXeQl fVAG7b9U0lP9W7m3bqlWvBAjFhMnY51jufeKY8t5tnKLicIg/ltbRBQ1NM4qMp6O2gd9 Wb5w== X-Gm-Message-State: AOJu0Yzms+nsosdShFjq83D/12fmIGU064PBUU8h37hr/T9uJtFMORKb QeTsFEglTLfYJ3FONZYD6OY= X-Google-Smtp-Source: AGHT+IGDR6sEYvZLp1EUHVWYzYDLmkjPKzYaSX8NVxBbX3kMOwTBJtn3W7En40VpiG5TyAJJ6KW+dQ== X-Received: by 2002:a05:6a00:244a:b0:6cb:8995:9028 with SMTP id d10-20020a056a00244a00b006cb89959028mr21578789pfj.19.1701339235345; Thu, 30 Nov 2023 02:13:55 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:54 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 19/21] mm/zsmalloc: convert SetZsPageMovable() to use zsdesc Date: Thu, 30 Nov 2023 19:12:40 +0900 Message-Id: <20231130101242.2590384-20-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 93B1F4000B X-Stat-Signature: 86bodgd5w1ekztwxj8ya5jkynpfa8mq5 X-HE-Tag: 1701339236-346126 X-HE-Meta: U2FsdGVkX1/cTWFjEeWrr3puiRtPrVOtpCdP2t7ElhhDLUO74aBciOn2a1sOeYOarUwbzXh7VT3Od3y62C6giJT1kcRhF0r7OBJxpOH+1WxxBEK3c07vI3jp8/kORi+sS7kF3rE4HGgTYI7mYm+9EJBk5F7TdsT+o/OQmO6boKBMgROvU7HUxxKeNR2+32g0yRbc95W0qMRzmQbxXkJ1MzePXxIQAIgLQ0zbdE9jsCvjm7jJNScflxDJw8g+n8M1RhHljaq6PbQOaROlY/UKOvIruRHZru+941PtpwQ7uqQQo8pS+bbgKziUEqoNiTOV4ert7QbeB90npqewxY4IHjtFtMsNWMroLkKE596N0r2RoWafRgqLidJA2Yg51lVMf13plvdG53rcHRM/3cpxdcV3ZjnkK8C+0Cz2b95vcE5kVNReGC8O17oVbEPi7n+ZjxPE0V5eZAkNOIN5dFsHjhCb48Mq3jDvblcyN6fAUi603VquaMwSEawGPoV/cYjbE7ZyibkszJvhcPRdGN6FibupwoC9RwWyPR5FGkXlz1KPa++kghZYZ54T6Sh2W6ptafxCe44Sa4G5LvMyfXxayo/pz4qE9sxTAijXP4vBpgZXTYSeTr+zWDpwtN5REB0vnbU+uG0aKpayfKrFKlPsGZU/GOQQkhZYXZUMh6fG+jWQ2xODJTwUH+FpVofv0Ks2Kmhsxm3yaBKFUzG3CX4563CFVvPvaOSfkoxRpPCvfQyDX8p9x+KufxzqaEEnmod/pj73bywGrV8s7vwcGnu1yFhtR+ltjCWm0ibOakcJA6ISSBkQL0EuFqr8/MnP4P3Pc2/gDq+STbl23hWIp/KrV7Uth08e4nD1KJ7FXSnChj9P7MVyXFEcWXi1bLJh4HVtL+HCErMVRAdWPcE+9QaYVeYElYy4wHGqzEt0S6ZPxE0xH+wjx746BPnWk9QUbZVLhApskCVg3Ll7EPub9Xu Djt7Pu6D brXSxEB2XUH4Vp4cx8NRVHGFhf+Z5SQUO0vvL4cMtxYkDTVzsdcxnCvYR6/xmJsbcDo4aqwIuoHRkydG7HYFpxKxgsqcv1O0Ma97TxI2hp75g7/KL/oyBchvEEGdzLjpWLqAuzo9odz7QruM5E71CfPrhBnwoN0i6U9gCwGUdlrV8b4/r65DRiO178I1WfpFeYgGN9K2Ps2SlLCk/dvyNyHRFrzFU4n1ofNa4rd0upcrRbssXeBSBYWicQEyb1p/ZxR8HXo5Om6zmIKQHZz7KZFPhzc8vhOVEjccFfsLnTLsR7Pd3NKHpA5WMDF/D+X12jIGo7aADAZsMBrCRdIqgqQjKgW7oR4aimss66PyYIJQd5xQRQdsJXS9UghsCHCsQ77Xt+XCK80/NaoWgYPGbdipM7IlCEuSFGzg1qno3tC848YRshBZkn2+T7gRReuLfceUSOkk9DCt42kQntuUoks/tF/P+pT4K9XtJ9MtoNFSXjD/tre9eTWUwHvmxk4bj7JYWMle57YeVT7KUXQlBAfUIaBMZ23w71Ju/PIVvqARoAIA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 828c45eba8ea..1ff83081616b 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2125,13 +2125,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 Nov 30 10:12:41 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: 13474217 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 DF193C4167B for ; Thu, 30 Nov 2023 10:14:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E0528D0041; Thu, 30 Nov 2023 05:14:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 791818D0001; Thu, 30 Nov 2023 05:14:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60A618D0041; Thu, 30 Nov 2023 05:14:01 -0500 (EST) 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 471508D0001 for ; Thu, 30 Nov 2023 05:14:01 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 00A0C8016C for ; Thu, 30 Nov 2023 10:14:00 +0000 (UTC) X-FDA: 81514209882.08.92B2722 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) by imf18.hostedemail.com (Postfix) with ESMTP id 26BE11C000A for ; Thu, 30 Nov 2023 10:13:58 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X9qSQs+0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.160.51 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=1701339239; 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=PU52qx6dxOM5bnh08PClP7wM+YBrueR/AqMAxCI8vXw=; b=NrbBZTITFxAmYTiVT8ijfIpTxZMfOKhK9jMjtG5XRAe/SOkl24K3sVVeQtlU4DxQqspPH+ zBFSKccLxQThkcWnSgaZ2gWz0byWtYpELJnQ3iDQi3e4Fp/O7KFtvrEzASde82qZw2hDO/ S1+wN7zI3Jqk9/SMNnKregDytF4o7uY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X9qSQs+0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.160.51 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339239; a=rsa-sha256; cv=none; b=dQYOlCMZ1SCV2doPak4q0z0dHpQdyFwG0/Pi7/vOY8QL21L9TXflzzhOeiXqVI8eY+oYhu f/r4jA+1oEF8x9VJloSWVqrVxmEussGG/B5Wj4L3RlVLzQ9fj6/zoioYR4YKbs1770Uxx5 9XIgnO8r3SgA54tVnzfzgVNE05MxPVQ= Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-1f9efd5303cso364743fac.0 for ; Thu, 30 Nov 2023 02:13:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339238; x=1701944038; darn=kvack.org; 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=PU52qx6dxOM5bnh08PClP7wM+YBrueR/AqMAxCI8vXw=; b=X9qSQs+0JncdiXNN5MRK4ogbZRfI4b9WjhyDY1W2h1n8pOC0r9wktFwByIExvMB5ZN QHAF89+gzoLD53q9/SVS4+QSYAZL9IU2B00uZs/A+rGlXNXM+1bs55KBKHblDEZj9rzl qL0UKVbJ7zR+YeJIQnlRrmvCVCERhoRQMfNJtGbkCtr//eM0U7BY50eSzaU4vlKw896x ECymnYIVIXlH+xAPQXSBQtG9LiVei3OJAwFVAvZnJOAecXip2vrNav49bobSFTIrZnL5 RR2MO1Y8uLFKQebOTA+cL9Lau/+qKl79OcgM9KN7GwhdAk3JIDEIPQr0zIEQPMeJ40Jk E0Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339238; x=1701944038; 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=PU52qx6dxOM5bnh08PClP7wM+YBrueR/AqMAxCI8vXw=; b=BCfbPhM9btKPR1C03rhujoDIgdjcv7sryHxVe1ydH9PDJxi/a7cpsMw9utQ2AD5g4O wj2MSy073i7inlw+cuKSDYv1ua9+HoSGKhgqPgKXHvkc8McjD2RQsnv7wTdJXZFYV0Sw qgh7KNk0cP5pzVNAGpbmgVjpbDIwQDOnt5TNt1KkospiRuc+bar6ckmAlL49TpxmV5he DUIYsQEvPw1CEPc+Id3eu7hSFoclubZ9y3LAcWCWJ9cBMhcBRvMdQr70jwmALSCAZs3H x1r7BXi0QuuQI9IWOlTYSKiBUq6rSExy4ZqCdOysP7YT4wfMhGMORWPT8UheP8UnnPkx EnBg== X-Gm-Message-State: AOJu0YwNKoGzo5wio9rjDZZRj9Fh8sIzgsjcEkwMoj4elfBfo8c9YhiW Wp84xCYmzrJ5lPSv7equ8pDg0pHT/b4= X-Google-Smtp-Source: AGHT+IF7xPs3osFcbAXtafC8zymTOpCuIX1QgOTCKCbFxpoQBFHGu5Zy/7PQlDhV6/BLbAm79OJ8QQ== X-Received: by 2002:a05:6871:3293:b0:1f9:69e2:7909 with SMTP id mp19-20020a056871329300b001f969e27909mr28828128oac.8.1701339238198; Thu, 30 Nov 2023 02:13:58 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:57 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 20/21] mm/zsmalloc: remove now unused helper functions Date: Thu, 30 Nov 2023 19:12:41 +0900 Message-Id: <20231130101242.2590384-21-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: ou4km4pdjw4edsm7t8zqgnuz6iwi8wza X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 26BE11C000A X-HE-Tag: 1701339238-920942 X-HE-Meta: U2FsdGVkX1+a+2FM8IjMBbMm+mtlNObY9dEDo1y630mGV0Y4+9AMli/nV5V7guWeYu8+Iu+F/DBGl/0hXs7qbCSFBlLCvYNyJOmrdtPJho9oO8vrDxL3RdRgq/wNA6jUnXJEwQMTippg0W1WZ7LGzTnTpe3FENbqF3eoqrO9/TuyjKC7mRu5TJzMyqNXS+i4ZMu+dUSJ4rO3ss1klCN0lkcrE3RLfzSihvYPGw2oOR2dvCPbsgT9PvNoSc22yhuST29kje1Nlk3G7WwEn0vMpgCtD+e49JTYeA0PVyPEeqkYMrb4QCaRg/MJ3KbQk6S3zh0ady9IBJpa4lXcqGnJanMl62i+5rSD/tOV9SZTEuoUPG+oBNB4Fi+H7MR9DMAq98rOxLSf5XTVtOITxXYlDnvip/Ppox8CaNwVG8X48Au8KdZvq15ZBSf8eC9nmdjBLT3eCd47EV+p1+LKOz8cayHkQrP2QJ7c/eEar8pRrcALyQnvcogo6XM5ZDSPEbhft3KNU8Y3+j2GeHCMyrXYCyNP9FuH6PglXiGigwiDJaPZyHh6aXKnQFXqGHzfD3pSaNg9omW18Hr2QzgjQWOCMQ0rZwOpFCYWTC+ldVFwd+llCnRIu7+4hJfQFlRCgt+5bY+TuuoYlDJ9fX4ZBUV5H/SuWwXq6SXBG7j2N8yu88MpGjzoNCKNMORrz82Rs0e7KSy7kl95gVooczYNSrL6cx2CXm+n0rZKOyUxkCnivzmnFbqkgI9H4yJjTuTu1a4NPb68q2gJmYY45rUJOq6iVCV9/KghSUJjEOi0WMij2H0dpbuwMZx2dNQ/o2d44aOdc/of7BxIdMuwEILFPoqTLRxVV1xFHQIAVm3wA73tyP5bgsYh6qUAkK1Wze8a77H95u8gGmyO67jGVe/FVz9o9VtKkZKbv6UkV4CTNTcOan0omHE0jxXUGF7CcmfEDJo815IqEioTEg0mu2NBm+y 4ueC10j+ Hy0Cq/kQCMtcJPZmpSu4PSKbSJSXiHKtCBF7MJGhBEfAdOEqIBkayaJQwBUBqWDHGo9omY9YTiEFhInp1o5q2eOA+dGzUPn5Rg/Qafw3g7dLOTXtPy7JdyRxQlYcnq86GdY7PQlKOpdbxGvWvG6MgW3/K9+fJaDZRPO+aFSIb4mwMFG2mP3ZTWBcIbIMuxS/iFZJWlfAI2fuoeFgBIUTMc73lWOVXGRwCuUaxXp1feY/iM2q50s+sNJ/RK31CH3ltvtqByKZnOo8uKilukROLV7rJVdEg0O+j2f9QCUX9rUMoGbIk9Hrm6P5XbUtHNcs9zttjAsg1OdJ6Ulv0dbjOVXTyLJdkGRicCY/WxJ+vd9gDd7LFB+9kjdj6X444eicI3zu/6BXwxEhqWk421PM4nIjXDrqY5BxgoQFR71O6KaMl/mxDhoF8+Vf12pwU7foHb1YEKCPaPPD4J/GL3Iufs7rKLQ4f/ce35hPp4jT/OgBYPMrXJ9dexdfmoSmXwFzLngs6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000024, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 1ff83081616b..65387cd4cc5d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -585,12 +585,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)); } @@ -607,15 +602,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; @@ -911,17 +898,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 Nov 30 10:12:42 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: 13474218 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 F08E6C4167B for ; Thu, 30 Nov 2023 10:14:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A4CC8D0047; Thu, 30 Nov 2023 05:14:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 853B28D0001; Thu, 30 Nov 2023 05:14:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FE718D0047; Thu, 30 Nov 2023 05:14:04 -0500 (EST) 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 59F218D0001 for ; Thu, 30 Nov 2023 05:14:04 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2CEB18016F for ; Thu, 30 Nov 2023 10:14:04 +0000 (UTC) X-FDA: 81514210008.13.18AFA09 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf16.hostedemail.com (Postfix) with ESMTP id 5E55D180007 for ; Thu, 30 Nov 2023 10:14:02 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AFt7IJTz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.170 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=1701339242; 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=lyPb56hbhEM/FKv+hmpEw5e8ZouRuLUTuexmLJPMtQE=; b=FpuzZ762Z6YI9VIgo4KVtWC4LmenuZgIKIE/vtBqUfIfsiMn9NeA4Xz3ffPL4NT7PJjSts zcXVpqwqO8imLRdHVKKpMouERfwRf8r8xjyUjDek3N9JXNPasEbDslLXfWC3Ud2QsLQKNf qF8RD92ZrFIFRpO7kLl4OXMYSRpneLI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=AFt7IJTz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.170 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339242; a=rsa-sha256; cv=none; b=LIUeFCvcV6Nu0srlWG/oGSZ6XyFvmb3JDxadx1kAOaSnVPP68QglzjmveR+PLOO0JDYZK7 VraeN6BLzqIJYprDaw7wwjQXX/a6nPxeJPiIHMbrfirp9TntvV1UGV942vqnx5LDTNzzBI 30e+ohqVLuJ+Y394bdUSSCuXbaYnImw= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6cde14ff73bso698723b3a.0 for ; Thu, 30 Nov 2023 02:14:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339241; x=1701944041; darn=kvack.org; 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=lyPb56hbhEM/FKv+hmpEw5e8ZouRuLUTuexmLJPMtQE=; b=AFt7IJTzc281eWeyyS+G495L6pJWieFplUVajylU+sK1LUrFC7qFdsaQUE9x9BP8lP d3J+xE2fpr0xCoMNSPpmTv6l56NOzhxpimbqBz94FALG59CftilNZo0xf6LXiIfaFPZ2 9Vxj4+rb60XIDZieWtl7wB/NPOlWfWb0cUjJIGPuKJcmns8aewVK3jniDQ8TBt89ljcn yLWO64cevsKoBFFtUMwoj6B0TO8epo6eWzmQD00tD0zx4nmlNcM5TLI8rxax7eu4CT1y ANp6ZPXk8zxWR80mLzTqGxgRSX8fpF/7/rZeAgfvRqkYOgjtls54wDZVwPIdWuL4lq21 l1tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339241; x=1701944041; 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=lyPb56hbhEM/FKv+hmpEw5e8ZouRuLUTuexmLJPMtQE=; b=pTXEt7vp3BO9bGFlh/1bTGWzKQJ82xvFXmYJWChKjv+tI0y30YjyruyK6d148vPx4i oYgkPus8sTOwdPwlGdum14FESib61eVxh2F65D1Fp5ScL05U0+b55INSUISJFauv71LB Znlwqp3d0lANtkAFLWp/U67u0C7fV/jl5EyOBhZr/Hs2qer3VCm8DySB9YcdF+ljwuhs VcERx2qTY7iw5erN5UnIxdR+ZUkUhTi+qalN+o3+EGJyCz8V/I6QRQHbsxz636utdA3S gGWzXaW1wcMVqIPN+OaAdz1FfjSHa012yWL1eUUaqT+pwIKajnypzw+KFpAShiPaK0+v r5wg== X-Gm-Message-State: AOJu0YwPazyTacICiJObXA5wuDACl1KlQgqeqyXW5Ko+ZUe1d6SxK89u HSTWOLemuw7vljugsnNqZ+0= X-Google-Smtp-Source: AGHT+IEdZSW5j0wezUu2q7x8ocb5tF0F1aps8c4SQV2R23kMFh/ey419QmoRo4rTRx5jIHOWJ0JPKg== X-Received: by 2002:a05:6a21:7886:b0:18b:8136:f2d3 with SMTP id bf6-20020a056a21788600b0018b8136f2d3mr31762705pzc.24.1701339241118; Thu, 30 Nov 2023 02:14:01 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:14:00 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 21/21] mm/zsmalloc: convert {get,set}_first_obj_offset() to use zsdesc Date: Thu, 30 Nov 2023 19:12:42 +0900 Message-Id: <20231130101242.2590384-22-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5E55D180007 X-Stat-Signature: z64jha35m7k1ifn4jb8mmq6ucxhpeufk X-HE-Tag: 1701339242-757101 X-HE-Meta: U2FsdGVkX1/jH7yRAcEWqCpv6YTQt8zl876ZwwaBGPLnxuZW8YwiohgtaPbmceyfKYlqRHie3/mFOYHUYoMJyn/WUBEZFZMoO21WA9uKzKQlhWGLOSH5n3U3Mu10lt4XZ4hSaT9YSnaewVcHU1IxPws6MZ/zo7mOJXLDCypabKKbh4rOdmRCGhCsUNymLIUwMuE12bLINaod+eVeoeF151sYeGUqybyxXgmz4WW0hwmd89flP/oIUbgtu1Vp18XPwOQFpiOhBI3YfxwmmOeDoVg82gz980DcFT8JWJ14b/OR+PQE0/VVq6DFbuztY46+M6keydkPrd0L4d2bDkkRdp0n9aS6K0xhRK2y6VVMX462pXk0QnDgM4G/mPEEr4F32mvJhIQedJ0oDFpRPCq25UWzjZ4ZAtpCbx58/AFqDK577N9TvhmgLWQHF4yQXDcHvZpH5NRCcdBCbnn3kpzDCFh/QgFz924usdNX8tVhlzjTgd8wCAIbhqKhRv8KSn7xLpYTBAL5PkYyUGn/mYoE3meXKCUJEr9LPeSDJ0bUvZVRjiuvYlK01AnG5tGdXOvL9ECEO2ogkSNQ/6gSjrSMY+s6b/WPZA8yB7lesKqB/dvjA2d1CHsAZ2967SQkph9h8vre0gUnLswTBn9ImAg0AF2jihLi3TsWODeEhp24lv9xa63Oh9PdCaSLdmUroKIcqzmdgmn85qKWcuw99W+fEHICKvWNsbjMnmQh2NiJJv8QFsmT/NWxIsvlsNXvuY0LVa4TADXaaPdPJ090A2kqQlx9Y5DmJRnaO0pgE2TAAlQ6FshGzdB23fNlvoD9fiJShWELZHs325qvdmo8ThNmPJjlm258ecQYfua2KaE5rQCi4IZqaAPW8F6aSW6T0SlQXbwQGYf7cmr5+HJGtW/+mwTx8DvpaNhoeUKWeec8vCRnNexW51V/GuS18lphgqkfTI5t9mjkXSkuGYrsdbc yojCE6up 6+h6xjKpneh/dlrwlVQwm4eRXgpy+zOyH/A7DOzcTKnBBPB16qoUMk21NbY+IhpbFU8h6qbgRVsYwEYUX7i0UKAlHv6cQoOvCs6pkhBU7v3qy4U3H31nhprAmGwZQr5+/85sxGPQk1Tc1y4ShJ9P/YEfK0wV4MCUYGmteklMztZ7dUELOC/R7o+l93Z+Ck8kvdphOEc91rSXwKKIfTDWYZiQVk0vUVybmQxTQB2FkUR4+i25gsYdLEvwJWvoAzv5DVJYB8gADrDhc5uF60yJjiNCtDqxM8tkUfNGMoctQgWqdjiiaEa6OnBCzd1v+m7sZW+C/PqC2esu9PoziMiJGpNive6/DrppMdEho1DzwH1ZbcUwTNLWIaEsFNNfMe/CLzwyCypG/TzkE9koAtBpaE5Go139KDPlCw1Rc2mMGnk25pWGx8Tm9h+OlUOzxkUicGK9GXn/tmxckfhMbjzZp5L87zdiBl0L2OCaMhJ8zbZGIOc9Cd6arvDOtwmqbOJ/cxx4rXoRNHlGUkbawxQ9ObGCuSy0HJouKN/c6fjlvXG+1VXEtevJg4FXMN2x1lDt7Ny+aS8yaAeTIyS1Kj3bU7oeUdA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 65387cd4cc5d..0e1434f8ecdb 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -610,14 +610,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) @@ -1053,7 +1053,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); @@ -1703,7 +1703,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) { @@ -1914,8 +1914,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); @@ -1981,7 +1981,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); /*