linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [patch] mm, slab: periodically resched in drain_freelist()
@ 2022-12-28  6:05 David Rientjes
  2022-12-29 13:41 ` Hyeonggon Yoo
  2023-01-02  8:32 ` Vlastimil Babka
  0 siblings, 2 replies; 3+ messages in thread
From: David Rientjes @ 2022-12-28  6:05 UTC (permalink / raw)
  To: Andrew Morton, Christoph Lameter, Pekka Enberg, Joonsoo Kim,
	Vlastimil Babka
  Cc: Roman Gushchin, Hyeonggon Yoo, linux-kernel, linux-mm

drain_freelist() can be called with a very large number of slabs to free,
such as for kmem_cache_shrink(), or depending on various settings of the
slab cache when doing periodic reaping.

If there is a potentially long list of slabs to drain, periodically
schedule to ensure we aren't saturating the cpu for too long.

Signed-off-by: David Rientjes <rientjes@google.com>
---
 mm/slab.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/slab.c b/mm/slab.c
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2211,6 +2211,8 @@ static int drain_freelist(struct kmem_cache *cache,
 		raw_spin_unlock_irq(&n->list_lock);
 		slab_destroy(cache, slab);
 		nr_freed++;
+
+		cond_resched();
 	}
 out:
 	return nr_freed;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] mm, slab: periodically resched in drain_freelist()
  2022-12-28  6:05 [patch] mm, slab: periodically resched in drain_freelist() David Rientjes
@ 2022-12-29 13:41 ` Hyeonggon Yoo
  2023-01-02  8:32 ` Vlastimil Babka
  1 sibling, 0 replies; 3+ messages in thread
From: Hyeonggon Yoo @ 2022-12-29 13:41 UTC (permalink / raw)
  To: David Rientjes
  Cc: Andrew Morton, Christoph Lameter, Pekka Enberg, Joonsoo Kim,
	Vlastimil Babka, Roman Gushchin, linux-kernel, linux-mm

On Tue, Dec 27, 2022 at 10:05:48PM -0800, David Rientjes wrote:
> drain_freelist() can be called with a very large number of slabs to free,
> such as for kmem_cache_shrink(), or depending on various settings of the
> slab cache when doing periodic reaping.
> 
> If there is a potentially long list of slabs to drain, periodically
> schedule to ensure we aren't saturating the cpu for too long.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
>  mm/slab.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -2211,6 +2211,8 @@ static int drain_freelist(struct kmem_cache *cache,
>  		raw_spin_unlock_irq(&n->list_lock);
>  		slab_destroy(cache, slab);
>  		nr_freed++;
> +
> +		cond_resched();
>  	}
>  out:
>  	return nr_freed;

Looks good to me,
Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>

-- 
Thanks,
Hyeonggon


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] mm, slab: periodically resched in drain_freelist()
  2022-12-28  6:05 [patch] mm, slab: periodically resched in drain_freelist() David Rientjes
  2022-12-29 13:41 ` Hyeonggon Yoo
@ 2023-01-02  8:32 ` Vlastimil Babka
  1 sibling, 0 replies; 3+ messages in thread
From: Vlastimil Babka @ 2023-01-02  8:32 UTC (permalink / raw)
  To: David Rientjes, Andrew Morton, Christoph Lameter, Pekka Enberg,
	Joonsoo Kim
  Cc: Roman Gushchin, Hyeonggon Yoo, linux-kernel, linux-mm

On 12/28/22 07:05, David Rientjes wrote:
> drain_freelist() can be called with a very large number of slabs to free,
> such as for kmem_cache_shrink(), or depending on various settings of the
> slab cache when doing periodic reaping.
> 
> If there is a potentially long list of slabs to drain, periodically
> schedule to ensure we aren't saturating the cpu for too long.
> 
> Signed-off-by: David Rientjes <rientjes@google.com>

Thanks, added to slab/for-6.2-rc3/fixes

> ---
>  mm/slab.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -2211,6 +2211,8 @@ static int drain_freelist(struct kmem_cache *cache,
>  		raw_spin_unlock_irq(&n->list_lock);
>  		slab_destroy(cache, slab);
>  		nr_freed++;
> +
> +		cond_resched();
>  	}
>  out:
>  	return nr_freed;



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-02  8:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-28  6:05 [patch] mm, slab: periodically resched in drain_freelist() David Rientjes
2022-12-29 13:41 ` Hyeonggon Yoo
2023-01-02  8:32 ` Vlastimil Babka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox