From patchwork Tue Aug 13 08:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13761566 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 0E01DC52D7C for ; Tue, 13 Aug 2024 08:42:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C70F76B00BA; Tue, 13 Aug 2024 04:42:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF9906B00BB; Tue, 13 Aug 2024 04:42:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A74DD6B00BC; Tue, 13 Aug 2024 04:42:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 83EF16B00BA for ; Tue, 13 Aug 2024 04:42:16 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0F2011406D4 for ; Tue, 13 Aug 2024 08:42:16 +0000 (UTC) X-FDA: 82446580272.17.AC8EEB6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id 611B440007 for ; Tue, 13 Aug 2024 08:42:14 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cyXENoc4; spf=pass (imf04.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723538522; 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=wV7BSr/1QairbT3fg8+MgBmQkzh01Sx27nNz+bgrgRA=; b=DyoH5TIPeYh16Wne7/fMWCYvjiWnQO9vzm374+K9Pg4Mg2q3GyZCMsCx/h/Mg2EOfvrOFS VGLFOYVgoe/LIp4xPraJYDZW1qpgunwPIWg5xAhaa7gW/GXoThUMHcU48lCSuyfqp/MgWp Ypv3YcHioSqwGPDRIUFR1Hs0h7ooWw4= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cyXENoc4; spf=pass (imf04.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723538522; a=rsa-sha256; cv=none; b=dF+8FKxRgWc7AHaP7JanQmd+X8SpY/9XkXgxo8jyKNpoaFVFIKkALI/Ny2SAbn1pY5wCAM cjP3N8DblW7UlIOwvaMG+3wL9Up8rg3Rqe0ybquCgonf/hT24eOI5Bctb5WwYaiApNXNkk N/QBdZOcegAfB1Jtn5QdbGRNGwcK+bc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 9A6CB615A6; Tue, 13 Aug 2024 08:42:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3D94C4AF09; Tue, 13 Aug 2024 08:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723538533; bh=8TsEc1mQDjgsj8r155q+1srlMOAnmBBOJU38nCFETQE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cyXENoc4P62M2wfhgRRIdhledFsy/PPHOdILmE+RD6XzAahA3OzA3VF9DM6zOSCoy u1k5uThAaRqIGvfMJb3qwlxKDH5Bc+jo/ELrtOcius+pSxrZu+unAkJohA+TEjsomK Q9ugK5Af0stkeShlVpT7BbLXOsslLhd2x80E336Te/5DhiYu4aKBmX/nCYEFTpkeuJ ZGWQv62YyFDgnMRa1mnUu7X2rkdLlxqjuG+p0kUVj1S1T9k3GPAssIrfEgYe78oyib IWEIkNs5axTKVNgVzYx7J00DrOdE1P8HL+qy/HVN2sz4Nl6Sdwmq4j96BmCBTeY2wJ qVDdhTuO1dZAw== From: alexs@kernel.org To: Vitaly Wool , Miaohe Lin , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, minchan@kernel.org, willy@infradead.org, senozhatsky@chromium.org, david@redhat.com, 42.hyeyoo@gmail.com, Yosry Ahmed , nphamcs@gmail.com Cc: Alex Shi Subject: [PATCH v6 17/21] mm/zsmalloc: convert get/set_first_obj_offset() to take zpdesc Date: Tue, 13 Aug 2024 16:46:03 +0800 Message-ID: <20240813084611.4122571-18-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240813084611.4122571-1-alexs@kernel.org> References: <20240813084611.4122571-1-alexs@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 5u48a5hjk33uka3h67687izoft4eh8cw X-Rspamd-Queue-Id: 611B440007 X-Rspamd-Server: rspam11 X-HE-Tag: 1723538534-367161 X-HE-Meta: U2FsdGVkX1+QGsGl0G4vRt6tEwW3EqUdWHw1yOqGisV1G3MCdpPeivUhrjhEX6f5MlOfkXVPZVOmDkQVX+iL6xW9BEYMobDahTAgEBv1jTmq0vZH1bqGoYMn4/WTQ4QhsHErzCOE1etsUR+NRrWxp/e/J/5ILhEAvGavx6lPi8jNRorQfXrlXKBnLXfISFF0QMx74SdA0aON7PcNojauSvqDoCeG8Jcg0zwDSavh2KZU3GXcUOfYoMePu8YY+SI6CD+eoOyy2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cx7yMzwCMExKNYbArToLr8tanH1LUw76 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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: Hyeonggon Yoo <42.hyeyoo@gmail.com> Signed-off-by: Alex Shi --- mm/zsmalloc.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index e2b203db192a..8553542edacb 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -488,26 +488,26 @@ static struct zpdesc *get_first_zpdesc(struct zspage *zspage) #define FIRST_OBJ_PAGE_TYPE_MASK 0xffff -static inline void reset_first_obj_offset(struct page *page) +static inline void reset_first_obj_offset(struct zpdesc *zpdesc) { - VM_WARN_ON_ONCE(!PageZsmalloc(page)); - page->page_type |= FIRST_OBJ_PAGE_TYPE_MASK; + VM_WARN_ON_ONCE(!PageZsmalloc(zpdesc_page(zpdesc))); + zpdesc->first_obj_offset |= FIRST_OBJ_PAGE_TYPE_MASK; } -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 16 bit available, we can support offsets into 64 KiB pages. */ BUILD_BUG_ON(PAGE_SIZE > SZ_64K); - 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) @@ -844,7 +844,7 @@ static void reset_zpdesc(struct zpdesc *zpdesc) ClearPagePrivate(page); zpdesc->zspage = NULL; zpdesc->next = NULL; - reset_first_obj_offset(page); + reset_first_obj_offset(zpdesc); __ClearPageZsmalloc(page); } @@ -928,7 +928,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 = zpdesc_kmap_atomic(zpdesc); link = (struct link_free *)vaddr + off / sizeof(*link); @@ -1583,7 +1583,7 @@ static unsigned long find_alloced_obj(struct size_class *class, unsigned long handle = 0; void *addr = zpdesc_kmap_atomic(zpdesc); - offset = get_first_obj_offset(zpdesc_page(zpdesc)); + offset = get_first_obj_offset(zpdesc); offset += class->size * index; while (offset < PAGE_SIZE) { @@ -1778,8 +1778,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); @@ -1834,7 +1834,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 = zpdesc_kmap_atomic(zpdesc); /*