Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp168248rdb; Wed, 17 Jan 2024 22:57:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgxF0ClJmcqFc6CLtgCbJZfqqhfgZcKpM1pmuhekXgAcmlhgUKcsHQyCJbZb8MUCDewSfy X-Received: by 2002:a17:90a:8a11:b0:28e:23ad:2d13 with SMTP id w17-20020a17090a8a1100b0028e23ad2d13mr392585pjn.74.1705561078161; Wed, 17 Jan 2024 22:57:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705561078; cv=pass; d=google.com; s=arc-20160816; b=gjlmuSp8To1s+SWIPuMeL03DZQ2DQkvOSBAE31W8IetyRRFIcLqReQpjTEhM+RLEtj XFNdcc2Wq0NjjXqGeFCFn5Pcc0xju42uc1MD4cEBS/55GdNsxRUZCjA/jRQyqIJF0L38 QJ95qTBnNLh7IcJtX5bIsjhvJVC0dV3pOGeKl71QBtLpcfcu04PS1U4M9phO4bXK2iIU y4uv8biNxSa5HZQz1Kk8BmTd6t2CSB3vSjvrM3EhAyQ+1I1gEGN+aJwkMExyOKSCoSZT V4GzvKgJoq6PAgaNXjTuwOe9hUsg1Brc9njt+KNgsYGO/RtwBiXflGfa/IA0fAgoJBLZ VF1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=HYP/cl0xfMYStGxHC3bDdvWKef1/hrUDd9p4oYOcRUk=; fh=lcCvUupxlEJQDCVRavkHnjDtibv3mluG8Ng9axgH8l8=; b=QsJPpZCQUMWLbtgur6qHWylDzl3CKCDpwZuf40R9z9wwAiqiyWGx8rJqrvgo8ikz7g AyrP9CuKYPlUt4+KbhOgAZe4NhTPnDJmkmAv1t+bYw0oGhxIHHCO+tcU4ZzossROofUC eFI76qsmiVFJ+cpyAPy/Runhr9pwWtk+wX97de2LeIjZgnzcqmX0Z8A7LQWNLNvD3rYd +3uIHs7Ozn5LESOGtdF3ngVTFY6O9en7h3qGLKNrTY149P2RTf2hxjbUyPMVuaiyzvOH 8AWMFPX59i4Sh7XXg+dKtaQVytlO19YuWUp3utlAcMHpk/DFDgA/MgKReZHoApBT+148 bTCg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=IgYNv4x7; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-29748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m8-20020a17090a158800b0028e79c30119si1009527pja.90.2024.01.17.22.57.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 22:57:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=IgYNv4x7; arc=pass (i=1 spf=pass spfdomain=bytedance.com dkim=pass dkdomain=bytedance.com dmarc=pass fromdomain=bytedance.com); spf=pass (google.com: domain of linux-kernel+bounces-29748-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29748-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A7BF5B23DA0 for ; Thu, 18 Jan 2024 06:57:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42793946F; Thu, 18 Jan 2024 06:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="IgYNv4x7" Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 9CBF19444 for ; Thu, 18 Jan 2024 06:57:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705561065; cv=none; b=F8czGfG8HkfzupMr5qcPnonNtKq74YQ2sqWMpGD1g5m4gniYJrdrUZc3/AWF37ZosRKqyIYysbI3vSe76ZreVHYHGHo8ibqZqcNb8ozMRZsSTslOxPbW1oxngfw/bqLgkTLfRAd9dmA2SrHPEL/eH8ERE8f5HIyRSq3ybERBtBY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705561065; c=relaxed/simple; bh=kG+rN8aFxG0mxJryn3v+GMXskNk7MkMH9uZygutc9Ck=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; b=ugvdBN4UYsbVt6cGGlS6Z6KM9WCePDPVxxM981XkrgtfdpklCiKnmu7e4nRtlzI9h3maaTSfGhNJHwbcRcjls8b5/qhNgiJ7Sk0Gdzr9LjofmbJ/v5bz1zYsSn6EClxMb7ufl4M3rgjN4NFrTJOujEAA4GcJcW5GpA6qJeOsWuI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=IgYNv4x7; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-28e7673233dso2251082a91.3 for ; Wed, 17 Jan 2024 22:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1705561063; x=1706165863; darn=vger.kernel.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=HYP/cl0xfMYStGxHC3bDdvWKef1/hrUDd9p4oYOcRUk=; b=IgYNv4x7P/YYM19uGRJHDJnVtqnqpsaGCeLZCYz5bFB9CSJChl/7RKrmDL+7QQJIP7 scNBddMmN7E/ORxCuhSx3kknU8sdn9DM8t+tki07lHsdXM3m0PtsyUDza1EfITxM/2NU uAubVzeXvIvjKo6xPjxPB30D4qYlp7EB4ctNVzWNY0JiGNud4PsU8hIPYYz8Y8tYdpGy +RSc7Ct9Ml32ZF6R6LdGyHGyfrlwcVIKS5vDBMWyvmUpgkiSc715RLyeL0I/IyAWzKRv hGy727+9lg3Nawka1sScuK1ilgRX2lk1CWYW3yAjZbEZzJ1Ej1KBTSSroRr6prFmYHiA 609Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705561063; x=1706165863; 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=HYP/cl0xfMYStGxHC3bDdvWKef1/hrUDd9p4oYOcRUk=; b=Zq9SRR2RjUP3BRDxHg5YZ4CMiatKSS0na7L/c+rTobffJNOoZ/7gUEKsG3qnKyQgZN MItYYJOFFFjgMPVfn2AR98frPwm1YUJtbgetKS4Dji1FZh4sBObo35YtgNEuAZOX+3De 4JU8ouPJspHArXESIiOVcsuS8mVA2tdVKYGwu6fR44Q9fp66VxU0izVMxPcNhPXYbc6d pkkHi8malUjxYjpSPQuobugeKp5S/w9qTlUo7pZFCCNmwDJ8XJZ9dRbH4gcjvkkOkG3N JnbTSs4Ux+UhT35GXeD9nXgdDpNo04V1cZyIcbzdz/1KH8vpbhfBWex1K4eB9mkWngMg x7dg== X-Gm-Message-State: AOJu0YxSLHbWNsYCDx5GIwskqI+F8q9az8BemBhkqyi/wpI1g5gq0c/8 uwlhQkYwphRciRTNmu3/AGCzvA+rdB/MpO8rZF2DAu/D1c6nW4dhZCLHrIOlbfA= X-Received: by 2002:a17:90a:d3c2:b0:28d:876e:250b with SMTP id d2-20020a17090ad3c200b0028d876e250bmr355597pjw.43.1705561062866; Wed, 17 Jan 2024 22:57:42 -0800 (PST) Received: from [10.255.202.70] ([139.177.225.232]) by smtp.gmail.com with ESMTPSA id pa5-20020a17090b264500b0028e193e1edcsm897627pjb.25.2024.01.17.22.57.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jan 2024 22:57:42 -0800 (PST) Message-ID: <7f52ad78-e10b-438a-b380-49451bf6f64f@bytedance.com> Date: Thu, 18 Jan 2024 14:57:30 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/2] RFC: zswap tree use xarray instead of RB tree To: Yosry Ahmed , 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 References: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> Content-Language: en-US From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi Yosry and Chris, On 2024/1/18 14:39, Yosry Ahmed wrote: > On Wed, Jan 17, 2024 at 10:01 PM Yosry Ahmed wrote: >> >> That's a long CC list for sure :) >> >> On Wed, Jan 17, 2024 at 7:06 PM 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? > > 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). I just give it a try, the same test of kernel build in tmpfs with zswap shrinker enabled, all based on the latest mm/mm-stable branch. mm-stable zswap-split-tree zswap-xarray real 1m10.442s 1m4.157s 1m9.962s user 17m48.232s 17m41.477s 17m45.887s sys 8m13.517s 5m2.226s 7m59.305s Looks like the contention of concurrency is still there, I haven't look into the code yet, will review it later.