From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 00D5F2D321B for ; Tue, 30 Jun 2026 23:02:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782860530; cv=none; b=nCyz1DBkjMqn1wkjhs/BtG21wFd3UTEq+Htg5ZbaeM/XyuekZESZLUcxD5lPEgyR/0SkFfQz4pvKAVNtYvPZXN4gaqE2098y+d9DwGynIQ6dErGTSnQ+qTooWrc6xEa3C1Q8cK1fFEv21NAVT7l6pPL7sKlcmxyC2ROygApY5I4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782860530; c=relaxed/simple; bh=1VzmSD4klI49NLI47oLqB83/RtSjdlc/vhjluyZqHlY=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=IIbD9oj+qyNH8/+dazfUF+KiVoWSJg6RRPy3w3uI5qHnF9raamZRjHTLpAix/ppwDmQxXUd+F/DPesSe5P/Zf7hiz4xoBa4d+97iqAOiPVkPoButiNEB1JxrYEjqTrn6gS8dnVkUlU0vX8gzMJjoHrFHd0BSdUO576xTfTr9VVA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=YX6u1Gd1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="YX6u1Gd1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CF201F000E9; Tue, 30 Jun 2026 23:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1782860528; bh=nzgBLJFQlQhHqV4QWecB48NgOHTUMuZPtVSuPWBMy+w=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=YX6u1Gd136+Ad4gA51fknftI2nAcS+KZGnpftdh0kBYHWxtljz5LONfJyynuJH1Er r/01i2oz8KjJpIJQ3XCUiA+9Yo/R3BjLrdjm6F8iPW8fBAjGxi45e9NSn+j4no/dbd eJStX7RHbkNwOEES82mHjPJq0t+wWyHbpGYBvyVk= Date: Tue, 30 Jun 2026 16:02:08 -0700 From: Andrew Morton To: "Liam R. Howlett (Oracle)" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Rik van Riel , Jason Gunthorpe Subject: Re: [PATCH v2 14/19] maple_tree: WARN_ON_ONCE when allocations fail Message-Id: <20260630160208.b6d1e09d60c50c8fbb80e830@linux-foundation.org> In-Reply-To: <20260630190843.3563858-15-liam@infradead.org> References: <20260630190843.3563858-1-liam@infradead.org> <20260630190843.3563858-15-liam@infradead.org> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Tue, 30 Jun 2026 15:08:38 -0400 "Liam R. Howlett (Oracle)" wrote: > Allocations should never fail in the circumstances that are expected to > occur. Add checks in the code to ensure the circumstances are correctly > set up by the user and warn if they are not. > > Also add a warning on failure to allocate, which should never happen. > > ... > > --- a/lib/maple_tree.c > +++ b/lib/maple_tree.c > @@ -5720,6 +5720,10 @@ bool mas_nomem(struct ma_state *mas, gfp_t gfp) > if (likely(mas->node != MA_ERROR(-ENOMEM))) > return false; > > + /* Allocations can fail, don't do this. */ > + WARN_ON_ONCE(!gfpflags_allow_blocking(gfp) && > + mt_external_lock(mas->tree)); > + > if (gfpflags_allow_blocking(gfp) && !mt_external_lock(mas->tree)) { > mtree_unlock(mas->tree); > mas_alloc_nodes(mas, gfp); > @@ -5730,9 +5734,12 @@ bool mas_nomem(struct ma_state *mas, gfp_t gfp) > > /* > * Return false on zero forward progress. Partial allocations are kept > - * so the retry path will attempt to get the rest. > + * so the retry path will attempt to get the rest. The failure should > + * not happen as we try our best to reclaim. The user would need an > + * external lock with a non-blocking gfp in a low memory situation - > + * which would have triggered the first warning in this function. > */ > - if (!mas->sheaf && !mas->alloc) > + if (WARN_ON_ONCE(!mas->sheaf && !mas->alloc)) > return false; > Can either of these warnings duplicate the effect of !__GFP_NOWARN?