Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp478723rdb; Thu, 18 Jan 2024 09:02:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHc0weVzpJclypNBzJknXaPyIs3ZjxhZfYYN4r6USUm0p3ldfkL585R/fjjJoxuOOl6j4M X-Received: by 2002:a17:902:680a:b0:1d4:14f1:3aa1 with SMTP id h10-20020a170902680a00b001d414f13aa1mr1278010plk.72.1705597366741; Thu, 18 Jan 2024 09:02:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705597366; cv=pass; d=google.com; s=arc-20160816; b=fyA6DXbIoKSKfs/dc01IHY8qs+Mpg74j8U5BejSshjeU6NTGNk8fcudVpjWDO6v8VV 2bakoTnMz62sHNSXBV+CkpFo7JLC+pKaL7OpQo3ZMYE4bLVviLI4+GLYeBl4i37xj/2X BJYLbKA1DkoQR4YbRAW9NRdznjHt7+rQOcLy53PzF8fHWptYLZp1bWWAUUYj5gSOvOns GpAzD4Cvnyh6huRTcSDxexoTncd7Fxr96D8k30GJKd9w3m2FqbMu55pkP5LSAnPGhsoc wGQDghApyYrqH9wuK8yystzpfsWBfLQnc3nZ+DPv3P5pN2Y+g0pDmjecAhwP185vn4wJ 5bsg== 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=8kjrBGDaeevj+9jk3sVLGectZbotvZgvQYBHMTvFb5U=; fh=TBCQYozPItp1/pPlHVA/a0Qs3k5CK8Ooz8pKhjEzIzo=; b=GLSCtDgJYvkeEEz82BG6T2k7v1VEKMTr9210GIzwIcz2bUunx9No1IeznkXJytPdmi KBQcTUcY+sxKvVhnLe31y2D3wsYu7Ps9wjHOCtRv1Z4LqC5YOygC6TK6QSJThOFs9G08 lVhhdxR9ZxuZo/4sZt8isOg7kXazY3t513jPCC8qb8sWBftN2kykc2+pnmASDZknRz4+ wAoOCWxLMHV1qO+V3+Y3W38ZYZA+QQ1t1zO9GU5gTpmfOS4Fs5K4R6N7v3cp/f1UOBAF X6Q86KdraI6ACGJnyT7xe8/bcaytO4hn7qdo9H6nfBoolJv/7Am0ahcCIJ4TCN3H2wii JY9A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="N/+XHgjh"; 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-30390-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30390-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p20-20020a1709028a9400b001d569371c91si1605518plo.632.2024.01.18.09.02.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 09:02:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30390-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="N/+XHgjh"; 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-30390-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30390-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DCAD228429A for ; Thu, 18 Jan 2024 17:01:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D11C32C857; Thu, 18 Jan 2024 17:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="N/+XHgjh" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 839F42C845 for ; Thu, 18 Jan 2024 17:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705597237; cv=none; b=oh/KR2vxgpXejTPF6ZPgY0+nQhF+QtiBvovrHLpPrkaok6lhjPnUHYss/Nr9T3OCXdgNdTq8JOMldmtdjf4grYajthYYZnvlsITxjVfGA6kfi/8YavoCfzF6ULINoSuzSEU5VIz8jyPDhYRPFpB47hyQJE7B/Xk2Kzn5EfbHcEw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705597237; c=relaxed/simple; bh=1m1rU7Y8d2rR1bpdRYBhiZEswfbajZFmkz5LTl7Jhps=; 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=NXN3ZkwM83bkzBd8VfzbiKjgOUcIX7lSINzVQUlcYStQuN9rZ0hsXQvC9RMA6PsySNsYV9AavriMYZOLriYwzgEvjX2/f6+PtSvnYTvszW9Uk7poEmVF98WOSojyTzKE9zXVMorzn4e4G5H8oRMSY3r4NlwlVW3d58sGbrMGqbc= 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=N/+XHgjh; arc=none smtp.client-ip=209.85.218.43 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-f43.google.com with SMTP id a640c23a62f3a-a2e0be86878so184795666b.1 for ; Thu, 18 Jan 2024 09:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705597233; x=1706202033; 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=8kjrBGDaeevj+9jk3sVLGectZbotvZgvQYBHMTvFb5U=; b=N/+XHgjhqwm2At02+oHFpLYFf+JI0hb5k0w6bNYKpWQ2W34qfJ/CdPLAr6VupDiKrj kKJN/j7GoQkl42e5vNEfiP7yjUfoEcEd7QVtRRsV5zdWIEE9BpwKkoOW6uRP1I/hxCyZ RQTbCgZtcrdO2R7g9gjuOysPW6TvwAlt2szNye7Kh5guiMm/b/fCPD6kt8dr4jEBy64A cAbKoiUbh8+EK1p00Io3XuLdcywk3MtA7ZHLGGCgxx1jKXpzej2iBihlv5iPsjXj1CWO 0Z06WdzzvjtTZtsi1uJdlKkgPjcy+UCG5RO6R7s7+TXuMcwoUBtPMZ8anTAe3tqQ4xw2 SiZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705597233; x=1706202033; 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=8kjrBGDaeevj+9jk3sVLGectZbotvZgvQYBHMTvFb5U=; b=L4wPI5MRBJQR/484ZHfCV5FtlDzu5IQNZ9XUq+2ebiOM1os+4zEOIcO/PeLINLW/tJ v4Qzkf8O4TVF55PePeRDt4E1DYjmFazpm8EpKYQjbCTlkDLBzJCum+zW/NfZf2WNL4cb 00SMeoTD5S+acF0RXPqZGlKbzCFH093D1mPoSzlIeJCUpe8yWeK1quWXF8CmodnU2BWz Lx/9bBFyRdT+SLdgdJv64u4QKt0N+637DYIN+IMdjp9P68vEBCSFCO1a+wAn7w/ZnyGp q3CZ1yjJrCEBB+npa50VgeSfrl6BgkxLQD7WBBtSEw3rwQbr42pWpOfky7If02/peN+O 8d1w== X-Gm-Message-State: AOJu0YxYhnC4BQO+KWkZLavxfzNqubyDHVzlt0hZTdg7v8DEvE1kZR8O 6fQMx4ll9LIBAI3rqvaUb13YOiA0kWcxoCPzuXxLRhuDnHjnhtpaQM4SYwg3OEHGDBeRG2QFxjJ 4nAx1Cam2U6iyUwUw03TZYCUq1JHF2J1Vfr60szXy45v9Gn1uJw== X-Received: by 2002:a17:907:3c0f:b0:a2b:a4c1:52ef with SMTP id gh15-20020a1709073c0f00b00a2ba4c152efmr1065632ejc.3.1705597233504; Thu, 18 Jan 2024 09:00:33 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240117-zswap-xarray-v1-0-6daa86c08fae@kernel.org> <20240117-zswap-xarray-v1-1-6daa86c08fae@kernel.org> In-Reply-To: From: Yosry Ahmed Date: Thu, 18 Jan 2024 08:59:55 -0800 Message-ID: Subject: Re: [PATCH 1/2] mm: zswap.c: add xarray tree to zswap To: Matthew Wilcox Cc: Chris Li , 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 , "Liam R. Howlett" , Joel Fernandes , Chengming Zhou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jan 18, 2024 at 5:52=E2=80=AFAM Matthew Wilcox wrote: > > 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(). Thanks for pointing this out. Out of ignorance, I skipped reading the doc for this one and operated under the general assumption to use xa_* functions were possible. The doc also says we should hold either the RCU read lock or the xa_lock while iterating, we are not doing either here, no?