From patchwork Wed Dec 28 06:05:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rientjes X-Patchwork-Id: 37111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1739407wrt; Tue, 27 Dec 2022 22:08:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXsubwQlhVudWRLQZKOsXv8LzIfybe2NImJH9wCnukS69qb55k0nrjEGg5umSxmkfQpHxuCW X-Received: by 2002:a17:902:8f87:b0:189:2688:c97f with SMTP id z7-20020a1709028f8700b001892688c97fmr27330604plo.50.1672207725897; Tue, 27 Dec 2022 22:08:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672207725; cv=none; d=google.com; s=arc-20160816; b=gv5mJjXbDojO61kUZs4yTkV01Kf9ZcFavoa2hZOjwXn+hEjg4i3gVs8tsu9i45TQUt 7G3b/sS15sh7jOB0TgAemWDrB9EuKWsUNR4LfpG21VjVwGTRTG0dDGwV16bFf8RM9Io4 uGag7JFy6+MfMA8N6dxta1/XpUi01ZWu5RlRzI8h+Kc+58PjSQi7tNyuCV7DCOpFbT7e DH0lAJfFEzXhQdsk+z3lNo+5zz1v8kaD6R+nFBHfO1tAjWtv0HN5I0R73y507MxZhY2o Sr4duY8ddQgOko+z75krLPYqMoEty8HI1MSHh9pTq2VgKpoewE6kotekhKwGt9ECSZDU 7eVA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a170902e74400b00189d297243fsi16773580plf.254.2022.12.27.22.08.34; Tue, 27 Dec 2022 22:08:45 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753436888199533822?= X-GMAIL-MSGID: =?utf-8?q?1753436888199533822?= 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;