From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 A45661946DF for ; Fri, 19 Dec 2025 20:57:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766177826; cv=none; b=KaCL1Le6yvUpfqkF/6VVCNMk66aYuFxpJmcDSBg4VhQg1W4WlRz9w/01yZG2KvgGB/gAzUy/QaCQe7oG4zd7+rj+m600hr6rcABxQLI2oPb5u543tQxgW6E0lfceymsiZPX1xQ/CCpOy6Uki7YZdDNYdGovd2Rrmd1HZDMvK5FA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766177826; c=relaxed/simple; bh=qrhLVW32+CJbzlS6LKKmAbunROyTSQtaIXIawRPyoQU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SCqhSJofwQpw6CXDlAP2iK3l3O02y5+7LdoD/k1nssuE2+MjUJ/jGc1E/cIhFvk6BXw432oTVNdJm1XQSxTAtfuE3KnO7ZKTQ8ctSJCpi53wGuSWs0L1f42nCJJbGWofT2BIh3VGpF2ki8ZDNDZ1UZR57SFmUKBczUxJLN7XNgk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=no7Me2jQ; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="no7Me2jQ" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-4f4b23c23ccso9325521cf.0 for ; Fri, 19 Dec 2025 12:57:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1766177823; x=1766782623; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=t509bwztenot/CP8kNyRzbdexzlGui8MOb3iqN5WlEs=; b=no7Me2jQMEpWiRJ22Ev7K+/UxB9cqDA+vY5pWaXRifmI0gKyzp/NJtl/tt4EUlgzdt Sr0A7wfwfyU+ZzvESNsXaTCieCsFc1uPRAm1yF6EMsnbYS89R5QfJxFg3UEdu4KhUrs7 rvX7nQDi3WjUcNDSNW08+TKHRiUa7PZyTo+MQ/AQVlsbW5RtbEgf1bMvgoty2g0zGiCP XXB3cB2ix8peijIu37FvgvhItixnCBmJe0M5ihBGuk2X7zhXkCd319IgtzIrjf56lYYe ia6w+gRD5QatbuFXSusR2xhyxxVJRA2grhfhr1Af8EJrVKq4lAV62+pSA49CHb/oaMyo GMog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766177823; x=1766782623; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t509bwztenot/CP8kNyRzbdexzlGui8MOb3iqN5WlEs=; b=RDBCca1gLsxuBUKb4j58C/XQCxxLuq4XxMqA34OUU8MSWlWv//U+JrxqgDo1j0bzmm B+/yy7YxeI9PrpJF9VDiVX0EWwQYBr1puTKsHOToLPck2ZaudUB7V3eeuhUTV/+XcZHM FuBh0V2m70PNkR8JGfLvrmwq8F4qTEaFxNZawlFdUsYBcU9/XJ1RXRymO/MCAfcE3reF geqL49yUMukeZuFgYcnl8QFtgyvOGVdmcE5dVgYlaUcGY0aPCR36YFv3Jkj9VIzrhbn2 mjlRq8Uri37UyKkXlZtYjK7y6zVc5Dk8UvfR9+MhZd4BbHuRs/t6mFGueX6j5x2NjU0I qlgA== X-Forwarded-Encrypted: i=1; AJvYcCX5ccXItO0YCNMmhYxQl2zJjRI+sih66K4aaVD6rUFhBCO9zQBW+AImBr4XcBGARiCBDS9H0X1Uc+9umuQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxFBUKZP9S1bxHcDx8Wq9kUMxCmv/YqMfrL3ObmMfs2RVJOarhe Ypdqbypo3h9ueTWkWw6e5xaGSxS+FQnGV+L8oSNWyqGBRVrXrqLxMqqZIVSwT/C83bQ= X-Gm-Gg: AY/fxX7CLVpHjFc7sk1Nr4i3gAFyMsVlVF1pvn3jacrXpcqHxxNnh3DSIKRGfyCyDPo MXtMtRruHR/VwsZvT2r3teU/DFp1q3h//yIhjcNH3xdo6ITs+Xz06H1WA27YxjRKHrfZ4AzvZM0 wxabskLFvYenwZi4qJzNl62DqIKr9o9PQepZp1WNC0y3AIoAVviONpA4A+GwCR5q08UeB0I5HVg AlnQ9mD4CgTQ2+WuUl/QVFQRqzg149gSoRLpBwU2mMmZLKE8zKgLvQWFNaFJaWjdWeYL7MzDPnh fMxoVXLVqaSEmqnA/ROXs/ReHtjMfvXKE6RSkuDZevs5YC44XxqhFK4cSjaTOs5dHqCX94Fy1Sc Fty5MU9vnmddr9Qmbn4aXU6O7MJqK143n6XkNIT1w3LQbEPp6cTy5kv15qlCEpOfvTM0SmNeI2V 7mfYYnTBa8QeaYOGS2cHknQnCNILCi4iGaRy/lm/J0pFii3POxekHxPgU/rWuNfbMXmeMstg== X-Google-Smtp-Source: AGHT+IFcc982nWdpBtU/myoa3OSL4Lx+tf1/WhI5JBF/tQgeQcpMo4ERuhRNkwwEGYKvbboveZfS1A== X-Received: by 2002:a05:622a:904:b0:4ee:2459:3d6b with SMTP id d75a77b69052e-4f4abd6e209mr60644641cf.49.1766177823513; Fri, 19 Dec 2025 12:57:03 -0800 (PST) Received: from gourry-fedora-PF4VCD3F (pool-96-255-20-138.washdc.ftas.verizon.net. [96.255.20.138]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-88d9aa3ac8fsm27024046d6.56.2025.12.19.12.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Dec 2025 12:57:03 -0800 (PST) Date: Fri, 19 Dec 2025 15:56:26 -0500 From: Gregory Price To: Zi Yan Cc: 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: 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> On Fri, Dec 19, 2025 at 03:46:25PM -0500, Zi Yan wrote: > On 19 Dec 2025, at 9:26, Gregory Price wrote: > > > 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 += .... > right, and we hold the zone lock here, so we shouldn't see a page suddenly become a tail page mid-iteration. I hadn't mentally worked through whether it was a good idea to encode this behavior now with only one user - but i suppose there's no point in optimizing for code that doesn't exist, so i agree. This does seem fine. Thanks! Gregory