From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 B2AAC478861 for ; Tue, 18 Aug 2026 14:08:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787062104; cv=none; b=KU/wWRKXCt36Kd4daXpfC7SKf5sGzqLcnGE3MA0pJ4IgxDn25ahTtibahbhU+xHGQMVlbuVn1b0qx4FZwcRPYZf78827IHO0PRcp2FMq68YwtH9UMrUWgQTpYINGECiCCbGnzlDR9CAYn5SqSGBN0LUaIkcx2QrfKMb+je0y5SQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787062104; c=relaxed/simple; bh=fzMEcD+5r6tKxrknAhnrjhJs621wSLote86+3QEYlRA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UjAm9VZ6VW/J5iVM8MOaeczHGUUgDjkpRYrooKfczlu/Q55LHkPes4JAREN9HtGxMnFjewdMRYLQ7+BZmMr5LIQJLJn9Frdhp7s2w8khU+LCR3TFYMyKEDpt6+6dTawFOJLSpbk7WI4LU1Uytr1d8PwGWi8CBoaLVVKY0Sp2Pus= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=FEnq+zDE; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="FEnq+zDE" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4954f5e8020so24886415e9.2 for ; Tue, 18 Aug 2026 07:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1787062101; x=1787666901; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MIbU6RCAysXGTpiqsbxIiRINbcDHCsMbZAd9JSG5n84=; b=FEnq+zDEkODyxvvgfxfFU1tl15ic3Z5aWCn8BfwIOGfpL8+/aamt8MRXjws6LFsgxB hiaWce8yZvfuJAH9Gqsol6SVTaikJ6f4hXsl6rv+iK/JAvh8PbkfgisbZzKvkf7Fl+qb /GM0QCoQFCLpVmiFIG1NREwgmpngnT2e5i/w/wUsGHt0R2KtOf5ZLAA3XULUPDON0qPh 6yf3jANMp7oziC9yM4cBC9yXgA283uUQt+PoEVwY81cwVxrbrfdYKF2XBNcL/PQOGRyb o+9dFlqyE46/ufQQXUOgGlmFMOirRvGVDYhwV2L3tiBXM5aS9ADvknYIwFdawLd0giQ+ et6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787062101; x=1787666901; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MIbU6RCAysXGTpiqsbxIiRINbcDHCsMbZAd9JSG5n84=; b=o1sogBlMVmVozmbW/Zk/+yVDA8yrM3W3slr1YDvEjogMY3+XSrWK3pDFC/g5h/3seR MbNqmOhLOeT8HGR6U70zo3qCxaNHxdFdvZEeHCu3ake93tmG10p6chKbNFJoT65mA8Zo eUf9AHBzhciQMq6siTJRI3MkSlyeUjyZmk/mIp2ZjHX8aqg3UbhvH9SrUr32g070N5dS NTZ2UmytLmPoI34k8xHJ4xHuFDbF/L3+qOokrXVRBGr+Xo97DoZbUUgljnJZ3sGN9z5F jclqqau0zoRIxMKHNbwt5MVC0X9reXhvOSwnxxoEb+yBe0ctQs0McU5xriJn1NFi2MEs wZbA== X-Forwarded-Encrypted: i=1; AHgh+RqXMn2E64Ge6SdLKaSLD+IcuxThhoiK1wLUTcbUNnZwagC2EBwMf8NpNpDu83Hh7oddYZ2Jp5EwRwrC6OA=@vger.kernel.org X-Gm-Message-State: AOJu0YwclG5XwGs6lq4fw9+O82BEtiJjGupQcy6lGUFpB7YxlRzeicgF 5LN+LaAUJBYVLv1DJv9grNPx4JX5ACNUIfhtlcBnG34bBLmScgBN0pzJ7mRR4bgG4kM= X-Gm-Gg: AR+sD12lGd5tOc29ZzGJ6msd/eNksZ3BLlG0XcQG4CG3aXn1RP0VGt1+Vu6vi7SjaDw pHWMaNoS7a/5opEDKwCVxZF1UjYiIKydAc/RKqzWUUbeSLAlKmkME1MxE2XVqD5Mdr6SJdEyn4K GL6i4lgtqbQaSYnieeJu3CxDPhERACBV+6NA0lYXkJG+TEiFV7UdrAhRapeLFhgIrrcCRIPrAKy iBQM/p5F2gIu2QpDYUJIEmyg/j4MF70fDrZMPbmH9GyszHK+MZN4Hbn2RAcUzw8KJ4S0LkoNd69 B4fzcj+1jtbpvd0E+GctgAje7zV38ccWZYRb6cfHl1BEdH7NW+vqdDAqoDee2Veby1ltA9nST3m ATYFNmb+EZF/UGeDPvO5DzFImBoTV5mWuEiJ06ckC6fW9rvH2CISkWC0AHVKjbAa/8JZu15Pa67 BRqoU7PhPkACxBi5yWJqI5vmnuNfiyabO9TxGJT/Ni5lpHkgu3sLPRkHT2EBQ8hrcMXgOwJPI8P A== X-Received: by 2002:a05:600c:828c:b0:495:3da3:beb with SMTP id 5b1f17b1804b1-49989345963mr567071855e9.10.1787062100854; Tue, 18 Aug 2026 07:08:20 -0700 (PDT) Received: from localhost (109-81-87-166.rct.o2.cz. [109.81.87.166]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996100184sm300612795e9.1.2026.08.18.07.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2026 07:08:20 -0700 (PDT) Date: Tue, 18 Aug 2026 16:08:19 +0200 From: Michal Hocko To: Leon Hwang 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 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 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? > 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 -- Michal Hocko SUSE Labs