Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp163091rdb; Wed, 17 Jan 2024 22:40:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGas04iBik6je/dJkqxPEFSjFpmcvGENjBCX/irCGwcf4VIi04t1I9e9hKzIvrcUeG8BWgd X-Received: by 2002:a05:6a20:4295:b0:19a:ef31:e8a9 with SMTP id o21-20020a056a20429500b0019aef31e8a9mr451553pzj.74.1705560032912; Wed, 17 Jan 2024 22:40:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705560032; cv=pass; d=google.com; s=arc-20160816; b=wu2fWKG/urQZ638t6BNkhHxa826olcPaDKU2uoRzxesmRlHE79+djjlqvDAv9MZr9d NwmGzfZfJjXtXmO7m02UuPOL+QjiCA05stQ+9JnJYww5L6nVh44jhpa5/f2UzvwkS8Vl 6BkyLVQLl/xDsJ2QV7iIF3tDbvL8VonnzW8Mrw3i9iY7co1OSC3L4zR5BQTGGfFnYCce alAwD69fIrZFC7M/9bPaQW6yKf+T3vNVLrsMIxmO0hz3iFmICO93zAD9E6PnpQmSeClv vY1uqQL8xPtVNy1NChzvBUmhOSYIT3GOVbEnUXShqxfdMFzPsK0y+LtIuvdWJ9ks2FUy I8/A== 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=Fo8gKI5wcPqBhTE9n7Z17rjeWkfglngA29Ql06ELL7w=; fh=X6ryCwQ0Aal2Ve8IO+xkZ22uIPGtGnQM9Gfby62l8Cw=; b=szQwbH6EvzCyeEiV+6yRgvKy4szQh9sj+1CichdE9Y8jAy0U86hnenquPHBuTv04az poUH1DyjPbsALrwiTNHRH2NibQzMVTjHc5v5e3YWncs2jLpNt7KPCRdev5QFwScDYZqk 6GvlMzumrq3+vie5bL0FYGxL3GQqVC0/mZ4eDkVNjhGnf148J5dbIrarinLR0H0atogm CWe+vbJPkya28zhzR2o4TnyHt3xTIYyj+E7Meqf0y2+YwBTc9p4oC58Hffgb3M4yRJdr H1AapSRx2cEsKFvsJ56BoYi3C6GaDtr51LQzaef2x6mSYavPTKRED3wK2K2ZCXFzXyDD HXdQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tLbJWL+A; 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-29742-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29742-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n12-20020a170902d2cc00b001d7073d2f8esi462578plc.364.2024.01.17.22.40.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 22:40:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29742-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tLbJWL+A; 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-29742-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29742-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 59CC5284BE7 for ; Thu, 18 Jan 2024 06:40:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B49CFB65F; Thu, 18 Jan 2024 06:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tLbJWL+A" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 4C0ECB641 for ; Thu, 18 Jan 2024 06:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705560025; cv=none; b=MqSGOJ6vxeyH2X5FVwlUGl3kUkXEOQF5D3cZzcJBGV06orn9sFedRTmNc1n2+s/OvlyJbdbp9Ef/Z6UBtirks/Lr6pfLlyBifjqqsUK1XJHpuXEDJMwFyap6iEOvm4yYFwOPsxAsTNdc6z6kfinj1bYM/XneVc2/2c9n2aRvuwA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705560025; c=relaxed/simple; bh=Fo8gKI5wcPqBhTE9n7Z17rjeWkfglngA29Ql06ELL7w=; 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=aRglJkXTNd7NAhtpuIbxJ+cMONTMuriluSBgyfgv1yP294mQj2QCVnTIQj/pkCO4JFSBAAK2sDy+BHLysiibDEI1e6dZP/JTTlnZCNWwzX/Npu8zx0RkAwtyMszhcv+YnnURc/aK891uNiUwbAlbn46g9w1uWcUd0qcCTHhpYuc= 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=tLbJWL+A; arc=none smtp.client-ip=209.85.218.44 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-f44.google.com with SMTP id a640c23a62f3a-a2dda9d67ceso456216366b.3 for ; Wed, 17 Jan 2024 22:40:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705560021; x=1706164821; 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=Fo8gKI5wcPqBhTE9n7Z17rjeWkfglngA29Ql06ELL7w=; b=tLbJWL+AMJctIj7G5NRCj3pGWCsyJxQ38S/ZxFUEKCtdfp1ij+aibIX6mHe9xpPz7S XyrBGpUV4/MfCsPKlqscvazrhfyeohs+Mj+98bB58Y4zN79GNPOhDFdOOnN6DMZLXUiz UJIp96WFyDQwBtgeDeWyldbUC/mHbtPD+j2ufr51MWLEu3VEVCv4V0kF3TGM6XYDJmdb k3w+I8WaOtlg+a//v66EpKwmvw66fHgMLFYkcO7SJRVBxhaAVnqFAI4LlEFugXeSMMVm JEhswNjnJ+c1JzpmlUyFf0zubXK3dyOkdndgV9pHzZYPaFpmQS0zYQeUgwR7UosiSseh 77IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705560021; x=1706164821; 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=Fo8gKI5wcPqBhTE9n7Z17rjeWkfglngA29Ql06ELL7w=; b=PeN1kQ1fMgnX2LW/EooNN6ieLaJSfQVrxChXCpe+iaFnBXgo4xrnNT4qAgrsdW5lJD 5fVQVOIzDh8x50X52KLXWtFwmwiWZ5zX0KqDT16O+JMHK+7xmiHWYgQAvKvwzWsIJ1Z8 MvRAH+wXlR3hqsdAN2FbYGE6u8UrxknM/mI0IEdt2ZXjlNE5XVaJRAGac4oT9zJFC+Wn fUhMj8eV3So7mWbckQxGQjlI8/CEqEA3QsNbLUCePke0mPQAvoABL0vaNU8mZa+tqaff 8Bei1iGmon7TMYhHPto6uNx7Cl+nFxo9BOOWpF8/24IxpSaud0Pi/1QpbG7X5PzdfUUN 0MEw== X-Gm-Message-State: AOJu0YwHeiTA7meh3slw56MAmIAxXTXqnp1H9QfcrwVQJmAY1ytPn1s5 MiFea78SiPDglwYjMto9+Uq9jevdOwOw0NnkxMBaJcPKkAEhne2+FN8auOi7mTPfcpeoY+/L5XL RZzDLFEl+eibSYrKxSh60Oo8u5taDpQtttJbs X-Received: by 2002:a17:906:5916:b0:a28:f6a1:f0c0 with SMTP id h22-20020a170906591600b00a28f6a1f0c0mr173495ejq.103.1705560020964; Wed, 17 Jan 2024 22:40:20 -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: From: Yosry Ahmed Date: Wed, 17 Jan 2024 22:39:45 -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 On Wed, Jan 17, 2024 at 10:01=E2=80=AFPM Yosry Ahmed wrote: > > That's a long CC list for sure :) > > On Wed, Jan 17, 2024 at 7:06=E2=80=AFPM Chris Li wrot= e: > > > > 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? Also, I assume we will only see performance improvements after the tree lock in its current form is removed so that we get loads protected only by RCU. Can we get some performance numbers to see how the latency improves with the xarray under contention (unless Chengming is already planning on testing this for his multi-tree patches).