From mboxrd@z Thu Jan 1 00:00:00 1970 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 E4BBAC3065A for ; Mon, 1 Jul 2024 03:40:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DB7F6B0088; Sun, 30 Jun 2024 23:40:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08A7B6B0089; Sun, 30 Jun 2024 23:40:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6CE86B008C; Sun, 30 Jun 2024 23:40:13 -0400 (EDT) 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 C9AA26B0088 for ; Sun, 30 Jun 2024 23:40:13 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3E8C1141819 for ; Mon, 1 Jul 2024 03:40:13 +0000 (UTC) X-FDA: 82289780706.20.347C6F0 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf06.hostedemail.com (Postfix) with ESMTP id 4684A180014 for ; Mon, 1 Jul 2024 03:40:11 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=D3VUNWOT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of seakeel@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=seakeel@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719805194; a=rsa-sha256; cv=none; b=Dcq9VjVQUpuoi08XYbxjAV/GcuPCYg2g/7LxNqhofnuPnNCYqdPfEdsghrqWwkHeO+E2Kt wV2aKXr9Kz7BaSenex7EHPCb6swCB5/7y6qpze928P8/rZ1eHRa28TuMgCoQOci8xsV8i8 S8AkEdeehx6mKvXS1HyYpNN+WuAgH7k= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=D3VUNWOT; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of seakeel@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=seakeel@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719805194; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SgLx/VnUuHyviAFrV554OvWCd0rnqob6XndqOTMcVR8=; b=yClL1mofv6h7v1AqmEFnkFVtYt2zy6N5Bjz2q9nBACwKGqYHzdv8mS7Qfb2AVdftsHdJNG pt2c9DEfaVop7Pi7l9OzsHL1GO280AyYO3WhT6vgXHxDQsUu9U9hvVSC7DknmBSpVDHVIb F5XkZ0rpfkVvMf4Ha36kLLb+nEDFjBw= Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2c92d00059eso1378856a91.3 for ; Sun, 30 Jun 2024 20:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719805210; x=1720410010; darn=kvack.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=SgLx/VnUuHyviAFrV554OvWCd0rnqob6XndqOTMcVR8=; b=D3VUNWOTRWZ35BhgIp3xegP5P6fIKFHEz/9Or3YXzoZJF7hmIqqQVzhO85Inik20B+ rH51NVPrIwvg5crjRltdOgsHXuf7P2tAm7zljDkoR/7StaZDfOflc/wfLX4mTNBFs6k+ qsCpsaurVHLmbRoDMFVpy59+BMTJCnu+S28LKqgoAzNZ8xrt+prc+bbHYjZHhO5srCsD EoPuWzR9CuVA24yPyKUekY2wNijV3mxMIG8wHe0iP6+korCpuPILLupX9KR/yuwEF92r ivVMilWkcUw8aQs1C1Huf09E8YvaAifHD5aU4L1+MCdYX+z2KqPbw2/ztU95Czod1bRc SVcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719805210; x=1720410010; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SgLx/VnUuHyviAFrV554OvWCd0rnqob6XndqOTMcVR8=; b=arbP5znklV21U2qyHKAAHoKhFdRNiPDZ+k8fgXAfmk9+TNMX9P8VxFNl4fkP0F+Upc Nr3VlLy+rORiXT99uKmoZkQTGwvXEcnF13BMRD2/Jm8B2sVhyQVOitG/FsmfTJF1A7cK RCU77WT1WzDBuL0MZhLmKoyQpkkBY3aPcolUqxHzTkLSObp6vSNGThdNzx0CsMh6uzSi JFqJTaApoohOTH+7LJdcEyO2omuLOF/5VJ3SWwOfNEZDF9zT9wtRtl78WbmDCfTQm2/C jRMrbLWfqpVjthj2KkL72rD93ORT6ipbe1YhXbb7YfsA8g0XZ5EKiu+Yb2xtI3Z22CT9 4QKA== X-Forwarded-Encrypted: i=1; AJvYcCVJXHZp3dJig2sfoQgQbX9ulz4Tg4/oQWM0XCNYCcX7dPBvt+2OouXQHE19E994gKZtwny2tVAoYKoYh+Kgf4/NdBM= X-Gm-Message-State: AOJu0YwbsISYyEMfE/5Esh0XF3XAi77Dz2UE3VpBeV9AltOwoAqUIW80 Mz5xLUbqbqAppf3P8Mc77UUlZpxQ5gDSD67QAQg/2YjaLcCjGiX/ X-Google-Smtp-Source: AGHT+IERtwgU9u26Oag1D/d5ru5zwJeyeVbrdbzzXf8Yl5ztX9m1ngLjBgRtdpDriKACIEdPWCUkvQ== X-Received: by 2002:a17:90b:d87:b0:2c8:dad2:83e3 with SMTP id 98e67ed59e1d1-2c93d72d7a7mr2091017a91.6.1719805209925; Sun, 30 Jun 2024 20:40:09 -0700 (PDT) Received: from [192.168.255.10] ([43.132.141.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91ce74143sm5584386a91.27.2024.06.30.20.40.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Jun 2024 20:40:09 -0700 (PDT) Message-ID: <429f4ea1-b94a-455a-a4e7-27e1536c0b7c@gmail.com> Date: Mon, 1 Jul 2024 11:40:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/20] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool From: Alex Shi To: Hyeonggon Yoo <42.hyeyoo@gmail.com>, alexs@kernel.org Cc: 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, Nhat Pham , Yosry Ahmed References: <20240628031138.429622-1-alexs@kernel.org> <20240628031138.429622-2-alexs@kernel.org> <4418c5c6-60f3-408f-a4ea-8d8ba1cc8afd@gmail.com> Content-Language: en-US In-Reply-To: <4418c5c6-60f3-408f-a4ea-8d8ba1cc8afd@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4684A180014 X-Stat-Signature: i6mjrmb9atdxrrabkmwcc7qb9wmsokwf X-Rspam-User: X-HE-Tag: 1719805211-809433 X-HE-Meta: U2FsdGVkX1/lyNl6lMI0DsCa3fFhSeQaCApJw98kCsRqEvRdfbXyVxf1EHkR8bheOjLPXxs2VETwi3JL7oInzHpgS575WpM+ayDlzD2tWGBBt1t8grpo4WP9xFXIiY+O64D+mdWiEwPNWhcJV9mq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Rr8e0u7PV9riMvyBe5GVed2J3zrITpSi9+E+ylr3z3o/JRbEfP9s6Ozr1TUr6mspepaUsRvRBnM7bHqgoQ0PqQbVTKdBjmi4D/R2g9RPXidD1a+acUtxjZ5ntya5iXMGfOqmU0bOBr3tw5xIqKmn6oXTrWg0MqSzbiFw5JQrIOhB6NWLrrbbB/2zX6nA1LTdvIhUEcCD01wyfomdjyyLrnyzH7tYSEoLRo2fuDfQD056a6Unsyx+GbKm4Ay/Lo8FxBXYac4vvjQ4GffZBaF4X1aLv+9Mhmf3yQ8fVp2ZgT4vBh3PoMa0EpnVoPCA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000102, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Ops, Sorry for missing Yosry and Nhat. How stupid I am! Here is the first patch on lore: https://lore.kernel.org/all/20240628031138.429622-1-alexs@kernel.org/ Sorry for this! Alex On 7/1/24 11:03 AM, Alex Shi wrote: > > > On 6/30/24 9:45 PM, Hyeonggon Yoo wrote: >> On Fri, Jun 28, 2024 at 12:06 PM wrote: >>> >>> From: Alex Shi >>> >>> The 1st patch introduces new memory decriptor zpdesc and rename >>> zspage.first_page to zspage.first_zpdesc, no functional change. >>> >>> Originally-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> >>> Signed-off-by: Alex Shi >>> --- >>> mm/zpdesc.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ >>> mm/zsmalloc.c | 19 ++++++++--------- >>> 2 files changed, 66 insertions(+), 9 deletions(-) >>> create mode 100644 mm/zpdesc.h >> >> Hi Alex, thanks for your effort in pushing this forward! >> >>> diff --git a/mm/zpdesc.h b/mm/zpdesc.h >>> new file mode 100644 >>> index 000000000000..a1ab5ebaa936 >>> --- /dev/null >>> +++ b/mm/zpdesc.h >>> @@ -0,0 +1,56 @@ >>> +/* 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, now is for zsmalloc >>> + * @flags: Page flags, PG_private: identifies the first component page >>> + * @lru: Indirected used by page migration >> >> maybe Indirected -> Indirectly? > > Hi Yoo, > > Thanks for comments! Yes Indirectly is better. I will update it in next version. > >> >>> + * @next: Next zpdesc in a zspage in zsmalloc zpool >>> + * @handle: For huge zspage in zsmalloc zpool >>> + * @zspage: Pointer to zspage in zsmalloc >>> + * >>> + * This struct overlays struct page for now. Do not modify without a good >>> + * understanding of the issues. >>> + */ >>> +struct zpdesc { >>> + unsigned long flags; >>> + struct list_head lru; >>> + unsigned long _zp_pad_1; >> >> for understanding, I think it'd be better to replace _zp_pad_1 with movable ops, >> because mops reuses this 'mapping' field. > > Right, 'mops' looks a bit more clear. > >> >>> + union { >>> + /* Next zpdescs in a zspage in zsmalloc zpool */ >>> + struct zpdesc *next; >>> + /* For huge zspage in zsmalloc zpool */ >>> + unsigned long handle; >>> + }; >>> + struct zspage *zspage; >> >> There was a discussion with Yosry on including memcg_data on zpdesc >> even if it's not used at the moment. >> >> Maybe you can look at: >> https://lore.kernel.org/linux-mm/CAB=+i9Quz9iP2-Lq=oQfKVVnzPDtOaKMm=hUPbnRg5hRxH+qaA@mail.gmail.com/ > > Thanks for notice. > The memcg_data isn't used for zpdesc. And I have a bit confusion since Yosry said: "I think to drop memcg_data we need to enlighten the code that ...". So we actually don't need to have this unused member, is this right, Yosry? > >> >>> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c >>> index fec1a39e5bbe..67bb80b7413a 100644 >>> --- a/mm/zsmalloc.c >>> +++ b/mm/zsmalloc.c >>> @@ -13,17 +13,17 @@ >>> >>> /* >>> * Following is how we use various fields and flags of underlying >>> - * struct page(s) to form a zspage. >>> + * struct zpdesc(page) to form a zspage. >>> * >>> - * Usage of struct page fields: >>> - * page->private: points to zspage >>> - * page->index: links together all component pages of a zspage >>> + * Usage of struct zpdesc fields: >>> + * zpdesc->zspage: points to zspage >>> + * zpdesc->next: 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: PG_zsmalloc, lower 16 bit locate the first object >>> * offset in a subpage of a zspage >>> * >>> - * Usage of struct page flags: >>> + * Usage of struct zpdesc(page) flags: >>> * PG_private: identifies the first component page >>> * PG_owner_priv_1: identifies the huge component page >> >> the comment for PG_owner_priv_1 can safely be removed as it's not used >> after commit a41ec880aa7b ("zsmalloc: move huge compressed obj from >> page to zspage") > > Right, thanks for info! > >> >>> @@ -948,7 +949,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)) >>> @@ -1325,7 +1326,7 @@ static unsigned long obj_malloc(struct zs_pool *pool, >>> link->handle = handle; >>> else >>> /* record handle to page->index */ >>> - zspage->first_page->index = handle; >>> + zspage->first_zpdesc->handle = handle; >> >> FYI this line seems to conflict with >> bcc6116e39f512 ("mm/zsmalloc: move record_obj() into obj_malloc()") >> on mm-unstable. > > yes, a new commit made this conflict. will update this in next version. > > Thanks > Alex >> >> Best, >> Hyeonggon