From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Leon Hwang <leon.hwang@linux.dev>, linux-mm@kvack.org
Cc: Muchun Song <muchun.song@linux.dev>,
Oscar Salvador <osalvador@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, Lance Yang <lance.yang@linux.dev>
Subject: Re: [PATCH] hugetlb: add cond_resched() to __unmap_hugepage_range()
Date: Tue, 18 Aug 2026 16:23:29 +0200 [thread overview]
Message-ID: <3dadebb3-7e2a-459c-a5e8-b375faf89938@kernel.org> (raw)
In-Reply-To: <20260818135029.93288-1-leon.hwang@linux.dev>
On 8/18/26 15:50, Leon Hwang wrote:
> Packet receive timeouts were traced to sparse HugeTLB unmapping in
> production. A task unmapping a sparse 2.5 TiB HugeTLB mapping could
> remain in kernel context for over 40 ms without reaching a scheduling
> point while walking empty huge PTEs. Although hard IRQs could still be
> handled, the per-CPU ksoftirqd thread and other runnable tasks could not
> run during that interval, delaying NET_RX softirq work queued to
> ksoftirqd.
>
> Add cond_resched() at the beginning of the hugepage loop so ksoftirqd
> and other runnable tasks can run between iterations. Testing with
> PREEMPT_NONE showed that the maximum interval between scheduling points
> fell from over 40 ms to below 2.5 ms. Total time spent in
> __unmap_hugepage_range() remained about 36 ms.
>
> Reported-by: Lance Yang <lance.yang@linux.dev>
> Tested-by: Lance Yang <lance.yang@linux.dev>
> Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
> ---
> mm/hugetlb.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index dded1768193a..0a91aac2369f 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -5233,6 +5233,8 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
> last_addr_mask = hugetlb_mask_last_page(h);
> address = start;
> for (; address < end; address += sz) {
> + cond_resched();
> +
> ptep = hugetlb_walk(vma, address, sz);
> if (!ptep) {
> address |= last_addr_mask;
As Michal just put it:
"PREEMPT_NONE is effectivelly dead and most cond_resched will/should be
removed. Is there any reason why you are not using full preemption when
requiring low latencies?"
https://lore.kernel.org/r/aoRnUxUlgf_kRlm8@tiehlicka
--
Cheers,
David
next prev parent reply other threads:[~2026-08-18 14:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 13:50 [PATCH] hugetlb: add cond_resched() to __unmap_hugepage_range() Leon Hwang
2026-08-18 14:23 ` David Hildenbrand (Arm) [this message]
2026-08-18 18:17 ` Andrew Morton
2026-08-18 18:21 ` David Hildenbrand (Arm)
2026-08-18 18:55 ` Andrew Morton
2026-08-18 22:18 ` Lance Yang
2026-08-18 23:24 ` Andrew Morton
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=3dadebb3-7e2a-459c-a5e8-b375faf89938@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=lance.yang@linux.dev \
--cc=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
/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