From mboxrd@z Thu Jan 1 00:00:00 1970 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 219CFECAAD2 for ; Fri, 2 Sep 2022 03:15:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234448AbiIBDPj (ORCPT ); Thu, 1 Sep 2022 23:15:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234274AbiIBDPd (ORCPT ); Thu, 1 Sep 2022 23:15:33 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91FB72A24D for ; Thu, 1 Sep 2022 20:15:27 -0700 (PDT) X-UUID: 3482856cadea4ddd9fb7aad610f43852-20220902 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=g2xnOcGvBy3Njjbz6b+gGaRXL1W5YwhL4H3CLYHZZnE=; b=oEkwR3Wi64K/9jiLcuqJ7nvDXg/FHOLCwD5JOqc8liQ/42rT9A5vcp5U9RVLpT46K4BZNOLgZMgkUKL6pyOFbps9h9VKvNPyuEBIrYY0I8desglfWXl98oUWXPxRldtH/kpfbwQi1DwQ24CGQZxbMsUQD3j7lTrq5PN+1S+kOho=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.10,REQID:3e20c926-97d5-4b7d-9de9-bb76eb4d32be,OB:0,L OB:0,IP:0,URL:0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Rele ase_Ham,ACTION:release,TS:75 X-CID-INFO: VERSION:1.1.10,REQID:3e20c926-97d5-4b7d-9de9-bb76eb4d32be,OB:0,LOB :0,IP:0,URL:0,TC:0,Content:-25,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_G S981B3D,ACTION:quarantine,TS:75 X-CID-META: VersionHash:84eae18,CLOUDID:577c5b56-e800-47dc-8adf-0c936acf4f1b,C OID:8e22b45f06f8,Recheck:0,SF:28|17|19|48,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 3482856cadea4ddd9fb7aad610f43852-20220902 Received: from mtkcas11.mediatek.inc [(172.21.101.40)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 429735254; Fri, 02 Sep 2022 11:15:23 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Fri, 2 Sep 2022 11:15:22 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 2 Sep 2022 11:15:22 +0800 From: Kuyo Chang To: , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Daniel Bristot de Oliveira , Valentin Schneider , Matthias Brugger , Greg Kroah-Hartman CC: , , kuyo chang , , , Subject: [PATCH 1/1] sched/debug: fix dentry leak in update_sched_domain_debugfs Date: Fri, 2 Sep 2022 11:15:15 +0800 Message-ID: <20220902031518.1116-1-kuyo.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: kuyo chang [Syndrome] Lowmemorykiller triggered while doing hotplug stress test as below cmd: echo [0/1] > /sys/devices/system/cpu/cpu${index}/online Rootcause: Call trace of the slab owner & usage as below after hotplug stress test(4hr). There exists dentry leak at update_sched_domain_debugfs. Total size : 322000KB : : <__alloc_pages+304>: : <___slab_alloc+404>: <__slab_alloc+60>: : : : <__debugfs_create_file+172>: : : : : : : [Solution] Provided by Major Chen as below link. https://lore.kernel.org/lkml/20220711030341epcms5p173848e98b13c09eb2fcdf2fd7287526a@epcms5p1/ update_sched_domain_debugfs() uses debugfs_lookup() to find wanted dentry(which has been created by debugfs_create_dir() before), but not call dput() to return this dentry back. This result in dentry leak even debugfs_remove() is called. [Test result] Using below commands to check inode_cache & dentry leak. cat /proc/slabinfo | grep -w inode_cache cat /proc/slabinfo | grep -w dentry With the patch, the inode_cache & dentry stays consistent so the lowmemorykiller will not triggered anymore. Fixes: 8a99b6833c88 ("sched: Move SCHED_DEBUG sysctl to debugfs") Signed-off-by: Major Chen Signed-off-by: kuyo chang Tested-by: kuyo chang --- kernel/sched/debug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index bb3d63bdf4ae..4ffea2dc01da 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -412,11 +412,14 @@ void update_sched_domain_debugfs(void) for_each_cpu(cpu, sd_sysctl_cpus) { struct sched_domain *sd; - struct dentry *d_cpu; + struct dentry *d_cpu, *d_lookup; char buf[32]; snprintf(buf, sizeof(buf), "cpu%d", cpu); - debugfs_remove(debugfs_lookup(buf, sd_dentry)); + d_lookup = debugfs_lookup(buf, sd_dentry); + debugfs_remove(d_lookup); + if (!IS_ERR_OR_NULL(d_lookup)) + dput(d_lookup); d_cpu = debugfs_create_dir(buf, sd_dentry); i = 0; -- 2.18.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4000AECAAD2 for ; Fri, 2 Sep 2022 03:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=/chHKqdU8d7Er9OKSH1+nUTRSkvPcjWnQMBslTOmZ/4=; b=LGy405Rgh5ao0X /+mf14Fk0wJFUzrdLgHD3qnYb3vhwiIzMBcgQE3ub47EdRCuTZHafCdg3CE+RwHTel77zqoqLzYDk pWDh805OULAyJsfOl6mLmmhifyds/n5/hc6l13s/pJZVJPSadLknAaiwshzSeQhU6oxf2N61HNt38 w1xbFjF+MNb2ToiOgHuVVESPgSgLFovK/QymFnSRYuwo6iBDv+fiR6Py8qga6aifsb8webbIrMpFV al/AXBjfE19Tv8JxnbuZE2nZ2FVv6WezvHYlG7lW5TNBpFuk36E7VxMyQxOFCDca9YHAO3fqgx8TR NhDl0UwA6Ebua/ybjEVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oTxO6-00HMOf-J0; Fri, 02 Sep 2022 03:30:34 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oTxO2-00HML4-VA; Fri, 02 Sep 2022 03:30:32 +0000 X-UUID: e366445ba6ae4f6ab786cef997444d12-20220901 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=g2xnOcGvBy3Njjbz6b+gGaRXL1W5YwhL4H3CLYHZZnE=; b=oEkwR3Wi64K/9jiLcuqJ7nvDXg/FHOLCwD5JOqc8liQ/42rT9A5vcp5U9RVLpT46K4BZNOLgZMgkUKL6pyOFbps9h9VKvNPyuEBIrYY0I8desglfWXl98oUWXPxRldtH/kpfbwQi1DwQ24CGQZxbMsUQD3j7lTrq5PN+1S+kOho=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.10,REQID:be8397f6-bfc3-4f0b-951f-5a98ad7e8865,OB:0,L OB:0,IP:0,URL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Releas e_Ham,ACTION:release,TS:-25 X-CID-META: VersionHash:84eae18,CLOUDID:63825b56-e800-47dc-8adf-0c936acf4f1b,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:1,File:nil ,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: e366445ba6ae4f6ab786cef997444d12-20220901 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1878482296; Thu, 01 Sep 2022 20:15:52 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Fri, 2 Sep 2022 11:15:22 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Fri, 2 Sep 2022 11:15:22 +0800 From: Kuyo Chang To: , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , "Mel Gorman" , Daniel Bristot de Oliveira , Valentin Schneider , Matthias Brugger , Greg Kroah-Hartman CC: , , kuyo chang , , , Subject: [PATCH 1/1] sched/debug: fix dentry leak in update_sched_domain_debugfs Date: Fri, 2 Sep 2022 11:15:15 +0800 Message-ID: <20220902031518.1116-1-kuyo.chang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220901_203031_023189_8EBADE0E X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: kuyo chang [Syndrome] Lowmemorykiller triggered while doing hotplug stress test as below cmd: echo [0/1] > /sys/devices/system/cpu/cpu${index}/online Rootcause: Call trace of the slab owner & usage as below after hotplug stress test(4hr). There exists dentry leak at update_sched_domain_debugfs. Total size : 322000KB : : <__alloc_pages+304>: : <___slab_alloc+404>: <__slab_alloc+60>: : : : <__debugfs_create_file+172>: : : : : : : [Solution] Provided by Major Chen as below link. https://lore.kernel.org/lkml/20220711030341epcms5p173848e98b13c09eb2fcdf2fd7287526a@epcms5p1/ update_sched_domain_debugfs() uses debugfs_lookup() to find wanted dentry(which has been created by debugfs_create_dir() before), but not call dput() to return this dentry back. This result in dentry leak even debugfs_remove() is called. [Test result] Using below commands to check inode_cache & dentry leak. cat /proc/slabinfo | grep -w inode_cache cat /proc/slabinfo | grep -w dentry With the patch, the inode_cache & dentry stays consistent so the lowmemorykiller will not triggered anymore. Fixes: 8a99b6833c88 ("sched: Move SCHED_DEBUG sysctl to debugfs") Signed-off-by: Major Chen Signed-off-by: kuyo chang Tested-by: kuyo chang --- kernel/sched/debug.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index bb3d63bdf4ae..4ffea2dc01da 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -412,11 +412,14 @@ void update_sched_domain_debugfs(void) for_each_cpu(cpu, sd_sysctl_cpus) { struct sched_domain *sd; - struct dentry *d_cpu; + struct dentry *d_cpu, *d_lookup; char buf[32]; snprintf(buf, sizeof(buf), "cpu%d", cpu); - debugfs_remove(debugfs_lookup(buf, sd_dentry)); + d_lookup = debugfs_lookup(buf, sd_dentry); + debugfs_remove(d_lookup); + if (!IS_ERR_OR_NULL(d_lookup)) + dput(d_lookup); d_cpu = debugfs_create_dir(buf, sd_dentry); i = 0; -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel