From patchwork Mon Feb 20 13:22:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13146438 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 CC89BC677F1 for ; Mon, 20 Feb 2023 13:23:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 650676B0082; Mon, 20 Feb 2023 08:23:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6013E6B0083; Mon, 20 Feb 2023 08:23:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47A3D6B0085; Mon, 20 Feb 2023 08:23:04 -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 350586B0082 for ; Mon, 20 Feb 2023 08:23:04 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 119781602B4 for ; Mon, 20 Feb 2023 13:23:04 +0000 (UTC) X-FDA: 80487735888.05.FFBE299 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf20.hostedemail.com (Postfix) with ESMTP id 13C7B1C0012 for ; Mon, 20 Feb 2023 13:23:01 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lORX6IoC; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.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=1676899382; 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=3RJDtWutWGogP0/7qEs8fcsETlU2jUWF08HBLcLJ7gQ=; b=Kwo81bJoUuWUafancpRmCdOK5bwHu11v5FPosr1vv8N2HFfiwN6DvAffzWDCdc33fkkk+5 FYmEjSbSrVpquqBTM86NfS1Ac0mn+ix/lycJmA0l+n4xxvcLr8v0HpeVUZuIKAuWtvtyHR l+6td3ww+SdRY7x5cuzYUuhlrJsD3Fk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=lORX6IoC; spf=pass (imf20.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.214.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=1676899382; a=rsa-sha256; cv=none; b=UEllnd0lwyfNUFdU/9Qbk6PwxBJ0eoaU4stqZkJSxNQHhRtAUHGXY+Id1pV+joyNSaW9SL uwb0ZBfrc0oGDwXr/rjYWXyydhmZADzz8skOVmz6K75XZjWWmI5RmPf5vSBZCbk/7yMamj 6LYg1gk/0miIcEijDUWsPUe630pLmZk= Received: by mail-pl1-f173.google.com with SMTP id ko13so1974170plb.13 for ; Mon, 20 Feb 2023 05:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=3RJDtWutWGogP0/7qEs8fcsETlU2jUWF08HBLcLJ7gQ=; b=lORX6IoCM3PB5Az4NBW+udpMDI6V3OLgqBSAbrUnBMP3LiDZ/1kHDYV6mminU8d6yM JkSQ+gFwTcE2fZp4ivrq5gjbZijq7o+qm+n3D6tYuRkm8un7pMrhjBEY1yy0mQZufS9t NsMvSZ4elhdgplLrSFlFVr9UXL0UK715ydao+odimrSQ5xMvZPOmLBiqk30iPM5Anojk TsBYYRn24v9RMtK8o7o5h6ySY4r7fAoG9Gk28ecRmcWvY0/+VkhQn6/Gjr4AvKn0Q12N FBxn9vg9H9ZdunHRoXwKvOuccRwb9NxDkRGd2ST8bmri/jNpvWp6eMFQ2eiew8SKiiyv P7aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3RJDtWutWGogP0/7qEs8fcsETlU2jUWF08HBLcLJ7gQ=; b=WSnfzXVvkQmmj+ZIGMfM2ntrXV0ohxkxiTS3zcp51jCIJJLNW+m3OyEQ6ZN+gdmg3N QW7vXwAiQtXzYYSCY7UwUp2Nutf3LXoOSPrG6vl6zfhdFPCcc1xt+BFGB3B1xPCuezgJ 5VAsNEhKeryWjNe03DmHOfrO4XWpb21/PsE6DnaaDGvFxJyYPXfw7uB9wIvPq5T/Pe9q mqdgh4M4P6IiAt/S5S2WfOaods2e5AnHzzz7bVhuh3+ZEYjvoYH23ZfZeD0Itt5x1OCs px/UQP0lzUccMMFusYLEMk2bvEDNlkiMkVWLZA9lEdYbSafyX8wesvbhhZrHoWXRSrcx 8wGg== X-Gm-Message-State: AO0yUKV1+J3hrQcFaXu5merdbbVsDoip/qVEdnJEgv/BdLllMLWT4iWE uYji4qwJYLhg4eJiCp/PLmw= X-Google-Smtp-Source: AK7set/2aKvQ5D4xiB6CLXNU7eah3aEC4doXJh4aSOvsCsJ/l2tQLy/HmNh6KCEWM0Q61QunR8TGdA== X-Received: by 2002:a17:903:41cd:b0:19a:a9d8:e47f with SMTP id u13-20020a17090341cd00b0019aa9d8e47fmr3580367ple.36.1676899380903; Mon, 20 Feb 2023 05:23:00 -0800 (PST) Received: from test-ha.kr-central-1.c.kakaoi.io ([210.109.63.229]) by smtp.gmail.com with ESMTPSA id x2-20020a170902fe8200b0019c13d032d8sm6125436plm.253.2023.02.20.05.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 05:23:00 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky , Matthew Wilcox Cc: Andrew Morton , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH 10/25] mm/zsmalloc: convert obj_tagged() and related helpers to use zsdesc Date: Mon, 20 Feb 2023 13:22:03 +0000 Message-Id: <20230220132218.546369-11-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230220132218.546369-1-42.hyeyoo@gmail.com> References: <20230220132218.546369-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 13C7B1C0012 X-Stat-Signature: 3aq96qzik7bgw1souocmcu37u8q7y83z X-Rspam-User: X-HE-Tag: 1676899381-943476 X-HE-Meta: U2FsdGVkX19KRoP4Vs/Ffcv46ZHfLoyVq69PgkVTMMntr3PjEzpdk3WaKWKPZSpn9jrCbB9c0F4HFnnPAzbBW0G+f515uY8N1QfbH0IWubn864EjHFh6tWgTmLGYAP4TcluBCIkdxbbyQgG2GEBfaHAekki7e9vJaWGYn+zQjbMS5dUwVem4IeHTaxcuqnDP84TZH/luxw/Mn9aFpU0wnxF768usQ+6s9wgkYBWuvT57MWyptxmLufkMlrvRPFX0aO61GIRztqHujyIDdAbDZHMBnwBamG0UWv8TSPQjj++cW2IlS7gB7D/fQVaGTXo/Y/BGHa+6fEJW3dH+yrr5UOvVhT98ebxD6x1Co990i+t6LbA6SqPfGBO8Qp8GG2EBPTb3SCOk296VP5Q/2Y8me2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X9jWWQNJYhasXhTNKTFiJwKhwICd9u9iiaTt35Q1btejhJedpOAvxtjsSEs8Jh9Vk5siqDwjqLRIQwWhyqwRloj/xQovO0kuNfZ8MOyL4Zvm6TZfCYyBzqpnVhVHLIS7elF+vIA9k3YQw2h4nCM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert obj_tagged(), and related helpers to take zsdesc. Also make its callers to cast (struct page *) to (struct zsdesc *) when calling them. The users will be converted gradually as there are many. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index c65bdce987e9..e1262c0a5ad4 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1047,15 +1047,15 @@ static unsigned long handle_to_obj(unsigned long handle) return *(unsigned long *)handle; } -static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle, +static bool obj_tagged(struct zsdesc *zsdesc, void *obj, unsigned long *phandle, int tag) { unsigned long handle; - struct zspage *zspage = get_zspage(page); + struct zspage *zspage = get_zspage(zsdesc_page(zsdesc)); if (unlikely(ZsHugePage(zspage))) { - VM_BUG_ON_PAGE(!is_first_page(page), page); - handle = page->index; + VM_BUG_ON_PAGE(!is_first_zsdesc(zsdesc), zsdesc_page(zsdesc)); + handle = zsdesc->handle; } else handle = *(unsigned long *)obj; @@ -1067,16 +1067,16 @@ static bool obj_tagged(struct page *page, void *obj, unsigned long *phandle, return true; } -static inline bool obj_allocated(struct page *page, void *obj, unsigned long *phandle) +static inline bool obj_allocated(struct zsdesc *zsdesc, void *obj, unsigned long *phandle) { - return obj_tagged(page, obj, phandle, OBJ_ALLOCATED_TAG); + return obj_tagged(zsdesc, obj, phandle, OBJ_ALLOCATED_TAG); } #ifdef CONFIG_ZPOOL -static bool obj_stores_deferred_handle(struct page *page, void *obj, +static bool obj_stores_deferred_handle(struct zsdesc *zsdesc, void *obj, unsigned long *phandle) { - return obj_tagged(page, obj, phandle, OBJ_DEFERRED_HANDLE_TAG); + return obj_tagged(zsdesc, obj, phandle, OBJ_DEFERRED_HANDLE_TAG); } #endif @@ -1112,7 +1112,7 @@ static int trylock_zspage(struct zspage *zspage) #ifdef CONFIG_ZPOOL static unsigned long find_deferred_handle_obj(struct size_class *class, - struct page *page, int *obj_idx); + struct zsdesc *zsdesc, int *obj_idx); /* * Free all the deferred handles whose objects are freed in zs_free. @@ -1125,7 +1125,7 @@ static void free_handles(struct zs_pool *pool, struct size_class *class, unsigned long handle; while (1) { - handle = find_deferred_handle_obj(class, page, &obj_idx); + handle = find_deferred_handle_obj(class, page_zsdesc(page), &obj_idx); if (!handle) { page = get_next_page(page); if (!page) @@ -1906,18 +1906,18 @@ static void zs_object_copy(struct size_class *class, unsigned long dst, * return handle. */ static unsigned long find_tagged_obj(struct size_class *class, - struct page *page, int *obj_idx, int tag) + struct zsdesc *zsdesc, int *obj_idx, int tag) { unsigned int offset; int index = *obj_idx; unsigned long handle = 0; - void *addr = kmap_atomic(page); + void *addr = zsdesc_kmap_atomic(zsdesc); - offset = get_first_obj_offset(page); + offset = get_first_obj_offset(zsdesc_page(zsdesc)); offset += class->size * index; while (offset < PAGE_SIZE) { - if (obj_tagged(page, addr + offset, &handle, tag)) + if (obj_tagged(zsdesc, addr + offset, &handle, tag)) break; offset += class->size; @@ -1936,9 +1936,9 @@ static unsigned long find_tagged_obj(struct size_class *class, * return handle. */ static unsigned long find_alloced_obj(struct size_class *class, - struct page *page, int *obj_idx) + struct zsdesc *zsdesc, int *obj_idx) { - return find_tagged_obj(class, page, obj_idx, OBJ_ALLOCATED_TAG); + return find_tagged_obj(class, zsdesc, obj_idx, OBJ_ALLOCATED_TAG); } #ifdef CONFIG_ZPOOL @@ -1947,9 +1947,9 @@ static unsigned long find_alloced_obj(struct size_class *class, * and return handle. */ static unsigned long find_deferred_handle_obj(struct size_class *class, - struct page *page, int *obj_idx) + struct zsdesc *zsdesc, int *obj_idx) { - return find_tagged_obj(class, page, obj_idx, OBJ_DEFERRED_HANDLE_TAG); + return find_tagged_obj(class, zsdesc, obj_idx, OBJ_DEFERRED_HANDLE_TAG); } #endif @@ -1975,7 +1975,7 @@ static int migrate_zspage(struct zs_pool *pool, struct size_class *class, int ret = 0; while (1) { - handle = find_alloced_obj(class, s_page, &obj_idx); + handle = find_alloced_obj(class, page_zsdesc(s_page), &obj_idx); if (!handle) { s_page = get_next_page(s_page); if (!s_page) @@ -2243,7 +2243,7 @@ static int zs_page_migrate(struct page *newpage, struct page *page, for (addr = s_addr + offset; addr < s_addr + PAGE_SIZE; addr += class->size) { - if (obj_allocated(page, addr, &handle)) { + if (obj_allocated(page_zsdesc(page), addr, &handle)) { old_obj = handle_to_obj(handle); obj_to_location(old_obj, &dummy, &obj_idx); @@ -2727,14 +2727,14 @@ static void restore_freelist(struct zs_pool *pool, struct size_class *class, void *obj_addr = vaddr + off; /* skip allocated object */ - if (obj_allocated(page, obj_addr, &handle)) { + if (obj_allocated(page_zsdesc(page), obj_addr, &handle)) { obj_idx++; off += class->size; continue; } /* free deferred handle from reclaim attempt */ - if (obj_stores_deferred_handle(page, obj_addr, &handle)) + if (obj_stores_deferred_handle(page_zsdesc(page), obj_addr, &handle)) cache_free_handle(pool, handle); if (prev_free) @@ -2830,7 +2830,7 @@ static int zs_reclaim_page(struct zs_pool *pool, unsigned int retries) obj_idx = 0; page = get_first_page(zspage); while (1) { - handle = find_alloced_obj(class, page, &obj_idx); + handle = find_alloced_obj(class, page_zsdesc(page), &obj_idx); if (!handle) { page = get_next_page(page); if (!page)