Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp42438rdb; Wed, 17 Jan 2024 16:35:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFrZLkMnCu1fhXpbq2ichkeKJkz7gnKn2ckn1JwUg/UFZXji8uOJ13AFPMwtx6np2oPLV2J X-Received: by 2002:ad4:5f8d:0:b0:681:35b:ff6f with SMTP id jp13-20020ad45f8d000000b00681035bff6fmr202877qvb.29.1705538111015; Wed, 17 Jan 2024 16:35:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705538111; cv=pass; d=google.com; s=arc-20160816; b=sRxjrBqLLG4uouuiJu/t0XvsrcIQz7dwn61rpEkJDn9o2vZNTuNmSS2C+8dlv5NcIc AHNjVoGtVcPYGo/48YUQuIDCIJ0SVeSH1fGB5NAY94WL21V3wd46gkdzDAdAKmdcQnbJ HBksL5K11paZNt/BdAi+Lla6RYMFS0/ejpooa/GwZqozrhA7jR80xh3otkCCNJASFRzY 8GO14jVVIiGrGZeWth3c9hZ77+KRDD7rQtmu3ZvJEz7sciCuBnBjDx6+/ACoSqWmId85 uRsIbpJ1MqYW4dmvuGAk8Cw1EE2XBdQvNsYQBiS7aZWij2EMcmWPU4aTP5+otUZR6ZhQ W1hw== 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=QHr9OYj+8osifau/ZxeJjzIY/aqizhg6RN0qn/bjsq0=; fh=z42tYhmEVyKbvVCoIn1ah1Gr9cnGWJFdg9VEk4s9rHY=; b=M4YVlx7HMZ6IG1YsLH4V//FxI5wrEsSsOyyF6WSMMO7u5JLJVP7i8m8NBEfVd2LGUR 8z3Y9lNQI6vyWDG1VneQzcR7hQDjLip9E3EkCp12MtCivKZ4Q6keYyXRRafwcCrfj0Cu KMNIIhLBaH1t6/iik/bcoY4+CMLDnyzQYf0xoI0tbcXVqMoGVHfBn/jSmpIBsX0qZuDd lEE4S7eKCxs1RiHtu/2KysyD5uyV3UGFlmYEZHWOmytRWl/z52svHBbZM0dGiv2LJ0l8 AeJU3/pSQIwi2H7J4qs61I3sWybD/4WHZ+9PcnXz3taEzxpm+GAFtAM0Qs5Jf3bICtU1 l2ww== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=IvLn4M8d; 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-29593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x7-20020a0ce247000000b006816df533casi3972575qvl.307.2024.01.17.16.35.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 16:35:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=IvLn4M8d; 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-29593-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29593-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6156D1C221C4 for ; Thu, 18 Jan 2024 00:35:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 757B21371; Thu, 18 Jan 2024 00:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IvLn4M8d" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 25A25A20 for ; Thu, 18 Jan 2024 00:35:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705538102; cv=none; b=odvBoixEdU+QYGTPsBUu4bTnFoYf7C48DQaaJLTq8w+IEBNFvHAWgnRjEAwQPmC2+Twmp8l/kgVPpXgBAh+cmx0+gp4HZ4RNGVcrejICeWb/ClKJ6795qsJV1WS7l+dvvQajyengFrzPRV7GjpoJkbBoYZ1rya6CTurJb3cC1FU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705538102; c=relaxed/simple; bh=qcqd6AUvMwYNsZlOf7YHd38WVMzw7ST5ATjLnWUfFGA=; 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=hrIRy3HvAdbHhVIbPh3GJMUqBH79kiGLwL1Xyj68s0u1LYmC7YArWlwgUvrMg4eYTymq4TIry1NW7oTVyY4aYeFqM3lqua8dAnTaGkZVNVLzClM5AHa8mHNAKNQVFCqpMqNbat7kB2UG8zG+IOcgkoeNRRa/MO6Kdrcm1XpHo3M= 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=IvLn4M8d; arc=none smtp.client-ip=209.85.218.50 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-f50.google.com with SMTP id a640c23a62f3a-a298accc440so1429503866b.1 for ; Wed, 17 Jan 2024 16:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705538099; x=1706142899; 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=QHr9OYj+8osifau/ZxeJjzIY/aqizhg6RN0qn/bjsq0=; b=IvLn4M8d5Vm6UphCxLGrMlcoH46ZVqgpdlIKEBT6pja4q24K5AJauiXUjwMfQu+R8f XlUyhEWxty0hSBb0q0r9dFHhcOf5iabki6ZPS6i8o6lgMXfqWmGN5rd6A71LMQLV5YjU 4N3qH3ZBcDUjmhfPJrA4UCRj+qJpIeQ/Vu8CoRMHJkS4T+QuL5LsYq8GENmFdjtzcem6 8mnljbn7wQwfGUXBmTPmwbAGWKgbPFfod3yMAxHapS7LKOz1J/yZOWQExXkl+rXN1MtC DjMnWEG/3WRq/Qo92WfEICKQOjRy626DXT8FXUsVOL2OAbJxn/ZURBdWswZwWatecooa kBGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705538099; x=1706142899; 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=QHr9OYj+8osifau/ZxeJjzIY/aqizhg6RN0qn/bjsq0=; b=cvqmheP6IXK6ApTC1Bizu30XzisZGNQtCIpV3+7qlnqwh08kMb9aOFNRMvnQvzt3pN xBVF7/Ergv0eT5J/QsUSySaDnsXTPlYsCh6arLspMmEbaEapllBeH8zQxguLPg3T0TK2 VMhfSqNMfMnynUFE5FeVBojOabUmud0ZAAXwfawuJ/0nWTng+KqSKuFCWcH5/VOB9htA Ncd+4ONmVjSWGPFAu3oKv1UFsNEUR9c9vNdaN99lU11IWuui8o/5BsjGJHJXUFwyhPGk Ir9QSKVhITw5pT2u1fkAMs4TBlFVSPE/x3DGOMaBPz4pMBAy+InwVU2r5ZubGNef7UY+ hoXA== X-Gm-Message-State: AOJu0YwXMAP7Vmg2GDtMeR9mr/M995llc4B5ywcf/R/bKxRejiuoBUr7 mh+V+vUSjlM9cBBKpn1LZW9zxpwPRZPHx/mg9Sim6rDrtysTAWkmbaj16Sy6mF3XABYcxiPy4n8 z/+WAA/5vpjefYr/nebczOEq//1jrV7SVlvx1 X-Received: by 2002:a17:906:9c8e:b0:a2c:4fc6:15d9 with SMTP id fj14-20020a1709069c8e00b00a2c4fc615d9mr26497ejc.20.1705538099259; Wed, 17 Jan 2024 16:34:59 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240117-b4-zswap-lock-optimize-v1-0-23f6effe5775@bytedance.com> In-Reply-To: From: Yosry Ahmed Date: Wed, 17 Jan 2024 16:34:23 -0800 Message-ID: Subject: Re: [PATCH 0/2] mm/zswap: optimize the scalability of zswap rb-tree To: Chris Li Cc: Chengming Zhou , Andrew Morton , linux-kernel@vger.kernel.org, Johannes Weiner , linux-mm@kvack.org, Nhat Pham Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 17, 2024 at 4:18=E2=80=AFPM Chris Li wrote: > > Hi Yosry, > > On Wed, Jan 17, 2024 at 3:48=E2=80=AFPM Yosry Ahmed wrote: > > > > > Currently the xarray patch should have everything it takes to use RCU > > > read lock. However taking out the tree spinlock is more work than > > > previously. If we are going to remove the tree spinlock, I think we > > > should revert back to doing a zswap tree lookup and return the zswap > > > entry with reference increased. The tree mapping can still decouple > > > from the zswap entry reference count drop to zero. Anyway, my V1 of > > > the xarray patch will not include removing the tree spinlock. > > > > Interesting. What do you mean by removing the tree spinlock? My > > assumption was that the xarray reduces lock contention because we do > > not need a lock to do lookups, but we still need the lock otherwise. > > Did you have something in mind to completely remove the tree lock? > > In my current xarray series, it adds the xarray alongside the rb tree. > Xarray has its own internal lock as well. Effectively zswap now has > two locks instead of just one previously. The xarray lock will not > have any contention due to the xarray lock taken inside the zswap rb > tree lock. The eventual goal is reducing the two locks back to > one(xarray lock), which is not in my V1 patch. Your understanding is > correct, the xarray still needs to have one lock for protecting the > write path. Hmm I don't understand. What's the point of keeping the rbtree if we have the xarray? Doesn't it end up being more expensive and bug-prone to maintain both trees? When you say "eventual goal", do you mean what the patch would morph into in later versions (as in v1 is just a proof of concept without removing the rbtree), or follow up patches?