Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4110100rwl; Tue, 27 Dec 2022 22:29:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXs2YeMWrKKICdY+CyDS+iIZOKW7EPpcAyE82Drjk0lLVQitX/2vjOyQQFr321LbcdhgFaSc X-Received: by 2002:a05:6a00:2281:b0:581:a8dc:8f95 with SMTP id f1-20020a056a00228100b00581a8dc8f95mr271287pfe.12.1672208998664; Tue, 27 Dec 2022 22:29:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672208998; cv=none; d=google.com; s=arc-20160816; b=UDjxXAPghB0KtyI0J11Xl1F6Spi2ubzkYc/oMrF4H+GO6RsAKLwXuwAf6XtlFDVvpb mQgmciquuye4Q6nlL5DTktOoukBm2Cex2VgpJ6ysf06CFzCMjcCiuE06OCi11+FdMJqj VJSaRRpV+aVBJvdet3LZQlSNHbZLMVLPHVL3mjYKmXGihzqO0LJ90zZQD5+O46WQ7ZxS xXri65YfsmtYWUbPSkB0xxtMWhIFgGNHCLtyp8N6d8RWCxeALcNduHekht8svkKy1usi PskG9ZI9D9HH1DccAk9XW4k/Ke+MfX+ys9F6BCUsswngYF6+fyVl4ws5pTtbRziQ/x1N ENIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=rnzuDwY9FmAO14Kx2NCVg1gQTcRNz9Evdut4pXlMBxI=; b=0YfmGhN/6Tr/Ee0/BHzZmXhQmCtipK31cB+cH2VGc5NLrU6Qrkcr6F9G+ZYqtFEUJX X7fw2ILJATayPeulxBF/b7/Tsrm0KgAOG+GWlSeVjae1r5u02xHAm5hDM2EpcLAkFjnP IXEYvTOcIT9kgKDiuIGS5LYBuNLFbc2CVheo/C8kZUP3FoEIsId8JZHE3PGnif0MmBnm dcmrQ2jtQVCvH6Rw7QiH1ELScMbG4c3BdDM9vmFHyk/tmeWQaPua7XRnoast0JtVqMAk hjkMNIECskjOymEdXsM2XBXzMLD3mPjG3zL7r61BrJazKT3VGoja91KumTcT+Bq7qdEu Cezg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=AuP2RTco; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 73-20020a62144c000000b0058167c50a3asi3697707pfu.142.2022.12.27.22.29.50; Tue, 27 Dec 2022 22:29:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=AuP2RTco; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232294AbiL1GH7 (ORCPT + 65 others); 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-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 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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;