Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: Avi Weiss <thnkslprpt@gmail.com>,
	David Hildenbrand <david@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	Soheil Hassas Yeganeh <soheil@google.com>,
	Arjun Roy <arjunroy@google.com>,
	Eric Dumazet <edumazet@google.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: return -ENOMEM for page-table allocation failure in insert_pages()
Date: Thu, 30 Jul 2026 09:15:58 -0700	[thread overview]
Message-ID: <20260730091558.12e3d9029002c87c1f00b4aa@linux-foundation.org> (raw)
In-Reply-To: <amr9zoSncZguF_uu@lucifer>

On Thu, 30 Jul 2026 08:42:49 +0100 "Lorenzo Stoakes (ARM)" <ljs@kernel.org> 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.


  parent reply	other threads:[~2026-07-30 16:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  7:13 [PATCH] mm: return -ENOMEM for page-table allocation failure in insert_pages() Avi Weiss
2026-07-30  7:42 ` Lorenzo Stoakes (ARM)
2026-07-30  7:43   ` Lorenzo Stoakes (ARM)
2026-07-30  8:27   ` David Hildenbrand (Arm)
2026-07-30  8:36     ` Lorenzo Stoakes (ARM)
2026-07-30 16:15   ` Andrew Morton [this message]
2026-07-30 16:27     ` Lorenzo Stoakes (ARM)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260730091558.12e3d9029002c87c1f00b4aa@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=arjunroy@google.com \
    --cc=david@kernel.org \
    --cc=edumazet@google.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=soheil@google.com \
    --cc=surenb@google.com \
    --cc=thnkslprpt@gmail.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox