Received: by 2002:ab2:5c0e:0:b0:1ef:a325:1205 with SMTP id i14csp265084lqk; Thu, 14 Mar 2024 02:25:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6zc1lY9t3G6W7gIjF984Z8gF6RQI6VCV5hLJW/5QJCqot6V8lgAse0YBigmSH5S2e/TbB3Ju72V1UE1XwUmyVFNCNYaEUmt8uua1ZIQ== X-Google-Smtp-Source: AGHT+IEf0ZrlBIbcl+DOGYN8LklLQ/hqTBRg7WCnUuUgE+W3P2yd5R1TCq3mCQ98Q4EVjGuZvx6n X-Received: by 2002:a05:620a:831d:b0:788:4e71:bd52 with SMTP id pa29-20020a05620a831d00b007884e71bd52mr57312qkn.60.1710408327653; Thu, 14 Mar 2024 02:25:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710408327; cv=pass; d=google.com; s=arc-20160816; b=mimA9BizRL4TBFnnbTj9yTCBMqv5XAeB97VCxJm9AbWr2phR4gltlH+MzXgpWW9a91 aIrjsp0eBKRpmjZ4t2TneIaMmoEKkZuZLHFok1GL0j3YFpTXZdfkE2PygkkYEBNkedsB X9aUhVvFOUdSoH7oJmIvj+28L37rkQxAEhqT7Tc8RO7OTWXNPNgpFcdziP1vxYkvzqkC mX3pJtcKzcQHANXe2iTpT8FQkMDRXrunQ9Y2BpDZ2TO9seBXwFs2jqMYNsuZCa36b2XP qiy1Jb4BJAdpQZQ9rCkl71LqgMydBmQrlBknZ8td8vb8xqb7ke95LfwWxWWaVL3LNw3Y MI/w== 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=ocCihU80Xv40gzd79kv18kcNVazvWx00n3HGC6M1AO0=; fh=1r0obvlhQdlIOcpBaLi2swgA40dz64qlZcdCrPz7YmE=; b=Q2HxxBkko4ShaPix6Wn8ddeMzezkXMuW9tLys9iODH9G1iNx9tN66OM2qt8NpLcEnS 2OmNjjSL7kFc7MP6uxFIkTLjhhWXFGXIhwKn4FiontSA2mldZJ3CMIAtKanLuDmCZ+jZ 9IRsf/tG4s9JzJLCv5wKfrGkylubTbpoUKhjT1euBqY1teOOItPLe2HzHCZNcf5sLUnB c1jSsmS6fXovAhgt6djyFbsUXAgsv3Onp71Wx3AvX/sa3eq/0CktcqD9LhjYrTdxdbw5 vQiyRv3y05IfQ/y2Nxe5VsnK3LVnN5GmOmBOlaJ1+TT8hUR3F3O4Vb92eqD3S4Q+QJ6i zfzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=L8JR2Lfe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-103044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103044-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h16-20020a05620a10b000b0078820c23843si1104310qkk.500.2024.03.14.02.25.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 02:25:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103044-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=@gmail.com header.s=20230601 header.b=L8JR2Lfe; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-103044-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103044-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 61ED41C20F36 for ; Thu, 14 Mar 2024 09:25:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BB746D1A3; Thu, 14 Mar 2024 09:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="L8JR2Lfe" Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 1D01F6CDC0 for ; Thu, 14 Mar 2024 09:25:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710408306; cv=none; b=KJ9jIWk7IiqICvLEcw4FPjqIFmDVLIioyOjL7XSZcRpWdPUl69mrEt9F8gH60YOU3KsNxlsSAji58Bykmx1igp9a9FUmiEKZNhHAnKFYdtzNJiqqKIijQUY7oyMkVcRJsOYazPVxrO7tCjN3rHV9OFlrqk3zBJc3w4h1x8GbDJ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710408306; c=relaxed/simple; bh=6tIt0rGYr3xffVSMMPnAuHzPxCWu+NZvjW36OSif+RY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=DR4h22UmTDobW0lPHR4yzdE/iSdB8nZMMM9GsweBvXy9ZUBx9TavZyNqibT+VdD3uPwUcdTWn9/v7E7ObaO6UPx9ukX3RZq2CICTLPZ7x8K6U3rjoJlgOSXF2KbmXeyWWi2AayyA3PB8qccNN0vXnUz1qpQW75XDXjj3wk8pFQI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=L8JR2Lfe; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-783045e88a6so52184185a.0 for ; Thu, 14 Mar 2024 02:25:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710408304; x=1711013104; 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=ocCihU80Xv40gzd79kv18kcNVazvWx00n3HGC6M1AO0=; b=L8JR2Lfe4xdc1AKMK620t6lsbDvLNgOkiPzYAl1gUjIgjYXifExiq+g1szLpy15JCG kQTn33ZhNVEYYBh4NvVkvmdPo/Tr4ShfVV7+jF42wGBl8TKGV0jynGymJeSvrmEgtJUE yGTi9dicaChPvPqffJKYcIqHkVBITJqpTT1PiaqOHY1bxw5AwzHhDka/Y/j2CqGfquAX OGwPczRIfgOgZGTIKMi8lpXXhOEQ9vnbrKiJH661cvfoCrlfS5/PbxFpynXZJglT3SeQ 5qNr1YGqgbGoQlgGyQJ03Sb+w3GUvKXOIwYbzpwgt6LVTRjKMELjU+6d5W9EnVAzdDtM DpBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710408304; x=1711013104; 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=ocCihU80Xv40gzd79kv18kcNVazvWx00n3HGC6M1AO0=; b=wH9JEl1bALFENFKveXAfW2DIHxeJbWWA8l+YtNhDj25wq0utRyiif2Hn0jXGqZBawN Q7jOhw9C/hWgo3uC64lEoCtPBbgYI5eGf+vXWdg/9pqemwcYhbl9yR0XGDhw1EH8qn6/ QQ1U2+nTQN20qlxt0hGGX722sSrrdhizdcwoS5sKOIRy3O3eetzHlMRDI23IeTfdHD/d 50FoGj7/IC0U1GqYNRC31MmF+5aDSPAaObl49yKPU10QA96t0+57mx33tEHUHYvdTs5h tYeis+mCAuGIYbqsj20ZD2XOruJ7oGJ6A5J3kjuHL6pEpTSEtAZsKpH9QVYr74MxA0dH 4WUw== X-Forwarded-Encrypted: i=1; AJvYcCVfvkSvK+wzdmQcfo/lnCzx80Yoh/b0ajv134qRcjWhGZQdQ3WLGHipVqZVHcjfYEZ78i2Z8rNd5CEAo0U8rnUwg4+rrPYuQ9t3Zqn5 X-Gm-Message-State: AOJu0YwffB9MqX7H0pX543voWJCbTvEuNsBsy+ia7dPscZcSnOBc9Pdi SjXG69q9fmqdPS/DOUG/kwk97/3FvREiJqU+fPsxMIoYkifhx5JPNHbx5DO4SbEt8eBaEMsDuGD yJWy1M2Iuud1oSGb21EoDR8U/zwo= X-Received: by 2002:ad4:4e70:0:b0:690:b66b:c43c with SMTP id ec16-20020ad44e70000000b00690b66bc43cmr126685qvb.24.1710408303975; Thu, 14 Mar 2024 02:25:03 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240312-zswap-xarray-v6-1-1b82027d7082@kernel.org> In-Reply-To: <20240312-zswap-xarray-v6-1-1b82027d7082@kernel.org> From: Nhat Pham Date: Thu, 14 Mar 2024 16:24:53 +0700 Message-ID: Subject: Re: [PATCH v6] zswap: replace RB tree with xarray To: Chris Li Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed , Johannes Weiner , "Matthew Wilcox (Oracle)" , Chengming Zhou , Barry Song , Barry Song , Chengming Zhou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 13, 2024 at 12:31=E2=80=AFAM Chris Li wrote= : > > Very deep RB tree requires rebalance at times. That > contributes to the zswap fault latencies. Xarray does not > need to perform tree rebalance. Replacing RB tree to xarray > can have some small performance gain. > > One small difference is that xarray insert might fail with > ENOMEM, while RB tree insert does not allocate additional > memory. > > The zswap_entry size will reduce a bit due to removing the > RB node, which has two pointers and a color field. Xarray > store the pointer in the xarray tree rather than the > zswap_entry. Every entry has one pointer from the xarray > tree. Overall, switching to xarray should save some memory, > if the swap entries are densely packed. > > Notice the zswap_rb_search and zswap_rb_insert always > followed by zswap_rb_erase. Use xa_erase and xa_store > directly. That saves one tree lookup as well. > > Remove zswap_invalidate_entry due to no need to call > zswap_rb_erase any more. Use zswap_free_entry instead. > > The "struct zswap_tree" has been replaced by "struct xarray". > The tree spin lock has transferred to the xarray lock. > > Run the kernel build testing 10 times for each version, averages: > (memory.max=3D2GB, zswap shrinker and writeback enabled, > one 50GB swapfile, 24 HT core, 32 jobs) > > mm-9a0181a3710eb xarray v5 > user 3532.385 3535.658 > sys 536.231 530.083 > real 200.431 200.176 > > --- > > > Reviewed-by: Barry Song > Reviewed-by: Chengming Zhou > Acked-by: Yosry Ahmed > Signed-off-by: Chris Li Apologies for the delayed review :) LGTM FWIW. Looks like you're sending a fixlet to address Johannes' comments, but I assume it won't change too much, so feel free to include: Reviewed-by: Nhat Pham