From patchwork Mon Dec 16 15:04:32 2024 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: 13909879 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 E6253E7717F for ; Mon, 16 Dec 2024 15:05:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5EEB26B008C; Mon, 16 Dec 2024 10:05:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 576306B0093; Mon, 16 Dec 2024 10:05:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EFEE6B0095; Mon, 16 Dec 2024 10:05:16 -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 1FDB96B008C for ; Mon, 16 Dec 2024 10:05:16 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9EC2614110C for ; Mon, 16 Dec 2024 15:05:15 +0000 (UTC) X-FDA: 82901144466.10.ED0536E Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf20.hostedemail.com (Postfix) with ESMTP id BDCCA1C0026 for ; Mon, 16 Dec 2024 15:04:42 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MblSN8TZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361499; a=rsa-sha256; cv=none; b=iYxfIEpj44vvbgARsS/LGvZMNbRji7qAKV35sDfWEQdSJj2yxYY8WSWKrEf7pIocGpRdKf aVn5QCBRpHFmPLuDMwsrVBocwJdnk/TgDiyg4HdUP3CZRtFczCvuH1Z+gYwugrqLFg4pg5 f9SCEeVwCSNOwRUr4FaNj9jkG4IEqJk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MblSN8TZ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 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=1734361499; 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=KJPcQRcezA/6SvJATreo3LdPfQhC3fUseHgH36/RUEg=; b=yF/64dhRCW7MrwgyqabR7UKp1L7LJ9nP02SjEVumkG1lGpU6HO1KQOFaSyG8N4CUQHQJuD HSA4PkVHWLyriz/IFFLGlsh1im/ugy6qKo40TbbXu143J5B4nJOxu2M66ZWlZBylDMXjAy hGWL36f0j2udOusP4/L7Kd4yoYc7T3A= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-728e3826211so3311612b3a.0 for ; Mon, 16 Dec 2024 07:05:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361512; x=1734966312; 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=KJPcQRcezA/6SvJATreo3LdPfQhC3fUseHgH36/RUEg=; b=MblSN8TZtWYrt1M521b0zz+XhEcrBy0Rhd9oAiMzrwiTutht2Jhwmc1Lj1m6Bn65Eb a3wvhPXXy2nJsf4ZCjJYYCV2SkDJBsz7fz/UbZTpaFhwx/cWl22cw54vzBIP1evaIb6p aTnEEIpzQTHPCVER5kYtJEirTtI2tLvBDePIWWkX67s0N0SbtXLsZ0Xdj77TElmLwyIB ib4Sqlh677/Co4a9WYHBClx2pTy5tTP16JhFZibcwjLWmyOQwpiDrsyMs9A49caKglh7 7FFtTEM6IpMHC0HD0oUqjKJk4DrV1Akh5pXEBZjLQmXiGGVxI/CT20NL02+j2RtbsK7A v4ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361512; x=1734966312; 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=KJPcQRcezA/6SvJATreo3LdPfQhC3fUseHgH36/RUEg=; b=DrXGe/o7WFbYrN9vWy0/Ydc9zUpYFTkEt4UhAFgE0awmYSicZJzW2xy9HnqoTc+s/7 QAsKEZKbapTXu2r3IMAZxYh9geE0k7TopgH9YYndBJsJ97sCKBej+cMtULDeJcJyDLrD +Zg1TXqAJFhAuiS1UEFcstQd+GZ4CwH/2R4wjN+VrfsVa9IjzVx9WB3vQzJ308PDHJkb fZm4flGQIUvoWefS4jHyEpA1sWuvyLkHR9DI8MEUmnYbYUzXNgWzFkUbjxtuSz8zdwV/ 0irZJkChLR5FtfwSqL5nJHBTFXpSJljmxANaiNlocyhfBJp0qptMKGt34GDfwTWAQ2CH SsnQ== X-Forwarded-Encrypted: i=1; AJvYcCXLp6Hsdc/9GtWt4ZsZeeqoT/1rG5h8lLcplpvQBzREs922/JuYLK0bGTZFP3SaUEN1Nwasnwg9qQ==@kvack.org X-Gm-Message-State: AOJu0YxTxI/EYpVcSxg01co7yzSghYI/W4LfDdWUflMSYwIBms4dqw6H jZteHnvaCf5IZF+1L4FwjAz1lDcLNosJT1jQOLhYXEsbOuZz2lI8 X-Gm-Gg: ASbGncuMMXW+8PTWr1jCWEqX90hECQETFl0KxlX0oFg/M+TaypSgIte/YZiyBQE127f ZNHbdsmzknP9PoTlJUAhZkXZI+oAj6SFSHS21zan81D5HU2ZXWyGDXn1qBENoVKZbokwOFcqGBF +7KXWHawKh3K6IbPpfc5k3TCdPL6XrA9krjIu8TfyOM6YZiCl4K6GXyYxCRnmWdCIptjjj9xgoT mp94eK5fBnOVudHiSga+I3BXLBqqYXuXknn6ozSntH6MHVOfaT8JMKBaZBwpY3b5Xo= X-Google-Smtp-Source: AGHT+IEATRy0BZlRxn8Dcu/3lz3Ry4v8RprlwhYAwyyxFpZKyNVsuPuD/mPrsn3MyrD2Fn/ugMKziA== X-Received: by 2002:a05:6a00:338e:b0:725:eb85:f802 with SMTP id d2e1a72fcca58-7290c11587cmr18819402b3a.2.1734361511273; Mon, 16 Dec 2024 07:05:11 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:10 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 01/18] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool Date: Tue, 17 Dec 2024 00:04:32 +0900 Message-ID: <20241216150450.1228021-2-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BDCCA1C0026 X-Stat-Signature: hid7qf49mjpjaxynfngnmetobgrabo45 X-HE-Tag: 1734361482-190866 X-HE-Meta: U2FsdGVkX1/Nj3uIPDe5g7xkKIwWyNrV8h2dmk1IAoR/R/1tDHc1xbmb1MSJ8uSoQ1zqHeUUCYRcWbUyzJIRS0qZgPNEsFe/pIURhW6Xv/mjDEbZbUpn+QEZIdsLGshjF7aSwIg2h6ACcMX9ZqjzMX8O2fP2YzLs0eNZX9J80pnFk++TqmcAKjfnYuXonm3BL+kEjMVQNTP2VG7Btoml9RdWsuRneeSWypbGjyvmSpInTDCmBbADYBzo6FrC+Eeh5YSk5pg1qKNA5qEZsnTqfNhVrKfcy3luWwvOqLn9FN10a6sCZ/jXrzIq96oFpa5y7ZDXnQVUSn1eqBhAnVMn07QqrL05mQhDzqNfv0w38sFOIeRMggp9NAG8uS5+KTz9fEUxj5aAeh1kcYiWqD1Sj6ZyrbZPQJYYaXVckBtlS4rR9g92kgykoxBuAgQuc8NLajFcl+n6/zsTl0LAfYmnZRc9P99B9e927ikoKEGE8FU6X7mlg9TjbDK6bNvWFG4b/j9kwXJlKapVNslKjLXyUPAqj0za6QO6iC//up3sXz+jXzaqqp4iS77cLr9eAmduSfnITRnK505OrtJucbim0Y6af/UnDDnKrY6MPRTSz716aE3f3Ejmjswto1OpW1QHlVmTs+/cdDXAVyUXKdonvUGelJntNVrbKSSUCOFwy1cNnhE9wU0ZhWaUzZXXdWMxHoSu490DWSDS2qhLqEcFOkX/4QzxXrvzUq2Ya4/XRcIs2j834vu6kMBrPfRr8hmh/IGN0YTTP52+n7rSQKq5MnzZQ/A0fYwjValpfVoEUc/sUNnjrnp9hvH97IvTX36dZp90QRLSqBaJkT14TO/WBn5KhrmcOode5+huhz8vjiAX23fv+iSbBIpe9cHgnSIlS6L4VkhDSql/53cd1oq495ZU6Te/3DonpckwbIeNBl+na8WXZ5W58y/TL5Tq//YyHoBKqORFCUXkArYfaME IwjmlllA uA5xlLZ9hcg/uL5BPm1HIaC389tGpt2/+T843Br/BrETF04lJ3kb/FPEw3HeTdzPdqsCLReW7J9kgJzK23lcNfkEaKDuhFtryQWsCao0fXh+WN4iDh5k4eLaudn09alhILOdd8fR7i70kN1B7ZSBIhRNVH3qNWxOB+mhzcR+R9I1QnGoVC0CRdwoKoUWbEhnBBuvo8OEwdDV7VjIeiwuB4aPQKkEL7i8BxwREuLcZYJb2FJg148n/2izoYmA8bBj1p99j4sBUh9V9tCWjGS9suf2XwgWyse7nGm2oPpepqHLVBQXUkYEfA/TDYkHxD9WHTO8KItVbxjNEPFWV8njqWp8k/qxgQ/5gB5SnAxPdD14Uepp6U/tmuTldtMOsSZiPYwhr6X+paAiOxJrBFRPbxveMugWRpdpbfzpjHhEE5RzIC9rfLKhL+1DpeC4CapQgqHvDf1cOv75a7l/9tpJJ/7SATWGMRXoa1pZjo4IqFWMTytRpY5yQkukAmZ3UXylzCtpw X-Bogosity: Ham, tests=bogofilter, spamicity=0.000126, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi The 1st patch introduces new memory descriptor zpdesc and renames zspage.first_page to zspage.first_zpdesc, with no functional change. We removed the comment about PG_owner_priv_1 since it is no longer used after commit a41ec880aa7b ("zsmalloc: move huge compressed obj from page to zspage"). [42.hyeyoo: rework comments a little bit] Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zpdesc.h | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ mm/zsmalloc.c | 28 +++---------- 2 files changed, 112 insertions(+), 23 deletions(-) create mode 100644 mm/zpdesc.h diff --git a/mm/zpdesc.h b/mm/zpdesc.h new file mode 100644 index 000000000000..e0852498aecf --- /dev/null +++ b/mm/zpdesc.h @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* zpdesc.h: zswap.zpool memory descriptor + * + * Written by Alex Shi + * Hyeonggon Yoo <42.hyeyoo@gmail.com> + */ +#ifndef __MM_ZPDESC_H__ +#define __MM_ZPDESC_H__ + +/* + * struct zpdesc - Memory descriptor for zpool memory. + * @flags: Page flags, mostly unused by zsmalloc. + * @lru: Indirectly used by page migration. + * @movable_ops: Used by page migration. + * @next: Next zpdesc in a zspage in zsmalloc zpool. + * @handle: For huge zspage in zsmalloc zpool. + * @zspage: Points to the zspage this zpdesc is a part of. + * @first_obj_offset: First object offset in zsmalloc zpool. + * @_refcount: The number of references to this zpdesc. + * + * This struct overlays struct page for now. Do not modify without a good + * understanding of the issues. In particular, do not expand into the overlap + * with memcg_data. + * + * Page flags used: + * * PG_private identifies the first component page. + * * PG_locked is used by page migration code. + */ +struct zpdesc { + unsigned long flags; + struct list_head lru; + unsigned long movable_ops; + union { + struct zpdesc *next; + unsigned long handle; + }; + struct zspage *zspage; + /* + * Only the lower 24 bits are available for offset, limiting a page + * to 16 MiB. The upper 8 bits are reserved for PGTY_zsmalloc. + * + * Do not access this field directly. + * Instead, use {get,set}_first_obj_offset() helpers. + */ + unsigned int first_obj_offset; + atomic_t _refcount; +}; +#define ZPDESC_MATCH(pg, zp) \ + static_assert(offsetof(struct page, pg) == offsetof(struct zpdesc, zp)) + +ZPDESC_MATCH(flags, flags); +ZPDESC_MATCH(lru, lru); +ZPDESC_MATCH(mapping, movable_ops); +ZPDESC_MATCH(index, next); +ZPDESC_MATCH(index, handle); +ZPDESC_MATCH(private, zspage); +ZPDESC_MATCH(page_type, first_obj_offset); +ZPDESC_MATCH(_refcount, _refcount); +#undef ZPDESC_MATCH +static_assert(sizeof(struct zpdesc) <= sizeof(struct page)); + +/* + * zpdesc_page - The first struct page allocated for a zpdesc + * @zp: The zpdesc. + * + * A convenience wrapper for converting zpdesc to the first struct page of the + * underlying folio, to communicate with code not yet converted to folio or + * struct zpdesc. + * + */ +#define zpdesc_page(zp) (_Generic((zp), \ + const struct zpdesc *: (const struct page *)(zp), \ + struct zpdesc *: (struct page *)(zp))) + +/** + * zpdesc_folio - The folio allocated for a zpdesc + * @zpdesc: The zpdesc. + * + * Zpdescs are descriptors for zpool memory. The zpool memory itself is + * allocated as folios that contain the zpool objects, and zpdesc uses specific + * fields in the first struct page of the folio - those fields are now accessed + * by struct zpdesc. + * + * It is occasionally necessary convert to back to a folio in order to + * communicate with the rest of the mm. Please use this helper function + * instead of casting yourself, as the implementation may change in the future. + */ +#define zpdesc_folio(zp) (_Generic((zp), \ + const struct zpdesc *: (const struct folio *)(zp), \ + struct zpdesc *: (struct folio *)(zp))) +/** + * page_zpdesc - Converts from first struct page to zpdesc. + * @p: The first (either head of compound or single) page of zpdesc. + * + * A temporary wrapper to convert struct page to struct zpdesc in situations + * where we know the page is the compound head, or single order-0 page. + * + * Long-term ideally everything would work with struct zpdesc directly or go + * through folio to struct zpdesc. + * + * Return: The zpdesc which contains this page + */ +#define page_zpdesc(p) (_Generic((p), \ + const struct page *: (const struct zpdesc *)(p), \ + struct page *: (struct zpdesc *)(p))) + +#endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 64b66a4d3e6e..00d111f011be 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -13,24 +13,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: PGTY_zsmalloc, lower 24 bits locate the first object - * offset in a subpage of a 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 /* @@ -67,6 +49,7 @@ #include #include #include +#include "zpdesc.h" #define ZSPAGE_MAGIC 0x58 @@ -254,7 +237,7 @@ struct zspage { }; unsigned int inuse; unsigned int freeobj; - struct page *first_page; + struct zpdesc *first_zpdesc; struct list_head list; /* fullness list */ struct zs_pool *pool; rwlock_t lock; @@ -459,7 +442,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 = zpdesc_page(zspage->first_zpdesc); VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); return first_page; @@ -952,7 +935,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_zpdesc = page_zpdesc(page); SetPagePrivate(page); if (unlikely(class->objs_per_zspage == 1 && class->pages_per_zspage == 1)) @@ -1317,8 +1300,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, /* record handle in the header of allocated chunk */ link->handle = handle | OBJ_ALLOCATED_TAG; else - /* record handle to page->index */ - zspage->first_page->index = handle | OBJ_ALLOCATED_TAG; + zspage->first_zpdesc->handle = handle | OBJ_ALLOCATED_TAG; kunmap_local(vaddr); mod_zspage_inuse(zspage, 1); From patchwork Mon Dec 16 15:04:33 2024 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: 13909880 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 EE8B8E77183 for ; Mon, 16 Dec 2024 15:05:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79BC46B0095; Mon, 16 Dec 2024 10:05:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7253A6B0096; Mon, 16 Dec 2024 10:05:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 550566B0098; Mon, 16 Dec 2024 10:05:18 -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 2F4A26B0095 for ; Mon, 16 Dec 2024 10:05:18 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D9AA84532B for ; Mon, 16 Dec 2024 15:05:17 +0000 (UTC) X-FDA: 82901144634.22.4BA4EA4 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf18.hostedemail.com (Postfix) with ESMTP id 82A4B1C001F for ; Mon, 16 Dec 2024 15:05:02 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=eiPPgVL7; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361502; a=rsa-sha256; cv=none; b=WOhG+127DacXMObA6SOoKh5nxh233TWJVoo9s0SKxd+UXQXuJkoP07zkqeKy/FcyLUzDhe ua/CXuVIXh//M9Jt+6O3jRvJsXP157086/0hWOLDLucYyBNmdz/JwhRHTK+p7XQOZpOWzI I6rxvsCcskQPzJFF1vs/V74lQiT0STA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=eiPPgVL7; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.176 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361502; 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=BCMEvH8Krrbs2dY96UiQdD2oaiZyPKRNYnh7gL+Mupw=; b=QnPwmRLWbKhzqx1OpyCDqnyiB4BXpbGdCtACiLoRFrlJaw03KMaIR1YqdoTk3RxruTgd3D t6aNckt4Z1PNlp9xQvEe0M8eUXRvJ6Dw0kHA7UdMbKnYtXQnCS7bQDPT7DUOVzIakBp4vH d2c7t81T45LW+mqEtk96vK+ysm7aYRA= Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-725f4623df7so3617661b3a.2 for ; Mon, 16 Dec 2024 07:05:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361514; x=1734966314; 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=BCMEvH8Krrbs2dY96UiQdD2oaiZyPKRNYnh7gL+Mupw=; b=eiPPgVL7pAgynN5E9viQJTnq6aPE6Jln6g1RM9Cw9WYKNyGS+QI6mWVzMyjVzBc0YX 12nebhdo4CNlEKmVRwQZu4tPLkh5B4lNKMuc5vyRKQyyeLdRNTo3I5Hq+KIFrjzMU/Qj 3o27mQRQzfViskJ7lNaeg0JaQZKi1ogJXJUg8nfr4eaIbKCkdkhhKcflCUNOVCr+FmFC Pb4nxFgrnhK23grIhZaKrJbFlU/ZsqP2Dwpw6YcS+MH3mw3wSDNpEqmSIvdUlHr4Av1A Ox7C5OOZtQrPAWtmcSzplD2blEa3eY5bX6mErgZhAfenLnoGQbscaTA95I8zsMkz5+kb SIjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361514; x=1734966314; 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=BCMEvH8Krrbs2dY96UiQdD2oaiZyPKRNYnh7gL+Mupw=; b=gldqpx8zeIPcYCHlKr7l5SwzSBPtS84a3TfAnLutYG+kezPgbkzgJQwIXIojF8M3Z1 1rdyo6IfJAHeAQAKNhAbINj54sowBJudi+eFOhi+ype8ma5UwMZ6kraxQqa9LDxZN2dp pWm8sB8C0aiOG6C90R+hZ2gPuBMJu5fE3SPHyZsi6SHlwYj888ppyBS0LotU41YjhjHU 0oTfFmx2Dx39tpBvo/wzzr43Bu+WTfQpp00B4PxAf48Qo4AcySKokZ9yDOY5oOAyheSD fJoISqiIqMJpSOGuB3bMyTzBZNBGFq66Eg08Wb7g5VIMFokzDY1pUPqgaMwVaFMCqKSO kxEw== X-Forwarded-Encrypted: i=1; AJvYcCXuzcNW3q948l8BrRqF0o0jxbm+TCp2SQep5mAr8FLLHYLDpj/MFyHa4PEYhc/79Jns1+LEfmywrw==@kvack.org X-Gm-Message-State: AOJu0YzHg8Tguvq25Ab+uISkMixOB3S3l28V83CVz9J0eOIL1t8I0Ugn ui9FY2sDIJ6L0dWRtBrsYvuPAH9Z1YqUx8O4oeTyNgeMysHcqP70 X-Gm-Gg: ASbGncsLHwnfeFCQnC32qL0YKVpUx1yoCXdltlrN6oFImM03tUUpyNPeKYoOdxJucrG qUbrCVYyecN0kCcAVI0+D4Q3DZYAhdmfzY8fCMrF41Aw4PQsnrH77NSEmOtkQ0VQvQasK7nMfC5 DDZSBpI14hRORh099JpPcldrS2QkJMcrBIpRDY046Gz38nrIIRELWn9JKaKN80EDMwnOyudieqF 6DzOBegrzK2r8vQggUdfOIrezVvxsVi56Xgutfi4fjGU5RJHmrvjUqbOuVuVh7+OWI= X-Google-Smtp-Source: AGHT+IHenymbq1naD5Q9pzchgJ5RTMcWmEHccxP5+wPQ45I2sXUsZ/pUpfYR4mUKVV0wf0JBoyugPQ== X-Received: by 2002:a05:6a00:929b:b0:724:e75b:22d1 with SMTP id d2e1a72fcca58-7290c25d977mr17443660b3a.16.1734361514385; Mon, 16 Dec 2024 07:05:14 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:13 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 02/18] mm/zsmalloc: use zpdesc in trylock_zspage()/lock_zspage() Date: Tue, 17 Dec 2024 00:04:33 +0900 Message-ID: <20241216150450.1228021-3-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 82A4B1C001F X-Stat-Signature: bmohq9w4e8897ei4wxh3uxrpmx7azx8m X-HE-Tag: 1734361502-127897 X-HE-Meta: U2FsdGVkX191hZ4uaFuBQXM6rxTejxwi0wc9qVCPBG8K+SsgqN8ozeZy5/HVw1R1V0gFiJR4ajH6NmEV35QMbmCvIen1OxpO8NX9G17IKURrdpeW+6/clksQqbTHEBq7m0Hmc4IZoskzMdD9tu59QnYLw+3q9EGf3AQpKpar4tgrDmH4m9odkaym76UHCSfQ+CXkldUCT+7BNNl5onWb+druSa6zEHm/HWyTn/iDcOk+FbYIC/WOJ28u54BAhLT/IE9nRTIOmgV6HJwht5L29gagptb18CyIQtCXavKkS7IA5CgL1nDeKZhyMbSovP9fsNyRttLHd7CMqQvpdVssSEBlbthDs0e7Rl/gOrKzUxo3wQtvYe4aLbCVBbls3T/zAL5AmdUwqOWnw7LYjmavJD26DrniAgydEt92CHskVWaR0jnJwpQ/Vs58ll2rz6dL9/4je/22fosrRbmjqNaq1/e/I8nw90laTnXu5ABqGvO4SCFtfh5YH/BOAeZehUvNbZL44vMDgW0Iq5AE29Shu+q44MlXmDsikImhy1JQWvpHXdiOwsdtVvS65b+pSbr+IZTOzngF+iedgImyfSWlsnZh3+mKNjyomZGHKyDcitnNnaZkErMk+gDLcyzqd3W1zT7WmH7awvPk1B1IalfF7GJPt1qSRVry2/hmosHF+DDzUAbCsG0KoAhwR8gX/uAyhlREyc0fyBSwPMjj6VA8khbF/Bx67L7qbqTECyxcEtUTWKdkQaHz0N5dqT3k+aCizMnO+YcGG+K3oFCdiYCOdpveP7MEnuenPq15uNDgE3S3uJUXzNKNpqfzCVE3FNRNsbeVwcZ6zxnLehMmNpRc8YhTNdAi6nibkc6Hga3KLGdT6caWT+BnHd5v+B8SDCpts8PP6PjOd/+R7+pRzlsdl6B7VRNmXzS2zF1h5P0PoVmHq78ae16zTcZqBGhfga/1lSMrrbTQYLlhs32zwHQ LgDtt7L+ DfDn29htytsXmdVOMHBuv+twhs5zXLyC6s8kFdn1xqTiGn/WNOrjA9juSkpPMJqaNqhH/9AZQj/o2kKuQ4UFXA/zjGgaDIxUKH+1K7dkKhCKpCLUZvtcmRja5rSM2/0hI1bzuBakGxTlwJXeplMjFxF+SA85GxtvDHlv02qUgUUAe/2dKDbbRFyKGr15uf9ly9leu5ibKcemFRYgvOY4RbNTlydSubsrzeZr5mvTPo2OlOccpd9Ar8VCfV7aKZ4J21QLViRR77KtysLLi6DJqvUu+jf1dN005rWmQFG7+xMG3yeyrIg25ukrXs/C3VNSpz/pRM6sqcPFSSJq4UApSuBUfiKOLuPvE3IR551E8KqdRRzbyo0Ht8sbZZcksMzEsNuGW6/QNNP5E/q25N5r9ZHLajPQuAPacO6lv/AcI2TxvWp45eB66eJqHqvJfXBlbUOGQaFpKahcsfBtZu/YyoO2cn1WHGRxqWdyQ015Dw8Kg4FQOSKdArSXZzOT6g5xsRIKdoyY/ig7p+buyyENOIA2x17ZwQQo7TBuoVwYJji+ygAs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.018469, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi Convert trylock_zspage() and lock_zspage() to use zpdesc. To achieve that, introduce a couple of helper functions: - zpdesc_lock() - zpdesc_unlock() - zpdesc_trylock() - zpdesc_wait_locked() - zpdesc_get() - zpdesc_put() Here we use the folio version of functions for 2 reasons. First, zswap.zpool currently only uses order-0 pages and using folio could save some compound_head checks. Second, folio_put could bypass devmap checking that we don't need. BTW, thanks Intel LKP found a build warning on the patch. Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zpdesc.h | 30 ++++++++++++++++++++++++ mm/zsmalloc.c | 64 ++++++++++++++++++++++++++++++++++----------------- 2 files changed, 73 insertions(+), 21 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index e0852498aecf..c866758feec3 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -104,4 +104,34 @@ static_assert(sizeof(struct zpdesc) <= sizeof(struct page)); const struct page *: (const struct zpdesc *)(p), \ struct page *: (struct zpdesc *)(p))) +static inline void zpdesc_lock(struct zpdesc *zpdesc) +{ + folio_lock(zpdesc_folio(zpdesc)); +} + +static inline bool zpdesc_trylock(struct zpdesc *zpdesc) +{ + return folio_trylock(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_unlock(struct zpdesc *zpdesc) +{ + folio_unlock(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_wait_locked(struct zpdesc *zpdesc) +{ + folio_wait_locked(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_get(struct zpdesc *zpdesc) +{ + folio_get(zpdesc_folio(zpdesc)); +} + +static inline void zpdesc_put(struct zpdesc *zpdesc) +{ + folio_put(zpdesc_folio(zpdesc)); +} + #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 00d111f011be..51f4a9b78023 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -428,13 +428,17 @@ static __maybe_unused int is_first_page(struct page *page) return PagePrivate(page); } +static inline bool is_first_zpdesc(struct zpdesc *zpdesc) +{ + return PagePrivate(zpdesc_page(zpdesc)); +} + /* Protected by class->lock */ static inline int get_zspage_inuse(struct zspage *zspage) { return zspage->inuse; } - static inline void mod_zspage_inuse(struct zspage *zspage, int val) { zspage->inuse += val; @@ -448,6 +452,14 @@ static inline struct page *get_first_page(struct zspage *zspage) return first_page; } +static struct zpdesc *get_first_zpdesc(struct zspage *zspage) +{ + struct zpdesc *first_zpdesc = zspage->first_zpdesc; + + VM_BUG_ON_PAGE(!is_first_zpdesc(first_zpdesc), zpdesc_page(first_zpdesc)); + return first_zpdesc; +} + #define FIRST_OBJ_PAGE_TYPE_MASK 0xffffff static inline unsigned int get_first_obj_offset(struct page *page) @@ -734,6 +746,16 @@ static struct page *get_next_page(struct page *page) return (struct page *)page->index; } +static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) +{ + struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + + if (unlikely(ZsHugePage(zspage))) + return NULL; + + return zpdesc->next; +} + /** * obj_to_location - get (, ) from encoded object value * @obj: the encoded object value @@ -803,11 +825,11 @@ static void reset_page(struct page *page) static int trylock_zspage(struct zspage *zspage) { - struct page *cursor, *fail; + struct zpdesc *cursor, *fail; - for (cursor = get_first_page(zspage); cursor != NULL; cursor = - get_next_page(cursor)) { - if (!trylock_page(cursor)) { + for (cursor = get_first_zpdesc(zspage); cursor != NULL; cursor = + get_next_zpdesc(cursor)) { + if (!zpdesc_trylock(cursor)) { fail = cursor; goto unlock; } @@ -815,9 +837,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_zpdesc(zspage); cursor != fail; cursor = + get_next_zpdesc(cursor)) + zpdesc_unlock(cursor); return 0; } @@ -1635,7 +1657,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 zpdesc *curr_zpdesc, *zpdesc; /* * Pages we haven't locked yet can be migrated off the list while we're @@ -1647,24 +1669,24 @@ static void lock_zspage(struct zspage *zspage) */ while (1) { migrate_read_lock(zspage); - page = get_first_page(zspage); - if (trylock_page(page)) + zpdesc = get_first_zpdesc(zspage); + if (zpdesc_trylock(zpdesc)) break; - get_page(page); + zpdesc_get(zpdesc); migrate_read_unlock(zspage); - wait_on_page_locked(page); - put_page(page); + zpdesc_wait_locked(zpdesc); + zpdesc_put(zpdesc); } - curr_page = page; - while ((page = get_next_page(curr_page))) { - if (trylock_page(page)) { - curr_page = page; + curr_zpdesc = zpdesc; + while ((zpdesc = get_next_zpdesc(curr_zpdesc))) { + if (zpdesc_trylock(zpdesc)) { + curr_zpdesc = zpdesc; } else { - get_page(page); + zpdesc_get(zpdesc); migrate_read_unlock(zspage); - wait_on_page_locked(page); - put_page(page); + zpdesc_wait_locked(zpdesc); + zpdesc_put(zpdesc); migrate_read_lock(zspage); } } From patchwork Mon Dec 16 15:04:34 2024 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: 13909881 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 CAE4BE77180 for ; Mon, 16 Dec 2024 15:05:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A03A6B0098; Mon, 16 Dec 2024 10:05:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 529CB6B009A; Mon, 16 Dec 2024 10:05:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3063B6B0099; Mon, 16 Dec 2024 10:05:21 -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 0CCBF6B0096 for ; Mon, 16 Dec 2024 10:05:21 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C3856B064E for ; Mon, 16 Dec 2024 15:05:20 +0000 (UTC) X-FDA: 82901144676.30.206850B Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf15.hostedemail.com (Postfix) with ESMTP id 18464A0037 for ; Mon, 16 Dec 2024 15:04:37 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fKdAPv7z; spf=pass (imf15.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361505; 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=lUn/gBv25T3Cd6KdLLN5Xt9D/fxWy2xIzcxbFVGSSxQ=; b=Bgu6Ye7DzcWNmsvPAzF7M6jF1eK1sc6ttT18XLpjpHuH5WkHxDWz4oypT+43o0DE6+r3aO Lld3fgkdKxLQlz4q0zL8Guupg2o/7icmgqdT5pI7QphtA2cAbJzmWiWJTNQVyo+l5CO6l7 Z/qTPeRlH8wTYf5U79Z3Hspno+mZ1yI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361505; a=rsa-sha256; cv=none; b=iT2mxzQQqvYPthLxTUL5kPgnzeB/X3Eza7NkuDRrCTrKQcfUhEs9jAOinaO7K3s3DU5n1e eE2DGJCCVKMfiuHFeJQgdypNxEIa+Gqpt8VJtSF9e4QAkZGGmqmhbN2BajAHzEL5WHQVZe qZE3dAS823X8rfKQ4Yrevr3LVzNjqIA= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fKdAPv7z; spf=pass (imf15.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-728f337a921so4383515b3a.3 for ; Mon, 16 Dec 2024 07:05:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361517; x=1734966317; 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=lUn/gBv25T3Cd6KdLLN5Xt9D/fxWy2xIzcxbFVGSSxQ=; b=fKdAPv7zPDFGI8EURucK1vtWX/JaxTiAvdfskdcB8Ee9pMIPIong18GP5a22bxZbw2 TV5Vrq6zLK03Z7s+yc6BbE2WjzdYons15Wsolbahk7k8nLtO1+1HDT7KJkLY825M6ejq nRkB2ESqbMznhI2UGB7Qm7LLMExwjyqueX8M0WfTBfp9b/mBdjNxW/f0bTuDdRX7WwOL pSbUs/FWxws0PYNnOOqrFmTuc3lEoclGbEiqdMoMQCIK0R14aLuiZ5tsmU/+QVmtu2fx X0e5FixW3WiGmC/wmjFHi6tKbHGzpXOaTbAr/FYUt6fI9aNNMuQYBNqTU69sbR14sNsU 4/Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361517; x=1734966317; 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=lUn/gBv25T3Cd6KdLLN5Xt9D/fxWy2xIzcxbFVGSSxQ=; b=LBrE/sELUW5FPaFosKZxiR75j+8qsKuK6Rvb+FhnPP8S5R4sIuXUkNc/NKxkjaMXiz KaZVXuMx/zV8tJeJxt+j7+tgW4jB608yju4ypUsg73KhqYiCL0iHdIdr7QRfvgEBY+8g ktG7tTIMhWZLvw9hXpHDZ98CeRGUITvyOGjQ8PprgJnlz5XZsbn+uIbguZXb8RxLSySw epA55uON1yETR9rGSwNewEan+y0so8qDcsY4IGnmoa1+TjQWB50dQGm/8G2H7Sn+ga3U SBs+EhkPwfuBHMSQdrzVpQYMXXjpL/GbTLusvoQW2JHOFE4a1508sRa+2c2ogbJKhKtm zWEw== X-Forwarded-Encrypted: i=1; AJvYcCXlEj3Zf4MWpqLmbawvFqBhVCUJZkvA3JEQSnWT30QUEPSV9miI+Mrse7l9l7cOjQtrWaMpLnhzng==@kvack.org X-Gm-Message-State: AOJu0YyAH0/qYcCpnq9Be2VfbvzbA7q0frYzpibdIx5McWnbIDIHgpBE SdCM4AMJDmPFlhGRcN9kr7PX7hdrL4BZq5QspLBdavLmsn1/LExx X-Gm-Gg: ASbGncvRGKETfHg5kDqjptXEKSk5V2oFReNwIlPnu9OH5wIm1rFi/Ym0k3NNthXkiO3 PFpNVOkzuTKxMHcy21zfB2sJylaqphQ3pyaz5ABQGR8/gZgA67j03vbMKFamR651f890u/42QQ3 0QcnV0BfXulV3vCTQTmwtFRpMPyK7nESlh8MijzuKKnuw+hgG9IfYWvFH/kRFM5alrM3z9FZOlK Dc9w1S3e09DFps8OkVMuffCe3yO128eAtaBgvhYv4fg7cmLgPVsAFOv7Yk3bgrkpoA= X-Google-Smtp-Source: AGHT+IEGJH+oTC4wITxq7ixqlLM3e/HIvJgSUVhaR4neTLa+rWu7QZPqzRa6GZ1WceIz+lNNlZJydA== X-Received: by 2002:a05:6a21:6da3:b0:1e1:a9dd:5a58 with SMTP id adf61e73a8af0-1e1dfdee4d9mr19642448637.30.1734361517516; Mon, 16 Dec 2024 07:05:17 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:16 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 03/18] mm/zsmalloc: convert __zs_map_object/__zs_unmap_object to use zpdesc Date: Tue, 17 Dec 2024 00:04:34 +0900 Message-ID: <20241216150450.1228021-4-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 18464A0037 X-Stat-Signature: ypuqens5w5sycnzphgkzqq1q9yr3nni8 X-Rspam-User: X-HE-Tag: 1734361477-298846 X-HE-Meta: U2FsdGVkX19ckO8cyvyOayAvC+WCx4hK3Zs5Q4qtGoC7jMnH6GxGMFnoHGxe9QzpMkl+RBgZOLEK9WrrAJtscUFapoz1hIS+093GhrclfiF3yh2wb4UkD2HPTeEIOE5c6OBUIGdnf6Vrqyzm2Gx1LfD0jueZ3JuOKtdGlCagYEBWTY+xVCphe96gaf5R2cCLeQ+zOV8/vOtcC0mc2aLqgiBqXtXFuZ+H744F3ul9bCMLx3A0/pehSaXT06yOd5CmRKZgJw0pxpK1QYyCThQd3CgRsPkPhtPq79JwSOu4M1SjqCnxESqMvsx+xWpneWlrQV+MVQ3vCVaHt936rcrh6kiCpfWS/d3Ke2jtH4GGd66CSA+ygmIvBB6l6LRsF1dPT3yaDCaRJVCsVqVVYoLAvQypyaGc2ue34IZBIb33aX6BOf7kBWIu86rXE8HvXq9k8SXMDcJZXW8hG43zBwRIehT1dLxx3P6lKT9KD9Axoq4H8EevjDLRwcZQXtD2TwIXi0slsxkG+oT5EjMabNzaMtAGgjdN9ZvzdSfdrmGHJR2O1CZw7UosRL02e8t9fieLTb5uKo9vWrVCklQRj4ojWc5TQyF3t3l1E/AiKuIn8XgNeYTd7N9wMTE5eo57TZK/nfW4lMG73e6WWhNlfmGfpQfpLC34+aoUbF+ZBMdar58vSV+situ6MteL9Tn1MUwILSEVzlIORESk01G4cnFaySU5NNxoyKhKqjOH4E+juPoBmSAsc+dABg3g2hlWWARR3HYAMW9vmAdInjYIeeEuppmR/bt5KM19LPjuAVJLGT5PkeeQaO4LJseTwm3iO07vP/2Khp7pA6A08oBxu3hascPlNKBd2ZI3T+A+maWQ2Rk995hv0o72l1VEqINC9GdONFoXIsLwseapf0oG2pUNATzcY3qzedY21XViiQF3bkdj0vlpB8Wr2U2DtjhFa2l27JttejxZMnrE++xJX4w IyNND4r8 rN6vUTyiMQgMHMpzwMuOMwepj/n1yhjXNJ2B+k353SdaAd5j+DQFUalQlN/9Ps4LUZZ5ujgPwtTC/+IoV5j6RRqSv93VPvRzYmetz37t0QmB85J4542+5j9KGqaSyXOnHwNHUBpHgHayod4Hy6xzrvoxy91lJ0iSE05ulNoUc35NpC6B11YambM7KSbcvhen9nWG9lVhbuyyFiNjWnk2Inbclr2ge+pc6lIi35yQ5BVYXVsA0A6mB/cFkIp1Oj46IhUHfe+ByK3jgTudtrRaupZ59YriRdqK0USRgXvfmuhJDQsKb2pBUlxUKjTXHYIy0SZeMETC4Q3iMr041aY/xdDgq/jjigATaNx7ZrUuSA/2sD66Gt9vi5leW23MnuMAtBv8qaHsEg0XM2nOUVvC2eJUYi2qBZB8b251NGf2iYBOCcwhsXelr8uIcjExIP0s9rAooP+5RAqMvj5tyzb4pi8keUc2a9N+f+c9kXaU03KX40yjruhGa7qSDrhFDJ0XcyLglp6oMwI8YUoyrgPFPyhDwh0K5WuhWNIKZLFIyacNdA04= X-Bogosity: Ham, tests=bogofilter, spamicity=0.347014, 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 a pointer to an array of struct page. Make __zs_{map,unmap}_object() take pointer to an array of zpdesc instead of page. Add silly type casting when calling them. Casting will be removed later. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 51f4a9b78023..c038caaef3a8 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1049,7 +1049,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 zpdesc *zpdescs[2], int off, int size) { size_t sizes[2]; char *buf = area->vm_buf; @@ -1065,14 +1065,14 @@ static void *__zs_map_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy object to per-cpu buffer */ - memcpy_from_page(buf, pages[0], off, sizes[0]); - memcpy_from_page(buf + sizes[0], pages[1], 0, sizes[1]); + memcpy_from_page(buf, zpdesc_page(zpdescs[0]), off, sizes[0]); + memcpy_from_page(buf + sizes[0], zpdesc_page(zpdescs[1]), 0, sizes[1]); out: return area->vm_buf; } static void __zs_unmap_object(struct mapping_area *area, - struct page *pages[2], int off, int size) + struct zpdesc *zpdescs[2], int off, int size) { size_t sizes[2]; char *buf; @@ -1090,8 +1090,8 @@ static void __zs_unmap_object(struct mapping_area *area, sizes[1] = size - sizes[0]; /* copy per-cpu buffer to object */ - memcpy_to_page(pages[0], off, buf, sizes[0]); - memcpy_to_page(pages[1], 0, buf + sizes[0], sizes[1]); + memcpy_to_page(zpdesc_page(zpdescs[0]), off, buf, sizes[0]); + memcpy_to_page(zpdesc_page(zpdescs[1]), 0, buf + sizes[0], sizes[1]); out: /* enable page faults to match kunmap_local() return conditions */ @@ -1230,7 +1230,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 zpdesc **)pages, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1265,7 +1265,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 zpdesc **)pages, off, class->size); } local_unlock(&zs_map_area.lock); From patchwork Mon Dec 16 15:04:35 2024 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: 13909882 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 525DBE77180 for ; Mon, 16 Dec 2024 15:05:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E03D66B0099; Mon, 16 Dec 2024 10:05:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D662B6B009A; Mon, 16 Dec 2024 10:05:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBA316B009B; Mon, 16 Dec 2024 10:05:24 -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 92C476B0099 for ; Mon, 16 Dec 2024 10:05:24 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 478C6453D2 for ; Mon, 16 Dec 2024 15:05:24 +0000 (UTC) X-FDA: 82901143668.17.EADA68C Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf05.hostedemail.com (Postfix) with ESMTP id 026A4100024 for ; Mon, 16 Dec 2024 15:04:25 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WJ+M4YXE; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.174 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=1734361494; a=rsa-sha256; cv=none; b=md4NdRKw/h4dzZDjRdUTTbc9K24ezFXJHYDbUNKW4x2wE60p/qXs3rbn4E5sDD2vORBWVt SBZiaGvjYd3D5wS7q1u80mNvjtwQPHACpVJSRPtkyxeBKr1tI/dl8hkvwK7ORpIR21uV7D Z3e4dCqS0bGRw1oYGWpFVlbrLZfXpIc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WJ+M4YXE; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.174 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=1734361494; 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=rflbkDAp6RcNtVda+UG2slAkUpkyNSVFqWrX1eClUo4=; b=4yZYrEkrhBLvIA5KfKlJneuMZV+nJIeMF/ekO0fODtNs/IJ0MBLBWJEa/QbEOwkIcXhx20 ZUUHy6SpTqdMxVNLHlONA4aF9RiNEC0ZLOO4ebW4SxlJqFZB1p+ozAPs45cn3UduLDEvJg Ozdvr13SHyYC6pPbAP4Xy+rOqaVaRs0= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-728e81257bfso3284929b3a.2 for ; Mon, 16 Dec 2024 07:05:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361521; x=1734966321; 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=rflbkDAp6RcNtVda+UG2slAkUpkyNSVFqWrX1eClUo4=; b=WJ+M4YXEnr5GApkOUu2yqq4mIp+Cicx9//r5YA5J9gmNQgEZpGPdGmQaxC6fMDBTDA aRhBdanKTV5TsTTJuIfYmtQeLIqhhtnVZs9jNzrQWna/KXfOVqtk9fXxsMZvPwKjOLnQ o36kdvckk5X6rUUZLLKBog/i++Nuh09dIXirJdx+oPumEBkuZkZwymWG9uAXYQNY6e7o 2PRLM0xC7ti8BFMo7HyWM7XM+wUTopMGz9U7oYFbpOjMWoYXo1xunqUTKJZ3g7R5zWh/ VW1oY0SWbnYOaSLFmt/QjsAhhv2INrIpFE3c080BAyqvErPp48sTbDEUl59RhBCJQYVl AXuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361521; x=1734966321; 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=rflbkDAp6RcNtVda+UG2slAkUpkyNSVFqWrX1eClUo4=; b=WyAjXaENzNkHq1ymCLG5+TxJuNC/O4YAY5gw0jkPM3eFG59bQ7ZkMq06iIMnUCCJvn r3Dgs3p9ZpNUgEXmFaxnWEY9GKUNN0bKP8jGOvqTm7nOy78MUTjycJE8mz8FuZf3EdFK LOISgkikMcfKs5LFA9yTEOhwLf9kR9gT+Ln+fBemZBGenyQd93E4yPWz/DhPj9W7zu+T BP0ysLoGe4kBryoQJKQMHRy4iPGaj3moys1xFJieVobZDwwlKLWuPNH5ZQfkKm5V2CCi 0IZM8/SribzDQJQ03PJhxXnZhpRWmTsLbF5f8JOtmHSmB9ch5WygGdnKcEC7PnAylwoN XJ1g== X-Forwarded-Encrypted: i=1; AJvYcCXKEvEpykzRzU8K5Vppo9YwEmEWGbfbbZG8NekkNFRQ6GIMXlEokxRjJZwre7EUaM/LuiSyPrivow==@kvack.org X-Gm-Message-State: AOJu0YzxSVYkcq3sAwi6AEQLjHVPb76qgK+2mS83eMTcJLqtbxsDilW+ 9zrc2jaGFFEwOYSKTgxi+aEXuGLonjrbCItDrOa9/+b47Po/XuEZ X-Gm-Gg: ASbGncsobMMV5jNEoDH3c2IEzHL3/fh5WBEF+z5sFdhBCu6eFl17mDhrSNR9ytqZnp+ 580z8UMh9Y3E4WEBozk891tbUQLgYJHKQn5TD2SKCILGW3vN/2y6LXr0XFk4OvUn5jGOd0HplvJ v0563OFpYbXjh2yPCKckImlTlM5XZpmT7ULSeuqJRNsVtmw900pUOvATov67jyBxJ0EuRYKq86+ hkhhNNhS48bApJ1uk/woBqnjdrDIW3Mcu21X0XsWD7v3ff4nCCpqTpCA85EQ2GLges= X-Google-Smtp-Source: AGHT+IHTXzJ38/pN9SU9hmW2MVA6I4WUxZ9xDsFXfQGWf70PGg/75+A1Wb+l05U0+9QH4TJPtl8H3w== X-Received: by 2002:a05:6a00:13aa:b0:725:c8ea:b320 with SMTP id d2e1a72fcca58-7290c1eb757mr18879829b3a.14.1734361520606; Mon, 16 Dec 2024 07:05:20 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:19 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 04/18] mm/zsmalloc: add and use pfn/zpdesc seeking funcs Date: Tue, 17 Dec 2024 00:04:35 +0900 Message-ID: <20241216150450.1228021-5-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 026A4100024 X-Stat-Signature: uipzdetxzqymsumjz6ibtxruhmuh1nrx X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734361465-855721 X-HE-Meta: U2FsdGVkX1+dCNzB3UzIOBW7hptuj+h5WLYkaAIq/3T4itmmE4CSkLntXw63UFzYiLHoWvXE14V3t/nKbPYYPitEkbKUFUSyG+2yCO7XkXbIyYG7ATqL4Y9RA7YKW7gG8JO8NW5rbkqhwPGcU/2H6326vSqWZD2BSX8f0h0bhPoP95xAOKKdIHp5GpXgSxDmOS2BgDz4jCKXaH4GVcVArfiA+enMKXjLmGHj0zNuI3jBUVKLzilOluaWRBz1+Vauj1Vv8GK6ITBf9shPJ6CUM7YzTjm1kXEUCR4/oHY86wbxTpxFfX4sBBJsaviFCt4RTjjYRt9oaUVMmRhmwDgxOYzn692eCgW+8N/Ts49FneQwflZCJRUyXbWVwS0Bq4qxieQn9cMQLb4lao+7xKFibDv/9yie8qxfdfy1bU9g2QLRrbqsrbs4uxDEsNplZ4FF5CMPikUCPJjuHkywwM6gaMWvIcPk8godCy6Hv7WtaiUyHisibhMt+q2re4v7s+zcBtXMnTDccBhxlA4a7FMwCwYdSz4NeD768iOjxAhTkYBQLQnpHdWcw6ciFcxxojRQhS4YFKG8Cnfid07/bObLzZzxUOcHB6pAmoTyafnJjyGqTL2ey8KjAEQ2CM9GaLtmCRWGA2IsGghKlQjvJr5MVPjGz1iImSakZ0tgttsU6Qx5RaQkkRouzJ2z36/whi5sCxpjjQwH7t/AGPUesWNbZk3FC95njPLJeRMuu6ZMFzyzw2SxYpHdKybhxzPNb6ubGbOzsNLS1vpB8IOzocNJisiKAQxsFCgCJOPpKOaqiJ+r3EtpTTq0CgYCncPU6Tyhdhp1xer4ei6D17Yi9ROcUGcKcGs53IywLuQQGACaMu5Pa25CG9SVMdHm3WNCegRVADAruH9fk2+yzVRumllMk43iBwmY1bd8PjOiymolZVYRdBRSsonHngvzpIfARme0MvItS/EheAZ7550VfBC /43np3ol 97JqMIIS6WA8fori3Rh9c3z4U6PrIc6/1+/BuuCNJFlcLLKrHi7zaDTEr7kgRLL4XZQ1+E5gd8rK+qRlLl013QfNpjyy64b5Rxn/Ilb38WGA4XZH8FpUdPjMdBNquFUioN9owuvLPY/Rz+az7hiEdqs0BNpNS6tjf2wR1KKOpfSEOJwxQQK9h4ppCJ+S3AZvBDbGIV/TsjVce+emPK9HP28IgTQ2kok7SqiPOEdlvq24dCbmwkmZ8DkHuGVw/6/pY1b/IrAwiCNolspcUK8Z0461FgJ0ioB5R3u1XEsE97bd2ytO6S9634C9Abe8A48ZeuFOKqFOrSUQfmC9seweo8j1J8Dkpa+EMyB0oVDpUSoaWPnBpVogV7s8q2++bvwVd6j1+W8RYFiuNz7lN7HodX/hehJdr8ubJsXpDsYl2I+1xCzNKBpAV7oOZrpqCYJ1yHSlrCEIqYKMsYTe32yF1TVipXZoUeB2K5WEer5I+E0pu4UBYNzYp2Bt287MTHW+U/Sb5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.009500, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add pfn_zpdesc(), pfn_zpdesc() and kmap_local_zpdesc(). Convert obj_to_location() to take zpdesc and also convert its users to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 14 ++++++++++ mm/zsmalloc.c | 75 ++++++++++++++++++++++++++------------------------- 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index c866758feec3..223d0381a444 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -134,4 +134,18 @@ static inline void zpdesc_put(struct zpdesc *zpdesc) folio_put(zpdesc_folio(zpdesc)); } +static inline void *kmap_local_zpdesc(struct zpdesc *zpdesc) +{ + return kmap_local_page(zpdesc_page(zpdesc)); +} + +static inline unsigned long zpdesc_pfn(struct zpdesc *zpdesc) +{ + return page_to_pfn(zpdesc_page(zpdesc)); +} + +static inline struct zpdesc *pfn_zpdesc(unsigned long pfn) +{ + return page_zpdesc(pfn_to_page(pfn)); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index c038caaef3a8..e71da84ad73a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -757,15 +757,15 @@ static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) } /** - * 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 + * @zpdesc: zpdesc 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 zpdesc **zpdesc, unsigned int *obj_idx) { - *page = pfn_to_page(obj >> OBJ_INDEX_BITS); + *zpdesc = pfn_zpdesc(obj >> OBJ_INDEX_BITS); *obj_idx = (obj & OBJ_INDEX_MASK); } @@ -1181,13 +1181,13 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, enum zs_mapmode mm) { struct zspage *zspage; - struct page *page; + struct zpdesc *zpdesc; unsigned long obj, off; unsigned int obj_idx; struct size_class *class; struct mapping_area *area; - struct page *pages[2]; + struct zpdesc *zpdescs[2]; void *ret; /* @@ -1200,8 +1200,8 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, /* It guarantees it can get zspage from handle safely */ read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); - obj_to_location(obj, &page, &obj_idx); - zspage = get_zspage(page); + obj_to_location(obj, &zpdesc, &obj_idx); + zspage = get_zspage(zpdesc_page(zpdesc)); /* * migration cannot move any zpages in this zspage. Here, class->lock @@ -1220,17 +1220,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_local_page(page); + area->vm_addr = kmap_local_zpdesc(zpdesc); 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]); + zpdescs[0] = zpdesc; + zpdescs[1] = get_next_zpdesc(zpdesc); + BUG_ON(!zpdescs[1]); - ret = __zs_map_object(area, (struct zpdesc **)pages, off, class->size); + ret = __zs_map_object(area, zpdescs, off, class->size); out: if (likely(!ZsHugePage(zspage))) ret += ZS_HANDLE_SIZE; @@ -1242,7 +1242,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 zpdesc *zpdesc; unsigned long obj, off; unsigned int obj_idx; @@ -1250,8 +1250,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, &zpdesc, &obj_idx); + zspage = get_zspage(zpdesc_page(zpdesc)); class = zspage_class(pool, zspage); off = offset_in_page(class->size * obj_idx); @@ -1259,13 +1259,13 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) if (off + class->size <= PAGE_SIZE) kunmap_local(area->vm_addr); else { - struct page *pages[2]; + struct zpdesc *zpdescs[2]; - pages[0] = page; - pages[1] = get_next_page(page); - BUG_ON(!pages[1]); + zpdescs[0] = zpdesc; + zpdescs[1] = get_next_zpdesc(zpdesc); + BUG_ON(!zpdescs[1]); - __zs_unmap_object(area, (struct zpdesc **)pages, off, class->size); + __zs_unmap_object(area, zpdescs, off, class->size); } local_unlock(&zs_map_area.lock); @@ -1406,23 +1406,24 @@ static void obj_free(int class_size, unsigned long obj) { struct link_free *link; struct zspage *zspage; - struct page *f_page; + struct zpdesc *f_zpdesc; unsigned long f_offset; unsigned int f_objidx; void *vaddr; - obj_to_location(obj, &f_page, &f_objidx); + + obj_to_location(obj, &f_zpdesc, &f_objidx); f_offset = offset_in_page(class_size * f_objidx); - zspage = get_zspage(f_page); + zspage = get_zspage(zpdesc_page(f_zpdesc)); - vaddr = kmap_local_page(f_page); + vaddr = kmap_local_zpdesc(f_zpdesc); 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_zpdesc->handle = 0; set_freeobj(zspage, f_objidx); kunmap_local(vaddr); @@ -1467,7 +1468,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 zpdesc *s_zpdesc, *d_zpdesc; unsigned int s_objidx, d_objidx; unsigned long s_off, d_off; void *s_addr, *d_addr; @@ -1476,8 +1477,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_zpdesc, &s_objidx); + obj_to_location(dst, &d_zpdesc, &d_objidx); s_off = offset_in_page(class->size * s_objidx); d_off = offset_in_page(class->size * d_objidx); @@ -1488,8 +1489,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_local_page(s_page); - d_addr = kmap_local_page(d_page); + s_addr = kmap_local_zpdesc(s_zpdesc); + d_addr = kmap_local_zpdesc(d_zpdesc); while (1) { size = min(s_size, d_size); @@ -1514,17 +1515,17 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, if (s_off >= PAGE_SIZE) { kunmap_local(d_addr); kunmap_local(s_addr); - s_page = get_next_page(s_page); - s_addr = kmap_local_page(s_page); - d_addr = kmap_local_page(d_page); + s_zpdesc = get_next_zpdesc(s_zpdesc); + s_addr = kmap_local_zpdesc(s_zpdesc); + d_addr = kmap_local_zpdesc(d_zpdesc); s_size = class->size - written; s_off = 0; } if (d_off >= PAGE_SIZE) { kunmap_local(d_addr); - d_page = get_next_page(d_page); - d_addr = kmap_local_page(d_page); + d_zpdesc = get_next_zpdesc(d_zpdesc); + d_addr = kmap_local_zpdesc(d_zpdesc); d_size = class->size - written; d_off = 0; } @@ -1763,7 +1764,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 zpdesc *dummy; void *s_addr, *d_addr, *addr; unsigned int offset; unsigned long handle; From patchwork Mon Dec 16 15:04:36 2024 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: 13909883 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 2B46FE77180 for ; Mon, 16 Dec 2024 15:05:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD1046B009A; Mon, 16 Dec 2024 10:05:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A598C6B009B; Mon, 16 Dec 2024 10:05:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 884586B009C; Mon, 16 Dec 2024 10:05:27 -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 630CD6B009A for ; Mon, 16 Dec 2024 10:05:27 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 23FC51203D7 for ; Mon, 16 Dec 2024 15:05:27 +0000 (UTC) X-FDA: 82901144760.13.5A43DC3 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf18.hostedemail.com (Postfix) with ESMTP id C9A771C0004 for ; Mon, 16 Dec 2024 15:05:11 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cuAxtTux; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361502; 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=kwR4Kblt9I5wGNH91Yw49hgsy/SeTIW9WrJpJz9IUNw=; b=WeKXeRSV/Ce6DnOZMwEbX5C0CiDmgKEtucIo59uiNWv3UYWIikwOm2e+1k0fGRwIUGKOV7 7FcSu8gPhqR8b8o9V3MduEkoBAd7yp25MGD5iIIGBZMKpZa1NBN3ePZaRsSGBLZRJ5cBDN 8QVJJyTvbCWSJavR5yDsNSxwtpCdKcc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=cuAxtTux; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361502; a=rsa-sha256; cv=none; b=tg6kWfH/JR19U8sb4L4q9n36jXoo7bfMv5YOfIenhgRbpyHbwGcYCNZLfIw7i2An7bcyg1 lKQtASKXuNbwm+xn2ytPD/o2d6MF8CuFZonV/WESHbKzs4l77nZUP4m0zW+N+cMomDNMyb /vq3S8AIpE+666UzeVf7ALwp25tUi2Y= Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-725c86bbae7so3496468b3a.3 for ; Mon, 16 Dec 2024 07:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361524; x=1734966324; 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=kwR4Kblt9I5wGNH91Yw49hgsy/SeTIW9WrJpJz9IUNw=; b=cuAxtTux4UaMEAbTWhGhnJAKx+Frk0aXeUyOWEPtv1UpeCfktJd24yuKYlln2K6h7T CFtcPB/wdezu9P8A1eJtyU+/SDM4qI+pWJSOdsyaNfYFNJsi9ZJX0zF1r6J6RV+XWK/H 1VJDZhbBepPOODuKaMh0hDC9yyCbRH09ZXg0kb/0MRrFZUXpyc51EDDyGGL5qm0AdcqW heGlNxZZ8nu7PeaOylOFVqBV/yx28OcSN/8KNnBUm6ELz5W5/okvgM+S5j3JYehP2+vv ydURCHCFRafpfrDfs62kSSCWoEhnzDBZ0hytnTVqwfrLeX5+g3UjT1tfksLMH/RmCNzp Ky7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361524; x=1734966324; 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=kwR4Kblt9I5wGNH91Yw49hgsy/SeTIW9WrJpJz9IUNw=; b=vY4X1nQ5JrML2V1aww4z6py2FCrr4jiEc0Gq7KwxqWYXGIF6EJnOO258ao1ZTzVUhs kYe3frHbev2dpvM/fETfedwOgheVckXqPANiQhzHjBYrmSLAEBjfU481AtiYf71k5nFX 1rbq9PH/0W61hRdk3uSxwWTGftbOV9BQ4teIFxcjRxX5QWvfimyoG/bpXArjNbZr1sIQ 43hxUsVWT4+S2J6iL4w3kNBPG0CCCsk6YE38F0Mqi/oqql8ECnXfdzw6bhOhJKdfHyTt 1UJ3Tpm29CtSqwSgUbzQkXPO18sAO3aYKMwRwwc/HS8FMoIL3VekcEDHGcRtCNz3sqUo y1Qg== X-Forwarded-Encrypted: i=1; AJvYcCWJvyMRkM8stJRNQYAiJtTZnFV/e+gTf+FgzxP8IctE9Z/ilL6q7gw4WycGEcZSpFXtZvPDbB/MRw==@kvack.org X-Gm-Message-State: AOJu0YywUZAcRzOL66aW3/gPw9Tnb9nOiwJ0NHwI3EgkekqT3Rjf5l05 c3pHsGC6fHH7Dx6Y7272sSUuZo3zD/uJa4B4yo6EppTKthn+R0Ld X-Gm-Gg: ASbGnctxtc6kYjVprTLfF67W919TXd+7aAAHcd2qpafpezeiVawndBwIRLrRtCWbcxD 0LsIuk8RjtpvJp73L7+xqYayp7JwshYB+EHyD20kUPIW31X+dUyXYib1QAS3678b4xDcW9hSJv1 FTS+5qfAF74SvtZH8JPfU0MVIhEm274KWe/7bdVjUrvGkD9/Up7WBXG/vgVox3px5FVVgW/yUXr Kzqc9cH3Cm8prTSQztyoZIQKuhId066O2NCmJPwvbRgmFCcVxlKP9sUtMo+KvqIqg8= X-Google-Smtp-Source: AGHT+IFdtXwULYpLfCdhZkikdihqfVSBIdLhwsM5YoIBA2XpOycR5dSAkcx2Y7UFlJRvJkhs5EQ+Jg== X-Received: by 2002:a05:6a21:1796:b0:1dc:bdb1:349e with SMTP id adf61e73a8af0-1e1dfd3ea3fmr18992894637.17.1734361523658; Mon, 16 Dec 2024 07:05:23 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:23 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 05/18] mm/zsmalloc: convert obj_malloc() to use zpdesc Date: Tue, 17 Dec 2024 00:04:36 +0900 Message-ID: <20241216150450.1228021-6-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C9A771C0004 X-Rspamd-Server: rspam12 X-Stat-Signature: baksroak9i7bum1r7811gefqpioy75bs X-Rspam-User: X-HE-Tag: 1734361511-567448 X-HE-Meta: U2FsdGVkX1/nmh6K3ZNV1vhujqK9NSSAO8VRqTlaNIha5RPkGcPtH1WTc2S/EHLtfSMZ19GMYUjY0zAl1yuz3e3FDsxzZkEPPeJL3VSYe69xMc2Rr1UtCdQu9ydk2ymU85l0TtVTmQp05Ac6NOFwMTv2uZobCtwxL9s4NWtNUDvWvC0R53GZXhLkJw98NiaXyMJmTaEQtPiK+Ecv0ho38VS5V3TuDOcqnsWMGiXj9iLAl3wYSJhYF/qnvXsqFBHCCH/XvPjhw03d7IXIiA5QbP5psh0gefyUAV0zpnyOxo4gxEinWYm0FowBFINc8tXPv3Tma5lXlwFS75gA1FGYbC/ljIa1CUz5OFISKECJ3MNQ3UOHqXSDUZ3tnTgWXixhB+ka+8YW0BxC4aZX0ltJlK/7bQbRj8TviieV+1NqZ9sAwuYTpMF6zIGpEEp1F8f9tQ++/ScKkqNBnw2fu6Q3cz1cGivT8PJ6Go5oNLGQovDBhXJdEDYf4gSgKLLMvIDNh6Vi+HLPm4FPwv3/lMQziCoh7w75NwPVVzF5lhOrJVyqvDQD6/GdvFkAA7irl8hnvmMMsjWH7STk+HP9nui7eDHMCzYnCINW8EfNKW1SUPvpnLFfDegbsKYVa9q/9i7rKCx5kItUylOZP4eL7adSQoQa3onpPzQ7bha+MLEJpjfYwdQ5Yqdk6UT06oEVuZKCCJ4FZzaJhVhfSkkMj2fQho6YAHiixPHqpa/IH+qMro22WOFzlLgI05mfveZQffsgDHehjE6j6Z9P0zx0FHH1kWiKC2Jxa+lS4K4ZvS6USsCvrT3mDXLpEbDYWfJnfo0u492Ccm5mkiFB2RT7SeQcaTQLRkZBjqtjV8ZiBB33TUfy5RwWaNm5kCtjaL3tagnYJ4XXoY+88s527GeTmifHXB3Chz6pMYvlBSW8mHMObDrNmV7aI0XqtpfqLoTq6n65ooHsfM32OnOghhx8NZ5 lAHJaxSJ mKE2nSNIhPLWARdb5WGnYLej7WWZK7WIwYLsy06cTHkVfG9J9lOcozsD13kZMC2fbXRR8cnMHWXWEoFP+bOS6CljjoaddJaYRZo1PcnEX00Xq7M2lE2RptESETYtXlw+kc68LEfsQPDCUJvBdCFL3zJdvRwc1efGa8vj1ls5+o7WTesX7KqcxXICwv8O+tPcW/3IYh3KdndwBV7NRT7+y0H4T7ACt2ftg66dDlMrPmK1unMaMcXQ3sYD9kjdxdZZPGN9ou0avnt4SKt0eXA1vnmc5fMLjoYCABEU1foK417aG6s4IYNdd8V29TtQUzmJg0J+xletodcXh37GBMltRN9PrjmOKQlKAIa5DTME00yFesFpDF2jNOsp22shoMFCZ28l6LACINYOfNNyv8zFmHEYCOdTlwoPTMb/wEEx7xb+v+wyt1lpkC6XhOXtKLm7jCIj0THCraFLOkUBEmK1MWAxkYypYZRoEcLVBz2pZVTD6GILEc8QhH+3jMehKL4IiThpMCPSva7P+RshZfxAMQrkAGmHH1HfonKIBoVkIELv2WCs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.428842, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use get_first_zpdesc/get_next_zpdesc to replace get_first_page/get_next_page. no functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index e71da84ad73a..b7fab2e28d87 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1295,12 +1295,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_zpdesc, offset; unsigned long obj; struct link_free *link; struct size_class *class; - struct page *m_page; + struct zpdesc *m_zpdesc; unsigned long m_offset; void *vaddr; @@ -1308,14 +1308,14 @@ static unsigned long obj_malloc(struct zs_pool *pool, obj = get_freeobj(zspage); offset = obj * class->size; - nr_page = offset >> PAGE_SHIFT; + nr_zpdesc = offset >> PAGE_SHIFT; m_offset = offset_in_page(offset); - m_page = get_first_page(zspage); + m_zpdesc = get_first_zpdesc(zspage); - for (i = 0; i < nr_page; i++) - m_page = get_next_page(m_page); + for (i = 0; i < nr_zpdesc; i++) + m_zpdesc = get_next_zpdesc(m_zpdesc); - vaddr = kmap_local_page(m_page); + vaddr = kmap_local_zpdesc(m_zpdesc); link = (struct link_free *)vaddr + m_offset / sizeof(*link); set_freeobj(zspage, link->next >> OBJ_TAG_BITS); if (likely(!ZsHugePage(zspage))) @@ -1327,7 +1327,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_local(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(m_page, obj); + obj = location_to_obj(zpdesc_page(m_zpdesc), obj); record_obj(handle, obj); return obj; From patchwork Mon Dec 16 15:04:37 2024 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: 13909884 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 577A3E7717F for ; Mon, 16 Dec 2024 15:05:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4E846B009B; Mon, 16 Dec 2024 10:05:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C7B6F6B009D; Mon, 16 Dec 2024 10:05:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACF046B009E; Mon, 16 Dec 2024 10:05:30 -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 8519D6B009B for ; Mon, 16 Dec 2024 10:05:30 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1DD261C8142 for ; Mon, 16 Dec 2024 15:05:30 +0000 (UTC) X-FDA: 82901145684.28.255B35B Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf13.hostedemail.com (Postfix) with ESMTP id 5D04920024 for ; Mon, 16 Dec 2024 15:04:59 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BtOojs9O; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.182 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=1734361497; 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=8CPvGJ/cvPTyS5UK7p6y0gXUdUDzIEZS5wzgg9UIGeA=; b=3C2jvBsqw/SmoZCHStw9bZ3C33BENOQULS5DP125cG/NOFolVqxnU5F9XluuAKqfC7ziPy TyYQzKbAt/XXsqvfaBP6mtA/Kus3a5Zb3wlFUhmWpsw+Knc27booEzcm0joV+hLN6Od2GH m9RvsFjQGichGVNiAv69khH4hHN3rgQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BtOojs9O; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.182 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=1734361497; a=rsa-sha256; cv=none; b=HPe1Af6Dd+M0nbUsxGjYUI2DvILsu5NRJWzS1DnMJnXPxQJHbTrXwdPixXrYHaJ0uQztJg nKxORVqVux10gQ4NE3/yNjrt9lMZzH0ePC3uER+Y3c7uQ5fyYTm6I9B0XrjN5XrH5XN3qV f6GloROi4tFCeiDQIkGyeV5hZRZeWp8= Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-728ea1573c0so3612370b3a.0 for ; Mon, 16 Dec 2024 07:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361527; x=1734966327; 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=8CPvGJ/cvPTyS5UK7p6y0gXUdUDzIEZS5wzgg9UIGeA=; b=BtOojs9OlbeVDVPEGYwRNJ9kPnp0ADcZQIFHiBwY7V1rMQW7as4vih1iPl1JMBukle dZrja2/YZ4ZDJdbGKMW0ahsaVQk84u0CM+tKCLUwpuHSz0NR9ECwu/tl+KznXJ263F8C 79RCvr0V1R2corR1fVIVS+6MMcHf++eqpBI5MkSyBafWDAJmirGouypLth7l3BAJrmXR 0vPwMBM4kChS1d5bRgaAWXxGBUYNQjUPR/jukoKWBxIWX9aDQNg7p3G8uqKDbEsMUB8i 3pw395s17Ea9KlctETZ+soG0Wy2t1l1DxeHe28BilW3iBTVX6yYnI///AAAmt0AZXdk/ yT9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361527; x=1734966327; 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=8CPvGJ/cvPTyS5UK7p6y0gXUdUDzIEZS5wzgg9UIGeA=; b=f/dDNg00DMFkG20VXEkfXZjDfdaG9e1BTKgEShPTa3g2GRK6/GZ81aFp8EVpMBXKq4 MWghwDVFF9RaDWIOyaw0KaUKt9AqseQeo23GtE/fcpolL9tp5zITTn31OoQrE3Iyzxq2 txbavmA5ZHTu3LHxQCRopk8nBdqVwyNJObRVJZNS0ovqiX9FPzGddiNic3ghNKriQKH4 7ZDPjoOwBNuu5jVSXhbeffgaR+LcIjY/r4BMm5Z/aMR/ZyV668UVFtVxgi+lPGMREABe xQEJNLPRWh1AydH7VdAtlP6JDXzV9xngDOdIpS/j06WvrQJ7dZOeM7wXz5EPytrh6rTf brHQ== X-Forwarded-Encrypted: i=1; AJvYcCUSMheXKOMXfU4VoYxsXBZkSemh2GnhspMp+qTOK3HZIUNU6Nk4jWgRVqIAb3Q3RhjwLN+tLa4vRg==@kvack.org X-Gm-Message-State: AOJu0Yx5b8+wTQglL+Z0YOISkDsKe3WHOzx9kSvRIqC9Ue12oDjegp0D 5mcHJKDhBFL7sqTcU26sO/cjQPooPEHf9U+ZOMCnu0RWnoGLRdxi X-Gm-Gg: ASbGncuTAB3BQIrnbb/wUKhLeDqBSovpKh2esjGg9hQCpXS/lvN9DCF67XL07+goHyN 5pH0qFgpAOcPcajihiYs2usVsDD4Hk5uPJmLEC+pEzYgdES+AH+7gHppt2qmB7NhlvaZg/JTjM7 qEOXIqByXcFas8Ole9gQ5zeWk+mE1Z5CDAoBZeb+gTiIcgNTxtcJ0Ps/iHEGu+H7REi53MX9kbO Q5pvc4o9g9t5u0x9mxlLblNSkxQxfNNt4cTTpSH/aJqHs80QaM8M7Oy97jTI2aQ1i4= X-Google-Smtp-Source: AGHT+IF0IuixUtLePxUF06qWaeSul3ZHb6NgVZn5KBzAPn8kgm5kB3cDfnzi0TIgos2HRYxqrYA2Dg== X-Received: by 2002:a05:6a00:3d52:b0:725:df1a:285 with SMTP id d2e1a72fcca58-7290c182322mr13615035b3a.12.1734361526735; Mon, 16 Dec 2024 07:05:26 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:26 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 06/18] mm/zsmalloc: convert create_page_chain() and its users to use zpdesc Date: Tue, 17 Dec 2024 00:04:37 +0900 Message-ID: <20241216150450.1228021-7-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5D04920024 X-Rspam-User: X-Stat-Signature: 37sgib6bykzfu4e9wmuxfhkx4ucf8dkk X-HE-Tag: 1734361499-102528 X-HE-Meta: U2FsdGVkX1+yaJ/oUB6/dLUOaNP+l4KENjTgV96nhhWohjY7YTBM0Jw5XTEN9e0g+11clYneLud0WajESnIyD/dgnXsravkwiRgHAP+RlY36cVqKYmmJPBY5+r9vZ1Xk+mtmx5i+82koPHry3uphv18BAAHAJ5aVY+UQJtp9wXluPPuy3u/+ixDGl9Sj6rgNKBCyC6DtoFJu8DgWFU7h+9CSNZDdM/al7TZ+Jy17FHaSzKxsAtVh0PBZb5h8nQ1oQMakskRqWnHWnTLn9ZZivUOg/W0VYyj+25rvjnC6zffal5G9uf2BbhyINKFkB7a0PYXw/n4vWaTMME8xCh8uLbekZm3L8nM8jVePSn5x0E7p4fsLD2rLYP7u28M2PkkUWtwIR5HsQpudv0/PZUQzxcovq62VbjC+vwjQweNP60guA5nQdqUinzWdXX6/2QpUFr/XYzNqA2cyFdOKJ3XBN0KvMyHP+z6+gLqABm+18lBmtYthTLZ+h2sFWoZdRYpiExQIk9k/nlrqXrDvUxdBflkzNhfOUkE3WSzWswmRw4yfZaVsVG0ST/6fospBDlHLIhcfbaIy+kB8wFM57srGgkbqog7vWgSt9uU4TLQT1ppGQ3LemD1K1ReQ3CSNWNIoZpVvuLjk9pwoRoNJf3tCBw2liDyQKRi3ZGq5Mcqyztd6MJcIzHfYk6SLpeR+twVOo516PHXJCzAxdXqrdue+jcHaw8Se21rJYUZQytpLqyipmYCbPNgGUPGr3FRsLCtsJq1KlbgG6L3uqjtwVU4CmnTY1ZuPbjnr/4EKczqov6ZgPy7YWdM34/tDiGnMjmOJuvrfIioSONjblvdAFxthFiUm9UWjqve75nZEMjC4dkkCjAR9JX8cP8vGFqtRHCP3aVhh4bcQ2amM/jReEwnFTT5mob15FApT1UYJs2gBJYzp7MaiNJCFjM7DAlJpqKf82I1NI9ksRBYwnJXFq+c T5bmP7/W KlF6EYORVLOuWk6hjPJS57zcckgRDiRHHsYDsdedMZ9wKcr2brwTnPswNq6k4zX7L8fFLjoorf4wr62CGXaQtAg429q9mfwcbsbooVw8mPniwaPXa2RLRMD5rdnGFJ8jZqBF+m7TKcAnEQNSxzUVZdJm+djAmlcywnnC1B5TpA/8IwAHubAt8VIjTHJqoca2/pwbOzGBUD8nfcNyaEvDpyMl7g3tsZNrLc5lzA4iE9oAUJNruuPLPoTnrW/sMc7Zy9o2iHj+bmz3bgMXmtu43fIYIykdbZh7io5DrTO1fsVcPFSsDH1nMN+xm2VendZMeU+94RJfkpwlWloG2u7b6zRrhWO69lceEWjV/H/Ncx+x6whXchDzQCCQy79QiRvs1/4vP/i/eCPSmsUvMAherIUyKYhR6xz9Np0GzTisiNhJuhBEGlUneuysRpOJj6nkTNa1fENGPS/LpxAckqXuiyf1klvyf5KgSSHEbaKO3ORJgBetdW0xDU5+15n1UjIgYKslsLhWM17gDfrA7iudetOyvIBBzfu0djUYBUqiU6K5CLa8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.228511, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi Introduce a few helper functions for conversion to convert create_page_chain() to use zpdesc, then use zpdesc in replace_sub_page(). Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zpdesc.h | 6 +++ mm/zsmalloc.c | 109 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 76 insertions(+), 39 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 223d0381a444..9aca8d307796 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -148,4 +148,10 @@ static inline struct zpdesc *pfn_zpdesc(unsigned long pfn) { return page_zpdesc(pfn_to_page(pfn)); } + +static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, + const struct movable_operations *mops) +{ + __SetPageMovable(zpdesc_page(zpdesc), mops); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index b7fab2e28d87..59a30c61160f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -228,6 +228,35 @@ struct zs_pool { atomic_t compaction_in_progress; }; +static inline void zpdesc_set_first(struct zpdesc *zpdesc) +{ + SetPagePrivate(zpdesc_page(zpdesc)); +} + +static inline void zpdesc_inc_zone_page_state(struct zpdesc *zpdesc) +{ + inc_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES); +} + +static inline void zpdesc_dec_zone_page_state(struct zpdesc *zpdesc) +{ + dec_zone_page_state(zpdesc_page(zpdesc), NR_ZSPAGES); +} + +static inline struct zpdesc *alloc_zpdesc(gfp_t gfp) +{ + struct page *page = alloc_page(gfp); + + return page_zpdesc(page); +} + +static inline void free_zpdesc(struct zpdesc *zpdesc) +{ + struct page *page = zpdesc_page(zpdesc); + + __free_page(page); +} + struct zspage { struct { unsigned int huge:HUGE_BITS; @@ -937,35 +966,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 zpdesc *zpdescs[]) { int i; - struct page *page; - struct page *prev_page = NULL; - int nr_pages = class->pages_per_zspage; + struct zpdesc *zpdesc; + struct zpdesc *prev_zpdesc = NULL; + int nr_zpdescs = 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 zpdesc->next + * 2. each sub-page point to zspage using zpdesc->zspage * - * we set PG_private to identify the first page (i.e. no other sub-page + * we set PG_private to identify the first zpdesc (i.e. no other zpdesc * 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_zpdescs; i++) { + zpdesc = zpdescs[i]; + zpdesc->zspage = zspage; + zpdesc->next = NULL; if (i == 0) { - zspage->first_zpdesc = page_zpdesc(page); - SetPagePrivate(page); + zspage->first_zpdesc = zpdesc; + zpdesc_set_first(zpdesc); if (unlikely(class->objs_per_zspage == 1 && class->pages_per_zspage == 1)) SetZsHugePage(zspage); } else { - prev_page->index = (unsigned long)page; + prev_zpdesc->next = zpdesc; } - prev_page = page; + prev_zpdesc = zpdesc; } } @@ -977,7 +1006,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, gfp_t gfp) { int i; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE]; + struct zpdesc *zpdescs[ZS_MAX_PAGES_PER_ZSPAGE]; struct zspage *zspage = cache_alloc_zspage(pool, gfp); if (!zspage) @@ -987,25 +1016,25 @@ 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 zpdesc *zpdesc; - page = alloc_page(gfp); - if (!page) { + zpdesc = alloc_zpdesc(gfp); + if (!zpdesc) { while (--i >= 0) { - dec_zone_page_state(pages[i], NR_ZSPAGES); - __ClearPageZsmalloc(pages[i]); - __free_page(pages[i]); + zpdesc_dec_zone_page_state(zpdescs[i]); + __ClearPageZsmalloc(zpdesc_page(zpdescs[i])); + free_zpdesc(zpdescs[i]); } cache_free_zspage(pool, zspage); return NULL; } - __SetPageZsmalloc(page); + __SetPageZsmalloc(zpdesc_page(zpdesc)); - inc_zone_page_state(page, NR_ZSPAGES); - pages[i] = page; + zpdesc_inc_zone_page_state(zpdesc); + zpdescs[i] = zpdesc; } - create_page_chain(class, zspage, pages); + create_page_chain(class, zspage, zpdescs); init_zspage(class, zspage); zspage->pool = pool; zspage->class = class->index; @@ -1725,26 +1754,28 @@ static void migrate_write_unlock(struct zspage *zspage) 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 zpdesc *newzpdesc, struct zpdesc *oldzpdesc) { - struct page *page; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; + struct zpdesc *zpdesc; + struct zpdesc *zpdescs[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; + unsigned int first_obj_offset; int idx = 0; - page = get_first_page(zspage); + zpdesc = get_first_zpdesc(zspage); do { - if (page == oldpage) - pages[idx] = newpage; + if (zpdesc == oldzpdesc) + zpdescs[idx] = newzpdesc; else - pages[idx] = page; + zpdescs[idx] = zpdesc; idx++; - } while ((page = get_next_page(page)) != NULL); + } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); - create_page_chain(class, zspage, pages); - set_first_obj_offset(newpage, get_first_obj_offset(oldpage)); + create_page_chain(class, zspage, zpdescs); + first_obj_offset = get_first_obj_offset(zpdesc_page(oldzpdesc)); + set_first_obj_offset(zpdesc_page(newzpdesc), first_obj_offset); if (unlikely(ZsHugePage(zspage))) - newpage->index = oldpage->index; - __SetPageMovable(newpage, &zsmalloc_mops); + newzpdesc->handle = oldzpdesc->handle; + __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); } static bool zs_page_isolate(struct page *page, isolate_mode_t mode) @@ -1817,7 +1848,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, } kunmap_local(s_addr); - replace_sub_page(class, zspage, newpage, page); + replace_sub_page(class, zspage, page_zpdesc(newpage), page_zpdesc(page)); /* * Since we complete the data copy and set up new zspage structure, * it's okay to release migration_lock. From patchwork Mon Dec 16 15:04:38 2024 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: 13909885 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 DBB1DE7717F for ; Mon, 16 Dec 2024 15:05:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DAE56B009D; Mon, 16 Dec 2024 10:05:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 662F46B009F; Mon, 16 Dec 2024 10:05:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DC186B00A0; Mon, 16 Dec 2024 10:05:34 -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 2AB5F6B009D for ; Mon, 16 Dec 2024 10:05:34 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DA7E6160E24 for ; Mon, 16 Dec 2024 15:05:33 +0000 (UTC) X-FDA: 82901145516.05.B81B774 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf03.hostedemail.com (Postfix) with ESMTP id E5F3420019 for ; Mon, 16 Dec 2024 15:05:17 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BqT6A0Rk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361503; a=rsa-sha256; cv=none; b=QG0nBYlHpf6cXJGr0LP1TonK3tfZQ2LwzpJfAEI5IBP3Hj7A9QdYC4JziD/mCHuGA+OYSv CRKr3avMAC1H8tYlPVvhzT6c7iPMeYWjLYxqjo/zFWYpsCr3W4APy4lH6rV/o4LCuVsEJD JllyujsItoE8jglKPu2O0BnuZJwBPg8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BqT6A0Rk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 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=1734361503; 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=TGYFKe0E/kNM1MKqESCZrh7ZCQ5AYAYwRFP0Y/nBgK4=; b=nas8Za4e+6w8iwAqn91kjm3Q4tT+3qo4Sj6msHSeJjmUIBV7vO+XR8vmeInc58C4RVoQ+L l4ThKgqZBl+F3XB8+hV9/XyxTnPWMrFgmALy+EHN5ku63YOB9sIDVDf0Q6Z640aYvW+PnF f81T0mMd8T2mIWUv3smNm8xQk5+dvNs= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-725abf74334so3612355b3a.3 for ; Mon, 16 Dec 2024 07:05:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361530; x=1734966330; 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=TGYFKe0E/kNM1MKqESCZrh7ZCQ5AYAYwRFP0Y/nBgK4=; b=BqT6A0Rk3g+7NkqXK1dBz9/c+AHV/Xw5hr6YnWCZ70+iIjJvKIG7HV9IXY5HCQucUh HiB8xrkOJuGMggucxDWl6heKi9rN2DuAAjBvTXGlCdIUhRJW/QVh3ZhgQ8vS44obevDy ilsqN2jw9hZL2LSFKh6/ToBWwTIGqdSUKY85MIMASOFKmS8fw1zYNnAdPv+urz/HiU6X obs+VueMZGDO3x41EmBB62X22oQaDA6fcVBoAtJl9Nl1R89qBO2kt7I0DcidtrroZkRQ v54wO6CsSR7/I6ZlDaFkWQgoinJ2DkJVedjF03nDt0mFc3hLTbjMzJRWXC6vaoK3rcQz w1Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361530; x=1734966330; 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=TGYFKe0E/kNM1MKqESCZrh7ZCQ5AYAYwRFP0Y/nBgK4=; b=mzpTJKcIF0/VPsJGkDKyb3vJ6pLeYsPxlU5EZWnepun1jkx03QvYRmtSCv5yb+5DKs ZiOEKbrsgRrc38Pbblkhu+vNtHWPf3zSHEMIRjJOQIB9uIvHAbZZE9eShEMpRzwv9UiA exSmiCxw1sbZfmjaA69BlTto21P8TgyGkOWLEWnXNB1ggvnXXFaTw4cyAUB+41qpL37/ BxpJuVd9ZKQ+e9p265sKEEWAD0KL5UxRAigqndAibZyHZuVQbAv/LN8LLkvlzaiQfRB+ sL1pWbLhp0p+Nc5qezNjK77T9fQWr3p/U39KacRHZXUU88r2snKhBsgD74V0sYa5BZp0 yHMw== X-Forwarded-Encrypted: i=1; AJvYcCVMAHeWwFA/zJjZL5ZIzPllz9AJaWeSIYjSALEwd6hmUPuZLiTrjR9PkYA5IS8X8iTwQlVk28BKng==@kvack.org X-Gm-Message-State: AOJu0YyqPdRSIJN/kNDKeBNnCN67iDVTgZaP7Ias6/E+cpuZhjZjv7uX auvbut8ybd2DisPPc+rvjdWk4P8svJ7NScnFzkipnZEV6hMimiuc X-Gm-Gg: ASbGncuhREE8HeHOiH4qrYgvOW/55s44kx7pngTMkOgwdZPZ2rtNIBMwczyJQrXF9E3 YB98xAvPzkqf0smzZHymEekFeEfQs0xlqqONTq8yvNTbH/V/2eJwVaZdXIw0k26bgiCIaZRlq9u Yvr9s9RjpvPTYwQKzvgho4iPsjP2ETPXTFuNqTu04haHrSQll9AKYIM8yp7b7qq/I+IJdNnuHbj unMzGUeI2rHWNWyUWRsE7CRHCzTs/tHmDZzPWtaS8rX/IBMHFy5RPYAC4YZ++wT+EI= X-Google-Smtp-Source: AGHT+IFpIb/eGN3yySKeKTyiWJ616xagwbMlJZ9wXbZtp5yUACdJWvrAdhrDWPBUBkRbz2h9x6UY4w== X-Received: by 2002:a05:6a00:cc4:b0:726:41e:b314 with SMTP id d2e1a72fcca58-7290c24324cmr18035403b3a.19.1734361529832; Mon, 16 Dec 2024 07:05:29 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:29 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 07/18] mm/zsmalloc: convert obj_allocated() and related helpers to use zpdesc Date: Tue, 17 Dec 2024 00:04:38 +0900 Message-ID: <20241216150450.1228021-8-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Stat-Signature: ehr5tnyrib6zrhfmahecdcaytjc3t7gz X-Rspam-User: X-Rspamd-Queue-Id: E5F3420019 X-Rspamd-Server: rspam08 X-HE-Tag: 1734361517-927561 X-HE-Meta: U2FsdGVkX1/xTfFfdOuha9P97VHChRKI1Qefqwzd7/K9GEwe5DwF50HPqTkYiXgVRhGwCY32+J1SeoIBTg6v+E8CAfBV4HlzrzxR9yUGB3CrVDudVdN2EiDAlV7qtR5ohK0wxh42d2k+jxRWasvfKQsr003Fkr5xvp50a4W+NMNbBLkwZFBImiNKJUKwIBqR96C3JavIpC0IEfIoF3BsO/wJ0nkxH9thvyllaXXrbpW05RqJgepmKK3md2+JAF0HJRxHHmU9JA2KLqLEw4U8OTeAkIWMuHfwbExRTr8EO9yi3bORraI0+JbTuBYjMMh9r6OfCMxkQQGDFH6Iv+i/+UZHFuHjjVBV9YXDpQUcJ7qJ957XdIlg/X66zHnNdBjFNKlYaaGhW3h1e2fCUqhijujv6/hypZxXS3J8KZLtoQzu8NsK46lE5XY2k9CC4SbjsHPIK6z7lUv6r0/zbKXFu09KyILFJHH1Iqh0QujSSaOaOMhETxSfn5R3tNZIW9y4FKAb1/L6kQB57alCXKsMdTDv+GlT3a8/zt8Zaxnu6va1qvEgiOdkBah/cUyiEHHQtY8K+8+hAsc6cVh44DT74btp1TJv2khdngScvAa+O9od95gZbyKO0+O4OAJQsPYZOZFh/ZyCQq5NCHIilfeUqPDNpHdZ3OdP1EKvxyvJ1mj2pnZjmoA3DUJgWE9mjpXYPzwNbTNCNS/K3cqZd2s/jwCPdO1QbAAeW9dMRr8Q7a0Af4yBZTJCe4Lgo9tCkGLplUh9LB0pRL5aU700b3tKh9ccQJtp6dCtx79Kr2YnuvrKqAZIO8yBSeunktVxo8chKYiJmGldB8hZvFnl2LTKEP9Pj8JNe0oOTYBSg1ypu1yVPiev3eFTO6oUjbrqPNKb/icsQdOv/BztrEFTEcRoY9klBOdWMX1l6h3WJ/98AMti+pfjsMaHymRG4WAz0GjNkot+RuIxw4MxR7rAMNC kLoOTN5+ 3OGVikUdxBfaGG6W5oDHnlsEi8l4muW4lHCMTYdkAFtyzUB/xwi8AxonJ/dRf4cfpoM17NPRxRNQL1o/nzrF9jxIfb7rEQWmKQq3nVGmEm2IHPA7oTPkXTpE8v3Lu4L0HXQa1GAkcuYXDrieRS0xTEE6lH4EJVroH3iW5uzyrdUdxaA/segy86IJhOuz4losSw71cujPOlyDiejfcBhnPxNNE+fkV5vEVGtfag3kb6pZebBnJ64eB+Bg20wyMk1Mafqx96ngx4MhFUNlsNl9l0+u7f1UT3EcDnv6e1UIsg2RDGj3SNAFmVTyjyqXo/BWNn2/zv2ITbhhGVKun/Up7ihSI9GhpSIGnKpJYqd/DeiiPqV8VfZVKCuWu61nzSWOIFFaqr9L5rzxXM/vwRIyC7kr6rPL7lQIypurGvOVRq6FPHu8Yfno0jF1vFfOkovxwVmzFNgoluU4LOBiuEGB/gdqEayL3OKV2cPOX9u3JhBLXUwF3ShVyaouFmBIDsC/J2R6HzYkQ9awLEKmrLoN0BfM+8k29stPfkXiMM55lM638Prg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.280769, 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 zpdesc. Also make its callers to cast (struct page *) to (struct zpdesc *) when calling them. The users will be converted gradually as there are many. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 59a30c61160f..a3e2e596b4f3 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -823,15 +823,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 zpdesc *zpdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle = page->index; + VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); + handle = zpdesc->handle; } else handle = *(unsigned long *)obj; @@ -1569,18 +1569,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 zpdesc *zpdesc, int *obj_idx) { unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_local_page(page); + void *addr = kmap_local_zpdesc(zpdesc); - offset = get_first_obj_offset(page); + offset = get_first_obj_offset(zpdesc_page(zpdesc)); offset += class->size * index; while (offset < PAGE_SIZE) { - if (obj_allocated(page, addr + offset, &handle)) + if (obj_allocated(zpdesc, addr + offset, &handle)) break; offset += class->size; @@ -1604,7 +1604,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_zpdesc(s_page), &obj_idx); if (!handle) { s_page = get_next_page(s_page); if (!s_page) @@ -1837,7 +1837,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_zpdesc(page), addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); From patchwork Mon Dec 16 15:04:39 2024 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: 13909886 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 51AF7E7717F for ; Mon, 16 Dec 2024 15:05:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB7486B00A0; Mon, 16 Dec 2024 10:05:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D3F066B00A1; Mon, 16 Dec 2024 10:05:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B939B6B00A2; Mon, 16 Dec 2024 10:05:37 -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 8C60C6B00A0 for ; Mon, 16 Dec 2024 10:05:37 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DE58E44E0A for ; Mon, 16 Dec 2024 15:05:36 +0000 (UTC) X-FDA: 82901144928.08.ABBA8E2 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf29.hostedemail.com (Postfix) with ESMTP id 305B0120025 for ; Mon, 16 Dec 2024 15:04:52 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PmX21Dvk; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361503; 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=gVDIhOdN2uAX8Aw1N9nVuvKRYeq4rM6oWNSpQXGIXHA=; b=ScH8P1AfWzyg/vJ3GtrXHgghZtULjzfsdq+d3Mt1pL1CLAeq/9WHHeXjLMc/wXK9qLxvnH CXiLOxovXneb+1LWXtHGxajNWjdnTIsHbOmsSn2j3kZy+k+dRkMC4wPWO+FjqIlPtThcLC eqda/TIuyLvTVCU/meWO+/hehk/U4gY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=PmX21Dvk; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361503; a=rsa-sha256; cv=none; b=A+c1SMQtMyWTvIZ0IFGfd0aWJEMPEVDuS68VHkp5sdRgdMj/ACOJ985j/SRoDuvtRclF/v hFWXaJehy6d19csndNoUYEqm63bQ8Vatszla3NLcSfXXGg1S5Ou5xWevRlWAXW9yObkaDb MLgv6WQPx3KeGOkeS+D4IFHHbIXoor4= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-728e1799d95so5013427b3a.2 for ; Mon, 16 Dec 2024 07:05:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361533; x=1734966333; 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=gVDIhOdN2uAX8Aw1N9nVuvKRYeq4rM6oWNSpQXGIXHA=; b=PmX21Dvkg31aTyYH9zIxI+Ypm8Ssvz55QcY83fys5BQtniythFgMYn0JWtF1e9kJ/1 ot5PI3wQZp4qzsmAUJMSIl1dyfGYU6EsCjcq0lh3/uXTyCjfZAyseZGev4MWrmFWdLDY 0vejCFudsoMzTYYjeHiF/qNaZXthTmPWI5HIGk5mwNL4iZRp6seiKv0EHC+HQL4MBm+V A6XHKKuw65CeRo70WLeXFClHaFc/tGAq5YRP/E2qscQl1AEHnMJR42mHQY7e27dNqBUc bUA8BiJKs3mEPLTaBHysyZE2KLPvZ5BE1ujHH2a8jCJFLpaiu3OXoT2wi0wZRV3xedFA QJXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361533; x=1734966333; 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=gVDIhOdN2uAX8Aw1N9nVuvKRYeq4rM6oWNSpQXGIXHA=; b=mIrs0N3f5athqKPdXDTV3dVuQLXtca/c8CYwVBM7HbixnS40K/J5cTMVaBwo/mtfaC 5XpWdOY7dJ9DiIS2O9FRwgsJGOLGOy802+AltOZL6pZFFCq48rjdjdDt3JhuoxfVVjm5 9jF+77NVsPf9fRLi1yhHCl/DiqSk5YGYrdJ0o12DXz6sa1/LMbhZT2HeolNCBu02aB1N /1StZKCJ48pnoAwnskpxJ6zqFRlclIB8PKeXYVhKZDI6O6Pv6LGYA0YZmDz6Xy6auJS5 UWQ7cdnVmCeSRNTgbDJ+7TFVsQmA2vU/QScedSIsx7b4VciHHRL+G8XTSWPmjBNtf262 mnHA== X-Forwarded-Encrypted: i=1; AJvYcCUGnhcDGVkhCCycho5qb2zYE+NwZUJaIhSHwvkHr76iVSt4QOXy12jzZTDbvXu1v4M46PdolFEIkA==@kvack.org X-Gm-Message-State: AOJu0YyNTZ8bbw9xkkD+BOSYgxirg7WlnAmIGNVDIQ1x/QGOII51tsiL +YXsPje7FMbDdEekR40lAt8MMQUzofJlgDlh5HEeG+P4rNXi12dO X-Gm-Gg: ASbGncvHDOMcmMnH+IzMYHjOLAV7KXuCk11k/GFZIFyyWdQqIGS+DLS/5pufHF/7aD3 E7DNbg1tfxioEPpb++HRRNMv+pZYDVRooKPIIKZgzvZBsXh+0geuXYhdQN0Vu06md8ju/rqCjrc h7UoVzW1ASkpYIGasTeFvOxMeu0VFfLNiarDPtO4ik+4QQcFF21VGEEh7UFxVsSzEu5b6bXlmi4 1UQaJF7PsLUQfRycyG7C6TTgJMaK+V6QESd2hGGGHNJ9yDDZCZHpFbXaoCbgdW4kEM= X-Google-Smtp-Source: AGHT+IHspep/0w0h+As3uPnNtbfPK2qsZiDD/ybT+qBO/FZrjZ6OW7hLqGvq51tGb4SkIBtbHR6EEA== X-Received: by 2002:a05:6a00:4209:b0:726:41e:b32a with SMTP id d2e1a72fcca58-7290c0e179amr15571546b3a.4.1734361532952; Mon, 16 Dec 2024 07:05:32 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:32 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 08/18] mm/zsmalloc: convert init_zspage() to use zpdesc Date: Tue, 17 Dec 2024 00:04:39 +0900 Message-ID: <20241216150450.1228021-9-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 305B0120025 X-Rspam-User: X-Stat-Signature: cquos7wi71danqexhb1ofmh7dwrz9993 X-HE-Tag: 1734361492-497383 X-HE-Meta: U2FsdGVkX19pGDj7rJFE1Vpcci/7X/4Ff7ZUXZxbXYXcxd6ma7TMW9cTbapng72fSq1n9+bC8JsXXdEr9p4cRKDC1vaBqJqpO7XTbKR//aoyDyjvLPsaMs2ZLwe5EnqY9lfKmJ1FDo1T7cIrbumxueGfZnKDF+xxaC7FMBpLHAm5osDUvk6yqdzD3fbM1d4ISiyxZIfHSQIulOVHDXW791l78MsdKuqoioT1dcVy8G59c5mWcUIhACQt+L+SbY/VrtevCfj7uwcG/dUt8pDg4l8iZff5D/j9ngNrA+NtbGCs205czUWcY+Dsk+ipiyx41NNBJlP5KkS5VBGJaswjx/WVLMvOXOMUAHaIgvJP3QHkR2l5tf/KbohMOVAdTDZpYYhwohpD87forzZAyA18rWVglZjuBSn+IHbdpRAeDsE2rq4uyhKoVRppSBhlhd9N1ilKaTCtvKII/qZVKV+Es8kmEgcYzizaV4f8oYFzIFcH5vgQizazHJAs4YZcW8W90u5PclmOT9Rl5H8HfT4PvPyCGu6VNQgH7q17t98syzB07UHRU/o+wKtY9iI45JUYjcawLpN3MwT4qzb95xUGb2xt7ZCuR9Azgy1gJ7ZVt4xsJjGL8ND/JCaNWylnMx4W2dFXDYPw9YR/9rLpPXiY6BF26EmgXI+X7HrJMhs6jfp4GahZluMhHelJ6k7L2M+nWBGrRi8HhGjnd04XBlgUP4VXsqH302tdhzrOlVvNeuP+1N1ZwcDAwLiacbPHQ1DNDZJ7y3SVLZ61i2C7BiPj221Aqxx/zkjGjxSFPd7aGrAi8Ck5YqSUyBGuW1UfA+YfcqRYIouhYwFjpfP3GcNt+bDjDo0Pm47xkxiB9kMbTKLJZvpSJgD569FUMnQdcMsPMJ6M8RJRMFxChOxUXCYygWElIa2f83OMiEm2I2aAis9V9eawLsVUAgia/XMKELrNmaD3bsLLVIgMJCT/hss ZF0DdLlu uLP2hYuqMYomQDdSDkrffKxE//QXXuYWr2PzzmYyEthA5CJJ8BMO5HuYJj8pIevcbRcN8uysItGRnUANwmkcwZ9ebKxgSuQJ52BcUeNB98fEwGC9AAGWdioKZb/Rd84LTkAwKmOyPZ/l1m43zbQSqDFYLGmvkKjbyK2TlxGkagV3M6SAVKtZFIGWgl3iEvyiXQcEIZ6iLsnIM/oYmrJuyIIrKyrKlaFH59JCGhDbrZjFyeS0tyg9DmKSDosji6bHWoxU1CmTTvtqsKU04/wkQfb2mm30U6sEeC0bFHzFKffzqPxww9OUav0OcXpyipB5sqpSZQxqswsjqcwIgUO5EzVkc5Uu4BkHyz+kmALTtCzIhjI84VoHATEJNtiXB/sqhO+EJ5223mD3NYT/B591E/90ewlZb9wSaLaFvBOi3AUBVI/CnoKIgxR88/t/zR3S0RD3aZEBdEoP1GWCDTHyTZ62csTSA63jKuPakuwFVcYiJiZGJ4hdyCxv3WBVGYCnfV3IEevaLfg3iLWtUNrZDjVQcVfipCqsYalUh1L8LTf/pagY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.248478, 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 get_first/next_page func series and kmap_atomic to new helper, no functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a3e2e596b4f3..83d48cffe96f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -925,16 +925,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 zpdesc *zpdesc = get_first_zpdesc(zspage); - while (page) { - struct page *next_page; + while (zpdesc) { + struct zpdesc *next_zpdesc; struct link_free *link; void *vaddr; - set_first_obj_offset(page, off); + set_first_obj_offset(zpdesc_page(zpdesc), off); - vaddr = kmap_local_page(page); + vaddr = kmap_local_zpdesc(zpdesc); link = (struct link_free *)vaddr + off / sizeof(*link); while ((off += class->size) < PAGE_SIZE) { @@ -947,8 +947,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_zpdesc = get_next_zpdesc(zpdesc); + if (next_zpdesc) { link->next = freeobj++ << OBJ_TAG_BITS; } else { /* @@ -958,7 +958,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) link->next = -1UL << OBJ_TAG_BITS; } kunmap_local(vaddr); - page = next_page; + zpdesc = next_zpdesc; off %= PAGE_SIZE; } From patchwork Mon Dec 16 15:04:40 2024 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: 13909887 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 C527DE77180 for ; Mon, 16 Dec 2024 15:05:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3313C6B00A3; Mon, 16 Dec 2024 10:05:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B9B46B00A2; Mon, 16 Dec 2024 10:05:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 096106B00A3; Mon, 16 Dec 2024 10:05:40 -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 D3DA06B00A1 for ; Mon, 16 Dec 2024 10:05:39 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6EAB31A10A1 for ; Mon, 16 Dec 2024 15:05:39 +0000 (UTC) X-FDA: 82901145180.27.5641297 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf19.hostedemail.com (Postfix) with ESMTP id 7CCE41A001B for ; Mon, 16 Dec 2024 15:05:06 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VcMMBjAO; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361505; 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=V795zn61RwP0oNq6Uk6kYy1iA7djNdknGUFc8lO4Kr4=; b=W0GFrd3E2oF4/16qpt8uHdp+576jPeP4Yvsxeut8jPYEQvk3mlanjgfXBOOPiS79Wb4HgF e6HLlxuT/RaaP7jxh+92t6cE89p7n1A105I/SLdGGgps5ytFMpEzpDrD6DMR7WOZuHOjpP PgY7CnFGW/kbRZcD9IkBh2EZvVvGFLs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361505; a=rsa-sha256; cv=none; b=L7tUBLuINfvL7J5U9fbAriM9kclYeu89gnTNXG25fauAxYdEl7nRHQGETZ8el++muflaGV y8Uzs2WUbx6KT1Vm52HOVGNuNCnrpOc7F5DcABHCjJJLoZWaAmj7Bu6BBn/LhOeN6klhUo Mw84SzbVpPcAUhoHQgw4kbLoEpuAlxs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VcMMBjAO; spf=pass (imf19.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-72739105e02so4580130b3a.0 for ; Mon, 16 Dec 2024 07:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361536; x=1734966336; 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=V795zn61RwP0oNq6Uk6kYy1iA7djNdknGUFc8lO4Kr4=; b=VcMMBjAOTcZ+x82xxjkq2UzQhCf2L06Ucjg8M5JqrvxQWvZA3kumXcyY3KGN61sNXF sMGz0KOM5EIj51c6SgGdkU55UWFY2LJgu433aaj1YP89stZVRaNjwuNFcp6IKcd0ODFk cr8AI/B2HiRP0B8MjLV25sVg+63sBSKKZmqFdJLb/cUCn+VG5Z0XLofqA2YW3O0zDKLv Km9C7hHzPeYLcE7cm+m1FgvFx7MVvXY7oVM6pAHFg+Dxh6KmQVD5Oi9hCUU1ehNg18jy uWhPtkmaODeS/wML+R+lGyxrklbQ3Yha6p44dX0iuQrf1pm3S74/b7ldZb9J3sVfsGDf IGsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361536; x=1734966336; 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=V795zn61RwP0oNq6Uk6kYy1iA7djNdknGUFc8lO4Kr4=; b=aa4fPSDlNKKpqvtZcangjdkXo/egkGiVoxuOilAjRwKrh6sZfHF2lbRKP163HMcsXd L6PWEqinrRt1jnr1pvQ36DrtZIn8WhLjl7gGRi1vc7Yzw1nWZlbAatuYHHxWTPtZMrYj OLdqEhdF4psBqYr7BC1M/FCQhbjvnw6OLh646FhrieuWM9BPHzvXCFU33AzNmhrDYavZ e8Lm/9fexeIz6OLahtk0zNzv2DJcgPsTb5Ri8bDwt5lX7EAN7r0JrTm0/PljWZ5rmfXK pnBSbaC8nBB7/xrD1C+l7F3duVzXrBeYVWddaaHvUrROgZ7O8tkK02QqSHtm/scLQ8vO 1XWQ== X-Forwarded-Encrypted: i=1; AJvYcCUSFpbWKznUXeb0HVIdqvHkNMw1INq7i9CUI6LiJxKXDTQSD8zX+qRrcFjg0AT4BU95TRksYzjWDw==@kvack.org X-Gm-Message-State: AOJu0YzkmW4C4RddXsgI069REAnwwBQyxjQe8XsSbt8dkj/MwFUHzOz1 mQYmAoe0LNKYgr1UugB9/4aR7mahITZnEy9keCORJyiwkj8JPlr6 X-Gm-Gg: ASbGncuAKxJN/N+qDdxDx4YO/eVrT83uDhxe8bS9R9Gx1bQ/66mFtt/49BYG+iA0iU6 JQFaoYrbTJNPLxsuXsUbz3pFCaFhF61n4MYztpqfoeAtbvYUwrT8TULTP5pn/T2ng5kCfmTOa5P tNm/07R0BRAGOCdBhaXL2J2ZvfHrMZ0XB0f6ncToZABMCswnxa3A+5D3M4SzL9K5oNV3E80B3pz IJUNjRDj33WquKJ9mOA4ewgZu0PO3372mUOBjdWa6ylJ9g7U06lAnmHtiNkfxlBeyA= X-Google-Smtp-Source: AGHT+IGnjmghU8VnzbX3ZJIL1K8vkccFxoqZLEV1ZhzLo2IiM1+EpkrCQkHcvru1dVMwLWl020wXzw== X-Received: by 2002:a05:6a00:ac02:b0:725:ebab:bb32 with SMTP id d2e1a72fcca58-7290c27c888mr18804743b3a.26.1734361536068; Mon, 16 Dec 2024 07:05:36 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:35 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 09/18] mm/zsmalloc: convert obj_to_page() and zs_free() to use zpdesc Date: Tue, 17 Dec 2024 00:04:40 +0900 Message-ID: <20241216150450.1228021-10-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7CCE41A001B X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: g81wqoxpctyojmo66phkt8o3tk4hnweg X-HE-Tag: 1734361506-629907 X-HE-Meta: U2FsdGVkX1+37rv+vK7qmD1Q6e5/PPLiDiVxcZx3ZXzcMCgu+NLQC6Pds/3EQgdtKaN8pL7bTdyC68mb6kllLiuIEF51zXB/eGoj49fxAoS9fPHWTgdlV46ZDz8zqAMxaVSPoFV32oQN68A2RsV9jHgK7EX9MoZsIekL381/0krV46JYERn76c4HA3yrS7C3ikCG8opQOs8Kl74mswSHP5k+QnO/OJAmSn0kbfqOCF5Aroxpqhs12RdJ7pdltd1MzKW6YK+p59iTUzUInqW/p3newf7X9M1q1zsTY2Q5Phpo/xkPU6K5LghmJ8bKdADKkeBPQcXturMceqUgcKWr7E1m3OwUVyhaw83c5DjEe7lifejlcXVHawlhs3ci3BxqibctNVPbQrAUCTIwIC2vYV9+dR54/Vf7VWVQHi+GMIr0aIU/F42pvMvJBqvdO9/RqckIgIyLD2MVu8SKX1iXCrmD2nejjHZzpL2PjZWSO5bVIp4AjA5DmC/onPLvcxaXsvb1b8LQe7ZDUrXESEl2Irfsyya5mgvq3ASuSxZHZXVCNoHHmfnf8ZUgpDjrNgVcNFdUIAVb2NfOQDQZ5b61sqZSPosxV1ZzzExxkgASwjnwJpKhBowcMFwN5c9etHq5nmLlys3/Zi3V/lrnLNiODHU1+csdzK11fXI3Jg5zYblNxg2clsY3z2O6Y24yTSZr9eANydOwNiRwWrcKL4+SAhgj1dmCs93ozIMjHmqb8iJU9uE3qG4yXyW8Byn5gfKBIqjXZNoCNjT4sfmbpJBeK7ndYN6unq88S+j7/CuK4NbGLUpCGtYuIzUqv2imHSLfn4wQL8AuxI17wKiNYiD8joX/+XnAR879eJw/6o2UoIoyFDITB5NuO7b0c4/daMDcCLZ4uh8GqcXZ0D0HprppKNxj2Tr5OKEVYT2G4fg7tH7IbNsuk8ZYDvw0Sx83GWmb+yJurk+HHv03eZwhBA3 WeiMluBq Tbug4eQzxPHw1nYQEeNgz2FQMJFA/XB6BShgVBsPaFFsNKeo8yHi0CHbxKmnbCno5jyf7ypipNB6V/XtkvZdtZWmz3xYbFA0L7HDw95Pl1Rcuc4AS5MK3CHm/XB3V6RW9k2vwtxvgBZPHA4uZw9/XORIcE5sD7MS7Q0RN5e+7gHGICp5nKnIzMXU4A0VQXamhvdoKNUg9IwEbXQCL8YzJSI/e1Lh2TCbPr5CXz3mc3FKdeGqbhWTOi2qeJ/KI0GgOyh3JYDWGLoe8LxoZ1VsfX8hd18DunZjiCYSkvESZHiqrzQODrWvs0xo6ciuXjVmaPut1ki6yuUQaYN80KK299rT8y6chxv2A3rLBcSLpL4otOzvB7JbrivKORoC1iGeXMjZRRZxztQKx2foWBMNFav2hIubmDC+Q78goi6Wp6WMVNwamITHEFRxvJQLl3eSIDn8vuzdSxc3pWI5VWpqVTZrR5sCBH4LgsR2g9Lh75bWFMTotIAbCiQtnVaZJEnu6GuIMl9O7teNcJY2SUELdjS6VMcNDLxrfhTk8pEBhMSeJ61A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.445202, 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_zpdesc() and also convert it and its user zs_free() to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 83d48cffe96f..112603f9449f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -798,9 +798,9 @@ static void obj_to_location(unsigned long obj, struct zpdesc **zpdesc, *obj_idx = (obj & OBJ_INDEX_MASK); } -static void obj_to_page(unsigned long obj, struct page **page) +static void obj_to_zpdesc(unsigned long obj, struct zpdesc **zpdesc) { - *page = pfn_to_page(obj >> OBJ_INDEX_BITS); + *zpdesc = pfn_zpdesc(obj >> OBJ_INDEX_BITS); } /** @@ -1462,7 +1462,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 zpdesc *f_zpdesc; unsigned long obj; struct size_class *class; int fullness; @@ -1476,8 +1476,8 @@ void zs_free(struct zs_pool *pool, unsigned long handle) */ read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); - obj_to_page(obj, &f_page); - zspage = get_zspage(f_page); + obj_to_zpdesc(obj, &f_zpdesc); + zspage = get_zspage(zpdesc_page(f_zpdesc)); class = zspage_class(pool, zspage); spin_lock(&class->lock); read_unlock(&pool->migrate_lock); From patchwork Mon Dec 16 15:04:41 2024 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: 13909888 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 3C74FE7717F for ; Mon, 16 Dec 2024 15:05:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79E5F6B00A1; Mon, 16 Dec 2024 10:05:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FE546B00A2; Mon, 16 Dec 2024 10:05:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5792F6B00A4; Mon, 16 Dec 2024 10:05:43 -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 2B1156B00A1 for ; Mon, 16 Dec 2024 10:05:43 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C4CADA10D1 for ; Mon, 16 Dec 2024 15:05:42 +0000 (UTC) X-FDA: 82901146188.02.AE7B554 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf22.hostedemail.com (Postfix) with ESMTP id CA20FC0016 for ; Mon, 16 Dec 2024 15:05:09 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NJyggAY4; spf=pass (imf22.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361508; 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=gAAVT3jm//0Jn0SieEbRABow8HKrLkziLKm7kqsvGKc=; b=BfFUR2faP9lTwiBLOn/QkqAXAcR+H5OZaTJBsTAtM/qwgelWNyc0m4f6CE9Excg+NQLMBx irARuOx/3F0roDhYPQfXcW3iHCg2DUhif+o6Y2bPS7EGOhr01Ko+EaSDXB6PHqW3qbci+q D1MH3D2/Okrs+I66LGF3+WvB+vfcrHM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361508; a=rsa-sha256; cv=none; b=znIfp5Bh4/cfBIy8sHmFV+O7VmxhG4SW+EeE97dz0PX1kU6QFvdxB3Lho18b6Z9evL/6u+ UkAk+JfSrpPYsVCWxIDPHPPzjYa2PksyuyAdqatp8hJaETs/xcve7KFCckgrenwetY4qhu 1J79Dk8z/21QZLO4P1CTOFWsRUfzPqQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NJyggAY4; spf=pass (imf22.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-728f1e66418so3603693b3a.2 for ; Mon, 16 Dec 2024 07:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361539; x=1734966339; 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=gAAVT3jm//0Jn0SieEbRABow8HKrLkziLKm7kqsvGKc=; b=NJyggAY4yEHEnnJjnqZCB+X5UwEsO2EN8irfrUqmc0F4wFKTu41OHAr942zQaI8nzi UMJ8L49UKOdDiiNU9MN/NAQazgQGDrTMutjPN3gbVLkdA3KbUrZBCKuh8cj2XgPtK3hx VyHFfC7RuA3tVrui37OqqI6iT4PAuZgWIdy3iXpXxe9Q4QOevtBm/fvwNj7h9WMUu1Ne ZHnmXKL54dW7SQltM10ebC8HpE51oPZ3rB1VUaxDVkZ2eq0m7ClvNRh03LoS6iVftiAI 2NBNTtzmbteaEdyYpYTVdfJNuiisacctFMbqtkyZoa/rvj76TYfnR7JQMwZVUykAIRDd x5Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361539; x=1734966339; 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=gAAVT3jm//0Jn0SieEbRABow8HKrLkziLKm7kqsvGKc=; b=R/6LTYCx3x+IYeRdf63dsOH8fN/heak8nciJ9CQPKdSAFlsIHVmPygP/Oz66KMZSJd kLzhRV9xRyFs0pwnMP+T+uwKPPE/cRAoVAGadHxcpJZ1Ck2TFEUGGC8M6RY49c1Dqk9T gBkTieqlEpXw6QhxUSLxdVj5r7SfNH5BsJvr4sWd1+Oycxqjq3LjXQsv0RJ0azpfg6yf w8kF3IESW6b8vZ0/lgVBQvH4Ytoq6YaHBv8nvOelc8IqjMxvk5u5BHXdGWKBoR3+osSK NhkpbEvwz7lp0zeMjhs4BT4DdflVOS6UbZP9MEf2nr202W5xZPH6M993kzcXFQkUSRN/ zP5w== X-Forwarded-Encrypted: i=1; AJvYcCU6aLBvDDkFjICwhjFKPiL5ul+OSg3AEYRRlnMCedRS5lAOKcBtwemkkmqeeMZvdSRIHGyZ1aPGrQ==@kvack.org X-Gm-Message-State: AOJu0Yx1beW2DbIyXUWqYqvKHuG1MRq8/g9hFAW+HrUObziDS59OXMJi hqoM+f3pWrNQgWn4qo0OQMq9lSPu6dzi008qIoXAhSL6nEkAhVGy X-Gm-Gg: ASbGncuuCiixsT+vsZbBfHQm3wEXCd/MM9RxRArg9h6Mbvyd5fTZeQJTUUD+izBYVdl TPtYxbHKbk7P4q08zMvv/SUNUDciCZs67ekLKv9dPHY+qaaIoyPe7hN1PeUvyRmxC66AqsBi9yT hpk8lbBhOdIlWIPaE7VXW2av3aC4Csgk9GStjBu4QJ0hS6M/o75MmYtRRZ3bk7e1Zf7GzkpxcJ6 GtC5cKHhDEnEEVUvYrdm2KLfde363b3RtXlb8UuOpIWdVCO/rfcaTCfTUY/elpm934= X-Google-Smtp-Source: AGHT+IEfq0n7VBFbKcEE2XQEuBMbK2QTTJcXcrXNXlUVilzeSIcYZLRhQ6uyisODQLBXIjnG8BOM2Q== X-Received: by 2002:a05:6a21:3287:b0:1e0:da90:5f1f with SMTP id adf61e73a8af0-1e1dfd58f6emr20096828637.16.1734361539138; Mon, 16 Dec 2024 07:05:39 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:38 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 10/18] mm/zsmalloc: add two helpers for zs_page_migrate() and make it use zpdesc Date: Tue, 17 Dec 2024 00:04:41 +0900 Message-ID: <20241216150450.1228021-11-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: CA20FC0016 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: an3riib8gmhzpkhk4n1m38gp9m9aq1te X-HE-Tag: 1734361509-698913 X-HE-Meta: U2FsdGVkX18NHy6DfIVJ7VYj4veHK6e9Wl/90eiQ2eaS+dx6OxfBuOSCNo513MN4No+oFPDpq1EoYwBYukQbHxmH/7n2L1491YU8RvBT883lQTNvhk6wips73s7Zj6lDKECC/s1ZDUM81AkS4n/hzgDkhB5S9y2sZC3eqEJ7shD5Feq686FXIErKKKRW0yk5i9acc/6xkAufckKqjfY1hs5Zce86tVAtxUUVVoCJP+GlLtVEBV8L7OXOC4s90xytZhwcHUiwLa8rDdZHoPFvz7lMo851e3zUAU15k/iqUQEbBGVun2QFhi++Z7+vE6rj6x/eQ71cpFWGei/Io3f2ZcvTpxevdvX5JTkWmrtKIBEV0E34YjyTnYEf+OsYpkTnq5gBPMy6GcK4coKtL2m0wtwWzaEghbj0Gqv4vFysUMIdk/WJF4HQ6LBztmQglRd2k9OZUpAmAamdmbOxFvAmVpjFDoXeAZgPMx1fAmTgX9khpFwtf6QGMv+yKDehoyFSbaNPgJyrCp1Z4DhmsoGJJSGEMsVc3t9nExRCVz7eEgPkNCi1Q4xc5pKD1Qe3Afe1lBUod/bevuO+d5tpPaeIHywQbeky2i3JRJLjY+jufk9gT2sVeo1ExbeH1hWDIVZUJYU6XNjinppaJjsAKvuP6UxgWhqNKP7ueedD79GyQnCdAeXzY5ek2rczKUhp5Q6Pr4Puz2su3CvLM8Xaw9EuCX7mwpfpPL+Tv50Yev7Ok4m+6cpOMO4hfP2TphLHNj4dTYOjI5++/cOPmQ6SgRrd84I23n4gPGWeJ/orwAVAD4RTQN1y8cRgSbanJnQCOuWURLI5vuS6l49I4o3BN1Bw1x4XoLghO0/SeHBdKNFap4JULrikLq6qT0fqV0qocShcpBKyXFhVqQ7qfIwKrbSWDeSonRrghILz6g0+Pjc4ToPdqhYlwbQ5afd680YW1oMtxqhTJENbXBiQk3uYuyv +DTHzzV2 eFEc+fnSLodGLMHUvac0mmujXmBIOfsiq7Q1DEt3qWuQ+mqLiKccMorIZFhB5zflAix6nzO3xLGGzh5WCvTyZy38gbh1nmT4VNbViYiAypvvslIBRLAfelpyCKuFP7O9nYjrAjftpZS4YUqX9jN7P116+AG9LxkEnlkD3kkF9zJKYyqoqHv5401R80hyRzzZwM2Pb7V+KuHQOS9YeGLsXJrhAfjN/MI8xeASkuaehtYgNWm3n5y7Yq/5sjAeH+ErbT6fco6CUZgjppj6XGQOz8k9iyWX8k+rGtrUVs2jZmqARWI3tvysjRegY0E4e+GTLNbTy9a/lWaWIe0cB6Asvp8yDP1X791x+YqDLA+3PA3saiSt4CsJ52sPThcZAiQwYmrOBXfAnf3i68rUsfBmsCPbA9p4fSVH91t6wBZFfLq5bzYKEYWQSYF2AlOX+IcZcf3wSwwbuu5pamCb+3NiZCvLY6nu0JmD5LGXDYQaONamblGYLY2h8qlFhghBMs171wfECBRyY7LptfwqVavnEi8Aj9f2YcAR0GM5fWnyyB63umjE= X-Bogosity: Unsure, tests=bogofilter, spamicity=0.450294, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: To convert page to zpdesc in zs_page_migrate(), we added zpdesc_is_isolated()/zpdesc_zone() helpers. No functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 11 +++++++++++ mm/zsmalloc.c | 30 ++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index 9aca8d307796..c7c52e05e737 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -154,4 +154,15 @@ static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, { __SetPageMovable(zpdesc_page(zpdesc), mops); } + +static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc) +{ + return PageIsolated(zpdesc_page(zpdesc)); +} + +static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) +{ + return page_zone(zpdesc_page(zpdesc)); +} + #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 112603f9449f..432e78e61d2e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1796,19 +1796,21 @@ static int zs_page_migrate(struct page *newpage, struct page *page, struct size_class *class; struct zspage *zspage; struct zpdesc *dummy; + struct zpdesc *newzpdesc = page_zpdesc(newpage); + struct zpdesc *zpdesc = page_zpdesc(page); void *s_addr, *d_addr, *addr; unsigned int offset; unsigned long handle; unsigned long old_obj, new_obj; unsigned int obj_idx; - VM_BUG_ON_PAGE(!PageIsolated(page), page); + VM_BUG_ON_PAGE(!zpdesc_is_isolated(zpdesc), zpdesc_page(zpdesc)); /* We're committed, tell the world that this is a Zsmalloc page. */ - __SetPageZsmalloc(newpage); + __SetPageZsmalloc(zpdesc_page(newzpdesc)); /* The page is locked, so this pointer must remain valid */ - zspage = get_zspage(page); + zspage = get_zspage(zpdesc_page(zpdesc)); pool = zspage->pool; /* @@ -1825,30 +1827,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_local_page(page); + offset = get_first_obj_offset(zpdesc_page(zpdesc)); + s_addr = kmap_local_zpdesc(zpdesc); /* * Here, any user cannot access all objects in the zspage so let's move. */ - d_addr = kmap_local_page(newpage); + d_addr = kmap_local_zpdesc(newzpdesc); copy_page(d_addr, s_addr); kunmap_local(d_addr); for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page_zpdesc(page), addr, &handle)) { + if (obj_allocated(zpdesc, 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(zpdesc_page(newzpdesc), obj_idx); record_obj(handle, new_obj); } } kunmap_local(s_addr); - replace_sub_page(class, zspage, page_zpdesc(newpage), page_zpdesc(page)); + replace_sub_page(class, zspage, newzpdesc, zpdesc); /* * Since we complete the data copy and set up new zspage structure, * it's okay to release migration_lock. @@ -1857,14 +1859,14 @@ static int zs_page_migrate(struct page *newpage, struct page *page, spin_unlock(&class->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); + zpdesc_get(newzpdesc); + if (zpdesc_zone(newzpdesc) != zpdesc_zone(zpdesc)) { + zpdesc_dec_zone_page_state(zpdesc); + zpdesc_inc_zone_page_state(newzpdesc); } reset_page(page); - put_page(page); + zpdesc_put(zpdesc); return MIGRATEPAGE_SUCCESS; } From patchwork Mon Dec 16 15:04:42 2024 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: 13909889 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 A3B1FE77180 for ; Mon, 16 Dec 2024 15:05:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68BB46B00A4; Mon, 16 Dec 2024 10:05:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 613B16B00A5; Mon, 16 Dec 2024 10:05:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 43F896B00A6; Mon, 16 Dec 2024 10:05:46 -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 1E39A6B00A4 for ; Mon, 16 Dec 2024 10:05:46 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A82C5121126 for ; Mon, 16 Dec 2024 15:05:45 +0000 (UTC) X-FDA: 82901146314.02.6D7C8ED Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf24.hostedemail.com (Postfix) with ESMTP id E3C7F180019 for ; Mon, 16 Dec 2024 15:05:39 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iZTE6nH5; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 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=1734361529; 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=ysdxU2iIQ2CuTsrwwSchICK8qjFCgYtZOf41Fa6yvn8=; b=lBR68V7ecvi/fl1meeVTXRDeCf1GbLDsW9gN9PDzCCRHB3mbdBmC6NljT1zKycstvqRRwX VKsO16aeZAjXnMXpd9flTXz0OtCBtmWzNuY4K9wuUxiYmKa2Q3Nxw33BUGu5eDju8Jd+eW zGJqSbJ1xdT8gBucPYDLhu5ElOelS3E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361529; a=rsa-sha256; cv=none; b=8L1nJJ8x3BIkc2iaWkVtNliWt1y3yAoIaCLz8KUwFf5opciTcRDFWS/9ExdvVOrPB8eL+0 N07jRjoKe/h/7DS3wDxTasBquFz7RjZPoL7QxiSHLMWunCvj2Duii6O8mJxaebZQcCBTdN cQrS0eewcPFIdyHEgrvnnSZPG9DuBIM= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=iZTE6nH5; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-725f4025e25so3500187b3a.1 for ; Mon, 16 Dec 2024 07:05:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361542; x=1734966342; 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=ysdxU2iIQ2CuTsrwwSchICK8qjFCgYtZOf41Fa6yvn8=; b=iZTE6nH5YKjQt9I0KY0ujKAfPB5f+8kBHlMI6GCh3uIfOwXWcnpK3OhVlt8k9OrV3r s8tXNaV2t+KpKJ506+PUSOiB4tKLeztoPi67DZwz245kEo9lw560cb4vsGtlkIODzOs3 SOt3ElAj04Q/Tz+Of+BFSxm+Q5w+v4NWmEI1jD6dAHPGsS9Mx3wfRWs9IvhKQiiSSM7y 79eQ6TT55UwH0OCZg9NJl7DfojWYwzuwf5k2ADjjPZGM6TtHuOCLxdnu5/WCrjXOQzwg uedRZYMpiPruTlFeIzq8NuRpwW1+QUUAtVWmUa+Ou/inCvggX68pSJsfbzsRBEx7e8XB x91w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361542; x=1734966342; 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=ysdxU2iIQ2CuTsrwwSchICK8qjFCgYtZOf41Fa6yvn8=; b=NbUV3CLy7XaQJpakeLTkX4zmIoR0wPggy2upBFmdeBNqca2n0HJU7YRYgMxThdFIxD 3zAWmB5MdptDx1FmMpZoJ0QDkW+Twxk36LWKkh0zTcz1/nMjgyASuW6VFQox1E7mNIy2 l0VCLlZywCoN4RS6deEGViquQZJzMih+qkbt9KL/VCW/b8xBjS7bX5ZWzkr02xKrXkSm uQ5LOrNl8fNuF76qVOmF7LhJx1AQ7WtQ/YGrfkovyPQzF9J8pQsKFHbPwhvdqkWTEQs/ Iu+G7FCwON9uY7zBzOZg1YiLsSpsEAr09+tUD8PnpffuK0XLEbo/FurMSjpeR36LYaeB ONiA== X-Forwarded-Encrypted: i=1; AJvYcCWKJUOP5eBMXb8W423vLQiLd95/6hDR+5wfxp7jFPAFQFQAQQYmzLxkcV9fU9Woj9SxRogIIiHB6A==@kvack.org X-Gm-Message-State: AOJu0Yx7XDFmO0gm/hk6n9OpyJhxCUUGUscRAsv2iED/3i6we8BAvJDq AVG0TOiAG2Baj3lAvwcX/IvWvOqf+/Nc2WMECxPPTC4QL9YIdsrk X-Gm-Gg: ASbGncv6RXuqM8GF9zwCDdHg3kZpGppFUpCnwGnbkCduZG1jCvgEC0yScot4yg8sxj5 Muk1PwmcefXiwzQ6xplqlkbJCZMS3aaTUs66LRPcGB+tjEIDJqNkdVnLHzzaYPW8Yx6QsRkn8p1 5BIF8tCusKJVXiTPnmYnKzeH++uvdw3flmN2SVZNZLdPXBzpvVIJ0LWgnaLa26WpNstt1QzTJ4f nXeETGPVNXDx8mnGqPnhuE14hiduhX+FR2z3+3HO3SrSoCz4MmM91KJ+hoCCysI2LY= X-Google-Smtp-Source: AGHT+IF8E8faLy/AkhJpKHn5uguKgfoXbmLpv+0a9fNgAJAqK/Kl4a6e9pElkLit8Z5sWpgLlssJmw== X-Received: by 2002:a05:6a20:c891:b0:1e0:c432:32fe with SMTP id adf61e73a8af0-1e1dfd87731mr17176399637.26.1734361542256; Mon, 16 Dec 2024 07:05:42 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:41 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 11/18] mm/zsmalloc: convert reset_page to reset_zpdesc Date: Tue, 17 Dec 2024 00:04:42 +0900 Message-ID: <20241216150450.1228021-12-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E3C7F180019 X-Stat-Signature: 4bg37cfiqntwyi5ocq3z99uwmnbgotw5 X-Rspam-User: X-HE-Tag: 1734361539-201765 X-HE-Meta: U2FsdGVkX1/kseGijgqgD51CZG207oluDE+tLQslqZrvkas4MharRDzPThwBPs4JRyZxuhoeWo85Ezx9GjXhrvj0Od6KY8bRACu/fCKtJgqzl03qz56VOI3jdclNy6ubM+JFuYZC9n6UvIzFUrDHV1qf4OYYFmBHxnVMHrRwk9xi6XnySbueWrrV7ypK9e5Zok8OgZL2dWsFShMarh6Jbx6hVvME+rnQP/1UtVCDfCMfj1NI6qf5s7U2YeDud6QVt41/5/C1nlWC6J8od4mJjyhlzj6cd4OyAKBFkRPctFr+8IhORrbEKCsi7t98ozCaIua1BShf/5yAcaYe5ShbCpSWkVDHpaORS3AkcRxDyowkS9P/tmRq+QAL817sVCEDedTT12Y+yaSHgvY1r7nzHfK8PRlEjnASXZ14iB6RvUgTuXTS+xprVmc2AdkiuOIuJ5RbIJLl0ztgqyMxq8a/ipuGoHFwhsGiS46qz1pJyLnZWskdhLYbFWv5HqP3MIdSRojuRNoQnsA0yWwiiCggZx8IBrgQfNIemudbq2HKPkvlaZgeoVANEVCpGFRHQlHdd3d6YvhQjWZb8ZZeNdRrBHM/UMEdVfj1uLKJC+W/5m893CHgPK5yugB7SApeiunueyVZj6LifbexjKpO+1OUGWWS28OGvUUUSK4i6sJDNoDg1dFqYAm2QWRZ7+SPxw0tC+n/QPHv0aqB6u44rgjw6X6uWttcLBYeSkggOaZsreLPmS/SiVZvkzK2gyZffZYAVVLSwpjXF58jCoB+qVdrV1129N0prF00MkBSNx6RLEwmT/SjKeYbPkRqGTmjLkplmOxYiQUgKTe1XSyY0zqU88Z9a4g6eJ635pLdEHmngPrqq4KO50YcnnNpzF/5GmozreoJgBytn2+qas3vb4h88tELShvlVccNtVxeKjS5mBHmiGzOhzOrkjGfD4i5PacZfvXg587QkmOAgqiAfIR NwUNPGxZ k73kW3gADmfHYzvQOcMcLiPFnlEzT3i8OrB9fk25/+kzULNc5e+m1p9jrOV7PIP98D36LLPZxZv18FyBsiHMZBvGTbTWgYe2URcDHI+575JagUVU1L+p4WJEQekXo2vrrOdReXq18MZYr6LkZd0nepHuTyZPhaMhJfcz22QhCHNQGpIYciapZdW3WtUVsL2JTTnjosMeNqAwJb2nhmE2plm9mf6weJDW0DyAXVSOxmZOoNrDM5zw2128L1P1JYIl4eqtIMHYpN/KYzG7ug0mJMnprKMId84gZnS3iqMAQzohzNbrPRM22yTxJnhtPneMpg60oc/G34SUqbeHEwBcCHig8eguH/YELzdG+bKV3cVvvJpZ3J9J8AB9z2lBErikI+1lIeB1hw5j8RIHiyFPkeEHAuKAj6SncDy5nqc3qNWJfw3cTI7CChzF7SQCW41H5/HLw2SdvM+ZyoLWDTrMECL0/zRjV85ezORzOH+UA0sGIfxg3tFbSLS8M44u9loiCi0xdbsxOjGyj94fzypIZrqILHVv8xEMoVLZkRe6kSsOed3s= X-Bogosity: Ham, tests=bogofilter, spamicity=0.336703, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi zpdesc.zspage matches with page.private, zpdesc.next matches with page.index. They will be reset in reset_page() which is called prior to free base pages of a zspage. Since the fields that need to be initialized are independent of the order in struct zpdesc, Keep it to use struct page to ensure robustness against potential rearrangements of struct zpdesc fields in the future. [42.hyeyoo: keep reset_zpdesc() to use struct page fields] Signed-off-by: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 432e78e61d2e..dded6d1f3b7a 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -843,8 +843,10 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, return true; } -static void reset_page(struct page *page) +static void reset_zpdesc(struct zpdesc *zpdesc) { + struct page *page = zpdesc_page(zpdesc); + __ClearPageMovable(page); ClearPagePrivate(page); set_page_private(page, 0); @@ -887,7 +889,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_zpdesc(page_zpdesc(page)); unlock_page(page); dec_zone_page_state(page, NR_ZSPAGES); put_page(page); @@ -1865,7 +1867,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, zpdesc_inc_zone_page_state(newzpdesc); } - reset_page(page); + reset_zpdesc(zpdesc); zpdesc_put(zpdesc); return MIGRATEPAGE_SUCCESS; From patchwork Mon Dec 16 15:04:43 2024 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: 13909890 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 23831E7717F for ; Mon, 16 Dec 2024 15:05:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 728486B0085; Mon, 16 Dec 2024 10:05:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 663C36B00A5; Mon, 16 Dec 2024 10:05:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B4C36B00A6; Mon, 16 Dec 2024 10:05: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 193166B0085 for ; Mon, 16 Dec 2024 10:05:49 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6AB4916105A for ; Mon, 16 Dec 2024 15:05:48 +0000 (UTC) X-FDA: 82901145600.06.EC59912 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf02.hostedemail.com (Postfix) with ESMTP id 6326780023 for ; Mon, 16 Dec 2024 15:04:50 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J9787JXf; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.170 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=1734361526; 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=Okd8af+xJ/uPeTS2068jlInbQIVkoFnfMsYSI8mfzHU=; b=MZq0qQVbNzhBzkwAjP6fJqIJ0yCz8DStzjFQevRaCDECRQ+I1D7kezg4NkKjV+o0CGFXXT hcEKpOmyfzfH83jUPU5F/KTvFslHZKi/rZD8aRO0WXTkk72ku6Dqado7bkJsKgoclmXwSK 8pgZtSN2LuCwFmPSIObGly3WxmZO9IU= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=J9787JXf; spf=pass (imf02.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.170 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=1734361526; a=rsa-sha256; cv=none; b=a4JwtittXXYu5baVBS/KvNSSx/sgos5t+AkVBHEDwRoxXBPvpUMCViBn4PhMYBabbnbhgM gGSz00rGI2/DFwNrQszvvoPZr3ODvKpp6j3Fx/HXQgHSrX8cV9QPuTzCwaK4ABppHH+dNX m7fFMAWw66wNqNw/iuPCIqjyovZQTx4= Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-725d9f57d90so3046208b3a.1 for ; Mon, 16 Dec 2024 07:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361545; x=1734966345; 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=Okd8af+xJ/uPeTS2068jlInbQIVkoFnfMsYSI8mfzHU=; b=J9787JXftwEyeg4Bk4TqytZOdS1ucszhv4qFeLLhmm+vAKcndBrRerAveR8kGbBF+9 cklQU8bhyluHA/O2u6dGojExlbL8yQAMIJLVdV+wHLCt0+f6Jjirbpe3vAR7SEi0ph60 ElJB/I2P6RVYhXX6kBhm73zJ/LxfJhAIhOVO7hGIeEV3taTNAmFtgoe0jBZ8LbrRebQm NxnVsePBqbWbORNBn7F1wCqmNTCBg+9TXwoJsROC0H9L++6yMwyFxZ4luNv39vye5ndA RQIkzKedCy1DEr0QHRhF+P8aWxwIfznfI2rirtEF3bWv8/EMAR2UpdbQI94vKGHTzr1Y 6Vzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361545; x=1734966345; 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=Okd8af+xJ/uPeTS2068jlInbQIVkoFnfMsYSI8mfzHU=; b=MVOzmLVSR7/lgcq/9mlufbB1Asp1nYSPygAyy/9NbpCN/I2kl/Z563QeUZJDJFidp3 cXp9Hp7OXmgtmejTup4wS1QjA8NcbELcnDcrrClw4zJ/9HpGvENKt5ZQ0PHZQce25Pxs tOvr3ZTIels9w+8gl7w1et+VKnXXncyFm4lYLKGEH2DDxBmwWsIYsk7PyCo4AH20UPpp bEc4jClXlCltJjW+hgWAnEnJFPeoINDnARNstMAB0t976rB2Th0q/ieJ4ZFtm9mST4fV IqEXCOLIQD8q83aEiVU3nEUawJjRRYqPeMq3J3Qr3qi8CvkMyD+9Eg57lLz7fGVMUlZr qiPg== X-Forwarded-Encrypted: i=1; AJvYcCWM2D9ALPCILSF5mWxqsEHYYUk7HYTLhSN2CFiJN4FgbehQ+2p+aA82CJ0GVo2UM1CMZB2RilkTTw==@kvack.org X-Gm-Message-State: AOJu0YxyAqXYk5D40s+kTaaoVfJ3bwq/iWrSCAA1OyIX0LaM2Bpv3jI9 O2wMEUuMPim7C7ISs8W9hJ5OAYFdlv2zKMI2OI35DmaDTd2llP8g X-Gm-Gg: ASbGncvq7epL/ON1BwfSEnQP94YetNblenEk1+75U+FCqEvmSt2+UrQ25zkOdVBsw+2 WMfgjODT0xXsG6+/fMe8JoEq6AX7W/ricl/i1KKjnReynmnsih4nS5yjjE+/04JBeho3CC/4tO9 QWE7ww6uwFBnLHGG/U1kCWi2k+CWemcycr61Iw/WbjlzLG6R9Q4Qox4luXu6HQOSLlCt8SgH63h 3FwndakBkFAI4dQQ4lDDl0NhGJUHB9pS+XNKaiQdkrc5A+nagPEvQ+3+tjNzg+P/9E= X-Google-Smtp-Source: AGHT+IFGnR9oXP/IG3Lkz00eu1Mfb0rQPKxhmwE/05PE6I6j7UQQncxs1M5cSGZ1liehbE42sniAYw== X-Received: by 2002:a05:6a00:4c90:b0:725:dab9:f734 with SMTP id d2e1a72fcca58-7290c12ed78mr19087392b3a.6.1734361545300; Mon, 16 Dec 2024 07:05:45 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:44 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 12/18] mm/zsmalloc: convert __free_zspage() to use zpdesc Date: Tue, 17 Dec 2024 00:04:43 +0900 Message-ID: <20241216150450.1228021-13-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: 4q16rgi5czshuj9ywxw8b46bg49chh6n X-Rspamd-Queue-Id: 6326780023 X-Rspam-User: X-HE-Tag: 1734361490-678728 X-HE-Meta: U2FsdGVkX19V8wZEIOC9xYSfRo7JfjmPWHmZe8HXxkMm/JsBa+sgR0GxmuWde6olLelpb4/tgO/mmRDjOY3tR/Kw/lrkAngRRvcbflgcCpoirsk80YO8r/DFk7pTWyz6SmzZuEYFhnDQVqxxCRPmr1lVoEPtwCtWtPfwtjUtFzW+6Nnpf67gJPeN2jurH4ia5j/wHqudOdBL7xQHQViOc2cBpWvtHg31Jnl7PScpEsQPtoB7AcJ5UmGHOaoiTH2fgXTTZTRLGxnk7l+4Xcnwu3/nf0bkIFJeYwgUZir0G6Vmq+IhuVeprEs08fow0BYeR1pQHQ/BfHsvU1Lw3ql6t9aH5bA095YcuhgpH9l68NgtaXukPY6hR0fK5A/P4GHJ4jCzWwifm35v9LenYP3VqgvS1pVKYLqDRv+1S0aZ3Np4WQDxLKQ/HHH4QBaflB1CtXMPMnlWMi0Ev7/TfuvsmWTOg8U24ddEzk/S0cYIS3HLM4Q2r5svXcez3dqZVvsMiWbnhOmu7J2MYD7QbD2azR1rvSXqpSIjoLijTcn0gPBvgLcL6wbIgMYO8FIinVGK0pAne/uVxFHbWp+k66Vp0ea2OsRU6+LMGH875uvhWgZgDNdk4mFJIa6Jse0Z1GRYL/62x1vme21+yyo9nku/P16yweAuD0U2qfj0Wtn5Nzvb6uHeJHuU4sD7GeS/oY1kwoASwSIN0Q0RqZTAeU1abtQiVQk7MEb8dOp3JtVNfdX8GsBUmCWh2um4wNSugjh4TWrXsiBEvXZAOPQgWhqJ1Ls3LJB8FA+TMpXqMwRyS3pOim7r/BUVEGe+KOAfwg6XDSsMUHG44EpRRNK2U+SFmpJBUfUgdVhlC2hOUaUiT/Gp01FuTlqIzfwOC9FL4ibeJSnfrRSVuhKIBWV1Okz1NAbZE9tb5bZsFF6Qb3ALqHr6tBm+xpewoth4cwE8UCxrUg7pjUmEfbU8sW1E6+y mZaRnvaJ +lJaRG9fL72AkUt7yR15XO3p/aigwwkc7i85wKPe8t8s4f34f51R/IkcBV1FQIp14NA51AUdefHv/wDgdK+iOrchXSdMzBen+W9DaTvIlU4KPTWgslo7uuguUEe5zoqlvDVUH9QlCppDuiiXXYvFqIZo++DrNft8FFn1IHPReuPIELZN8GrY3IzCVZvaRtmY/asasBk1swSsmhtUEfcAO4lWuu4/O4nH9MjP35r+amIDm0qKb5KHCFZYb/STACxK8KRHexp4++Dha4gZpG8MQc6/THqVPdDqBJVFnWI/M17PqXEHRQcXkx3tLQ2MFW0z/1CNWicP6e6Dk/W/WHX83Oi9eGsg8dHNtEtpT/ewfntXWWd2tpvNubpu2laC2le8LEKxypQmakRmDkr/8Ul3OU1gAAJFurdrerOMjDgZHIlsQVeGyiR7Gzx1CX5QwTCGSgmXMbVeUpdHrTN5VU2x7fh1gbdWehECT3ZR1gNAeqUB4zUsWUcgD+iTpccAPvPxVAOmFTxhUrkrpZgHVSFBWsKq6yzqxTa9C2vprG3Cy2ieHrL4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.429860, 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 zpdesc_is_locked() and convert __free_zspage() to use zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zpdesc.h | 4 ++++ mm/zsmalloc.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index c7c52e05e737..fa80c50993c6 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -165,4 +165,8 @@ static inline struct zone *zpdesc_zone(struct zpdesc *zpdesc) return page_zone(zpdesc_page(zpdesc)); } +static inline bool zpdesc_is_locked(struct zpdesc *zpdesc) +{ + return folio_test_locked(zpdesc_folio(zpdesc)); +} #endif diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index dded6d1f3b7a..e1f501d51226 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -878,23 +878,23 @@ 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 zpdesc *zpdesc, *next; assert_spin_locked(&class->lock); VM_BUG_ON(get_zspage_inuse(zspage)); VM_BUG_ON(zspage->fullness != ZS_INUSE_RATIO_0); - next = page = get_first_page(zspage); + next = zpdesc = get_first_zpdesc(zspage); do { - VM_BUG_ON_PAGE(!PageLocked(page), page); - next = get_next_page(page); - reset_zpdesc(page_zpdesc(page)); - unlock_page(page); - dec_zone_page_state(page, NR_ZSPAGES); - put_page(page); - page = next; - } while (page != NULL); + VM_BUG_ON_PAGE(!zpdesc_is_locked(zpdesc), zpdesc_page(zpdesc)); + next = get_next_zpdesc(zpdesc); + reset_zpdesc(zpdesc); + zpdesc_unlock(zpdesc); + zpdesc_dec_zone_page_state(zpdesc); + zpdesc_put(zpdesc); + zpdesc = next; + } while (zpdesc != NULL); cache_free_zspage(pool, zspage); From patchwork Mon Dec 16 15:04:44 2024 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: 13909891 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 38E8DE77180 for ; Mon, 16 Dec 2024 15:05:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 862056B00A7; Mon, 16 Dec 2024 10:05:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E8446B00A9; Mon, 16 Dec 2024 10:05:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EE736B00AA; Mon, 16 Dec 2024 10:05:52 -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 3A3806B00A7 for ; Mon, 16 Dec 2024 10:05:52 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EAAF9810C4 for ; Mon, 16 Dec 2024 15:05:51 +0000 (UTC) X-FDA: 82901144844.20.6BAA955 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by imf27.hostedemail.com (Postfix) with ESMTP id 1BC5F40025 for ; Mon, 16 Dec 2024 15:05:16 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VhyxqmAx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361522; a=rsa-sha256; cv=none; b=Det1B/4XXTcIXngPNfIlX1nL3KXHlstvv3rUGrN8sdIYGJNAxj7jG2YZyzxBuxevPSGpig UHPovBFEreaRjiQevROHizhDTCxI94E/ER2geUZ+3BH7PT0Tl4ELvAbwZn3jhCA9N2gYLG gZA5g4KfNl4yW2gkWJk08sFhOYdSu0E= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VhyxqmAx; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.181 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=1734361522; 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=JNNIvdO8t2iCYzARstvgeDaCH7MMZqqXTLJPJt73f0Y=; b=NgFyuSeoYRvWCfIjN98LBJfzqxWnIKLgc9uZXYlghJMGV+fDWsxlwqQBviIaUXCRYqDhaQ VF6Y+pdwBY9faCnv2rTwA8qFtNOirHPQIWV7L5NoUd6mFXZJGEGmw+Ol6HlAo6kufaeSpz erx90N8uuWKB5gT637Ofb0pED63nmyo= Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-725ee6f56b4so3625804b3a.3 for ; Mon, 16 Dec 2024 07:05:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361548; x=1734966348; 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=JNNIvdO8t2iCYzARstvgeDaCH7MMZqqXTLJPJt73f0Y=; b=VhyxqmAxImr1Z2eZ2riXBI0m/BCaULS9+rVdn7IFYNeoH8z5Tjp5Y+qPyFEjkx+j+t cf45V/2EEk+eDCqY9hMq4evE6iqijZ4IyWJ0M4k2+Z8B7DDzdKkNf3HxeCjTIRyBBOC+ IAHAkinOA06jdz2dyFiHHS1I1G4wF/bygxItJmBSjyOoHjpkCyTFh6iiL6eBzfckfZnL wNBDoUUpVyLy5lV8/xsUWn1T9tTD67FHjSEtHwtm3nnqXXY4g8VWlpCnQLym+6MoKSLf ce4AqzloV/6+97/ODRg77gaNZZ66sAQihFQjv1brLcw/g6xWbg5fITzK+EBzLYJrWeUU s7Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361548; x=1734966348; 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=JNNIvdO8t2iCYzARstvgeDaCH7MMZqqXTLJPJt73f0Y=; b=nricnsXnkTb54ReAKSJOvJvWZvr0VF4ATYDfHNmm25OsqQOJXp/MFFqZFhk0onhDTA iPKXhJU7JVwwQH+Sld6z7l+wMM8XrHieMKdykTQG22We6RG1D+P6JHJpVjmpDndka1+H xJg2puvLCKl+Lo7e1XMaq95UD9Jsu3TZiN/SXqLgG2NCN7WCoJ48aTncHfxrlrZSDVCi gfkXnRpoug4EiFS7Vv4yA7ItmBHDfsWKsbNhtrNZB4GQTYOrUCV46UyB1iffy23kYidB pLXJDVegSNw/eG6T0P5iU0iM2dTwT8/H0QKLjG97tseBKSAYW4TU0ZUkBCFS1hlwAyKo CR/w== X-Forwarded-Encrypted: i=1; AJvYcCXYzBEpSRdwBLVsW3lHl+sPHuzfI33IGH0gimjXZF1hFbH/tPt+wSJk+bUNqBrH/MTwpBjsiiQerQ==@kvack.org X-Gm-Message-State: AOJu0Yw+Ftn90JKkenowsiCqXWkRmW3odmlfDrD+BjhH1Wdks0GPOVEf cTFPPeOoqxAYtWUFBoqdIa78yWgp9NDUsWoAlIpfNIlhS8CnDVo/ X-Gm-Gg: ASbGncv5OLtmbkSpmFFhB9dbzSMSoDM3LRwqy7wxAebAQVN9yHsoOQgcOXoe3z8hwlM yQsgWazGTKrTE7r5HnV82hM9uXEQLHP4e4jBCfnq6FMMkUxvTr3JuNAUNflwOHKcvoXCx3BgQdc W/KtxRrCCEFIzzKKbKupzYDA2DO6CQ5BUIJZk/IM+lzpe40EaA/gKt0Ck40ReU0egKHztYQY2vr DgDIOol/AJsFzIeHQRgkoR0+3g2bVS7OXsirrVIoOKpzG6SaKGcYVoMRH8AWzD1twk= X-Google-Smtp-Source: AGHT+IH/KuANWO3BzkrFDMIcWhBwQCJ8TBIe54LgFWjj16Zw4HErAncmOuOB/4voQ65mdsf3YT8XoQ== X-Received: by 2002:a05:6a00:1250:b0:729:49a:2db9 with SMTP id d2e1a72fcca58-7290c24ef90mr16798371b3a.21.1734361548386; Mon, 16 Dec 2024 07:05:48 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:47 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 13/18] mm/zsmalloc: convert location_to_obj() to take zpdesc Date: Tue, 17 Dec 2024 00:04:44 +0900 Message-ID: <20241216150450.1228021-14-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Stat-Signature: c9a3n7h3qwq3umfahea9g6wqgoe4xjo7 X-Rspam-User: X-Rspamd-Queue-Id: 1BC5F40025 X-Rspamd-Server: rspam08 X-HE-Tag: 1734361516-285147 X-HE-Meta: U2FsdGVkX18mt4XKV7CrwH3p8ds1LM36aR4M5+FGfaYCapz5C03N1iEaz4au48YM0Iktk5+HxtrrhrOiWa8PCdYrGF9jZYNMZuKiKY04JMsTcKbFjoLSXZXipWmkIhaTvI5vXbzxNkn3A4vyoMDaXbEQewm/CDUWpCeiFturIB2ib4WZvFhisHiH8kHKbVseb0/uThPHgP/asXJ7imVaCYQjRtOOk4LcUnVhPQCUQelvS4v51JEwNBKDUUFFr+l9gRcDLkbom84Rn//TkJbgLL/1x5Cg26WHLuGFlhjPmS06t9mMqE7qPOD3PYVTNx/jzHYMPtfuaKBg7NHNoE3yexCNv48dGoZ5JMreo7pOl1JbdvgCgQV8NuGHo7igf2r69bzdfdjvt5GE6YUXbwtrYe5vzS6hz6LIqSvb9cdsmbyT/r+AvY4+HMMmFwLlogNzMfgcFTmjUdmqw6r+J452gT8Bw39EhhX6h3p1OReGL7FTdX6bPRMPexPR9jH3TD5fJHD41fwhWS6ReNObiGASUD4S1uBfBpQ0JFHCVnAmHSWagj+PmhzQn5kK4uaQxqBUbLeLBwSbJ14iCYIXNuPDVJHFEz90+fI+G0VdDd7WsJDE8DoZ9KX4/14Jgbute5uv6oN/aOgGNvY9gcbT3eeJK1F9weJAmgpwsjXxaRO4Qa+pElSzqhGn37HMycHacN0cg7P9yHZ9rTlPRH2rse45/w+AB8qfygbzHseAovGp5Un7qTRaubynsvMk5kJo226uxaJXmWDzeAApS1ctgUrfvgX7SuxPXYn6k3dKUQDsvWTFU7wZ6mgv0zg3taY22+X2YdH8oYAE2EZdjLIoQEPLz2UaaYr+T5+Y3isfP5stGqVi92tnC7AXb4dqRdomkhc5oNknWOGO058+to4SlsZcC4AjDz9SCqzOJCLXiQoYL38ITCgu0G5M8nLRZKtPkESrnUV6vqVRRDEZsu+cdSw KidjgqVp +OjAwuc7UN2brlFz8vrbfxsuYXFls3NzP2s+E4cobfq8yQq0Wh0Y/7G29633LLrpizNIkalaNyx/4iIChCXXfM53/u2Gj/Gw43o4j5K80y/iL5PtzfI0XYH6daASsn3cEzu96Xh+Uz7yEo4wNWF4XhtzWom/Livuq3vVqLeuOSNARafW1uyuQqPBBSd8bBeaO9ddt9lBFVli8PzrWLKAt09U0hi/IDqSYORX7tjHdGhyNCitZBfSyiM3ppaiIbgAloIiIF/A7WMCu44Xp0yXlbfGjI5mOGyYcRRsgdCNzJIDpmJCc6Duw+mh+qYUZAQOfa7w0pKfDTK0UxsvVgXKELZuozqucjeG9DgqvPHkfgngXiKrKijiZeLaVYxr0oonCbHwLO+dYn4CxYVZWhtlff8M5Iep/z05bXr+TQvFPGwSdBN3ug7v3I10WHYMMqtRaFBV2q4kDAAbfquLMmds83xF30vaaxvaVz+Cq7E8FVCSk655zQkf7nXhqketuWUy07T45cpIBT/bzE2CgQgaMXF5pjC/3AGWDwW0ch36w92uF274= X-Bogosity: Unsure, tests=bogofilter, spamicity=0.471812, 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 zpdesc, convert location_to_obj() to take zpdesc. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index e1f501d51226..37212964a365 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -804,15 +804,15 @@ static void obj_to_zpdesc(unsigned long obj, struct zpdesc **zpdesc) } /** - * location_to_obj - get obj value encoded from (, ) - * @page: page object resides in zspage + * location_to_obj - get obj value encoded from (, ) + * @zpdesc: zpdesc 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 zpdesc *zpdesc, unsigned int obj_idx) { unsigned long obj; - obj = page_to_pfn(page) << OBJ_INDEX_BITS; + obj = zpdesc_pfn(zpdesc) << OBJ_INDEX_BITS; obj |= obj_idx & OBJ_INDEX_MASK; return obj; @@ -1358,7 +1358,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, kunmap_local(vaddr); mod_zspage_inuse(zspage, 1); - obj = location_to_obj(zpdesc_page(m_zpdesc), obj); + obj = location_to_obj(m_zpdesc, obj); record_obj(handle, obj); return obj; @@ -1845,8 +1845,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(zpdesc_page(newzpdesc), - obj_idx); + new_obj = (unsigned long)location_to_obj(newzpdesc, obj_idx); record_obj(handle, new_obj); } } From patchwork Mon Dec 16 15:04:45 2024 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: 13909892 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 221AEE7717F for ; Mon, 16 Dec 2024 15:05:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 971266B00A9; Mon, 16 Dec 2024 10:05:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FCC66B00AA; Mon, 16 Dec 2024 10:05:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74D096B00AB; Mon, 16 Dec 2024 10:05:55 -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 4BD126B00A9 for ; Mon, 16 Dec 2024 10:05:55 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 097CC121118 for ; Mon, 16 Dec 2024 15:05:55 +0000 (UTC) X-FDA: 82901146398.05.5BB3FD5 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by imf05.hostedemail.com (Postfix) with ESMTP id 95358100027 for ; Mon, 16 Dec 2024 15:04:56 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="jejRY/lM"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361539; 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=XO1TL9t9sEITLWXz/LO/dGGG6UxP4KNUE2euE6Hbb1A=; b=15+ff7iXGjwuIPqCyRfhLXjnDxEbDiaQ4f1y/Dn/8ghQqS0uIvgnkty9hmOc7c6ayZQr2F kvQ5gIeONpvtq/rVbvgOQc4m6kGLKDCbBEwhHQ5x0q9SyNUpfoHDmP+h3Lwa0Fb4QSCoQ1 N/jTPgTYEunZBNbGNvB6/PIydCd2YLU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361539; a=rsa-sha256; cv=none; b=bBnbfqydADWFjN6HU4PCZdr85IvrLZMFCxx1dMq/avYBf8c137D4SAA0wwJR8Ly+HFT6Sy os0jAfZsB9PGP2NsD6Q4hgv/dY/4mi9R5WdQ1KYmMxChM83781pVVbkj33a5cKXSrlbU68 q+TUoKloqW3kfYibGG4Eu3Prc47Fvms= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="jejRY/lM"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.177 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-725c86bbae7so3496998b3a.3 for ; Mon, 16 Dec 2024 07:05:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361551; x=1734966351; 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=XO1TL9t9sEITLWXz/LO/dGGG6UxP4KNUE2euE6Hbb1A=; b=jejRY/lMLvwTxdx15sfZ3TGs5T6hZ0+cHxx5pSHStBXgTDWRr/oifN0sBouvnuz5fE E6FtIAOjY6iLv+K+XK0Xx3NF0D8gbAqGih2DXkBM0mKt+xAJ2EBDLTY1LvQb8EAjjByZ 3lmaVfZeOiEK9sLunjgDOpV+V1Xno5bo8yd7m09gEwmH5xQxIEWki0p/4n67BGDuFklz obrxPi8xFT2s3k9O4MKV8cSwyufg5JCtqHx5wtu5JKjrPPOSFs6jJccG9DTwr/d1wxsl Nw/pFt/qJxIiUpUhmYnRzLoKLUJqb+wo3BgV73nopv9TqtVE7wfgB6OB2QaqKHo471sT C+ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361551; x=1734966351; 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=XO1TL9t9sEITLWXz/LO/dGGG6UxP4KNUE2euE6Hbb1A=; b=nh8XW69UcJSvhvFzcb6b4xehf5cHinhLO6tPO9wVCLdZtp07IrxTRJbtmhajYq63Zl k8GDwTqqyPfUgjxK5OzhNeM3SobqbC53qrXvyNESI6g2Oq/6Vg9Ou1i/5f0Y7gGDknFW dd4PR06MngaVwvUPwXfWxi3J8epUEV6TUCKk9eZim7hIj3l3tPOvUN/GiHUn0vbCvSWT 3H1RT0hvtQuy4o6GaIciA+uvCOSFyOJbaVPXnz5ELGT/WcWINs4Af38D3NaYycC/S2q3 AcsP+kqS7lzP7h+ZaNCf/qkMxT8QxCszA10KRKfDbug6vMMchzYCCIaYSPMWb2VoLkt0 zrkA== X-Forwarded-Encrypted: i=1; AJvYcCVJzZ0fb/xGBWbqy6yje+Rk+kpdqYYN9fw9wkd+hEpYWVHq4Dq9kFkzWC+12BNeKuEssIfBLJobaw==@kvack.org X-Gm-Message-State: AOJu0YyVFM1/L4anhoazk21Ux4tqe2+P+biagqov4s5vkTPnUW5byv6P bUnsDyd0WHmG9kSOw4EI7d9050Vv1s45BeCH/dc7BiZQ4GqFHs8d X-Gm-Gg: ASbGncsN3+V1JjQbbXPda7fF0sIHL7AfRe+hCVizzbThexVVcS73Ukn+YFxVGu82dyE gntlAK4KR/XekAQHqYOKTUxSdlrh9yhvCsEVF7GEyId0b4DOmVCylHnbfjgyj2/06Bvu1oJ2zb6 erMXUJTIzxm5fErdNamYlr1qLqy9SCPZyY6TDfWhhX1jCpSGfVdW/6n7lzC2/VyO6j/yDGJzrGg J8Fdjt+DXTw+elfTqM83akZEQ2V7HkaBsmUkg9qm8GZJzHCB/vsO8rm9ub0jhgq2mI= X-Google-Smtp-Source: AGHT+IG5LuvGfGpaig1ary1c465JvqAs5Bu04SPm4PsX2qjUDco2WwufG64gaNPOuGAhiuIzS/zBag== X-Received: by 2002:a05:6a21:33a0:b0:1e0:ca1c:8581 with SMTP id adf61e73a8af0-1e1dfd60b37mr20606589637.21.1734361551510; Mon, 16 Dec 2024 07:05:51 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:50 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 14/18] mm/zsmalloc: convert migrate_zspage() to use zpdesc Date: Tue, 17 Dec 2024 00:04:45 +0900 Message-ID: <20241216150450.1228021-15-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Stat-Signature: aawq9f4iwccp56a8o3oeani1knkft75u X-Rspamd-Queue-Id: 95358100027 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734361496-360068 X-HE-Meta: U2FsdGVkX18ecrKPUqGwRUYw+j2ALmHCggkLXN62khCKWkmQ/GDqft0a/yofxG1EEOggu/VxQkwVDpHtpgeUHq9nXmO113ECxiGOOq5edM1sBMOfIA/gIdxmZbO7pzWenKDUOznmWmWPGlQPCLzHKEayECIOmeBZ2inOktJSiwd4HooFNu6+PYOrPdvSl9AP7F7T5ipQrdiuT6nehj/B2cxiKi6bM8r3O3lh3nIySj9asnCR0SpaP+abwTmk6Mv81qCuX8GSnpfVst9vbUo8XeLTLdJpxTsqT0tg/AvqhDqFOuG8vfK6A7FLmbZ/DXPGfO+LL9khTSwXowHKdp8yJcAPPctP8Lk73+/KYjMtWteVam7eajCqar6NaKn7RimV/o7F7I5gsr+0Lzus6L16E/PB0nhRbgFkl2B1DMtzQ2GLo+KF7C4Az/U/7FH5QFFJxfYLmeunOF1IGOeEGzzU3HUvCGYg77UCrxws215nOM3zxEHOsovZrRr9qY6UnNutnYkPPp0sC+u4E91OzzH7VSzH0OvqP7+UIvWxrJ7FBCuhxT+lQX4Oqy3Zt7erbybn5Coi8oHLlFidrGFaC+QDgVrbGv5EUlSkSiuO7/WaTxZSWN+yr7nRXsU/cxZy+dX9PiRWXid91pD/KGIrJyDebB2b+Q5+sRLKMrIsqMeIPvdWdh1QH9uHB9ODvOtKlC19Qe9Hu1dwlY5RHRg0NciRo5HPRHTy5YdKhkgW8w2V0HXh0PvwpG6F7/rEiRyK+Hcdb+EdqMFf1oMh4aRcahCBPxbYfpTHgZrMWWuXp77vklGsdzUvMreB7yUKjJGABx6NonQb/2PG2RTOxocAg9DCVbypG7wZ6jFB0eJXx2RgpYa6UU+Noq3sp/R2ZcrEnvJ5SVoC8aSnv8MWuYyh0kUbMSEx2jSqnW5ft4CdrGWh6BvB3J0BpysOpOdRDLoNa9QkbsXsxSYRE1SMiIoWWFO eQVdFNmk IeSxLFLb5StggBSVHXLt7Cd4pMLEJ+AJK+Ds3yLsWZj3bH1+F9u1aSctq+OsHo5Y/8xffu2lKR4sG/WOHdHzF+nPpU7TI4XZnr18pb85zV6dURCyMj1eYWwrfD57aTjU6+dCIintyJ6PbIBLAFT/Iym4iPt3IHtZVnVEu2m0lbZLlXvLLtC9JXJ64s5lrGhkhYxLc+OFSbrCrKlaLfI6b7iInEm5b9QswgpA+KuJ8WtH0ntlsT26sLu1vrGAf9ARQMiMo0q7y95RGAAhXJws0ClF6zDU/XQL5gv1bu7qAZBp5qKH+HQ1MWGK5DVj1a6Upto7ELz9uj1Z2o+ZC5tRB50jeBiEKDJmsTtLvyl2NqVey7BdT7tG+16yqQz0ZbEBEk307G2vD9iBtthn8RCoLR0VaM9TGjB0cU79KWrdKLFPgoRiEhcA1fLGzK0PdaCItL+DmRuUoW91v6MEvRpAYkU4X6tCOo9gPdpETTduxdXRM3Ew8tPeuxGW/Y4H4HbupKMxzzgIb21RyzsHrlexMjPJyVSC9lTxxx+J178z/6ISv8oc= X-Bogosity: Unsure, tests=bogofilter, spamicity=0.499355, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use get_first_zpdesc/get_next_zpdesc to replace get_first/next_page. No functional change. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 37212964a365..19c1ca3957f2 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1602,14 +1602,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 zpdesc *s_zpdesc = get_first_zpdesc(src_zspage); struct size_class *class = pool->size_class[src_zspage->class]; while (1) { - handle = find_alloced_obj(class, page_zpdesc(s_page), &obj_idx); + handle = find_alloced_obj(class, s_zpdesc, &obj_idx); if (!handle) { - s_page = get_next_page(s_page); - if (!s_page) + s_zpdesc = get_next_zpdesc(s_zpdesc); + if (!s_zpdesc) break; obj_idx = 0; continue; From patchwork Mon Dec 16 15:04:46 2024 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: 13909893 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 F0D2EE7717F for ; Mon, 16 Dec 2024 15:06:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC1416B00AA; Mon, 16 Dec 2024 10:05:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B47046B00AB; Mon, 16 Dec 2024 10:05:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BF1A6B00AC; Mon, 16 Dec 2024 10:05: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 7B4BA6B00AA for ; Mon, 16 Dec 2024 10:05:58 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4265680FCF for ; Mon, 16 Dec 2024 15:05:58 +0000 (UTC) X-FDA: 82901146020.06.3450BE1 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by imf20.hostedemail.com (Postfix) with ESMTP id 5E1DC1C0006 for ; Mon, 16 Dec 2024 15:05:24 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aLp3RrCx; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.174 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=1734361533; 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=FwgMAYvwWVg4yaueRgoT/AVCt+LMoOGVCN4pN7WQJmo=; b=sIpz4f6a1mdai8Ok8QelVQebNb6joGc4HgPfqteV4cgDc9/jxrCJwisYohMGN36uh2zWf1 VYrsKntnjnq+YaawrrYYUjcP1KRu9Mkk2HsLzcdeeEPjZ3dYXJQlK+I+h1pUEo7wBF1I37 P47imbC/9iFCSIk2KcmV4AUhDnLRmVo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aLp3RrCx; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.174 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=1734361533; a=rsa-sha256; cv=none; b=wruYs3sv3TY1iNZiH6NXWl/mKKUMCEw3ymXCepIVcln3uRzVjGmvNW7LkMWkTLM42dQ+Ah SaT9kXKO5woKpf786D1on8OkfRakEydChgXVyQ6ieiN46lzyx75AARjqXCi72QRceWyVuq LgB21OkzGVzMufHpOnmLdevJCwHFw+A= Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-725f4623df7so3618380b3a.2 for ; Mon, 16 Dec 2024 07:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361555; x=1734966355; 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=FwgMAYvwWVg4yaueRgoT/AVCt+LMoOGVCN4pN7WQJmo=; b=aLp3RrCxQ/6yrPEEqigSnmUJ5HfA5bhQg8xC3HkOi/cuYQ+r8fP9Z1rZByl6nDAyzz gAeGYGhekl9bd6CefK+MpFfTn3cNG0XUEBu5irx0C1nddUWqgJUpgGv940S7QuD8yWer bB09A+z3LaT+9f5s7zchT2Cb+US2KJ3ooStgQBR1svK91hkTnr3h9qIwNNAIucFKM/OH RJJC2fovOsyKskZiJ5lDD+posf9EfvHnXqTutMeH6qfURfglKvg3BGGy4T0hswOMjLKA BNyIhaSs9qcF4G7ax+VujNoPD0z9Pf+sxRIOtgEN0aymKkDZqPum3Mbl48+BC2UEc+IP cHxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361555; x=1734966355; 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=FwgMAYvwWVg4yaueRgoT/AVCt+LMoOGVCN4pN7WQJmo=; b=Q8lVBcu96wgzLeJHA/p/Q/UgYeZUu0G1t7NIprQisFEgIG/70Pd73xk2C3/tPlAaQv oMwXBEO++gJhDQRqxoituyPt59I4f48uF8zW9ei38vHkptkna0hrKuV3uAV6kfRtFfrt PugRiCl5fRxWEDs3XF3ROSURixw/9392Jlv8NQdH2d89KCFT1/9gTK2T49HiWGTrC6a5 1LvNZ/iszUuLpCr8q3dW2PrfgFf86omXxcGMzFDbVE0UqpxypvH+y5XT5NFdmYvP6ro6 amL8HXgzwuPHt1a8iALax+RI6BfpaINzxMjyKZwgebswg3lPxKyrFH9q7kCi64dJq35H jRLw== X-Forwarded-Encrypted: i=1; AJvYcCXcTMK+JkZhpnndJJJELY2i/5mWPvCuGqTMvaT/OHoeK5FCnrYycIgaNp1aQomqHT9qmGcuS+ljDg==@kvack.org X-Gm-Message-State: AOJu0YzOgp1jlwb0KNJsCtvDJiSosVO38nAmy22DUjlVRfkZq8u6K7mb ktHwewtC3W8M5xjnDBvg/C1zLTdDkdCScsn0SrvE+tgM9kgbmsAy X-Gm-Gg: ASbGncsT7qWy/qbAc0yLFjYbwU8UisSHhb4jwBY5y+aBxyBpysHHjpfSbD/P/mCfBs8 OSbkLLak8C2voQwv6MVUwDKopVtv19wgj8VNyYTLhWzaRS2Vpl6eAxeg46B1iDM81ejRJUnlydO cntvG2UTmnQleN/ItnHiP/4vGHYkd9i/g9fMQSoc1sk2+LgEVaqEGVN4/JcAIJQW/iXYGgGhBBt e5uCvtMdRyN7ojb0GF4Xjt+ODs/gH7H9+w01zMJ80273Wa4wu2YP01MKoSxGikcqhg= X-Google-Smtp-Source: AGHT+IHxcNtWT37xGPAjfKBt6c+fDLiLp0VnvWHTPO/Ho3D8IRih6YUDGKHVePBI6Do2POU8c4CfAA== X-Received: by 2002:a05:6a00:c88:b0:727:3cd0:1145 with SMTP id d2e1a72fcca58-7290c0def0amr20406039b3a.2.1734361554548; Mon, 16 Dec 2024 07:05:54 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:53 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 15/18] mm/zsmalloc: convert get_zspage() to take zpdesc Date: Tue, 17 Dec 2024 00:04:46 +0900 Message-ID: <20241216150450.1228021-16-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5E1DC1C0006 X-Rspamd-Server: rspam12 X-Stat-Signature: ba7jybjz4qn1z5m15qw1oh1cg1t8uzyc X-Rspam-User: X-HE-Tag: 1734361524-678999 X-HE-Meta: U2FsdGVkX18HqSlxxoDuWUL2v6MKVVDFq5lh7tb3iXGgyfTCqthkYdR5JtcjK89cScLSg7EhgZnH+QRBjcqeDfi6lTR3tf5tD8aQmisHMXxBAqGk80jsqTJ1cIycGetq8j2CJIENoZCv69Magno225nxnD/w7Oy+827KItUwnv5SC3BnETZEl/kjdAGCwypjjxj5dDhWRxfnfJducytKYbu3IIBpEqUjTUiv+czUWlOOnEuMq70pe1InYrtcmBTICDBbJ700lO96Q2CHagZGT425OrhnLoWNrSG0Uu2QiC8HNgsL0R09sejmYGNANtbG+2nHz3tK5XYYhO6RN2TZ0vNPg799mz/mtwbQSbMbNlmxfbmotnfzxfCq9u/MCTG2uHLsGlAwELgqQKd/lX3yUZ7IewxmluT+Pi5E63dEWIA7HGTVU03B9q0AmrFXqAOND33zA0g+e6hjUob/3DFjEUkM0RoKqrp2/34KFXVlmTSLeyxAAaC30z5fZHwUtBk6jcs0q7+BmWa/jAGRQksofYi74H2/QWado+YXbMw7R63nc/cFX/oghMP/csWuidQR8tOSZElBTlyCXDAufess7zWUPxu0jD6EbYWUL2xBrG4mHt84KhCJN0/qRC7vhgd87K0zex81bxejjvdcv2j/TAIUe45ev/GmcX/fB4gRmxFb61SYQazLRK9Q6dcqRmrQvVYYzi9O5ysKbToZ5l2d97asOPppseAxtqsTndeS6dld7FqIu83Dj3c/SB0oJ5ceSYl5NDqDGyYIOhENZw/y3Hg410al8kGxb0hH8j7aWXYfO4dSiJkt213K7GUbYR5D+fJxSSkU7eL0B38uASqJIVfqHGuB1mor7DskOFcW+u7U24hIDtHOG2UIkjdZpwA+LnD/PeMNJDurEqITfUK3CBC5iHsICwxw0Z3ln0Pr3A11R5GLWn7V+UbgraPFf/CZAsxveBr9/Pu9+UK1RCw da4qqJW6 hVR/UUM2QsDbNSt7vP+pmKDIYX20ubOt8zWlBgy1TgbSUOw1EmzAKgsf+FwG6f6+H9zPD6a8EgKZM2BermDEaRN7GGhiiCtEJNOmps1U5RlS2p/t6l0o4C819/tOlVrAlvcXS4tTNn+p3QzSQvXZnlPfR3GK+HIM2XDTL7exTbO8xamFrd+4uAsT6xj2fshNY4GnLtdTYAOf9rIuyTkyau4IHdRLjOV+vnjypbNgwfA7+crqe1UUTVeZEpHWG45vijVtx9iFSRzPsZXu/LxXjZBAVP63fAt/edCf8MM2Yrh1SyEoIsl1rbuqFb9dkXhBPQu8Zg6CWqRI9MSQeVrHB+tD65X0e8tU7/lSRxsHoiafGhlPITH6BWtvqnlZwJRtejDMgPZZ6Syi/kd5XUAO3N6olmUB8/GbpwteDBlMmpFlTbbGlvZlQy97MYIRchRG+iD5VeXDWudSQ1FNFKOtwtQqV9yRyBj+Wx6pI+5Az0EJw5bUiPjmr2KE4O6HYZqUenwpRdrzYh1zoOZ2Hda368QlvrzxyqqaHySaKSl6W9OQPsyY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.425640, 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 zpdesc, convert get_zspage() to take zpdesc instead of page. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 19c1ca3957f2..a1a620192596 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -757,9 +757,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 zpdesc *zpdesc) { - struct zspage *zspage = (struct zspage *)page_private(page); + struct zspage *zspage = zpdesc->zspage; BUG_ON(zspage->magic != ZSPAGE_MAGIC); return zspage; @@ -767,7 +767,7 @@ static struct zspage *get_zspage(struct page *page) static struct page *get_next_page(struct page *page) { - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(page_zpdesc(page)); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -777,7 +777,7 @@ static struct page *get_next_page(struct page *page) static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) { - struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + struct zspage *zspage = get_zspage(zpdesc); if (unlikely(ZsHugePage(zspage))) return NULL; @@ -827,7 +827,7 @@ static inline bool obj_allocated(struct zpdesc *zpdesc, void *obj, unsigned long *phandle) { unsigned long handle; - struct zspage *zspage = get_zspage(zpdesc_page(zpdesc)); + struct zspage *zspage = get_zspage(zpdesc); if (unlikely(ZsHugePage(zspage))) { VM_BUG_ON_PAGE(!is_first_zpdesc(zpdesc), zpdesc_page(zpdesc)); @@ -1232,7 +1232,7 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle, read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); obj_to_location(obj, &zpdesc, &obj_idx); - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); /* * migration cannot move any zpages in this zspage. Here, class->lock @@ -1282,7 +1282,7 @@ void zs_unmap_object(struct zs_pool *pool, unsigned long handle) obj = handle_to_obj(handle); obj_to_location(obj, &zpdesc, &obj_idx); - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); class = zspage_class(pool, zspage); off = offset_in_page(class->size * obj_idx); @@ -1445,7 +1445,7 @@ static void obj_free(int class_size, unsigned long obj) obj_to_location(obj, &f_zpdesc, &f_objidx); f_offset = offset_in_page(class_size * f_objidx); - zspage = get_zspage(zpdesc_page(f_zpdesc)); + zspage = get_zspage(f_zpdesc); vaddr = kmap_local_zpdesc(f_zpdesc); link = (struct link_free *)(vaddr + f_offset); @@ -1479,7 +1479,7 @@ void zs_free(struct zs_pool *pool, unsigned long handle) read_lock(&pool->migrate_lock); obj = handle_to_obj(handle); obj_to_zpdesc(obj, &f_zpdesc); - zspage = get_zspage(zpdesc_page(f_zpdesc)); + zspage = get_zspage(f_zpdesc); class = zspage_class(pool, zspage); spin_lock(&class->lock); read_unlock(&pool->migrate_lock); @@ -1812,7 +1812,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, __SetPageZsmalloc(zpdesc_page(newzpdesc)); /* The page is locked, so this pointer must remain valid */ - zspage = get_zspage(zpdesc_page(zpdesc)); + zspage = get_zspage(zpdesc); pool = zspage->pool; /* From patchwork Mon Dec 16 15:04:47 2024 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: 13909894 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 675C9E7717F for ; Mon, 16 Dec 2024 15:06:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C9176B00AB; Mon, 16 Dec 2024 10:06:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 552A46B00AC; Mon, 16 Dec 2024 10:06:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E0856B00AD; Mon, 16 Dec 2024 10:06:02 -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 0C9A76B00AB for ; Mon, 16 Dec 2024 10:06:02 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7B50012102B for ; Mon, 16 Dec 2024 15:06:01 +0000 (UTC) X-FDA: 82901147070.29.2919A2B Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf29.hostedemail.com (Postfix) with ESMTP id D3D67120021 for ; Mon, 16 Dec 2024 15:05:17 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Lmev8qao; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361545; 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=Giyc6imQIJdJczErUr69pIQpgrMAMbU/kKt2HxXelDw=; b=ayly1IK4iqJpR7VYewyVR5SCcuWd3iMiqdtanHqDYc4BTSLonlmK2o5tunAlDf3dzeW9ub wzLY45yDTd1CUDSj70J06an/MMmNw0cMazQbdKq/Tfr5IYkUkiKDvxqArQm8WMMFQoTd0L WZDzGlwqCQZjhQ9MwSbIEMA+V4ahHpE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361545; a=rsa-sha256; cv=none; b=ycBCeCjieSLmPUTNuWkSSdrzcmONUdRkO6TY7jeuhzzrSYvLGeh+oZPIa4IRlhWKwkn8bq HsvkwZnOqmCtT8J0d0s7whcRkykaQ8sFq+YeXo4wT+/IOS9NG2W1eXh5U2JV6OpZpiJWZu L//fjrVCKE44kgEHQKPCdXLkBEVkom0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Lmev8qao; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-72909c459c4so2618984b3a.1 for ; Mon, 16 Dec 2024 07:05:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361558; x=1734966358; 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=Giyc6imQIJdJczErUr69pIQpgrMAMbU/kKt2HxXelDw=; b=Lmev8qaof5N8rXxH00WauvH6u1+VJH5ZJqVO1bPyiuetXr6kijT79zWS+W77iIy3Q1 tmqoGt6BQ7XEX9r0MFtPj0F7a4WKrZBy3z9iCHdh5SkfL6K6/BhC8LJmYal+tPwHEBUH yJ+970BVqXaKjW3NHuwRIjBTuS48pa4biNuHDwgFxwktlGN3e5p8TvNM+w/oM2ena6Zi lTz7tpfiZiPNzyI1mJwJ0BVzEIa36svDaOsSUFPjw9hWCkl2sVS3I4+gtPYn5WSFf1/d ygoRcB7SGA7JR3ft1FTKeY9/5rOfrzuE9oAENhhrxkBup+xfms+TGzPVwyBsJ2+TPUJZ 496A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361558; x=1734966358; 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=Giyc6imQIJdJczErUr69pIQpgrMAMbU/kKt2HxXelDw=; b=t+3S7yaxIFX4Cx0Ljur5CpIKj7Q5cz74z8tkDxKgfI1Qeyd1dnlgrwd34VO3g4RVZI La1ZV7zHloBB24P52KbNg0QLUemZFJB/m2zJFwHnBwZVgetyP8AK9ugRKMwZFN72ijLv rNWs78icb+WXiy4F7l0njfPGFspPn4oKhPohkerfvbRp8bN6+uB9++NIiwvd3OZFKf+y IVawe7+FWH2aXWEJgdEX5+yCbXm5R940H4QihEpc6kwQd5JEGcVv2ciMqyioYb3rHcEn Czl0N+RgpAlrm+SI2KM04sf45fQLjjnRrN/L/GZDU+xsS57xIjZA67MvZUag3gvowGH7 LHWg== X-Forwarded-Encrypted: i=1; AJvYcCXLTMebJMoYmgw2SfqwZ0ENFcOa1/ATI42zyFBIWwwZ8k8tDi9l/m8WWe+erk58opGVcT7cHRaSYg==@kvack.org X-Gm-Message-State: AOJu0Yz9gum5A2LDVFoTg0HS6QZTzb33qa2WNHfm0ydOfa64lltERDkm dk9CiKEtq+qaGsb52qyOSNRe5u5opYQTWwgigp+DC2+puymIjEYJ X-Gm-Gg: ASbGncu8Ae/iLkdWh8GOtlOs9VuVbDQSy965zfyuqWl1om8l1oKq3TNm3tTMCHt++A6 VCfs3//qYWRzwJZ9HhNGLryJg2ezYrhV1ujZBu4DE+yfEIaGrePjDkpr72z2WUQd4Ahr3TxZlFg NfEcpNgKBtAF7jEkghgg6SqQX6b/Vh93yzOptlpi95Fex0ipV47ea8610z65jXz85w6MBw+Vfpq 0mHTgaOS/ZvFcnQnVXl8o2pI8FVXO/W/ffNB+/KvGk9HEyJL7gWblarA8QxfxufvLE= X-Google-Smtp-Source: AGHT+IGv6hjUbxOOmjqtrAkaNIt0VwqljePea/Z4ZmFIAwKho+N/vYjdU4QRl3qGQbfx/Ng2EAXkNg== X-Received: by 2002:a05:6a00:6c8c:b0:728:b601:86ee with SMTP id d2e1a72fcca58-7290c24330fmr17274605b3a.16.1734361557657; Mon, 16 Dec 2024 07:05:57 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:05:57 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 16/18] mm/zsmalloc: convert SetZsPageMovable and remove unused funcs Date: Tue, 17 Dec 2024 00:04:47 +0900 Message-ID: <20241216150450.1228021-17-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Stat-Signature: supmmfcoic4dex6dkmysyroj4psxeofp X-Rspamd-Queue-Id: D3D67120021 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1734361517-610934 X-HE-Meta: U2FsdGVkX19W1V7zUYb8zy/VRpx9NDdHP7Znb8oeiShgn0S5KhgilTswhaS16aews8pPr7RLA3KA5t27egYFjOwrWC3+p0tTvqk2tJO2YEwcULYmvBFWWPyXSgZLk0XSYTSUB7X461Xljg5S70K+JiBAN2GXUdT7B3h8cbretD8EPf7xVrkoIpKTtooPtiDV0tene0HTWsculKPN/9zcpYT0cDGvX4SkolhUPJZDOI38UTTUwc0Gsrwmw5LEMNzFCyXqrhrE57y+lu/NAaOmEKFVNT1ya3PEGU4QVT0O8mkm24T7l5tWNw6+eKGKGNI9DGGbM+vOdGXyKdBL9q5z/Lxr0o5RhtL8mW5nSrkwooi0sMwqmSB20aFYMKyA7CL9kX73uyerrDPcmKEgf4MRYCBjPW3gUsDN1ytrpPqMk+GGW1pVphv512ASSzqCe8xm4a/PP54S1f1qiwkk75LYF2vH5Mco+EZ1jeS6VtG5Dn35v+dEQ2MG5r43MtHlcO5z3h+6INW0Dc2Fi4r+6jSM4GJ0JdcfdmB4KHpv+W3cONfM//dpZhu8LKpzte5RJ+wZ8rsvra2yN07suXozG2gmb/Ebu0FaErXCk5RSmbWzJYKK20nVx61e0iFdCq833tzoXMsz0lFOgVEkH+V2ORqfh4hzEM5cmpIPlj3yDP2wXg0fJGKG9+DQrhY2C4ajggcUZwW3LxtrEyFDVZ/ZjZJjFC+rVa70udiRPL7fzbac+KNQzKxrfADQ1YHQ1N0zQi8AqGzYWcuck3y6Z5G/SUw6Rpf6oBVH7Ngm3txJtox8RSfVXl1M2PURRMvUPYIueXOOpcOpeI2SfCccHlfmbkPdGUTtUM8n7/5VbOaxXA3TzmLZsJE7ngURvjlm0lose/1KYZoEtbRiBvLQy/jXbwRuzvIYhRkasKEviiRFbUW2uGNIWv3w21EExYLyMUrxPfltJ7YL2L/sEOQWSLualto L/UGXAQY yelr+Cu39xHTy7caPhq67GLPGSfteRW6HJFsfQqkg8GVVVezFWEyhLIGfPp0JJp8f6m8jbY/zYmg7rQ+LLKI3Ag7OcL6QJrK4/g255GUHgSYjsHnoIN8vEajUM4h0kgHaI+3/PMgah5QGbNvTCGYpFfIoWekRyvbQUVFTAw/gd5YWPSvY8BKSXr3ChOLW76Ze2i+vRqRtC9eccN8rvDBuQETuBg9jIu+/6TOZlped+CqBVSjubxaHqDB3hWHE79As9mCa+rD6YoVtZZRY4bQ0y48baURfTKAG0uhoYkHnX/t6bOW6Ce7hxYoqyZ9YQeHkX9RAxi7cX82twIAcv6IsRfQXvfSUoMXb4KyLnpUgZU2/URc6HHGjer9IbFQT7F0gKRYeHkKIa9tUXLYR6jJr9B0as6LU1QRG/IyUs92AuNGLbiVd4BQOyvG3p8TC7OPiLjIvbmLZYX2b+mx3hBrK9fhKnfliOtyDHQ/wePBh0LTOaJchJbxKmvWCEQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.363543, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi Convert SetZsPageMovable() to use zpdesc, and then remove unused funcs: get_next_page()/get_first_page()/is_first_page(). Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index a1a620192596..1801dce2f7ca 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -452,11 +452,6 @@ 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 inline bool is_first_zpdesc(struct zpdesc *zpdesc) { return PagePrivate(zpdesc_page(zpdesc)); @@ -473,14 +468,6 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) zspage->inuse += val; } -static inline struct page *get_first_page(struct zspage *zspage) -{ - struct page *first_page = zpdesc_page(zspage->first_zpdesc); - - VM_BUG_ON_PAGE(!is_first_page(first_page), first_page); - return first_page; -} - static struct zpdesc *get_first_zpdesc(struct zspage *zspage) { struct zpdesc *first_zpdesc = zspage->first_zpdesc; @@ -765,16 +752,6 @@ static struct zspage *get_zspage(struct zpdesc *zpdesc) return zspage; } -static struct page *get_next_page(struct page *page) -{ - struct zspage *zspage = get_zspage(page_zpdesc(page)); - - if (unlikely(ZsHugePage(zspage))) - return NULL; - - return (struct page *)page->index; -} - static struct zpdesc *get_next_zpdesc(struct zpdesc *zpdesc) { struct zspage *zspage = get_zspage(zpdesc); @@ -1936,13 +1913,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 zpdesc *zpdesc = get_first_zpdesc(zspage); do { - WARN_ON(!trylock_page(page)); - __SetPageMovable(page, &zsmalloc_mops); - unlock_page(page); - } while ((page = get_next_page(page)) != NULL); + WARN_ON(!zpdesc_trylock(zpdesc)); + __zpdesc_set_movable(zpdesc, &zsmalloc_mops); + zpdesc_unlock(zpdesc); + } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); } #else static inline void zs_flush_migration(struct zs_pool *pool) { } From patchwork Mon Dec 16 15:04:48 2024 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: 13909895 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 70F1CE7717F for ; Mon, 16 Dec 2024 15:06:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B48A46B00AC; Mon, 16 Dec 2024 10:06:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ACFF86B00AD; Mon, 16 Dec 2024 10:06:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 922366B00AE; Mon, 16 Dec 2024 10:06:05 -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 33F606B00AC for ; Mon, 16 Dec 2024 10:06:05 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 75AB2C1112 for ; Mon, 16 Dec 2024 15:06:04 +0000 (UTC) X-FDA: 82901146902.04.40779AE Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 63DEB180025 for ; Mon, 16 Dec 2024 15:05:58 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="FOrBjm/R"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361534; a=rsa-sha256; cv=none; b=USKE1gg+lVqH2AgoWfIJQHRdOjRXPlclYXVNGOIUt78kruVrH6oLk626oeXgdeBT4PrJcW sk814rnTvCceZTw3c7ZYGU0474sBHujer0uyzN3n+osxG2/jAC2lLWM79JgXw45Q97yna9 cB4cEYvvEGDeuVh05aHPlX2qg6ExI3k= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="FOrBjm/R"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734361534; 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=WCbi/wYFFDEPej3gFSRK5hQu4Ni2dUdadNrYg20RN10=; b=60oRLdm/fdfEfSSW4OVaXj2omM3xMFShNGjm/9EHtv1XYtsvU17rSlCb4K4gZCtWv8N+HU mROxEYXwtkqn7yieCdoOOSseyiR0XKF/NwgAEFNVlu7ZCVDFM6HC0B1xDy9STXamyi460T 8N5G+F5OpULj88Y0iULPvFyIedxILPo= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-72909c459c4so2619011b3a.1 for ; Mon, 16 Dec 2024 07:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361561; x=1734966361; 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=WCbi/wYFFDEPej3gFSRK5hQu4Ni2dUdadNrYg20RN10=; b=FOrBjm/R6F1CpFqcjGYf7GrUQMXgBbVp0j4xxpafcpeRVLZCyo9lwuMOMyfn/X4zWN vPHG9P3hgkcZI7GbgtmrWV8mz7LSvHeKVeEaCU0xcY7gQv/HuHNHJw92a31CnITmgvMZ BCyBZ5yj18t7qz3G6z016L/Er3nAf3ymDbZvtvOEK+Wp8AeLXupakeH1yNztIO5eOG68 HToI6eR8729/6LeLJjRYyODG8Ubqwm0W0ZsZpQ57MVdUJQhkfgfXLNjikjRXOlRRR95U W+DK6lPoxCc6v7dOt2DU4ZKKkm9oMwrMyvEJ9sPJ4nes+53d8MP1D1yFUiyTsR5xfONH Lglw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361561; x=1734966361; 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=WCbi/wYFFDEPej3gFSRK5hQu4Ni2dUdadNrYg20RN10=; b=h7IJyMJK/SQuEdFU39EfuDXf/qv8I7XT6zgv5dujx2ZNVuzXMZTjARqoM7oKLhBZ05 8OKX+EdX/LESER5npu+4R9PLL5mfnIH+mS0VOKJxSb8EU0QBh+y6h9GApbmRJYZ/7NS5 gFGghET0z5LW46BC/zSErxBFGEESQfpG98jIlWopATNMVutNW/6lSsq8o9Gd8iMwQwPh WwgBEntXwLyVknh0T1q/bxuaMftHLtdApihcmcUwY97ozDK5lMrqCOJR+99Ed60v+NV9 4DGYuPQ9xxnxiT/AVleXw2S07e9vpiJAR7Awoj8nYE2d+e0GG7gK9crWBOJKP8zh5Oiu SJzQ== X-Forwarded-Encrypted: i=1; AJvYcCWJIP0fdYpuTJmxMwFMFM2XJO+V4wmFNXMVORAI0SVcAByGm80a2j0HtJSdBSwX12rys9de5kOgGQ==@kvack.org X-Gm-Message-State: AOJu0YyioqNZMFI2kKru3CtMM/ztc4iQhqrK67rMucs0afF3sS8xBETn sO/vcPgjei2sDpz00vv+nnQGdD+n9l/Zadxs2WH5FDtzzMgFOUjS X-Gm-Gg: ASbGnctBQakabPSQ6sviPuYNtoVHZBCpyeqt78FKW8/qL7xJrKOc81MouyQcDm3qYkA Y43yeo56RH0xWyPvIURj8qEl3fYalgZ9Pg3r7nPzG/u0hsLYhzs/X75GPZt70f+l2AcK0qRT3yn yohVcyHEWMBlZcb6vGm1bvlaTqcCtLKpPvKwEt5hyn4vHoPQJ9t5kQrGExexh09FICqWl/DZm22 HUoxwTHIVEbXC+P/Iu1HusiweXC+7QxITtUCLQGW7qI5dvnBBYt4lsBbqYuffcWqsY= X-Google-Smtp-Source: AGHT+IH/s+RFXtaht2G5asEek3t03T8vImc3qM4E+LL2aV0R9WqYL6WbCP8vNnNKFmkQJ8P11BD0dA== X-Received: by 2002:a05:6a20:734b:b0:1e1:aab8:3887 with SMTP id adf61e73a8af0-1e1dfe3f1f4mr21870385637.39.1734361560739; Mon, 16 Dec 2024 07:06:00 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.05.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:06:00 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 17/18] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Date: Tue, 17 Dec 2024 00:04:48 +0900 Message-ID: <20241216150450.1228021-18-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 63DEB180025 X-Stat-Signature: q54o7r385xbdjz7ydciqppqsexqaa5d9 X-Rspam-User: X-HE-Tag: 1734361558-695231 X-HE-Meta: U2FsdGVkX1/HeKPTeUkHcyZpWwbsI4ZaPgxoIdspyVoN062rI0UtqC20oIuvAknTf/I2M4H9t4uLR3XNooY9TPi8cHXi/n58ou6SVw0dgQUcFy8SibAlrLHByT/6qJbuidWb+3/Wq2vxF8EnCIxzXosk5el2VHIg9Hg/zWi9eEHGlTT64tVF88B6bXVw6UAGXDqWDjCNzprMeeyEXUArzQRJhmitHKjN9obJQ34HWye6ZbXSLcuJaDYXbF51X1VE0sA/tO0vbQFIjNLCMAuSv32uB63h/nSbKtwjWnlgR277OpBipPwJKuB6HL42exXMwjvalCkkQsyhYfC9a/4zxAxuKKaM7ECVJ3XxmE096tVOaFq1ru8ajIYbZSi/HpFc7oFcsY5rfbWiec/YCSx8yFLoVRQFnIaDsC0sR869V4XdyxWtLO5+0Whbl9diQ2xCvzohfToyCI9pbd+f6IlKH9GnH3TP9x671ZGk0SI+1kTESzGeCT1GcfgzyhT2gpObErbLSacEFsPdF707iJPlqQKNmQrm2/s2g2SCRLSsuSR8cbmZ+GvDUSk/BR7U1pHabeE3ilsKiX7g9fqPFjBy3ypLC7Y8UlnNHIdfB56ZY02CHHvYrXkmspNvhlhMk0cECaPStoA6E4yes3M7OrlZIzS73ywTvkxyB1BdK78tBS+NF5MNHIZkFfP//hmfv0VzQUzbVU5Xrww7yieVYGqKIVr/ImwA6zEeQgoH+9W5XPikK2h/rdp2VmjQXlUKOfH971ySoEPGfs1ZBk3CacBlOUTAEG82Ko2mwYJTK5qeJPZ7y879SwjJO6jnOZRPrkPz/0D0A1jPmXmuDG6Er9NdRb9q93pbkDGn7zzGxt/L/yiBSFJ8GDHAxBWEmmXKF5X52iDJoe+XNdfF4CEMKkQtXOw1PAk2I6sbTRjLyxABEebTlCx2ByzxbpDHEvUDLEyt3yA8d+IPtk9bidjsJ6c Fi/rNtJx i6UEbS3lB2K3H/FBTIuRXl38rUFZYU0gD5luaN4wgLn+Y3p2Q5xQvnH7HfSP/6PatrgNCTphGXJ+pAtQFaFovChLc5DP43/l2zhIAuHhCgosEgWtcilTvBcfPYYCoxTO8IzpUZp7wXUbxC+7frXjr80iO1+zE51IEJTfnSVOs4R9gJN6weimBeiNOa5af4RXvtyUDolc71nmDovkpl3ziYNtGh0M9tzlwBEl77FKTE6S8K7aTXAL1Wf9QVkBQicv5fZUmyO3BKw0E1rLRft2wAgcfDqKD+zplRRfGN+yPLYh0w1wl/zET2l2/3Q+dV+IywJnazNj5S8rHY1XIpSALc/Xa90LpnMqyaurYvhdyRdqjYJAi30wYLd1pY3OIv+zstA0z4iXjFvCBk5g8TjLoF3U2DENOLRct/K7u9RyTsfve5UNXy8kbNgRdFVcX9j/D3SfeGTm4M07F9Y6cfErwa58JcaMfMB2W30SvX9YEgcvJFb9iIZK0ifLuIetXNX51WZhgeCUd48ZkQ0dDCqSAPs23NC1NWTftqhROPRAIBZmle+g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.163894, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi Now that all users of get/set_first_obj_offset() are converted to use zpdesc, convert them to take zpdesc. Signed-off-by: Alex Shi 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 1801dce2f7ca..3a841e16746e 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -478,20 +478,20 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage) #define FIRST_OBJ_PAGE_TYPE_MASK 0xffffff -static inline unsigned int get_first_obj_offset(struct page *page) +static inline unsigned int get_first_obj_offset(struct zpdesc *zpdesc) { - VM_WARN_ON_ONCE(!PageZsmalloc(page)); - return page->page_type & FIRST_OBJ_PAGE_TYPE_MASK; + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); + return zpdesc->first_obj_offset & FIRST_OBJ_PAGE_TYPE_MASK; } -static inline void set_first_obj_offset(struct page *page, unsigned int offset) +static inline void set_first_obj_offset(struct zpdesc *zpdesc, unsigned int offset) { /* With 24 bits available, we can support offsets into 16 MiB pages. */ BUILD_BUG_ON(PAGE_SIZE > SZ_16M); - VM_WARN_ON_ONCE(!PageZsmalloc(page)); + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); VM_WARN_ON_ONCE(offset & ~FIRST_OBJ_PAGE_TYPE_MASK); - page->page_type &= ~FIRST_OBJ_PAGE_TYPE_MASK; - page->page_type |= offset & FIRST_OBJ_PAGE_TYPE_MASK; + zpdesc->first_obj_offset &= ~FIRST_OBJ_PAGE_TYPE_MASK; + zpdesc->first_obj_offset |= offset & FIRST_OBJ_PAGE_TYPE_MASK; } static inline unsigned int get_freeobj(struct zspage *zspage) @@ -911,7 +911,7 @@ static void init_zspage(struct size_class *class, struct zspage *zspage) struct link_free *link; void *vaddr; - set_first_obj_offset(zpdesc_page(zpdesc), off); + set_first_obj_offset(zpdesc, off); vaddr = kmap_local_zpdesc(zpdesc); link = (struct link_free *)vaddr + off / sizeof(*link); @@ -1555,7 +1555,7 @@ static unsigned long find_alloced_obj(struct size_class *class, unsigned long handle = 0; void *addr = kmap_local_zpdesc(zpdesc); - offset = get_first_obj_offset(zpdesc_page(zpdesc)); + offset = get_first_obj_offset(zpdesc); offset += class->size * index; while (offset < PAGE_SIZE) { @@ -1750,8 +1750,8 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, } while ((zpdesc = get_next_zpdesc(zpdesc)) != NULL); create_page_chain(class, zspage, zpdescs); - first_obj_offset = get_first_obj_offset(zpdesc_page(oldzpdesc)); - set_first_obj_offset(zpdesc_page(newzpdesc), first_obj_offset); + first_obj_offset = get_first_obj_offset(oldzpdesc); + set_first_obj_offset(newzpdesc, first_obj_offset); if (unlikely(ZsHugePage(zspage))) newzpdesc->handle = oldzpdesc->handle; __zpdesc_set_movable(newzpdesc, &zsmalloc_mops); @@ -1806,7 +1806,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(zpdesc_page(zpdesc)); + offset = get_first_obj_offset(zpdesc); s_addr = kmap_local_zpdesc(zpdesc); /* From patchwork Mon Dec 16 15:04:49 2024 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: 13909896 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 6B770E7717F for ; Mon, 16 Dec 2024 15:06:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94E536B00AE; Mon, 16 Dec 2024 10:06:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D9056B00B0; Mon, 16 Dec 2024 10:06:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6FF6B6B00AF; Mon, 16 Dec 2024 10:06:08 -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 4D9B36B00AD for ; Mon, 16 Dec 2024 10:06:08 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C01E2AF93D for ; Mon, 16 Dec 2024 15:06:07 +0000 (UTC) X-FDA: 82901146734.22.868F8C9 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf19.hostedemail.com (Postfix) with ESMTP id 6B3DB1A0031 for ; Mon, 16 Dec 2024 15:05:34 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WxAd3zvx; spf=pass (imf19.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=1734361545; 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=SDy/4l6WZCYHIxqVeHu4DE3K2dZLBweVBJks1R6lg/Y=; b=jefMbT5DPyX7equ/j/+o9ju1lekaPkJiB+0ADMEwaINmFJBAKeTiHQluiZI5Ug3Y030fd9 BJB3YV5aLIHy0OiCsLkA73gWkygrx4t+ZAbSEqKyRflooOhHKGUvG1htKXf5Y6xR4bGxNV Gm5SljN6iQRkqbSjSWkZZnVygNeqkjw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=WxAd3zvx; spf=pass (imf19.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734361545; a=rsa-sha256; cv=none; b=N0c5U9cWSymfR0JOP5QiBwVyhMritTAVzAZhc2y7hTo+6bU5pg3wYymA+/W2AEaoeSElXv TAjnnUHrPp4DCpKKAiGQUiy60FkaBysQO95b0TNpP3jua65G+cUzyaTgjNvm+hzV34ht3H v5C4F2FIH+BoJ2djk8N+17kWcisZwuY= Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-725ecc42d43so3603583b3a.3 for ; Mon, 16 Dec 2024 07:06:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734361564; x=1734966364; 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=SDy/4l6WZCYHIxqVeHu4DE3K2dZLBweVBJks1R6lg/Y=; b=WxAd3zvxmx9SOQbX8vfPuZHaAqyPk/P1VtgyxL4OXQ28+WkkYq4UBng1CLj0V/t4iv dvNz6lN4I6fNzCbASFVi1Q4JiAWfRNNgVIaJq3Ylm0g9wuXRmU4JfDZTUgkgfjDyTCRm osPjZ3KgGHY7rE0O54nbCg69Hbohpk8l2eY895aUvJvVfUqYjdQ1tdDYKNjsvLW7SiOY nwiztazgAZTG6OKM22V7rHbY7Q7YDO25/rKxndtIYohtfJ0m9ARhJSFUpj/xijLTC102 rL0PTJ1DbPQJinklP1x4309hlWAcDdTJv7bnrc4NDipIw53ppjieHhQHXv6EZ3m/9GGK m8SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734361564; x=1734966364; 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=SDy/4l6WZCYHIxqVeHu4DE3K2dZLBweVBJks1R6lg/Y=; b=INf0EtVD8ESZA7lx75T0V8S5Xs6+go7WCwUuEisSjxkQ/kH3XNoWcjOBHmCmpr/tyB iUI4NQbcnvgDUcei65XMvZfnOVcV3gRj00k3hciAFfZwZ2QqKy/Osadv0rxHWqsQcH2J 8tVx/saZvKXtr8Sy/GHJfwVYf2R2OzyrdX2AIf/vUvxvufZw6IHWJwrGWwFJdJ8ic/Er SaPtnHOPlS8xvSKTeOpRksn7GSssh76GsbJOO1nL7gC9mwn8cXfEaBi0r92Aq6a/zYiu hbHsHVpeagQde2HAxXG/VCs1tQO8NqYHTx7xGFoVWMYKlkaVHf66BE5VcmOHqHsLhgLM c5qA== X-Forwarded-Encrypted: i=1; AJvYcCXePGNLBvTREqPLmjhHa8FHfqCqFrEfAAtm+ZJHffsa4RdvfkKT5R6s3Bu1sUIHh1gZbGkZZCFKfw==@kvack.org X-Gm-Message-State: AOJu0YzCvuEXxiOYAEDwTuKTRdyuZQzt0ABcug5kWB23th9k0wfgM4Df fCMzdGzBxe9V4W1inY1fyU7QLggiCdh7R9PpbrCqsIQUHyjSz5xN X-Gm-Gg: ASbGncsRpfWGKRsGvUFO2K3O/5x+0YEraMkBIJvLRqggGSYeh1yiQjEFk6GlqGhevMz wWM/tEOTFEnP+24Z/Sumwbz5Exw2kmcryzheztf/4hG767yBlS3fyVJbiKdFOaVbaNQI7lBQVxO ii1R6iSwQL5E9dqYFGebPSdpFJiMwPla24IjVtYvT/3z4m1roNtf1/xHHQ/ePIXcvmtWdOY+w7b KOdeYKuKAvCvRXLc83luEqx7qj/9qUv+WNeysF9YzCKFT+L0fXKuMyT39BmUuOLKCU= X-Google-Smtp-Source: AGHT+IEdw/+Pzemx7XxtqLq06AKTuoV9ilZgKIIM2PTneeVOEZXsB3cNcGgHmuKkrU6W4FdJM3qWng== X-Received: by 2002:aa7:888a:0:b0:727:3c37:d5fb with SMTP id d2e1a72fcca58-7290c248b32mr18630427b3a.16.1734361563802; Mon, 16 Dec 2024 07:06:03 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918ad5ccdsm4845518b3a.74.2024.12.16.07.06.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 07:06:03 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Andrew Morton , linux-mm@kvack.org, Matthew Wilcox , Vishal Moola , Alex Shi , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Alex Shi Subject: [PATCH v9 mm-unstable 18/18] mm/zsmalloc: introduce __zpdesc_clear/set_zsmalloc() Date: Tue, 17 Dec 2024 00:04:49 +0900 Message-ID: <20241216150450.1228021-19-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241216150450.1228021-1-42.hyeyoo@gmail.com> References: <20241216150450.1228021-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: g5kirn6jy5kabwsmiea9ucc7n8qc1fmb X-Rspamd-Queue-Id: 6B3DB1A0031 X-Rspam-User: X-HE-Tag: 1734361534-710854 X-HE-Meta: U2FsdGVkX18LT1koUSX6pDGAqZ/jmWVaJ0JkgDbKY2YkQB2QooP/s0j5TMUJrSbLEOhMOJqYvGWLIdlteVYSdy7NmoAB/FS6ra7mUmWQNv+Ohtk/pRM0YrazSxWwu1HAliQa6oE4lyqU0bxsRzP/TXMyZAtNnskJtHRnI1nkXNBeBJtZhA1KfbItUpEx8oNrxT88b1udpWkxtGcxxyuOXiAnknTW7mPr1++O5+sBHjVaz5NFzK4qfWH904aDmPfH6OC/4+i/JHd7I20yO3UFlhncJ6J+jT77u2ScRA2a2JsSfqUz0mP6wjv1SDCe97wgv5ROacGxspb7bthg0AtRtFILLP+PxaM3kcH/g6KSy3Np/BtQExwIE31RsLVkKEddvZBhnrcuW9VUVbnMKWMrQ0EKIBlLxgMAzwn2zg8u5oyNWx1eXDAnEXqaE4AjVyUHTSY2FVvlKyRD78HKmSO4za2kRgw2uGQ6Qk+xI4sfGflqQZBhMJgQ0k7yLmatQW7tGPLfs+UUKCbUpz/n4gBFsVPsahPG0teFIt/teWbAlAFJ4qXuI+G4SVPzZ0CzXVpZNECaJwWmdt7fKg74CLMlzUwcWxR0dRPPBZzOW/+KQuFRg1EPaMo9Ab2wOnstTmgagVDVhaZ0RvZHJxta3jA9scrcsAp0QVFs/OAOdoEDaUtb+gV6WbP2zn3+HURThPT3QO7JXNFiO6PHBga2wOvpRfiuU5ehdSTh2AgJTIl7HT/havvXM35v3MwkX9r8H7OWfnwfAM80KlWCdz9+B1ClhGthXFeQy6G4u2rRpWZJqOBEYZpAPgO/NT9jJAhTnvnvQDRjgNKOuyMMBpBTpd7zUdtUmPJVxr8tjIzk7a0Fuu0p2T8BHYAGXNyadNXBPZi/dqYHRRnruMeckyrAGK5t0O6HlrFKoNaxDzrxfCN+RyfxQAVtY+E+TSHU5A8wEMuUTEVwVKbQxN0IKEGH1o0 aaxXpdNk wl6siS5dEIjoENHIZ4dvrQLWuiSf+OAXcGvm5xQ3fKrCcN7zkspa5J2/PFOkVPhZQzviJy4wRJmE+VIS7OZquz7sReBY1FZ8iGansq7qpJhE8bmdWMmrDI5zhUTrZ4/jukhZrTUVXAlfU7fY81FMW3JonGba3s3z2DlcjluCRdCZsML3d4B4Iu7ZsotOhNXk4bUzuTNSy0lbvwOdEibpeTn60S/H8k79pxDaqd+khkA6Urn1YoUVPJf8pooMqfTiPbdrwbudGT5wdADRfkEfPihhDIML1I+VPLJrAmVp98mtbDEBW55EXZpd87E2D9bij1m/tyzn5+++XvkamZ1MR2t50LoMBDJn4JNYSB/BPk8W+k2tWwaHDNQx5TxnPOUvHflhiH+qa9DbNQ81LsDzzf6J1fIsxgY6SVl3NWtUDGMkXWzB8gV2dziQ+JL2gh4HQwI8gP4EE/pIVCE5w4ER6hLkNpKCfXD7PrZMEzIzMpR/fmj/v7AzhZSgAAKJKplYBG8gXIKdk9WRu03vWjeSO6ImS7GNVP+2DwgEw8nT8bd50+1k= X-Bogosity: Unsure, tests=bogofilter, spamicity=0.491619, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alex Shi Add helper __zpdesc_clear_zsmalloc() for __ClearPageZsmalloc(), __zpdesc_set_zsmalloc() for __SetPageZsmalloc(), and use them in callers. [42.hyeyoo: keep reset_zpdesc() to use struct page] Signed-off-by: Alex Shi Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zpdesc.h | 10 ++++++++++ mm/zsmalloc.c | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/zpdesc.h b/mm/zpdesc.h index fa80c50993c6..2da58339ac5b 100644 --- a/mm/zpdesc.h +++ b/mm/zpdesc.h @@ -155,6 +155,16 @@ static inline void __zpdesc_set_movable(struct zpdesc *zpdesc, __SetPageMovable(zpdesc_page(zpdesc), mops); } +static inline void __zpdesc_set_zsmalloc(struct zpdesc *zpdesc) +{ + __SetPageZsmalloc(zpdesc_page(zpdesc)); +} + +static inline void __zpdesc_clear_zsmalloc(struct zpdesc *zpdesc) +{ + __ClearPageZsmalloc(zpdesc_page(zpdesc)); +} + static inline bool zpdesc_is_isolated(struct zpdesc *zpdesc) { return PageIsolated(zpdesc_page(zpdesc)); diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3a841e16746e..dae32e051779 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1001,13 +1001,13 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, if (!zpdesc) { while (--i >= 0) { zpdesc_dec_zone_page_state(zpdescs[i]); - __ClearPageZsmalloc(zpdesc_page(zpdescs[i])); + __zpdesc_clear_zsmalloc(zpdescs[i]); free_zpdesc(zpdescs[i]); } cache_free_zspage(pool, zspage); return NULL; } - __SetPageZsmalloc(zpdesc_page(zpdesc)); + __zpdesc_set_zsmalloc(zpdesc); zpdesc_inc_zone_page_state(zpdesc); zpdescs[i] = zpdesc; @@ -1786,7 +1786,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, VM_BUG_ON_PAGE(!zpdesc_is_isolated(zpdesc), zpdesc_page(zpdesc)); /* We're committed, tell the world that this is a Zsmalloc page. */ - __SetPageZsmalloc(zpdesc_page(newzpdesc)); + __zpdesc_set_zsmalloc(newzpdesc); /* The page is locked, so this pointer must remain valid */ zspage = get_zspage(zpdesc);