From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AAE56302169 for ; Fri, 21 Nov 2025 19:31:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763753499; cv=none; b=oW18pvqlCjxcV8Y3x7+EiqyQLfdls+l8WFivkryD+edvQfl107MywKwnzm21/agNfq+1gDXK4A1Y37WqTIuixIhdtqS5HXd8+x+WrcIkAoRTveh24R3kmHuX9BruSK2jTNxPuPzlUbGBrE/4l1tf6UM+YmiWwOGfAUxbjMeqDYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763753499; c=relaxed/simple; bh=Od/tHklQw3fH6Wn+uk2dHPMmYlEu13bGh861GdW3NVM=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=X3e/1fNjJRJnOskhn9tkKRk1zn+NPfVaQveoYaKbLCooNCR8i+y/mRezqY8hV9ta1QICDqQkMnBOjh+BfT3hh9QtUeOJGp6HBygRMK5575Fulk8Plz0gRThOXSczwZL6Q2qUYY2/DFcv1/I50UDtf0L6Go4EwwUjH3hKLH7odaw= 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=XlfmxEk3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="XlfmxEk3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D81DAC4CEF1; Fri, 21 Nov 2025 19:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1763753499; bh=Od/tHklQw3fH6Wn+uk2dHPMmYlEu13bGh861GdW3NVM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XlfmxEk3vKdIgqeJxzR/KtNt94w6/kXkFJYkVLu3TgNUX5PP3Rl0MeOjqsd58kvYl 1mNP2dehRPrbMn3lW0bm/4RZzPaZ+N1twwqR29YDSEcXcpsk8nWr3tjPXs8H1Sboq0 JCBL8JLdhV2R2sL1vdvbgqX6J3mrvFwYx4mCTsgU= Date: Fri, 21 Nov 2025 11:31:38 -0800 From: Andrew Morton To: Gregory Price Cc: linux-mm@kvack.org, kernel-team@meta.com, vbabka@suse.cz, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, linux-kernel@vger.kernel.org, David Hildenbrand , Wei Yang , Oscar Salvador , David Rientjes Subject: Re: [PATCH v3] page_alloc: allow migration of smaller hugepages during contig_alloc Message-Id: <20251121113138.9955cb18d9b6c7ce812d5c0a@linux-foundation.org> In-Reply-To: <20251121191540.253624-1-gourry@gourry.net> References: <20251121191540.253624-1-gourry@gourry.net> 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 Fri, 21 Nov 2025 14:15:40 -0500 Gregory Price wrote: > We presently skip regions with hugepages entirely when trying to do > contiguous page allocation. Instead, if hugepage migration is enabled, > consider regions with hugepages smaller than the target contiguous > allocation request as valid targets for allocation. Why? What benefit does this have to our users? Some runtime testing results might be helpful? > isolate_migrate_pages_block() already expects requests with hugepages > to originate from alloc_contig, and hugetlb code also does a migratable > check when isolating in folio_isolate_hugetlb(). > > Suggested-by: David Hildenbrand A Link: here might be illuminating. > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -6849,8 +6849,19 @@ static bool pfn_range_valid_contig(struct zone *z, unsigned long start_pfn, > if (PageReserved(page)) > return false; > > - if (PageHuge(page)) > - return false; > + if (PageHuge(page)) { > + unsigned int order; > + > + if (!IS_ENABLED(CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION)) > + return false; > + > + /* Don't consider moving same size/larger pages */ Comment says "what" (which was fairly obvious). Please reveal "why". > + page = compound_head(page); > + order = compound_order(page); > + if ((order >= MAX_FOLIO_ORDER) || > + (nr_pages <= (1 << order))) > + return false; > + } > } > return true; > }