From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D545D3F29E for ; Fri, 18 Oct 2024 21:38:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0AA326B008A; Fri, 18 Oct 2024 17:38:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 032B06B00B5; Fri, 18 Oct 2024 17:38:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3C7D6B00B6; Fri, 18 Oct 2024 17:38:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C47776B00B4 for ; Fri, 18 Oct 2024 17:38:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 96E5914024D for ; Fri, 18 Oct 2024 21:38:12 +0000 (UTC) X-FDA: 82688036802.02.DAC6239 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id DE39940022 for ; Fri, 18 Oct 2024 21:38:09 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=a71QD695; spf=none (imf11.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729287356; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=nzyRG3Z7ZIbPjAZ+tjsUIqSFqFzTEvGVVhA8rfQPaao=; b=CxOUcMvHvEC8oBx35QP8MEDakZzmIypTveU0okWuzDQTOOF5BPiVuYrkCntskhcDjihs6q NRXDrza+CKuSuU/48dPW3Pv8Wk3EHP0t3Q2jcB+UBHxIswceKT6/rbzboOygV/szmfBbQL Nn4WJoVSCkgbTXC+6ggbk/+bU9zRdm8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729287356; a=rsa-sha256; cv=none; b=W6qAi74ms54ppzawEPkUA33XfN/vVTAAxrE/KCeUuW9h6toWhRHWnhXUm4j2paZNlmFdlK EPku4f56tHKluQVX22JjwBoo6YE3QOlwvLr0XgPceW4S3bZE+I5MTHf8QqugGvVPG8FxAq TwwL1vdXE20Bc1TOeLwcTLTyX6bpEcs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=a71QD695; spf=none (imf11.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=nzyRG3Z7ZIbPjAZ+tjsUIqSFqFzTEvGVVhA8rfQPaao=; b=a71QD695gI2GeQXJO1lHwGfGD8 ngDqs9+mdtFf4bvRaUwaGnRQPIsGZAmJjR1mL/SjSU05b1V+vYmWFW92aJs66x/GmtlPpv6dYhgav WNJKrrzONZF2sP7wKzcWnOhGKsM7BWIyGUmlD5RkxupxLyTPv2hjzKpd52V4VkuWiza8TN1ugu9ZH tXz25z1GXGzokfKcXdC05X126JuGgNcn/pM6U5GUKToT5xeavL3DSI/ofC+1/HVQWIH6GZi2a3vGp f8l8jtr/uwNSXOXyU2pOt77095+/WLCi6JO1sUbn2XqwWJmER9igO77mTI/9La6eivYrF0Yf9avVK +EalVuXw==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1t1ufq-0000000DcXM-2o2A; Fri, 18 Oct 2024 21:38:18 +0000 Date: Fri, 18 Oct 2024 22:38:18 +0100 From: Matthew Wilcox To: Yosry Ahmed Cc: Kairui Song , linux-mm@kvack.org, Andrew Morton , Johannes Weiner , Nhat Pham , Chengming Zhou , Chris Li , Barry Song , "Huang, Ying" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm, zswap: don't touch the XArray lock if there is no entry to free Message-ID: References: <20241018192525.95862-1-ryncsn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Stat-Signature: cckgco8ozrmoooto69ogyoirjkn1ozyi X-Rspamd-Queue-Id: DE39940022 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729287489-133969 X-HE-Meta: U2FsdGVkX19GdRMYPIxlajGu/cfK/IKQca5NjKW4YU/87D0GmOhsbXm9XYwA8mWQTDtZAPrq6RAUbVRsOrJmrDVv/h+yBpgHRLPmSesgv7BptiGL7sBL/KmuDIBI13DB4hpzbY2JT0UEvgkJL2Qk6LH+5EOe8rGQVyAFzAUp+aDLO+7F6e0hTSKal4Ok3CV/KXvfePibIpv2hG1e2jOXMtIQ93Hh+xDTlrXKKJvrWAtdx7wLpkVzezdQM0aw4y1oo7vaX+5o/OH5gYsY6eEei4vuk0/Yv73fCz0c3VINYSO18abBQXHoizNxPvGscOXQZJZN3A4OLjNs5xhUDEIPlQ1zJGxUVbL08Es5PMhqnDLQUiLzgwTBKoxzzS5/RkZgsLqJgfPlf0Gvhy/cuOOwdKYU0gK/kpIApxdNzur6Xzy3oI1rWsKpwBW9NHiVBuQgyegZRumQpOd+pXieIhj7eaDYcJo2v+qaTrQN+A76xTCT2C1Ux44i7c3TiUdKMuohYfpBjhPGJebeIIy2Hl7uIwZvEOaPV3aOmNfuAsjT95HGNVw7IuQmuzA5QgGNJMm7GBJe09fTm1j3yGTIURL9Ofo+OW7797CqBCfR/4PGyJPFu8cHRQrBgNF4NqAqrYUPPGYs4jivjc7xVjEzLxySu60iRD2p+991UDFZ1BkWSvfGDqc4LIqKuNgdEvXNjBc2syLA+hg2JhyVrdwatWZKAFbPAw8hph4qi7b4fPo17eeViubWbu6CjLvHKNAc0Oiq5xfTViYYK3bLfw3SfTNqXZIXpoH+Ubtk3D5z+36uxpdiiRaZfxnKYhd0eWGf7L+b+8ZicM7w1+BArIbSva4Q4jvSMNd33YPPSn0KUyQM9yuApm4QB0mosKUlc5w6/eaMvsIhUiA+oRa1AVt9D+GO5PsGi9tjViax/lKdPupuPapoj7vXEFOO3IRCkQmrK1oDGgET53yfms648XvN5QX QSyqucxM Tt5P4caPZntELfLA4IzeBAXmjhHabd0sbnTGOhJjYjKRLjuvGezpH5hhL/23wjJQ3Egh/hP/CTbIEY9s5bTAzewhjL/X0Brslp83htW6V8/NDom9OKt2D+OkM4RaE7q9VXZ/33QEDeZYSu69YiE3c8103xTY1alPRxd7ELQCuxBXUDzDSC8wB5tBo+IUQbXhQ69pJp2jMFcGbTWyUjPN3SzYkHdD/eN1AQifn9V2AFaitgwhRUBy32kyBxm97R+bg74jtLtUfzIJcE+hQvc6mQrUkeKNf/EECdMnft3oYFPuUq8Ae5+Q1h89P89QcfqOxdWaHetD/CuOCanTqnFvktQw+JT61dDhnrCn16nf0nEm1icG0hletGo/ZaPc61AmyrCftxWSWg5WVmVQ= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Oct 18, 2024 at 02:00:16PM -0700, Yosry Ahmed wrote: > On Fri, Oct 18, 2024 at 1:55 PM Matthew Wilcox wrote: > > > > On Fri, Oct 18, 2024 at 01:40:18PM -0700, Yosry Ahmed wrote: > > > Oh I thought xas_reload() is enough here to check that the entry is > > > still there after the lock is acquired. Do we have to start the walk > > > over after holding the lock? > > > > Yes. The entry is guaranteed to still be valid, but the node you're > > looking in might have been freed, so you can't modify the node without > > making sure the node is still in the tree. We could make that cheaper > > than a rewalk, but you're going to need to write that code since you're > > the first to want to do something like this. > > I see, thanks for elaborating. > > Could you confirm if the current patch with the xas_reset() added > would be equivalent to just checking xa_load() before using > xa_erase()? Yes, I think it would, so it's probably a poor tradeoff.