Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp589217rdb; Thu, 18 Jan 2024 12:22:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvL6ioqDiC/XdEQtenYOnnkRN4RiHeHMrrU4L0m088nH8H1hRgkXZVcWb8Gy7YRV/i0Ivg X-Received: by 2002:a1c:4b1a:0:b0:40e:9706:9a42 with SMTP id y26-20020a1c4b1a000000b0040e97069a42mr233152wma.29.1705609330090; Thu, 18 Jan 2024 12:22:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705609330; cv=pass; d=google.com; s=arc-20160816; b=GzzJSgeBtPHfuFcjN4SlmVhbCawHtJTHqP+K13WfaHGu59ijAUOZRG/0aaAMKfv9KT Iqfvo+6AHFbj+xwPuttxWRfOooex25QK00Ej03gO9WIdP1LInDA0R8uCIKb7IaLeigdO mEhCNigJVi4gz3RDeMXmhBWfpXIg6vjMZoxOjKPncc+GgBFa//KQGthtSj7TC40EMkf3 U1L9mVbO+MvXFXN5X/vF2gRi+USILi+aGRtKoc4wkXA1b8gzhLI0PVhW+tlNrPLaW6/l jPeeWb4vrqRVoEhJ6cf0P3OOTpgU5goRniLu8w+fGcUsSS5wYmY56o8bCEtHF3z00o4I B15Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=W9/7D8zr0MVRfo04WFLM2Hg/uD4l3zgSP1ZQDm3F38c=; fh=Kq+j82KAzmGmQWFXLzKYJ5gjhox7wFalgIKwAznV6qI=; b=el5IeFHl8Q5+Pwt5RhoJbBcNDytG1EVI6TV8qtxyJWRDnImIiL7bq23WGti9piOA1R K6MnomsihJ+gbezVtM8af6M/NVci024UZoAefuJqFyw0lnk51ac4EHfqP4+0R3cp9m5r O/iyZ3ELwxaHrYujchFs9fAyMW93ukxVQhfHGw//c1m9kWJyv7Vl+hx48197Qo21taRQ XSxyn4JXrDL8pJ0i82FYv92Svuya5pdKR7mTE9vOZjDiLydO5F9OaMQpHxg+mQkI3y5E +KL16tfIuGqTUlO0sAOevh6Mp2LMmUerTJjue+RUhroUfkwTgd27zxKnIWyXVK/qUikC 0uMg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=f9C8gWyt; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-30168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30168-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gw10-20020a170906f14a00b00a26e021b6b9si6669376ejb.307.2024.01.18.12.22.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 12:22:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=f9C8gWyt; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-30168-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30168-linux.lists.archive=gmail.com@vger.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 52F4F1F24D90 for ; Thu, 18 Jan 2024 13:52:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67D3425764; Thu, 18 Jan 2024 13:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="f9C8gWyt" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 1F9AA25750 for ; Thu, 18 Jan 2024 13:52:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705585969; cv=none; b=YYB/7Zie8uGBV9UdC6PKVQjcy77FbLEWnc5jH0oo9yKaiZLGVNjjTc1/FRteNfXnIh2gGGUJzP7z+ku9+PuqTZIeMN2dcM2U+zQ7NAz8cbq0uDUMd6XTR/xVEGHj5bLQGcKZyczDxU1cG9WRr97ojAJESWCFEyyfWim+qKb3M0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705585969; c=relaxed/simple; bh=IW1xp/zSK75TUUrkIaLH/h5dTGlIYGYeVzMXhC7sDp8=; h=DKIM-Signature:Received:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; b=iCX6CI2WV84pqR7/8QaDvkBwJhhT8C3qlEf478UPwG24B9+l8dvQ7uXaRnGiWWu04PJrFPNKUOJ01v/GutHQYfRNB9yglrslJtjzjylAazn7H+EPgr8eK7haI8Jq2IOUc36T+gqoWdkJbxtfN83L9wvtgY8qM6Y+/tlN/Bkm3Gg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=f9C8gWyt; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=W9/7D8zr0MVRfo04WFLM2Hg/uD4l3zgSP1ZQDm3F38c=; b=f9C8gWytSlHaoCzve+NEsrEN0e n8GeYnFhf3w7fe6Xw8td+APR8rQXPLRwAF7vCPFKWGXjIaRjskZQJ7IsNalOZHxSiZk47mk2LSHAu kuKrRDc1n2Qpgu26poeGELzxdXMKzUMwCyUyPlXV2zIuEPmDSbxFUUDbHvejN/lhDr5kFGBZoNGtE uPqdWKoRVl58HFQjNZ/83Np9JhKExqqraKnhnOEBoS5sFsc8cZveEvgYe560um2sl3qADr9tyMwXa KwS39DRsbH5X6UfN3pO3ONh7noHCZxZo7ImWO6a6EsYtjPTo+bMGVcX9V1fNtfSdCGpjn2FnvznND ftuH64Ig==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rQSop-00000002JMU-2dbI; Thu, 18 Jan 2024 13:52:31 +0000 Date: Thu, 18 Jan 2024 13:52:31 +0000 From: Matthew Wilcox To: Yosry Ahmed Cc: Chris Li , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei =?utf-8?B?WHXvv7w=?= , Yu Zhao , Greg Thelen , Chun-Tse Shao , Suren =?utf-8?B?QmFnaGRhc2FyeWFu77+8?= , Brain Geffon , Minchan Kim , Michal Hocko , Mel Gorman , Huang Ying , Nhat Pham , Johannes Weiner , Kairui Song , Zhongkun He , Kemeng Shi , Barry Song , "Liam R. Howlett" , Joel Fernandes , Chengming Zhou Subject: Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap Message-ID: References: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> <20240117-zswap-xarray-v1-1-6daa86c08fae@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jan 17, 2024 at 10:20:29PM -0800, Yosry Ahmed wrote: > > /* walk the tree and free everything */ > > spin_lock(&tree->lock); > > + > > + xas_for_each(&xas, e, ULONG_MAX) > > Why not use xa_for_each? xas_for_each() is O(n) while xa_for_each() is O(n log n), as mentioned in the fine documentation. If you don't need to drop the lock while in the body of the loop, always prefer xas_for_each().