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: 13082711 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5997FC4332F for ; Wed, 28 Dec 2022 06:05:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 612E68E0002; Wed, 28 Dec 2022 01:05:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C39A8E0001; Wed, 28 Dec 2022 01:05:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48A6F8E0002; Wed, 28 Dec 2022 01:05:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3705C8E0001 for ; Wed, 28 Dec 2022 01:05:53 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 00D391403CE for ; Wed, 28 Dec 2022 06:05:52 +0000 (UTC) X-FDA: 80290678986.07.8CE8D27 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by imf21.hostedemail.com (Postfix) with ESMTP id 66D781C0012 for ; Wed, 28 Dec 2022 06:05:51 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=AuP2RTco; spf=pass (imf21.hostedemail.com: domain of rientjes@google.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=rientjes@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672207551; a=rsa-sha256; cv=none; b=wzzetF+d94mGwnZneR3a79gis8yLOJlhuk6H5GhydbncVJyhsWvQuGkG8nxaoOaAESbDLl eBfc0wpMDaFIIo2QyPO1XsuhHALKHSka9DKSlfQeaR8fXlvN5fiiwFXHUUUm8DepeSXNbI 3Yqkatzytb3kLA4durvll9vnV5DAumA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=AuP2RTco; spf=pass (imf21.hostedemail.com: domain of rientjes@google.com designates 209.85.216.42 as permitted sender) smtp.mailfrom=rientjes@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672207551; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=rnzuDwY9FmAO14Kx2NCVg1gQTcRNz9Evdut4pXlMBxI=; b=DVugP1r5T3E+6BxR69FcPV8KKouvWaZjVkK7tihL5ZjmS0ElHHqt3oASqFUyI9IIuopVgJ 4Q0UOlMmYG1N5J8YStQoCoNhZ96df1dPo4j5aruacUsSEr4wKsTnPDVTy8clJ/AscWDrBo XPaF9jWOvRhmHJ143bgbaIw8LVwBTZU= Received: by mail-pj1-f42.google.com with SMTP id j8-20020a17090a3e0800b00225fdd5007fso5531392pjc.2 for ; Tue, 27 Dec 2022 22:05:51 -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=NqHXiVR8V00OTE5AeyLV58FZkDGFN96gO5GCn4u2EoqSqyqKoAlEIIFgHeagOssFxg lCOQypjGgs2rSewkR0yqdub2TwZEAA1qdOT5V2SBBa83dGofWn7OsD7i6UI0E99ZKNq0 ibsBnQG/8n0FZ9znduH4v6zY0Zy1o4DtWaVM12PJc8PvTaM7JPmXREIY1W7n2gkYwXQJ sOfZS1kONMXFvREfu4q6qofQYvF19YRON2ZL4isjg6IADOzCWuSixZNgjC/jo1269pr3 5K1dJbb7p9N3AxXsBg0dg8pcnERqKiVVPALQSqaOcW+RqXMhk+C3bJaCH4rcBc7D/ue/ sblQ== X-Gm-Message-State: AFqh2krb5Y06cFo8CBjWvSwu+2ZawproFgsQ2WaQY2bdPloIb+T+w4Ud U8gpPUbvKVCo4g3prEk9gpwEFw== 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 X-Rspam-User: X-Rspamd-Queue-Id: 66D781C0012 X-Rspamd-Server: rspam01 X-Stat-Signature: h4tqr93k5iy9irqcqe15da8uwqotzotg X-HE-Tag: 1672207551-327259 X-HE-Meta: U2FsdGVkX18iTQdsozPt/b0GJLJ0iQdxbqcb6MX6Ej3CxKyj/R4JSKvbvoe5RqUtFWhCAAeEj1Cl0hMIUUzqWpSkWQ3Xuof4MAHMNs8ZmP5sm6u2osVm+ibDH/KjOXM9XPr07D3yTVAbNhypW2jtB3GkV+oFlWyeuGJMmky3uiTw990YiVxhaZFfE5iT56sxdaadXiTmvq7vlNCLCre78DtDfZn6JdGbDngxDLX+e1Z9VKrOAe4DoXOnyuL4CQnT5CAieP5jBxQ7oLO9nelKuwseDADDA5raJjjn3hgd8GB2GfO/YcyL9OBoRaNvdZzObdUhC7piuoF/tO0Hj6uTbBD4jZHMx3UBTS6PfBJ/oyxLJ3JRE+2EPYP8ukbMWH32skWtL8fyzPTkH7l7d2L5JsorXyl+NAjsxy6ketDHUTBeqzew8SDcpbtyvCRBzPJJlF9qn7aLwQEeD5UfekLm1dDoRaiEZL3OACT5K/n2SPgLxMhd79LdNCb+IANW/6lEoCdJFevmF5D9n2ZQSfzypYkxc4B5MkE4Yy6u7LCxgAuw8MTac4SjT4bAuJcWTmQa93BgelxuTW3aotUHbTB9STDKwDc8ozp4S9E1IwGK7jt6P5Cz1iZYwahJqTNVMjkPWcVP8FZl4syJb3sXj0/a9ET7VPmv7ftGcYON2wNt2zPh7SmFwtWOYbz8ptUWRgrDwR+0pryI19R4ZzauvE1slVlzAgfWif4ZLmfXhw+Tp9fN6nq+oQqBtSCEVVttHkcjbmpgzt+CPZgeWh7j1DulJySHgNzlpxJPSepulUvPbTxNSD8RWjWTbRwVa5/Eu4IH4ZwahkdUDppsqNcqRsznb4sN9DyMeDGyz2TBYmMdmZ4meePWXGrgk0AffSViiYwwRxOem6EXv7SRrpf3hDy99JnWr+LFRZWaTsEeHuTlU8JVV1gZj4nSLUXmQ7viDaBIChsku9ZwLM2J0sCArZz ybiBN9wl VHG8jbyPESWeHGoK5BCohjK+ZR6pplUq5sh/2X9lT3hBnLk+Opew/oXlKe7J5Woq8/8KByl++D34Ln8nARjSG0RWMl8UyVtAVeSVO1tPCJMcJKZ5dSIqfC9gCW9EMZj6qRUdF4DjyC14M4TEARIFNU9JMY1bz/4diG4h74zkAO2EJOBhyEsAFXkVnXM7NscD+9Wy7ia+r6zKT2zjjc0SjUisNqg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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;