Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2956793lqp; Mon, 25 Mar 2024 14:30:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVB8rOa3nrlUGikscUdw+uU8sHUdEuBnbmhTEfufgYybUxL28186qcU69wqUaSHzLyAIQjH9LyxD3Q+ip9vthcBPNmbct0yvlIEROxQSQ== X-Google-Smtp-Source: AGHT+IF5DXyNIdJ0QsUA7VnHEh4IihRVg5TJHlLT5Fzs8IXzieOnaPFt1Cxa8/I96J5oyg/8uVAD X-Received: by 2002:a05:6808:1247:b0:3c3:902e:3a4a with SMTP id o7-20020a056808124700b003c3902e3a4amr9427439oiv.17.1711402222898; Mon, 25 Mar 2024 14:30:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711402222; cv=pass; d=google.com; s=arc-20160816; b=WbTWBXD4oyJVxTyOzYOGSrY9R380dNOrH6z+V331wwMdnglLQGANy61bf7RTunZn1H HpdHnXBq/YCCtZKsGBH4jX9HhpWZQDZsUjDARMJi2nBbK1EwymGGzorK/fxzUilDsUjd 63kDgUnGk9Ha016sS55BbtZZmou7hdFHdZvh/i28IB8ZVMJppIkyDba98bvHEoNMGwSj Vjzh8KztNsTDB2fcN+D8+sULW38EWEt3SBUI3mUrr1q8ee4spZqsUeHz4xn1KJ+74123 zP9QmO7baWo7kOjD/z6P2X/Djno8ErGvKkidQrjAEt16Sb8uXyU9Z3uPOErEQy8w3ips d93Q== 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=Cz0MAcdsHg8g8zFSugRiesOtw7x89juAn9kSx7uRt6g=; fh=a/TC/8MM0oi3OBO5lXAZSknSMAnPdnvl+s7q6Bb8sPA=; b=UefY4m/Bls8b+PGngHPa7nQbt9SQ5ham4iejVWB+7c7FZXCCIqHejvEQB2J1IYhoAH xkjE8rn+jhFaTpL0jYj1DH4dBMEPycDxtiWuwtYG6BqJgyo1KvA4rD652vEufe9JCJMP /y8CG+ac+MlPaW9hWmbDRolrknpVjx/NA8AL6ySjDu0ZwpztiSC4KovRv9Yrybv1XEuJ LMEIK8+7+YZ/WOAnTsVrs/8VrxIOxO6QsVu8jPdiboBgxSuKKFgszJHd8HhffFp32DuV i856JVMRPDzrIE6wQz3isVjyznb9D22pdY9SjFDtjAm56mLKR9Vd/M0k3IE/UT/nn2Oz ARwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZQcB5Pz0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118042-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118042-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z16-20020a05622a061000b004315e23ccd8si1983237qta.197.2024.03.25.14.30.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 14:30:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118042-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=@kernel.org header.s=k20201202 header.b=ZQcB5Pz0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118042-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118042-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 9B7C11C60744 for ; Mon, 25 Mar 2024 21:30:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2281C6FE1C; Mon, 25 Mar 2024 21:29:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZQcB5Pz0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E0B56F520 for ; Mon, 25 Mar 2024 21:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711402194; cv=none; b=BO+RRtyGJOMb+YBL3SfQrEFjGXUgDOLGMF1Ti/ClglQg06L/7JtCSdSgNqiNIgI/8MlMLd+LxSkeU4VLzarz7L01oveIlH2JHx/8Lh7kJJPpAit0wK2rYou0vJXxARgc5fu+xhew1Y3xS3Tb4mvM7kO7hQkkVFfUVlufcfzeJ1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711402194; c=relaxed/simple; bh=1lnSa8EaNX8MXlNYG3Qt6kVt761yhy3NR6trhzbBYg4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=UxWmw0LunJU+/iSdhZHDdaDs8BZ/yUY5gCBzV66Ogxu0dHfqy9meDOkiD0CShzEleYlNN2ozWm6ec4Oloo0T9xbqOaMqzxpjdhhrVjA+p+dtuxyVyd2uz1LC2yS3RawCk5R18zfrdrnRvt3fgSsWn+FMyu9j/fTvx//vic7/ZG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZQcB5Pz0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3290C4166C for ; Mon, 25 Mar 2024 21:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711402193; bh=1lnSa8EaNX8MXlNYG3Qt6kVt761yhy3NR6trhzbBYg4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZQcB5Pz0y5artKZz3sO1MKzvSHSvnB9HerkEl0eqg7wgEKqtQLNpcxZi45jDlLfpD gyEEvmYb54jcPhYYApSSKpuC6xbda5zFaGoj3eLI2dfsYk01J/3/8vgGGoRCxqL76+ QjSagz3MhIuKxSTl8LhXeK0k/vQA+D1ZP1yfW+IppSsgLliZp9pDS0MLYevFBzwa7o +27rPP36ZKMOnJzyG9XzU3DZCDs9jjhZRxAzGB4cmaaTfbmc3t2Q3UBYwBlD3EEPSy 8VsXZY+Z0E0z5QCCi0xGra/Ksy7IYoZkXK/t4U7tkfJDozIz9vHViF6+Ilu7juzFYg /iXVLWgeIrjjg== Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d6a1af9c07so69660091fa.3 for ; Mon, 25 Mar 2024 14:29:53 -0700 (PDT) X-Gm-Message-State: AOJu0Ywe89ddPSyqfv0XtFstWeO8j8oztHTv0b+gJZhJyIg/wdNdA8Lx d38j1vxvUTacQiQqzWFuFbK07wUz3DR48pNj5mKfvpfYINC2QstW9A/UQ4Tr0AeixuC1Axpcopt x0Tkj77roKtNo3OgBY2LeTQCJ8w== X-Received: by 2002:a05:651c:2c9:b0:2d4:a232:757 with SMTP id f9-20020a05651c02c900b002d4a2320757mr4659418ljo.7.1711402192564; Mon, 25 Mar 2024 14:29:52 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240320-zswap-xarray-v8-1-dc08ee9f8744@kernel.org> <20240325133546.ffd728d1c309ba58eadb179c@linux-foundation.org> In-Reply-To: <20240325133546.ffd728d1c309ba58eadb179c@linux-foundation.org> From: Chris Li Date: Mon, 25 Mar 2024 14:29:41 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8] zswap: replace RB tree with xarray To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yosry Ahmed , Nhat Pham , Johannes Weiner , Chengming Zhou , Barry Song Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 25, 2024 at 1:35=E2=80=AFPM Andrew Morton wrote: > > On Wed, 20 Mar 2024 12:31:38 -0700 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) > > > > So this conflits with Johannes's "mm: zswap: fix data loss on > SWP_SYNCHRONOUS_IO devices", right in the critical part of > zswap_load(). Naive resolution of that conflict would have resulted in > basically reverting Johannes's fix. > > That fix is cc:stable so we do want it to have a clean run in > linux-next before sending it upstream. So I'll drop this patch > ("zswap: replace RB tree with xarray") for now. Please redo it against > latest mm-unstable and of course, be sure to preserve Johannes's fix, > thanks. Sure, I will wait for your mm-unstable update that contains Jonanne's fix then re-submit a new version. Chris