From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 4CA762D739B for ; Sat, 20 Dec 2025 06:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766212663; cv=none; b=i8rf6pYS2MJb8ziN8uTymlBzERHoTr6hhRnz4zye2ugaYURrXxDcsCBLx0jUIfUW/xzdjVHEdT8SfWNDTHc9pcNojV9wQpFhAZ2cNS7OV4BPmt5TcL7veUBv6Nr/ca/zSQcD+ycrtt2kN/5gnpDY7G2SuLrSmhkpTIyJmUjFQnk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766212663; c=relaxed/simple; bh=Ub6xh61YNj4OgS1RHjFwoPvm6/rxnmaK8yESgsLkEf4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eQv/m9U16EPjUH63e0b8TXZV1mdHdiULVspVoeMP67thZ8PYK1B5FMxL8/MqnCh0AC7kVz1lS4pvLd0WM+fKJm/Nvz3x9GYiWy6iGEFvVMZpRYFyqqYy0HVRh6f2HcAhBSMh9bb6t18P7U3RgcoqqrEge5YjRjDcTaohvs/hQw8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dh5uL2CH; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dh5uL2CH" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-b728a43e410so421987166b.1 for ; Fri, 19 Dec 2025 22:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766212659; x=1766817459; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=FooWQpfOMINmJp+FnpxctjXY4hgx5RbcOIyby+amm+A=; b=dh5uL2CHJaOxHOXuN9dvZQMsAr7a7wZOIfwYzIioOiqxDpf3a6WiJzBXvVBFXWEceT Dtk4u/jz4jaL7gfnkxSkUYhV7ss9byMjnvXqQ8R1CAPL/z9UxUCf2mjM/Lx0UxCRSO4x 3ZIrg9lVKiEBVvTL5WHrqO7W0acfGdbQe4OlEzDtNProaR/M/pwv6lnrAMRJE1R7l8b6 fWJb/HhADdYTfhHMDa3A5/v+rduhawOIprjhitSOsMhTSGStqphor7EkqFGmWYivruMN eqQ/wOr0mkJ8BJWmlVz+WiESho84XqyjtACWrPk56RcGzRCivExbIjWMxqJzuXKH7cXk Sf3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766212659; x=1766817459; h=user-agent:in-reply-to:content-disposition:mime-version:references :reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FooWQpfOMINmJp+FnpxctjXY4hgx5RbcOIyby+amm+A=; b=mLfIp5gBRTBYjvTIP0dEZLZ+2glm0IPZj5kg4YLLO8w9uJRxA1ADA8zMVykqu1LzaJ BhpaOqLbt8GgJp9ckczfjugWjm4rhaQSDDX7mQwjOm9EHcCCMNCt1DICFvIVeVTYKaQj +C2RIsZqsJeqzp+XXzHedzdg0SfXZhmMH1JVpIBK8LsSD1c0jRNaPVI/EtviV/boqEWI o72shB+bKMmTZTHIINl4PfS1LDn2XJpQkf1O7T4xpWD/DgrdJspblIFJH/FN0J1XA4dr tMgYmZIw6vvKgx4xmQ/N9jcanP87CHvkcjyjyyxLFQak4RwuwDIMXMdCHDcqFU1SCv7j RmzQ== X-Forwarded-Encrypted: i=1; AJvYcCXcOm1zPWxMcxGvBCvvYl4slbtSwyn2OkOi6I7vM0g5LMKRp4ocVL7t5rjXXvCc+4aHx8yiGqR61D8eOTc=@vger.kernel.org X-Gm-Message-State: AOJu0YxR9Cywu3UhLaYjJyL3NbPn39iriqM0P9GOdCMQ42oDTrLGSdcf ymaO5OZXjX1pJVNQYpqZP3SvhnIonfnNWpQ8WJxm5NwAytUjJBJA4gTe X-Gm-Gg: AY/fxX5B3p8E84NoJm0iOg9f+JJNqYMqOPliGurTkYbZdIEF5/MaGWCnP1wuT9NcjlI /yCyS+gkzn0eCI0aux+i2HC2PSpD/0iAmMRVuMr8lLqg1aSWp+fYfcDajsd5UDTLoUPgkE/vJuN T6GfnKeigUZy0wiVC8QgNQWRiDi0nsx72uE/Eg8+1pcYhKvJNnIYzUcI+rXSH2NZtTm1Qpnb5Ya aAW08CgiBK13ngfxVrjK+0URyIpv+hlcMhphuV/J7yXtKCEcOZGcugXWXm/lC2R47mZBIJ/bnpo U/Dm6bEjwY2soci2hkqiM41rRQTs3vXN4R70sQtUCwgfa/RonlLJYpp9cQl+YRuZ00Cou6eh9ZN +2naa4ComssNehjsKgrIoAtPx8/hmG+42bhPCAffHd2JI7B1EdDe5d+bkEJiAH/IMk7Q2Dro7pN 1BFEbehlAl4w== X-Google-Smtp-Source: AGHT+IE52VYLOIWDODLUJLXC/zJ7l+ayf/itcSPoY3h6Eran/g1nN6W0kCqfPtmbO1FwsH4IWYVq+w== X-Received: by 2002:a17:907:96a7:b0:b7a:1bde:a01c with SMTP id a640c23a62f3a-b8037218276mr487561266b.64.1766212659251; Fri, 19 Dec 2025 22:37:39 -0800 (PST) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8037a604f5sm431928366b.11.2025.12.19.22.37.38 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Dec 2025 22:37:38 -0800 (PST) Date: Sat, 20 Dec 2025 06:37:38 +0000 From: Wei Yang To: Zi Yan Cc: Gregory Price , Wei Yang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, akpm@linux-foundation.org, vbabka@suse.cz, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, osalvador@suse.de, rientjes@google.com, david@redhat.com, joshua.hahnjy@gmail.com, fvdl@google.com Subject: Re: [PATCH v6] page_alloc: allow migration of smaller hugepages during contig_alloc Message-ID: <20251220063738.hbypivj3d34c7ffs@master> Reply-To: Wei Yang References: <20251218233804.1395835-1-gourry@gourry.net> <20251219000800.tnpqzvcdyeqcwryt@master> <7EED2D83-AE17-49CB-BDB6-954793EAFDBF@nvidia.com> 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: <7EED2D83-AE17-49CB-BDB6-954793EAFDBF@nvidia.com> User-Agent: NeoMutt/20170113 (1.7.2) On Fri, Dec 19, 2025 at 03:46:25PM -0500, Zi Yan wrote: >On 19 Dec 2025, at 9:26, Gregory Price wrote: > >> On Fri, Dec 19, 2025 at 12:08:00AM +0000, Wei Yang wrote: >>>> + >>>> + page = compound_head(page); >>>> + order = compound_order(page); >>> >>> The order is get from head page. >>> >>>> + if ((order >= MAX_FOLIO_ORDER) || >>>> + (nr_pages <= (1 << order))) >>>> + return false; >>>> + >>>> + /* No need to check the pfns for this page */ >>>> + i += (1 << order) - 1; >>> >>> So this advance should based on "head page" instead of original page, right? >>> >> >> hm, I think the thought here was that since we're moving forward from >> start of an aligned chunk, we'd never hit a non-head page - but this >> may not be true. >> >> Will think about this for a bit. > >The sole caller of pfn_range_valid_contig(), alloc_contig_pages_noprof(), >scans from the beginning of a zone to the end. pfn_range_valid_contig() >should see head pages all the time, except it scans in the middle of >a 1GB hugetlb when alloc_contig_pages_noprof() is asking for a smaller >nr_pages, like 2MB. But in that case, the if above i += (1 << order) - 1 >would return false without reaching it. Basically, to get to >i += ..., pfn_range_valid_contig() needs to search for nr_pages larger >than PageHuge(page) and nr_pages is always power of two based on >alloc_contig_pages_noprof() requirement, but that means >pfn_range_valid_contig() always sees such PageHuge pages as a whole >within nr_pages range, thus cannot see a tail PageHuge page at the >point of i += .... > Thanks, I think you are right. For current use case, it is safe. But I am not sure others could get it on first sight. For example, me :-) Do you think it would be helpful to add some comment here? Generally LGTM. Reviewed-by: Wei Yang >Best Regards, >Yan, Zi -- Wei Yang Help you, Help me