From nobody Tue Sep 16 23:31:20 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95E1BC4332F for ; Wed, 28 Dec 2022 06:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232391AbiL1GH7 (ORCPT ); Wed, 28 Dec 2022 01:07:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232405AbiL1GHK (ORCPT ); Wed, 28 Dec 2022 01:07:10 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8D626390 for ; Tue, 27 Dec 2022 22:05:50 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d3so15167841plr.10 for ; Tue, 27 Dec 2022 22:05:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=rnzuDwY9FmAO14Kx2NCVg1gQTcRNz9Evdut4pXlMBxI=; b=AuP2RTco0awU63q4n0GIvtcwnCHVbdJez5/WLQXESQzc/nIG8P+V8I1/YQ0XABgROh AJUunBwsQS5gpyEd73FnNTNJPfI3itXYrO4XsBpksWezZoyUAsq+BCFb+2S8d7Gba3xT K8vgYhXdLCRBrTgApccHpwg9VbaJi28eFoH6LUMhu7Gfyhii8pMPShKDc3M1fxceuqdu nXu527EnqbfxW10ZbxiDCwMFHbbyS8AppjLYkvLczwvMh9UQaPjw+H2dfRx8Sjer6lm1 Qz3blw42igyyTPs2tMSuhiK+kADhcFq+9b/8x2OKfsIxS5mZVZ1XPcYdZVnpqw04CQV7 I0wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rnzuDwY9FmAO14Kx2NCVg1gQTcRNz9Evdut4pXlMBxI=; b=xJltLeKsjEO/o3co/DUX91A5TL0kfkZdQtu+nCWvioYvCC3AkHXfgDkr281z5lggrj CBo6/RLf+pD8lVCKiXYerFgdK/vbY5Q/nzbY/aDd0Ld86h/upW8Ye5WO7j97sORbKrQT hkje9zIWg4mNV8vf+qiekfF2XlC/NJLBEGcq46q9nohvxUnGpQoVZaQQCh7jD7WllAKh KCjqAHzl4uMzlrowuid7btNg2TA7zydQkMXVhGMRsueUjUA18bpqmy+JRjp19IYNtf2M SrUvVyQ+IlLeIv+mdCaLjPDjwo1xarlO6aVVYdGRLB5umCpdgbj1urO0dsfCZrmdzlvq cH4g== X-Gm-Message-State: AFqh2krqUvH8oJXTOZZwcpIsLx4+b1rffcRaXqDFu1YXwxn6NCjb7K5e qv0GtjEjqHH88tlBE7DdgiyJ0w== X-Google-Smtp-Source: AMrXdXtlwww+E/odVueMr/N2wKd4XOMnCpTXEuIng2vOgpPBqnamR+zOalyxDDPEbMTdu1fZUbZ7MQ== X-Received: by 2002:a05:6a21:788c:b0:a3:49d2:9504 with SMTP id bf12-20020a056a21788c00b000a349d29504mr2890705pzc.3.1672207550025; Tue, 27 Dec 2022 22:05:50 -0800 (PST) Received: from [2620:15c:29:203:93f7:84:3b7b:8294] ([2620:15c:29:203:93f7:84:3b7b:8294]) by smtp.gmail.com with ESMTPSA id h7-20020a17090a470700b002192a60e900sm11029318pjg.47.2022.12.27.22.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Dec 2022 22:05:49 -0800 (PST) Date: Tue, 27 Dec 2022 22:05:48 -0800 (PST) From: David Rientjes To: Andrew Morton , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Vlastimil Babka cc: Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [patch] mm, slab: periodically resched in drain_freelist() Message-ID: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.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;