From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) (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 11F063E7BD9 for ; Thu, 18 Jun 2026 15:24:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781796295; cv=none; b=hhFI9nFIuLusIqH4RDnA46yKVlbqk+TUcaRAuYKxwRWZxSRiCv+2ZwcZjfnjrxpbwcKlLXtUKyyYjHGXfH5v1ew1gr50d28mpuW12YnB48T2tG7/2VDV2LLUb+WSEyUCqL7ly7s1a/F2N739bGjH/+BKKlcrjjSY4aAz6Aju1kI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781796295; c=relaxed/simple; bh=ZovzLQyiPv6W5F/MNpY/mwsM0rnVIgyZZuCYNFrli6c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=czccxLbzg0BcUe/P+e6R8wMlyShD/bdaGMr8fi+qC+JqRu5s2KcULWauG9n4L65iwTUzvnOsvjsNelkgLVbFgsGmLco7UEQZlh8uRE3ZrRPevC+oVo9iOFulLYB81Pjpqrtc3+1MlqfsCkQN6rr2/5Qvc6jZ28JaCWLFkizUywU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=j7fy2ea6; arc=none smtp.client-ip=209.85.217.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="j7fy2ea6" Received: by mail-vs1-f49.google.com with SMTP id ada2fe7eead31-72695bd3ba9so632762137.0 for ; Thu, 18 Jun 2026 08:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1781796293; x=1782401093; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Koroo30upNuvUdLSvEsP2T9t46cltHI5siJNKWCJyMg=; b=j7fy2ea6obT73rasWlSw0gqOxnH6oqxTKOLFBFRxfvCw1v+Yud3xe/KNN5gE5wREdG BB4J6uDUF4kdTsmysqePyardQwyHAfmpta6zdsWfiOBugO4tCuVTLmzM7Whfs22OvZbJ NQ46U8GsKoTFd6afIpFpgCU4y5vDUA8gKOvlLOz/GbZaFYX5w5fPwmT9jJx+XeQ0Ov3V sar7QJdeKy1sT6ZvJhVQfRcuoglOs2SK0g6B372YAJ5JKGZQwYe1BV77wFD1SWuiVHLo 6RXhm6ot167Sx/yo6zX8GESzCoJJqVRyKKoJ1SWo+37VDMUd967+pGyuFJj8GL2hs7PO wdlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781796293; x=1782401093; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Koroo30upNuvUdLSvEsP2T9t46cltHI5siJNKWCJyMg=; b=WOUmtoPLD+yHmZOve/FFAAyZBltOEnfHDHdNHy2O8URPNO1UJC/HWWDSp1s2XHQvom sR6QEcwK61ejAzbQcS3eMBzxy4+QsW+g8qL5dxqoJK7AiyPg5VLwXJOP/6AWsL3oqByQ Q7IG2HlRgPjCV9+8ruGjoRo7KHfnOeUI5pNuThZ4zKRwPzama/4I3BAVFp0018XPjEIr UydeOhCpTmZ+XSLzYztq4/9le2BA3ACltS+Eym1KjUdrIitDjSj1ygJ8mGo7/EkYKvX/ Wk5GrBGI1tOY0CUQg8HUaIB6B4y/lARwT2BGiM/zqg5jhYg091gf8VS5bpyAMwFp/GVm y6AA== X-Forwarded-Encrypted: i=1; AFNElJ/YFdFfTHl0g/Gc3eI9i1lOHwdZ5iGyjWc8L8+c0YmLZCs0eQsHu/dZ7CYRSN8rGfIBrZuklq+DwsU3IUA=@vger.kernel.org X-Gm-Message-State: AOJu0YxZ+Ah2h2uRGMrajRRfOPCGUnACzsEgYSryfbbZg2dy0a129CVt SyP5m4CNiioopqmEqwpHCSQf4n9Iysai+dNwArwjCDJqrT+hdEBebo/OozKB4ksII+RLCmfvk17 0bhCI X-Gm-Gg: AfdE7cktgMCXGk3krN5V7bS8leibFnWteWt5kAJodG6jYrNwgn6LLwbnknLQA28JvxU 1ALUnBKtkX3U3fy4yHUdYqXMYgLJWzZNIzZq3+NSU8ldhKHC3bP4cNNPmj8kiQATAW0koMLE6G/ WvMMVG6UKJB4TE2D4NGuD+/wUTO+4eeucdbzshqaPpnKnszA9mMxmIBK1mzi8KI3We5px2qBC6y nu3pEUcFVplkjaxigE8sxxRdHgpTi/5tt3BM+kwN/JudehZSb6/bGSoIfD/8oY0p+NAE+wCIlVq XIcaGB7itRSe9hWDGIl3XihPzygyHasSu682CkEPCfusKYrtzmOVTn2HQYvoyYbVp9WWRd4xj+4 Ch3OnpcrWLUGUkFbaRcZs4NDMm0Mmdi3epn+lhlY/sIXC10POXEsLK7REa0GAjVVIWLh4sJJZOq GbY2RYoXqIRI3Uqu2kItT8+TXqL53qSOnlCEh3YF7oj3qVrzExNckLro43a0NwbCBPk2Y= X-Received: by 2002:a05:6102:c46:b0:726:8813:2085 with SMTP id ada2fe7eead31-72a03a6bfa5mr52389137.13.1781796292971; Thu, 18 Jun 2026 08:24:52 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id af79cd13be357-9161a006e35sm2126884185a.28.2026.06.18.08.24.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2026 08:24:52 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1waEbr-00000002sU2-3SmP; Thu, 18 Jun 2026 12:24:51 -0300 Date: Thu, 18 Jun 2026 12:24:51 -0300 From: Jason Gunthorpe To: "Liam R. Howlett" Cc: Rik van Riel , linux-kernel@vger.kernel.org, kernel-team@meta.com, robin.murphy@arm.com, joro@8bytes.org, will@kernel.org, iommu@lists.linux.dev, kyle@mcmartin.ca, Rik van Riel , maple-tree@lists.infradead.org Subject: Re: [PATCH v3 3/3] iova: defer maple tree erase on GFP_ATOMIC failure Message-ID: <20260618152451.GE231643@ziepe.ca> References: <20260609130418.GI2764304@ziepe.ca> <61d51d4b5779d80145ceb38e9632a7cc8a79dbec.camel@surriel.com> <20260612164852.GL1066031@ziepe.ca> <20260612180303.GO1066031@ziepe.ca> <20260615115633.GQ1066031@ziepe.ca> <20260617180419.GA231643@ziepe.ca> 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 Thu, Jun 18, 2026 at 10:50:56AM -0400, Liam R. Howlett wrote: > > If that's the case it should be documented like this too :) > > Yeah, very much should add some notes here... but also maybe stop them > from doing it by adding this to mas_erase(): > > if (mt_external_lock(mas->tree)) > might_alloc(GFP_KERNEL); Yeah, and then I'd add a might_alloc() to mtree_erase() as well, it can always sleep.. > Otherwise, I'll just be telling people they didn't read the docs. Okay, so to summarize: - mas_erase, mtree_erase cannot fail with ENOMEM. The check for ENOMEM inside should be changed to a WARN_ON to document this. Rational: in a GFP_KERNEL context it will sleep forever until it gets memory "too small to fail" - External locks must be sleepable, add a might_alloc() to check for that and document. mtree_erase must be sleepable - I like your idea for Rik to try to store NULL to erase, on failure store ZERO_ENTRY, and then set a note on the next alloc to clean the ZERO_ENTRYs? Jason