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 71517C27C4F for ; Mon, 1 Jul 2024 03:03:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EAAA86B0099; Sun, 30 Jun 2024 23:03:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E59BF6B009C; Sun, 30 Jun 2024 23:03:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFA566B009D; Sun, 30 Jun 2024 23:03:45 -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 AEE936B0099 for ; Sun, 30 Jun 2024 23:03:45 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 396AEC06D5 for ; Mon, 1 Jul 2024 03:03:45 +0000 (UTC) X-FDA: 82289688810.11.282DA8D Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf29.hostedemail.com (Postfix) with ESMTP id 4BE8512000F for ; Mon, 1 Jul 2024 03:03:43 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i8dSkLPN; spf=pass (imf29.hostedemail.com: domain of seakeel@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=seakeel@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=1719803002; 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=hylkKysnQs2URCgI6f4H+azXob1gJRcDJ2yV/tK5m6A=; b=eA4Q8I5dMIwkbugSGs+ilEDvRQhUso6Gma8Yc0KNJwMCz1kXMlgz7l5HPmj/4+tp8p3thU Wra9b6ZNiduDAWBOA+aUfPFhXSjT23MXWN43GDu+gjORTGq8oL704QIupvwQFaxkTxY0Mi rzqIvm16ffxMe68XT7MN66sIyIZBqBE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719803002; a=rsa-sha256; cv=none; b=khVMNEjETlXomSS7YvP/R16WdcOPPFV0k/YmYJIY/AOIkiSHq1KGIbTl1xO/hbp8/369KT gnOcpeU67czLSkr1j3P5GQnBsgrcaeTPCbYJayjVgPanTNLaYceqWiIF6i3v0aZXS47lbg mDXWR0SkxeQwdWhCcUjg9URHoVirzfg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=i8dSkLPN; spf=pass (imf29.hostedemail.com: domain of seakeel@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=seakeel@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-706738c209bso1281071b3a.3 for ; Sun, 30 Jun 2024 20:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719803022; x=1720407822; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=hylkKysnQs2URCgI6f4H+azXob1gJRcDJ2yV/tK5m6A=; b=i8dSkLPN1E9jg6S7zz369N0J3MREFsZlMfS2JoH1T7uUYhUVAUvjNuo4KwvNsL5vFb 8EnMxwqjr/luUX04Bh8W/5UTcKIsTAnOlZsK7VDC5W5DYze87MQtTSEoZnUrnKxZ3kU6 Bfwbey8sddktgujz+vI9/CWXS/8bB6rExOOHwb57waSr1dnpSrKr6RlTJhj1M6dVBLWo 8VngV9bwovxoe1VhTrCGuD8UwV+Og5EetZQOHbdaB5fG1zCDfn3iGoZhML8F/Se5aXBS 4Wwt9gSBP82BA/p4nBNAX1W8jGb/rP9+MmrYVBHI7PTj7hUCdZjqpbC80BKwh56AuXf8 1L8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719803022; x=1720407822; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hylkKysnQs2URCgI6f4H+azXob1gJRcDJ2yV/tK5m6A=; b=dP1N4xEex8ufZL57vbIrXYepuM+BSsg3CMtUShcYbmwIPDZOf9h+RN+bxRfuiQPeXG R1WhSEXmOEt4UJHYxqjFSP23rvZy0Ko2EUnNjGFKGWbWiOZLOmXuRuyHyY6FL7l4Y7fP gRlwOQWg6e4F5ufTYgsk0pRswKB+eIC/edey+lV6TIYvNPQ10pUUkxUEVKVKLO2pRVqD wBODw8YVc3KnV3UjNx0QfGk3rNVFWecuNZJp6uo00jCCqX/9b96lpUBL9hnPwAI6Ir0Z HjwAMZ2VXxGvjIWkulDOP9teSHhhoVujt7n5r48NaTg49cRsYYVRWXbaMOt+jdGuRGH4 0TFA== X-Forwarded-Encrypted: i=1; AJvYcCVJw4V/q0ua9yxeB2w+iqmW0jgK0hUQE1Mf/RWkOEcLcv7MNZirPG052B/ZjgnvLXEGLqVf2/sgfSc2n4LFiHrWmkM= X-Gm-Message-State: AOJu0YzvVTotwp7nLucFsHxieuNqvs6KRs7fV6e7Uyv380Vn+RKIfwXw ZWBYyBB6P4BSjTf52JrHIF/8U4lfOrJbHhsmXzYFjml75ZwNgrMk X-Google-Smtp-Source: AGHT+IH6e/ptwM0Xw24RgpyigCdn0UuK5f4uoERcJeojQn8zh/yEM2jskzW7a0hTX7CbMa7Ug9F6YA== X-Received: by 2002:a05:6a20:7348:b0:1be:bf38:7b1b with SMTP id adf61e73a8af0-1bef61201a6mr3630670637.33.1719803021915; Sun, 30 Jun 2024 20:03:41 -0700 (PDT) Received: from [192.168.255.10] ([43.132.141.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fac2f03acdsm52584645ad.302.2024.06.30.20.03.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Jun 2024 20:03:41 -0700 (PDT) Message-ID: <4418c5c6-60f3-408f-a4ea-8d8ba1cc8afd@gmail.com> Date: Mon, 1 Jul 2024 11:03:38 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/20] mm/zsmalloc: add zpdesc memory descriptor for zswap.zpool 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 References: <20240628031138.429622-1-alexs@kernel.org> <20240628031138.429622-2-alexs@kernel.org> Content-Language: en-US From: Alex Shi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Stat-Signature: cih75mu936f67axfck6ug8sri1kbzjw3 X-Rspamd-Queue-Id: 4BE8512000F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1719803023-953572 X-HE-Meta: U2FsdGVkX1/MMlzaCZ1aLf4OT1Fkrt0s6cjWlk90CMtgXGbpfRSEFRJprVo0xNJ0RjmHPUjl2OUTgJyF8GDm6HY8zn/XPURznvlAwIDuQEQAFonBodOnF+elv0AYzOWfmgOD9VhtVgrBAlIC971F1dlfrY340bUwzh6kfZRgZvXktCvUpgQg8HWvG9yt8X6+HgMmsjAQcFHxZzRBlRgUsM+1kX2wuvaftsSu32fYCjA/xcgFVEkv5F5uvMaGZN97NB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G/NWQGzaheAGF8yL8sBYx/RYh5Ewy/U5YovOYvSwpPiJjxXBINsmhsyAnt/QywXdYavmS+PMCzF5vdOvYwXVbptt37Dlkof4Pbr7TLkouGw+Iy1Ol9JL/YQjWpZIVyHU+1zsBYhwe19JtnY1baJtqCVxA8XQHorf6MlCArz7Ko485jNXst2I5NRiQtl9FQavADGN884K10BfqcwizqGKPMJJgfuxrrSPd/A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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