From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 BCFB140628A for ; Tue, 30 Jun 2026 12:01:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782820907; cv=none; b=pRjH/ZHUsILlPI0OwGL+K4adY7AWgOltYOqbj03WYUW168IqWUD2dfD/greC7+j63axtD99iSY9NNZo6rcd+IZNVXtogO7JhGp13suqw/LamM+jg96lvdpIWmwbXdMPP6CTe4vU195ffwa3b9m1JiMaNfalwyYGZa5GJ7TwMXbA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782820907; c=relaxed/simple; bh=Fpoj61fYQ9LZ9snpJcRO8d2GgN+0Y/Wo3E/ucp8C7mI=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=aGTKznS+lmZSe1OBCFsVzSIrlYp+BUU4mUsBK2SAfuA1sfubzQ4e+3ntbamXV6k8TisRahGu+k1PU/CacfQw+fU4bsxNd6S99dIZE3nJPWwemL7KEM80LBI6gFDC3hemvvArZWd7LB7y1H1d/9K60x5Ib2vokWkbmh6Af3XTrhg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=n1XbjA+P; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="n1XbjA+P" Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782820902; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wBN3h+z9xy1yHoFYSo2ztdKUYrT1IOkpJyl6BOeo5uw=; b=n1XbjA+PlPOt32zEosvdgU+vBAYCy/muv9WwOXfVqY+tr4OFvzach5+18L+vKcF7glyPWo eU5C0GgzPbrGmcQkbO3YX+jgJeXzqNRKrWgkBNSCS6WyoggSUWKJD0qZf8/ZDRcHMK+Bn2 z7fLbXagzLECmEI01Zrt77Edjwx3PMQ= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH] mm/hugetlb: avoid unnecessary TLB flush for empty folio list in vmemmap optimize X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260630113857.3319612-1-guanwentao@uniontech.com> Date: Tue, 30 Jun 2026 20:00:51 +0800 Cc: mike.kravetz@oracle.com, osalvador@suse.de, david@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <6FEB0F1B-CFD6-4999-A9D6-CBDEF9951C8A@linux.dev> References: <20260630113857.3319612-1-guanwentao@uniontech.com> To: Wentao Guan X-Migadu-Flow: FLOW_OUT > On Jun 30, 2026, at 19:38, Wentao Guan = wrote: >=20 > __hugetlb_vmemmap_optimize_folios() unconditionally issues a final > flush_tlb_all() in its out path. However, a TLB flush must be paired > with an actual page table modification. >=20 > When the input folio list is empty, neither PMD splitting nor PTE > remapping takes place, so no page tables are modified and the flush is > pure overhead. An empty list is reached in common paths such as > gather_bootmem_prealloc_node() on nodes without bootmem gigantic = pages, > hugetlb_pages_alloc_boot_node() when no pages were allocated, and > runtime allocation failure paths in set_max_huge_pages(). >=20 > Add an early return for empty lists. This restores the basic = invariant > that TLB flushes are only issued when page tables have been modified, > and it also makes the NULL hstate passed by = gather_bootmem_prealloc_node() > on an empty list harmless. >=20 > Assisted-by: kimi-cli:kimi-k2.7 code > Assisted-by: Github Copilot:gpt-5.2 #Reported-by >=20 > Fixes: 79359d6d24df ("hugetlb: perform vmemmap optimization on a list = of pages") Actually, this is an optimization, so it doesn't need a bugfix=E2=80=94unl= ess it's a hot path or causing a massive performance degradation, that's clearly not = the case here. > Signed-off-by: Wentao Guan I actually have a local optimization that covers this, so LGTM: Reviewed-by: Muchun Song Thanks.