From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B2C9437A485 for ; Tue, 18 Aug 2026 14:09:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787062182; cv=none; b=e72Dg2Taq7BhG/mS/MnyMgmQWxkEE30hRqsbsGPqCRHZzm+AjVpUpn4w42Gy9e9hl+H9BNvlfQa72cjXj6XPEnA0wvrPYrfWyjZAX2bQ8zjyUjhEZrC/L9XaJms+X5sOXhTWlXjylwagH4Qal0nGQ4TWriAJ6Qpt/43pFzvpr7w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787062182; c=relaxed/simple; bh=wc4aCEjvjglPmcIKV3sWInZe2JOq3Wor0HOVWL4NOoY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q3ocuQ6L5G529Lg43Cqvq/P6WKC1icEK0H6Hfss4DiSbbJpV0Bykd+v6Sx0shJreW851q0rwqDxpL1XEsaGay2FNhEOXpfGMlx8m1beutjqP/mLw2ojrsi+vRWr5S3vFJxXGOUPjWKcKlOajDCheCg1DflGVTTkFdr05p63owP8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bVi5P/GX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bVi5P/GX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 769261F000E9; Tue, 18 Aug 2026 14:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787062181; bh=X8oJASEVHdJhH7uHF2vR+gZb+csEP8hI47I9UkZtJlM=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=bVi5P/GX9ay3YUlRE1FTJTFV+g9LQuHC72s4fDxSBwDEcdf1+laLaC8h8z3yaG2iL OVAWG7HMg25vuVgl9hhPokSFjdoyU0W/muL8vOJRWPmbnraprsgt1H2LZzArN/oS0r pBgxo2VOjkCJD/zX2mlqYY5rJhXVCgPR9fdIUZtIFuPgxjLfqDO+Wbthl36m8ZrR1z r9UyDoiZEVrFLZ/WizWZlUcF9A0TKw3QT9Njf83KUs9ARV3+rKwRDld45AMD0gjtb/ M22ZOPIEEin/dBuQRzT0NSsGZwEq0bqjMnLm+PA1SWhKymOqVn6DpO37LuA3MbVdgI 72aoqmJUlLoBA== Date: Tue, 18 Aug 2026 17:09:33 +0300 From: Mike Rapoport To: Leon Hwang Cc: linux-mm@kvack.org, Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , linux-kernel@vger.kernel.org, Lance Yang Subject: Re: [PATCH] mm: add cond_resched() to free_pud_range() Message-ID: References: <20260818134934.92354-1-leon.hwang@linux.dev> 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: <20260818134934.92354-1-leon.hwang@linux.dev> On Tue, Aug 18, 2026 at 09:49:34PM +0800, 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. > > 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); This is really obscure, can't it be in the loop body? > > start &= P4D_MASK; > if (start < floor) > -- > 2.55.0 > > -- Sincerely yours, Mike.