From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-137.mta0.migadu.com [91.218.175.137]) (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 62F72296BCF for ; Tue, 18 Aug 2026 13:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.137 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787061012; cv=none; b=Rp67NReo375evpzUu1veFfYcx6FPBPkzcFyvFOEkBuDTps5hzkbAzBPF81UvLNJUg1dvX25vjtyl+msNOKEaszOt9atGRboBKsfMU2ZIVEB9i7s/hRhYLyH1h4XpO9RYgwGqtez/hsCcPAvqZ7A10L/eVJna+jfnrq/GUYTka40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787061012; c=relaxed/simple; bh=KPnY0tQYP5AcqkJrwZ0WtXGocUVKhhxCQ9WVaistIKo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=hKoCqDt4gT6246k10zTbfiMNC6U7i/TtjWAOFs+SLDM712oq8oNTHTbF/y+629hzzuabr23UOwS5aQrbeYX3u0ecxs57sb1syvbwf30kP4RznCWpWRU6fiMZ6z+B8Zhz8IBoMe46/RnwdgbxQKNzL1mV/daVOZL702TDuByrstM= 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=eVZVlNSU; arc=none smtp.client-ip=91.218.175.137 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="eVZVlNSU" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=KPnY0tQYP5AcqkJrwZ0WtXGocUVKhhxCQ9WVaistIKo=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787061007; v=1; x=1787665807; b=eVZVlNSUmgenRMFUN3YteOMM5UGFDH9JMIKJet/BbSe569W1GTgyhY0Jc6l73xmUDKMUZ77l dCUfcyl3qY/3RnIO7zlIFpJb2UCEOWy0b8C6xFsVmmK8BEpMuctgQd5Hdxj5U/5cMyHM+bEEcwj 3j1x9DZcJQBUaFPHCzTC1lRo= X-Envelope-To: linux-kernel@vger.kernel.org Received: from .linux.dev (117.20.149.64) by smtp.migadu.com with ESMTPS id f87da00a7e642c61; Tue, 18 Aug 2026 13:49:57 +0000 X-Migadu-Flow: FLOW_OUT From: Leon Hwang To: linux-mm@kvack.org Cc: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-kernel@vger.kernel.org, Leon Hwang , Lance Yang Subject: [PATCH] mm: add cond_resched() to free_pud_range() Date: Tue, 18 Aug 2026 21:49:34 +0800 Message-ID: <20260818134934.92354-1-leon.hwang@linux.dev> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Packet receive timeouts were seen in production. Tracing showed that an exiting process with a sparse 2.5 TiB mapping could remain in kernel context for over 20 ms without reaching a scheduling point while freeing PTE page-table pages. Hard IRQs could still be handled, but the per-CPU ksoftirqd thread and other runnable tasks could not run during that interval, delaying NET_RX softirq work queued to ksoftirqd. Like zap_pud_range(), add cond_resched() to free_pud_range() so ksoftirqd and other runnable tasks can run between PUD entries. Testing with PREEMPT_NONE showed that the maximum interval between scheduling points fell from over 20 ms to below 2 ms. Reported-by: Lance Yang Tested-by: Lance Yang Signed-off-by: Leon Hwang --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 4134ac607ee0..68c15449de07 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -231,7 +231,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, p4d_t *p4d, if (pud_none_or_clear_bad(pud)) continue; free_pmd_range(tlb, pud, addr, next, floor, ceiling); - } while (pud++, addr = next, addr != end); + } while (pud++, cond_resched(), addr = next, addr != end); start &= P4D_MASK; if (start < floor) -- 2.55.0