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 EC929399013 for ; Thu, 30 Jul 2026 16:16:01 +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=1785428173; cv=none; b=dEHoHvOhpeQ4l5EXfZFGV0z7b8LNbDPbqxjLnjBi/Xke+dgC/I82dFT24stDN43Q1fe+wvkF7+iMoWMyZ9OqLj0LP48E8gHgtLT5hHktJnrxOjsrbVb7d+te1y70Az9XZVrXRUNz5UyV/CNYZ4M5hDFbWJszsRn1bqCP3CoPmjA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785428173; c=relaxed/simple; bh=/q8dOEtdHgyagxJz2Nmr0ZbCO5yUtVzWztkv6IzcXgw=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=cnpU/scJhYW0soy6tKQQmecHN+xF6g2ijqma7wVczbgGSlCGtJq/12nvXzcr+SvuP2+DzzSia9v4ch7G0X7w2Lnu9CYiLcokLfaE2+lp60PPo7eaR8X5iH8NjP2IRB9yxDzP3hZA3Z1qTPU9U9veKDPUC1MbPrT1uKo9FhbB0w4= 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=TS8leGBx; 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="TS8leGBx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6EB0D1F00ACF; Thu, 30 Jul 2026 16:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1785428159; bh=v4U8SW0YxWrww9IDw6fuGEu6zQ2HQAvAF1fb2z+mrWg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=TS8leGBxEjN+OzJUFZz4SdEsyN4Xv4yZ1kByZqOl+cGkTUgTGz2XHpBPfiQCe99UM Z+UlPp38Ws337aMaKUG2Ki0Pry/RvXWCMEDX0mgCSDMeWEke7N8C197/uLcM8N+akC hKT+yjGkR63d7kkqqWlOPXcQioGfAT7t+xoLidLg= Date: Thu, 30 Jul 2026 09:15:58 -0700 From: Andrew Morton To: "Lorenzo Stoakes (ARM)" Cc: Avi Weiss , David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Soheil Hassas Yeganeh , Arjun Roy , Eric Dumazet , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: return -ENOMEM for page-table allocation failure in insert_pages() Message-Id: <20260730091558.12e3d9029002c87c1f00b4aa@linux-foundation.org> In-Reply-To: References: <20260730071323.964321-1-thnkslprpt@gmail.com> 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 Thu, 30 Jul 2026 08:42:49 +0100 "Lorenzo Stoakes (ARM)" wrote: > pages_to_write_in_pmd = min_t(unsigned long, > remaining_pages_total, PTRS_PER_PTE - pte_index(addr)); > > /* Allocate the PTE if necessary; takes PMD lock once only. */ > ret = -ENOMEM; <------------------------------ set it again? > if (pte_alloc(mm, pmd)) > goto out; > > The way this function is written is horrible in general, I hate 'preset default > return value' as a pattern. It used to be the preferred way because ret = -ENOMEM; if (expr) goto out; generated slightly better code than if (expr) { ret = -ENOMEM; goto out; } Whether that is the case with current compilers I don't know.