Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp591993rdb; Thu, 18 Jan 2024 12:28:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhDaYfmM1kexai9m4Z8UYq5Fk8Xn2EI9XWlwpdlLz+NnM3uE2aQCaQFvFQ25EaTQcArjPk X-Received: by 2002:a17:90a:6f84:b0:290:2494:3d2f with SMTP id e4-20020a17090a6f8400b0029024943d2fmr1251205pjk.36.1705609729899; Thu, 18 Jan 2024 12:28:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705609729; cv=pass; d=google.com; s=arc-20160816; b=WSujawRhKGVCaR17tVFjTqVAOfKBD+9BQueVuUQb9jKeF3UxCZqhSe2Dj3Xd+4QDPl w3K4sdK9gZ4Z/Y4gxeoarjdfQYIq3J3EmL5E6yIzEGUnp0hO5APrwk82UPowlEc8ChCh aelf7qYaTZLWy9q+rPsQxXsJs6+ca3fz/UKs7ROZaxqgqTm6j9+gpP9O4qmtIOkb919B QNtU+CfYSBil9iSLNjEnwUayEMuoYLEw7LN1B2mzD/L31JadFLxjM9sQmeaTaCxOsluf IW/OhyLNCbo5GJq+lBlMX1FczFePrBhXD5KWHPEukfs8nFpJd15EfvG1RxchG17nhP2M KULw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2i/k1Z2tU3KCpUOMZ3sK/SSQo/PyL7UxFRzxbgPK8Ik=; fh=Kq+j82KAzmGmQWFXLzKYJ5gjhox7wFalgIKwAznV6qI=; b=QJ4VJJkOaVB7G51OSozeKqt4WAZnk06lzuxLRbG7wT4dJfBH9FnF13rtwdZ46OmXzf zewqBEW2zcCXRBttduU4Qg/gRwjlFSawTKuzrFA5jO92hKx0q7Y5RZ4ked1G9paM2F3s NDF9rrhBnt8qSghzsp7htQ+9wS9F0h1u2Hls04NMpupsLVZvmV6K2i73opsgqZcVSreg SWQjPSMkTNRs6amNHUBPGLpp2SMrVTD3p69TazDoxFROyjK+84Y1Ixv90sJUwFSRZYg3 +O3idsrCqAa2QHE52N+KO0M/mp5f7O34DrBgjkiFkeyh/h3pNKgJLBwSjtZUYFwelpMg IBVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=SsNUuUkH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-30468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30468-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v15-20020a17090a6b0f00b0029023f51f61si1494024pjj.117.2024.01.18.12.28.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 12:28:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=SsNUuUkH; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-30468-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30468-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 34D14B23097 for ; Thu, 18 Jan 2024 18:25:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA11A2D61B; Thu, 18 Jan 2024 18:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SsNUuUkH" 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 346532C6A6 for ; Thu, 18 Jan 2024 18:25:41 +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=1705602345; cv=none; b=avNACOKIhKbwpO2RFHKk/uUijZj7wONXSgo8KYzoxylvjFKcagKXmpI67FHeHSO4mjnj/gnM0PzHiKpxrCv1juOnBINwOot/yKig7csVfFFUNCyI5BrgV22YctFztUUN0rcJeqfH6+OlKjjFttDnAZmjTq/bs4hIJETxIaZrxzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705602345; c=relaxed/simple; bh=/D9duSKrItHHns0upfiDxdFxl0rUJPb9JNSyJ+gDcTs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tbddXwax0fkyUmcAoZZT8qghlSw5icLNOcXCoSolyM4TaEyrUn/BgzvAuYZzSDsZ8OBf+hyxeiu8bP6H4HOyhMYxsPK8n2sZ2b6G/rWVdeQvaQ4+GOacrqr3czx/xiVlyigKrogaP7WuKOQwNqwqm6qul4TUV8+xFnhUNIIQs8w= 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=SsNUuUkH; 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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=2i/k1Z2tU3KCpUOMZ3sK/SSQo/PyL7UxFRzxbgPK8Ik=; b=SsNUuUkHnxggJEdKhDGSwjWYUv QB23fJ4pju35mJcfq1+iTizo1sbQSKRv8cKtiqzVcCkXD1W03FP4TanC8zcDofzuayFeNFRo09ePs F7ucH4v+p8x450QdZrGsCC1YqGQ6ahbmvHEsWpOjUnFms1MQSTLN14+zv+x4FaBxrU8ottnN38Xkx 7kjYmrfxE4JLIdmkKYGqvPoUgUcMcSsW7l4B99whiqgAVIker7n2KF47sJAwCrGUUBIwEQTkF0dOn 328+YHANH52L0riSiUrTaoanholJk38msH/VLlHCPhOsbXzyE2PCdhKezKTNwHbAtJ8pgiy216MOj JLgXru5Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rQX4t-00000002pFb-1QhZ; Thu, 18 Jan 2024 18:25:23 +0000 Date: Thu, 18 Jan 2024 18:25:23 +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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Jan 18, 2024 at 08:59:55AM -0800, Yosry Ahmed wrote: > On Thu, Jan 18, 2024 at 5:52 AM 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? I have no idea; I haven't studied the patches in detail yet. I have debugging assertions for that, so I was assuming that Chris had been developing with debug options turned on. If not, I guess the bots will do it for him.