From patchwork Tue Nov 15 12:32:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13043631 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 B4AAAC433FE for ; Tue, 15 Nov 2022 12:33:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF8D66B0071; Tue, 15 Nov 2022 07:33:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EA8F96B0072; Tue, 15 Nov 2022 07:33:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D709A6B0073; Tue, 15 Nov 2022 07:33:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C86436B0071 for ; Tue, 15 Nov 2022 07:33:07 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 851E11A0345 for ; Tue, 15 Nov 2022 12:33:07 +0000 (UTC) X-FDA: 80135616414.26.A2CA7E0 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf02.hostedemail.com (Postfix) with ESMTP id CFDDC80006 for ; Tue, 15 Nov 2022 12:33:06 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2C4411F8BB; Tue, 15 Nov 2022 12:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1668515585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ov4IntMh1mYD05NlyIvDOngzaPFng6qjIpx/DzR1trk=; b=keligk7h+jx7OrwjZ/ogOdXwUBllamH9JSZRDSps5w6oxJF4fpZ4OOCkoD1IREpEHTo1sS a4OWMZq9V9kvs+GJBFfD9oRRJncj2Pxj4dl96twpBkgpKGuuf2Zui5Gon93JBkiX7xqfiE N5fQNn1jcaPBLjBfp5mUmJA0glEpDf8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1668515585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ov4IntMh1mYD05NlyIvDOngzaPFng6qjIpx/DzR1trk=; b=XFSneoHklT/wSYY5Q0BhkMHEfCaldnTjvgAYh3VAmxl44YZf7s23BGoP5kZn/j6DfFBjjX DwZohcVx7X1fBtDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1287A13A91; Tue, 15 Nov 2022 12:33:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id tAN5BAGHc2OhQwAAMHmgww (envelope-from ); Tue, 15 Nov 2022 12:33:05 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 69B9AA0709; Tue, 15 Nov 2022 13:33:04 +0100 (CET) From: Jan Kara To: Andrew Morton Cc: , Vladimir Davydov , Jan Kara , You Zhou , Pengfei Xu Subject: [PATCH] mm: Make drop_caches keep reclaiming on all nodes Date: Tue, 15 Nov 2022 13:32:55 +0100 Message-Id: <20221115123255.12559-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2135; i=jack@suse.cz; h=from:subject; bh=DaUH7Om3HqpY36CIZHQFPOvUJnNSTJwkledILicaaFY=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBjc4bx1VtHKdnLLh76KEfVB6wgpaKGPBnc3BaTE6fq 37+ZWQOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCY3OG8QAKCRCcnaoHP2RA2Z4VB/ wNKc4CTmpps4MZKobJo137gvhUN23nLVKReB7Dpj7YyWBG6IIg4roFF5AD9nci6zE/+wolyFt8EGU9 PhTMEuWjtRSE9qNKiz2jEl11HPYPN/PU8SYeYdCXHT8eGw5u5RTenB3Fs0YEQqvgo/o4xCF/iYhxSV h0Xtsl4V4FmZpr8oNELm4F/5KW27NJugaJYx+wkX7/pRncPejKeDxrmUDl1F/m4py5UCOfDbSO4TCI +savnlYasAbhfDjanRNTGZzfgTeql9JVNQsbPF1v04J6GBpFOsr0NJsp6LYMVIm/wZaZbblglLfJRz 9ThBdkvNQR8p4LXswMNfaGF9oWyVzV X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668515587; a=rsa-sha256; cv=none; b=jQP3AeO5tGuJK1xa95p48s6L4CbcUpxKGr/bZxpkY4s4cUyLyAwBVeU8Bj96Bwth0aNZAU vOm+ezbXRylSbjtDYNT8kMJVzj6tb3zPcuijmSopkdeFYawsM34UptcptgRMJOleFxxT6T aL9GKMQF+2HZLDItj+1ysDvnrzppKuQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=keligk7h; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=XFSneoHk; dmarc=none; spf=pass (imf02.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668515587; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=ov4IntMh1mYD05NlyIvDOngzaPFng6qjIpx/DzR1trk=; b=DXKmGJntCEgjeFnWKjYrWDtyPl/x2QgG61Nfq9hQ3zIT/7MHGZVaSl3RhldI21CwhptYEp hmiehTB8sb+DP4hs3frGK4eM7YUIKB+9RVA2XL/w+cX11K9Fj4wypsHYPIhUv4geqR/i0K AWSMm0Yf5cMYqVz9YcDdAvv9MPcbijc= X-Rspamd-Queue-Id: CFDDC80006 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=keligk7h; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=XFSneoHk; dmarc=none; spf=pass (imf02.hostedemail.com: domain of jack@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=jack@suse.cz X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cno4zbipohtqqoyyru1igp968k5kwgmo X-HE-Tag: 1668515586-119084 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: Currently, drop_caches are reclaiming node-by-node, looping on each node until reclaim could not make progress. This can however leave quite some slab entries (such as filesystem inodes) unreclaimed if objects say on node 1 keep objects on node 0 pinned. So move the "loop until no progress" loop to the node-by-node iteration to retry reclaim also on other nodes if reclaim on some nodes made progress. This fixes problem when drop_caches was not reclaiming lots of otherwise perfectly fine to reclaim inodes. Reported-by: You Zhou Reported-and-tested-by: Pengfei Xu Signed-off-by: Jan Kara Reviewed-by: Shakeel Butt --- mm/vmscan.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 04d8b88e5216..70d6d035b0fc 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1020,31 +1020,34 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, return freed; } -static void drop_slab_node(int nid) +static unsigned long drop_slab_node(int nid) { - unsigned long freed; - int shift = 0; + unsigned long freed = 0; + struct mem_cgroup *memcg = NULL; + memcg = mem_cgroup_iter(NULL, NULL, NULL); do { - struct mem_cgroup *memcg = NULL; - - if (fatal_signal_pending(current)) - return; + freed += shrink_slab(GFP_KERNEL, nid, memcg, 0); + } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); - freed = 0; - memcg = mem_cgroup_iter(NULL, NULL, NULL); - do { - freed += shrink_slab(GFP_KERNEL, nid, memcg, 0); - } while ((memcg = mem_cgroup_iter(NULL, memcg, NULL)) != NULL); - } while ((freed >> shift++) > 1); + return freed; } void drop_slab(void) { int nid; + int shift = 0; + unsigned long freed; - for_each_online_node(nid) - drop_slab_node(nid); + do { + freed = 0; + for_each_online_node(nid) { + if (fatal_signal_pending(current)) + return; + + freed += drop_slab_node(nid); + } + } while ((freed >> shift++) > 1); } static inline int is_page_cache_freeable(struct folio *folio)