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 3666AC47DAF for ; Thu, 18 Jan 2024 18:01:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB99B6B0096; Thu, 18 Jan 2024 13:01:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C6A296B009D; Thu, 18 Jan 2024 13:01:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B32A46B009E; Thu, 18 Jan 2024 13:01:38 -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 A24196B0096 for ; Thu, 18 Jan 2024 13:01:38 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 77E491A0224 for ; Thu, 18 Jan 2024 18:01:38 +0000 (UTC) X-FDA: 81693199476.16.334FB9E Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by imf18.hostedemail.com (Postfix) with ESMTP id 5FA551C002B for ; Thu, 18 Jan 2024 18:01:33 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TeDg8CFu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.166.45 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705600893; 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=gql2dWnZ2ERl3+pU3WuNWOTW7xdtLV2bCUv96eyfuAk=; b=QQcSnzeJnbsW0cRzA9bFc/iatdSZhj0tCtYiR9lgt2E/8qN/w5pG2t3lSJ7DkNDdiBxu7s MtreSPh4Zl4abmcZEXX8moGwRg4i6AK4zGTXisu2L5tMP240xA+L9G8gJlqs9lZIZ0WsHF FrqINkWcb0VIN8gY8W/d4Xregl08ZrY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=TeDg8CFu; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.166.45 as permitted sender) smtp.mailfrom=nphamcs@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705600893; a=rsa-sha256; cv=none; b=caBxU79ZOdZu7BrVegzh92xHfVi/Kptht7f3k6teKF8xobSBedjW6g7LtxkbPuQ3fBIpTq xIyt3bsG6ll9P9S2Gtvx7xj5PNy86xt5sir/jQZuSoaHUGr8Hr0Ooe8EomeNgxsTOcvTFI QNxP3BMv3aQjMbYjRKrcghg3AJpdF94= Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7bf2ecba260so174349439f.2 for ; Thu, 18 Jan 2024 10:01:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705600892; x=1706205692; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gql2dWnZ2ERl3+pU3WuNWOTW7xdtLV2bCUv96eyfuAk=; b=TeDg8CFuiqOh5PubvRouiq4PaYPjs65Pu6LqDc0ITYH6KNqRPNybBasuwkuSp4+PAr EG/Txzae7YZOdOqtUGZmfe+WZ894wbIuLgQpVsdCvaRNT7y/6gERJnFwwuiz0SDDGY2A yUxJf56dHSBJ6Bdj/WBziJhF6phBkTYXdkBYKQb1rYBDgg27GxuFo9phE7VfStUcZtF1 tWl0AsbktTjqlvzmCTv6M93aQGcBg/lCBk/W06Qj8hVz6QRa+M1jYxQkg7KuGHbMxyay 9GC+Rnrysa7emsBeqXvgc3zSJDqXY9S23UObJLZN5uCaV63HtQUIGc6Fzb1r1cp9+3q4 MhUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705600892; x=1706205692; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gql2dWnZ2ERl3+pU3WuNWOTW7xdtLV2bCUv96eyfuAk=; b=xTCzCorRkflrGy/d90rL+PPCmncphAHdQAtIijSLHYbhc6fb03sjaiSGiWGf9AQGLL oJhBZnvdwiRpdb6Ly6nB4AwJXyyMTlaYBKuXnjh5Oaz8P/j0z1y4729JF6x/QhXz0lMt DiYwd4hMC6rZndx+pk21b1IuodujH7+umdIGaXqZBZVxKQPZGtIstlYRA4nJM0nSAq/x gdLdQChn8Td3vgLOH/mn6hiZVOoFMYstBqZmt7IwVIhuMkni3TPtUMbFp0jeN6lNyFpK xKj0VDcMJQ/xymMTf/fgdf0s8LHHvXy7+G4X3gI3vE55pg/plEReS5i69vq84W1u2v/d 2Zwg== X-Gm-Message-State: AOJu0YyyS46Gb7x31YMOXDAJwLytb4NxVgh5JyOz1HvMpoD+iRzin61A c+XnqLq/FzWdqfq3H0IAQuqmQujVsrySLrop+a6JyxEvMTv2erj3URhA4tz9jmUjlbbRzILiFYV VXCV61K/vekzw+DgaXmbL8I63YM0= X-Google-Smtp-Source: AGHT+IED1f6HXEGeea8vx+OGzr4gyatb/CWIwGNnoi/Xh0FaSKDxmWyMlt4nzquEg6fDC8fIfqdIqEAMAswTwKcZqsE= X-Received: by 2002:a6b:c8d8:0:b0:7bf:42d7:f4b with SMTP id y207-20020a6bc8d8000000b007bf42d70f4bmr1321080iof.6.1705600892417; Thu, 18 Jan 2024 10:01:32 -0800 (PST) MIME-Version: 1.0 References: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> In-Reply-To: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> From: Nhat Pham Date: Thu, 18 Jan 2024 10:01:21 -0800 Message-ID: Subject: Re: [PATCH 0/2] RFC: zswap tree use xarray instead of RB tree To: Chris Li Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?UTF-8?B?V2VpIFh177+8?= , Yu Zhao , Greg Thelen , Chun-Tse Shao , =?UTF-8?Q?Suren_Baghdasaryan=EF=BF=BC?= , Yosry Ahmed , Brain Geffon , Minchan Kim , Michal Hocko , Mel Gorman , Huang Ying , Johannes Weiner , Kairui Song , Zhongkun He , Kemeng Shi , Barry Song , "Matthew Wilcox (Oracle)" , "Liam R. Howlett" , Joel Fernandes , Chengming Zhou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5FA551C002B X-Stat-Signature: 6ofhro5e89pm6adcb491ttwxxbgn9eqj X-HE-Tag: 1705600893-783293 X-HE-Meta: U2FsdGVkX18SSN5PZ2zQlLv0o2WV0OVq3RhuLR5O7hzRhifCjhsYxwr8iQSAdvsonj+khk3XJ11hRAxmzyt2T6AHUTmvizLOEBtiN7a6Myc490KkJ2QMUgtqaiWptDN9J7vpl0Hgj2N1Y6VTVs85d6iCagnqNcJnagjXxeCkXZYrxxpZfEsiLwiZY/gRdhkS/lLt1nCrSUvhxNnbu7xvnAGjqGgyF+MX7lPIftQ767d40xNsQndtqs7xMyYF46Ty2LMmbmauRUsuJ/Jn3sB7nVfHyPwkhFjC0xjYX9l41aQuTWG2Wzed0lQt3QSIT2i/WEkQo//pG5BQhxay/owvgYDDIUgAHZ2UQuNDKbhZVHIfmqmAyhvyAtp6TOvXqE8fYDP2fvnxwDV6BRde/dYU+uei9p+SrwW2Z819w0DRwAK/uGCSrpAtW9Tk/c75D0Y76iNDjwB+loKaueriSVtDoP1HkcOslVFsSvH05WtDhQp+u8dp8YieOmsT9PktFMnopbeLJPGHYxdVmU1k7U3jQjwQ5p1fSCO64TwzQAE35q5B462uyAEgp9q3EU3ndxBHfc2oupcQ++PaLXGArD/CQHo5OfMLFgpUl3HkF6K0NDDZW7/sIM34CmjaaESe57wsaxHUCFShR1ATZ+4YTZQ1TUFeMBDSeDeNkMKJee1NfwrYB2WeoanNnlsgSDCiMQudonpQ+LzGPNopTPqValpwKXGIac0r4cQm7bow6VpjhFTHVPCFaOboJFBPLvbq+2z3D33a8LFRbSqvKCmahifx/ufgCGlj4wY3m/11nlHJqxKVeH66UzUOYUp++t6sG965IaewPUS+W8AOobuJTHe5iNEACKa1ZWELCDFhJw8lvcEBpEt5gciD8MbZOs3DOCyhVv3SkAJbmTz4nZnBfukUg88xDcOLDrK81zIXyp1oZI6Hw/7Mly8sWnnuAHhbikU4aZb3J0k2GY5SD7fGCTZ nlC27HJj fbEiUatea6yf7Kd0tQcJgHIkwqQzwefsiumfFKpTWe5EJohF+fzb6IRy0nQ7P5oh2pfNhHUGo+zL7yst/Yoej3rLoczBb2FM8ry2NH29NiCmTd90WXE8+BK2MxtEpgGyX0Jb9uv0iHSZQt21FIGtvoJ/UmA2zS/BArGMPolFZ1ADnoZjagN1GhVj1NSCU/2/Tdtmd6rh6d08UMCf2hsR935stNXrVmq/ya9MkKMV/Fx93OiAC6I4Xg+xlvciXX6sPgN3WWB/fp/rjXywAbsnMIRt0X4Ba8lgwK2TspiThjCZsrbPRruplGu+9eFkLk4BtoAjiUXX7/cG0ZMmq1cnCRjiIzRyPJe34Qe9P/EMTG9x30BqvRe0Ep6PVihlo7Ne2jvKWbmY6fze3EC3gNGeKW63RyIm/KjkeSMCO X-Bogosity: Ham, tests=bogofilter, spamicity=0.000177, 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 Wed, Jan 17, 2024 at 7:06=E2=80=AFPM Chris Li wrote: > > The RB tree shows some contribution to the swap fault > long tail latency due to two factors: > 1) RB tree requires re-balance from time to time. > 2) The zswap RB tree has a tree level spin lock protecting > the tree access. > > The swap cache is using xarray. The break down the swap > cache access does not have the similar long time as zswap > RB tree. > > Moving the zswap entry to xarray enable read side > take read RCU lock only. > > The first patch adds the xarray alongside the RB tree. > There is some debug check asserting the xarray agrees with > the RB tree results. > > The second patch removes the zwap RB tree. > > I expect to merge the zswap rb tree spin lock with the xarray > lock in the follow up changes. > > I can surely use some help in reviewing and testing. > > Signed-off-by: Chris Li > --- > Chris Li (2): > mm: zswap.c: add xarray tree to zswap While I think it is pretty neat to keep the rbtree around to check if the results agree during development stages, in the final version please squash the patches. One patch is enough :) > mm: zswap.c: remove RB tree > > mm/zswap.c | 120 ++++++++++++++++++++++++++++++-------------------------= ------ > 1 file changed, 59 insertions(+), 61 deletions(-) > --- > base-commit: d7ba3d7c3bf13e2faf419cce9e9bdfc3a1a50905 > change-id: 20240104-zswap-xarray-716260e541e3 > > Best regards, > -- > Chris Li >