From patchwork Thu Nov 30 10:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeonggon Yoo <42.hyeyoo@gmail.com> X-Patchwork-Id: 13474201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDD58C4167B for ; Thu, 30 Nov 2023 10:13:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 520A26B045C; Thu, 30 Nov 2023 05:13:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CF6E6B045D; Thu, 30 Nov 2023 05:13:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FB296B045E; Thu, 30 Nov 2023 05:13:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1AA726B045C for ; Thu, 30 Nov 2023 05:13:15 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DF518A0165 for ; Thu, 30 Nov 2023 10:13:14 +0000 (UTC) X-FDA: 81514207908.28.B94EE5F Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) by imf04.hostedemail.com (Postfix) with ESMTP id 0A46640022 for ; Thu, 30 Nov 2023 10:13:12 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=B8kUO4Fd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701339193; a=rsa-sha256; cv=none; b=6JxEBgDh2Iqn1vHBBf3DEWKPmXcOZ2Z5RDQQkzLwSbaEdhM+XPM49tJETCuJ41zIBChWPI +gkEhaqTFY1oMruU5bJjQNH+YoUGxarTZ10xawr3OzDDGnWzpp9irKcG2qxggrUKay7z+p y03n23DWfKyVNl/H9pEMcsnwAr7dOCQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=B8kUO4Fd; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf04.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.167.179 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701339193; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7hZ4QEa6qbbemjVgd5G8BNyx+l3Y0ydBKsZ1v56EUu8=; b=5ndDJ+ktL2ljFUO2M1NIMUEB572YkkjgHqiA1Btq/aCygpCA73zU2nDjcSBnQQ2t4721hC TdTVzFrGjLH7a8uDwwIom6mzSfr++nV2UG9uoPZjMehbcyIFFF2AoZ3xyONDEEtxKVUDF8 W3bKBvGYSW7leQd9Jw7E5+rlw1/IN8c= Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3b2f4a5ccebso407405b6e.3 for ; Thu, 30 Nov 2023 02:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701339192; x=1701943992; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7hZ4QEa6qbbemjVgd5G8BNyx+l3Y0ydBKsZ1v56EUu8=; b=B8kUO4FdmLVuub6ZONRlPqpdmc4+wpItTkLgvTZPDSZMe0pFcWqys39lB3QtR1T10O O7wf498X5MRyR6NxDJ99PELQ0J7j3u07oWZ3ggwHVa/RzOYNCbyCH3NLVYtWKZR4Wn9Z ZgW8H1NHupoubQjZkAao/p93ypoUiTqIbGZ+BHOhMexF/ofUkIm7diR/ytWqa5RsHmnq zBv8HR6QqWidud9WtL7C6wP62dgT9NuUQM9CHSp4KafJzbt/LJHwHHo75bfspCUml0EM 8Pg8CY/mA0Nkp2/7QVX4zTz8qWzhesYuCTgB+0cDZU+ZWhgxc1FO9q/566YxujJLtLYZ EzOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701339192; x=1701943992; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7hZ4QEa6qbbemjVgd5G8BNyx+l3Y0ydBKsZ1v56EUu8=; b=Ee0/yTN+3GcFb1HlfQhAFiwjMwvsBq3at7yhu2otbYdzgS0Ri8o0u2QmRxUO/VgXdx eIecMEZJX3iZE9HGF30WfH9/nQwf3LUoa3sHZnh+LnLM6j/iuX3RpI38lP/b2wGP3Qqg THb3SbvDbhDCytQWxc+GVoCPICV5Z4V3k6NLXrEqRlfxU5AlD+3aQZUlukKzz5ABuGjK LlJ3olXrskGbrlDN/U+Pi7c6fLWu1+HrJSTocVuNbla1pZ/Figo1A1GLJA6q34xNsQ4S eKX2Pwpq7/AWMZBIGVRmDWFQiH9+nJtOJP3nW6xoliaEIINETBpvMp3RRSuXU/5BJppM fFfg== X-Gm-Message-State: AOJu0YwCufHpMsIe2iORiwmy34W9Y6ry9VZLLefllEBB+PnSHY8wCeXf xCQQ1ehRLadARWSMlL91osw= X-Google-Smtp-Source: AGHT+IFcnzB21TtPzdY3IZ9ebd5sJCgNo9mdoC2Efki1ra/Kpjx5LiOuHG/hacNR39WaENx55nDQiQ== X-Received: by 2002:a05:6870:392b:b0:1f9:5e26:9509 with SMTP id b43-20020a056870392b00b001f95e269509mr22795530oap.22.1701339192028; Thu, 30 Nov 2023 02:13:12 -0800 (PST) Received: from localhost.localdomain ([1.245.180.67]) by smtp.gmail.com with ESMTPSA id r27-20020aa78b9b000000b006900cb919b8sm841402pfd.53.2023.11.30.02.13.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 02:13:11 -0800 (PST) From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Minchan Kim , Sergey Senozhatsky Cc: Matthew Wilcox , Mike Rapoport , Yosry Ahmed , linux-mm@kvack.org, Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC PATCH v3 04/21] mm/zsmalloc: add alternatives of frequently used helper functions Date: Thu, 30 Nov 2023 19:12:25 +0900 Message-Id: <20231130101242.2590384-5-42.hyeyoo@gmail.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20231130101242.2590384-1-42.hyeyoo@gmail.com> References: <20231130101242.2590384-1-42.hyeyoo@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0A46640022 X-Stat-Signature: my6mtsmt6dkmaxawr5x4ohnha6ck81mz X-HE-Tag: 1701339192-742007 X-HE-Meta: U2FsdGVkX1+jAwqBLLsTS2tmvDNZvVd0k0I22jzW6ZY984lBBDb9JDFYI49ewW4xUylN2s1IpToUGbuB9ky8h+J3jmHFfTemqa9OWawCFIt7mFOUgYzuQT6U+4L7/pF+aIMJSKWivK2OeHvty6sho2qFodSp2HlAlJIrI1opMUcShGExB/KWv6RC/jUfZ1hwRHhfwGNvrDKd3xcdyh2TCi+HNIdJm8Y5LxlCwHfXlfe5gpffIQ9D95XvkUH9LhxXorBmMKKqsiuY73C5PygGLWci3LxBC+3Fqm2oiVPiLosRIM1gi/y4gAFemawSvmA0qwVimNaIVDzfSWRuL7FWEAmx984wzfQ6REq/guO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g1eX6lCMeZ4dHx1dmiftG+bSYVNT9wj7boWAIFORXfH7OobA5rAtRdAIFYVWmwvjImJX8205/78YMj82FER9Y8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: get_first_page(), get_next_page(), is_first_page() are frequently used throughout zsmalloc code. As replacing them all at once would be hard to review, add alternative helpers and gradually replace its users to use new functions. Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> --- mm/zsmalloc.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 4c9f9a2cb681..c511539bee8c 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -502,6 +502,11 @@ static __maybe_unused int is_first_page(struct page *page) return PagePrivate(page); } +static __maybe_unused int is_first_zsdesc(struct zsdesc *zsdesc) +{ + return PagePrivate(zsdesc_page(zsdesc)); +} + /* Protected by pool->lock */ static inline int get_zspage_inuse(struct zspage *zspage) { @@ -514,7 +519,7 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val) zspage->inuse += val; } -static inline struct page *get_first_page(struct zspage *zspage) +static __maybe_unused inline struct page *get_first_page(struct zspage *zspage) { struct page *first_page = zsdesc_page(zspage->first_zsdesc); @@ -522,6 +527,14 @@ static inline struct page *get_first_page(struct zspage *zspage) return first_page; } +static __maybe_unused struct zsdesc *get_first_zsdesc(struct zspage *zspage) +{ + struct zsdesc *first_zsdesc = zspage->first_zsdesc; + + VM_BUG_ON_PAGE(!is_first_zsdesc(first_zsdesc), zsdesc_page(first_zsdesc)); + return first_zsdesc; +} + static inline unsigned int get_first_obj_offset(struct page *page) { return page->page_type; @@ -810,7 +823,7 @@ static struct zspage *get_zspage(struct page *page) return zspage; } -static struct page *get_next_page(struct page *page) +static __maybe_unused struct page *get_next_page(struct page *page) { struct zspage *zspage = get_zspage(page); @@ -820,6 +833,16 @@ static struct page *get_next_page(struct page *page) return (struct page *)page->index; } +static __maybe_unused struct zsdesc *get_next_zsdesc(struct zsdesc *zsdesc) +{ + struct zspage *zspage = get_zspage(zsdesc_page(zsdesc)); + + if (unlikely(ZsHugePage(zspage))) + return NULL; + + return zsdesc->next; +} + /** * obj_to_location - get (, ) from encoded object value * @obj: the encoded object value