Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp150594rdb; Wed, 17 Jan 2024 22:02:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyY5Tl3HtyNA84FSpF2sHsRoYOzXV8VVPAens1tRgE3e9LYJhT6UBKkPYVLU060Y5rCdOV X-Received: by 2002:a17:902:ec8b:b0:1d6:e986:615e with SMTP id x11-20020a170902ec8b00b001d6e986615emr418461plg.28.1705557756717; Wed, 17 Jan 2024 22:02:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705557756; cv=pass; d=google.com; s=arc-20160816; b=cVng5dKvOMhbrKs09jDLgWez+yT3EeHDZ+zeyNapzUFBuMdbKrR9mN6HLNUYBXBN8q OJy2JloEoiVI8UkKkSbmti9nXVEit/ZQPpNWdYd0+DT2i+hAGQErDO0BlTA8DqyjVsL2 rAA9GM6EOKBj6568xuvO7o+yGwLqAWWtZyIsa0foLJth/gEkvVKiZJ3w8gQtfj/hPNP9 cGGiuR3VWBjp/yrHHFXKbqdTKUFAmQGO9L8dVq5KMJ83No3KpuGJBkIWkOnJLq4bHUzZ DbG5NbhhIl6aJ5RGm9V2LXcd6WCWkeVGjzsXpKgRTlYl+WOA6t6uz7aRCfWTVv/rxE3l LAqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=7nGZnmxJ3pdqJ6wmKHxjoSZlS4o/scgVJ84X1tEAH1s=; fh=X6ryCwQ0Aal2Ve8IO+xkZ22uIPGtGnQM9Gfby62l8Cw=; b=RRTI7ZQndyr1A/Md5eTRVx4+VhBz7r9nSNifFY+V9GBJboixPxc77d+F4ZTT8QewyU dZYPWFxeEr3HWBkMnj3G03o2ODZAGFi2vwWBTRfnYhYR1XXZmqvyzUz2eOQD3NSe0MnU ZGH8QsO9L7bBBFJsug7ZvzHxk7hRSR3/QryHWyLB8tGnSit8X7GrPpfWPO0HvV/KWkbi GOop0MTwuxjmV0p3AMKKzzTGL1/TeWJV/mLajx0xto9SdR+/6w62pGeTtz+9BxfK6elL MYCM4rADfhn2w2dXS611aNmzCwLHSLKpUQAsqzVYBhxBupDeqYvvOU4MfoqSZqk2jyH3 +5/g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ly0XfBQ2; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-29729-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29729-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d16-20020a17090ab31000b0028bc0414971si901130pjr.143.2024.01.17.22.02.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 22:02:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29729-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Ly0XfBQ2; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-29729-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29729-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5AFE828728E for ; Thu, 18 Jan 2024 06:02:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E5F0B65C; Thu, 18 Jan 2024 06:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ly0XfBQ2" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E222CB641 for ; Thu, 18 Jan 2024 06:02:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705557749; cv=none; b=KJCHfrtZPpNsCd7aAflgaDbqs2BaUw/ufhbCsJ8TNs6NIrPG4BV6vzCTMxYt3tYoMcwJ29gEOmNfSanPkKEnQMSH3XPLYpXXM3EC0bzTGQYDRyPcbmwWacZPBUhDh6Sqa6q6rtDa2huVKOI6HTq4xQBqu+lvAgS04AIlcfly/wE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705557749; c=relaxed/simple; bh=u5RaG/b4PJwUTnZ4ynSVNBmNKKCbc+bIbPvRY2XtEzg=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:MIME-Version: References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; b=EWHTiNezULjzTIj4ra8xsevxrbhhe86KI8TiHa3TPh9tCTlN0QIZKy8ifdLq1rQbBa6wC2EWfLeCaJLuqQGHn+iSZp48K/euxP95HNxC+P6maOxwksDsW2HPnnNgwVLCa88PWrmQZwGi1oO9fkWIQYum8b3HOgeDEt+FW5gsgho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Ly0XfBQ2; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a2ac304e526so1174613466b.0 for ; Wed, 17 Jan 2024 22:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705557746; x=1706162546; darn=vger.kernel.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=7nGZnmxJ3pdqJ6wmKHxjoSZlS4o/scgVJ84X1tEAH1s=; b=Ly0XfBQ23Fhj0TGVr9IWC9zTGMyuAwRnc63/qpxHvop5SOIpup7rzbDR5rbtR4xUFM AEUu91f+DfIPBBWBxWyt/ZN3iPBFLzWEfxp+GGtajLQ8GwYnSzRzOo4mFM9vT/TYr8j1 kjmO203b74+XtV4qOQCwnvVKqFoUwmQKWJNIHxHB7EsFm9l24ZRSuS12NglUia06ywfR UatGA30NaC6fLc0s7EdO/XubUbUwdFV19rOIkEr68zILaUwK7lw0AVFpIgMhMQ8DrnV4 3/R4M/Z2rwXMUbkHI1ED/tVSKx1EaGSEkYt4hV7Fnn+CRDLoS+pSdpqmEmJCs1nvhSNT cqtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705557746; x=1706162546; 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=7nGZnmxJ3pdqJ6wmKHxjoSZlS4o/scgVJ84X1tEAH1s=; b=PtOomfu27TRcAYFMP2IMcSr4N9JzAi7enr31XllyoH+td1/6kRc0hVg3Yk2RJ3WYva AlCVyCeQgoSaOgSfAhCnuEqNB+mazg8ILUqDGx4L0+oHE2TgjU84ZtSM/SvHMoQ2aH9r IcrSdFJd9pggyxoFgOaiYbE1Wf1lnA61D0qfIn8UTNrh5ga/N3mTv046aa6XuedCJR11 Hgm6+7CgaxsNlMukSyBSOCn7kXb3GqE0fQ21Dkztiyk4jpt3k3gNPcBy0f1RRi4bdHxF zn2QAsG8ULyMOQdPMf3Y5itdJZ0I9smmQUGk9Gidd+6KYvXd/HW/sBrN7FDyJ1bkwEF1 iUvA== X-Gm-Message-State: AOJu0YzYocE3m5mzLQrRsce3fkGdVj+2tdRLHkBmzRuYrDc5ZsSBhZkM 7qBBXMwjT6lnfkQIXng683EZTgv4/Rz/LxgU1cfg/MJWs1WJfe0TYNZU4/cYClSE4hgCAeilbj0 V8s1+V8IM15rp79c7h++56tvpznQDhTy4jaXy X-Received: by 2002:a17:906:3797:b0:a2d:b4d3:b89a with SMTP id n23-20020a170906379700b00a2db4d3b89amr176271ejc.134.1705557746073; Wed, 17 Jan 2024 22:02:26 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: Yosry Ahmed Date: Wed, 17 Jan 2024 22:01:48 -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?= , Brain Geffon , Minchan Kim , Michal Hocko , Mel Gorman , Huang Ying , Nhat Pham , 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 That's a long CC list for sure :) 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. I think the comparison to the swap cache may not be valid as the swap cache has many trees per swapfile, while zswap has a single tree. > > Moving the zswap entry to xarray enable read side > take read RCU lock only. Nice. > > 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. The breakdown looks like something that would be a development step, but for patch submission I think it makes more sense to have a single patch replacing the rbtree with an xarray. > > I expect to merge the zswap rb tree spin lock with the xarray > lock in the follow up changes. Shouldn't this simply be changing uses of tree->lock to use xa_{lock/unlock}? We also need to make sure we don't try to lock the tree when operating on the xarray if the caller is already holding the lock, but this seems to be straightforward enough to be done as part of this patch or this series at least. Am I missing something? > > 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 > 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 >