From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-116.mta0.migadu.com [91.218.175.116]) (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 AF55B2DA749 for ; Wed, 19 Aug 2026 01:51:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787104272; cv=none; b=uiBdM08X8yydMhls9SWjHgITtjELCHJnSpSoSStncI+VJk/vu3Ixw0E/14n6KrfXtASQF6FGUW6upernePs2fOi3qx3dP3solLnAIgoW3UdrGIHC/rx96O18ni0tqqa7nXZYlplCBstRL9x46d0O76XXdD5MdqjVjuGmm0IoyUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787104272; c=relaxed/simple; bh=7Iz7QmaZlme6W5EkeBnypYFasClabBBUHorOF1oxkaA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=HMU/FQkf2FX89mhp93ia3YX2nAsKDLWDzLrmi7urZEJayWDMZ5RVtN/9RL6BzGiC0bFPhyShsqGaH5oz6IKzuZmNSgwcQOVaBaan22aRSiOEzNVNcYWgu3ghSfzVCRKcHkyZO8U2SNhdG1pz7u1nCe7agqw4pjuq/8Z0kGCdq+c= 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=Vvyil+kc; arc=none smtp.client-ip=91.218.175.116 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="Vvyil+kc" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=7Iz7QmaZlme6W5EkeBnypYFasClabBBUHorOF1oxkaA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787104268; v=1; x=1787709068; b=Vvyil+kcR9SwvrjpZfXy88zbKUIW6mNlJLzxTsWSUzwA5CpKhzwX2lZjMY7cr9tvgbIPYrQT zS8ZqKnUUScrmy7h92KUe6fo577zsiES7PRetqHTw3RsaHuFLsr96zJ/PFmNCR54OHhriAQoTUL U6SFJuAQnzP6bOZP3/oO9mHg= X-Envelope-To: linux-kernel@vger.kernel.org Received: from [10.22.64.46] (118.201.124.118) by smtp.migadu.com with ESMTPS id 845baff155800fde; Wed, 19 Aug 2026 01:51:08 +0000 X-Migadu-Flow: FLOW_OUT Message-ID: <2282ba9a-0c6a-4ce3-99ee-517231f515b6@linux.dev> Date: Wed, 19 Aug 2026 09:51:00 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: add cond_resched() to free_pud_range() To: Michal Hocko Cc: linux-mm@kvack.org, Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , linux-kernel@vger.kernel.org, Lance Yang References: <20260818134934.92354-1-leon.hwang@linux.dev> Content-Language: en-US From: Leon Hwang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 18/8/26 22:08, Michal Hocko wrote: > On Tue 18-08-26 21:49:34, Leon Hwang wrote: >> 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. > > 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? Seems that we have reached a consensus about adding cond_resched() [1]. [1] https://lore.kernel.org/linux-mm/20260818162430.0a51522ac9bd671cce62650f@linux-foundation.org/ Thanks, Leon > >> 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 >