From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754023AbdFMVSw (ORCPT ); Tue, 13 Jun 2017 17:18:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53744 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753950AbdFMVSo (ORCPT ); Tue, 13 Jun 2017 17:18:44 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 87BB3723A1 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=longman@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 87BB3723A1 From: Waiman Long To: Tejun Heo , Li Zefan , Johannes Weiner , Peter Zijlstra , Ingo Molnar Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, pjt@google.com, luto@amacapital.net, efault@gmx.de, torvalds@linux-foundation.org, Waiman Long Subject: [PATCH-cgroup 5/5] cgroup: Enable debug controller only with cgroup_debug boot option Date: Tue, 13 Jun 2017 17:18:05 -0400 Message-Id: <1497388685-31207-6-git-send-email-longman@redhat.com> In-Reply-To: <1497388685-31207-1-git-send-email-longman@redhat.com> References: <1497388685-31207-1-git-send-email-longman@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 13 Jun 2017 21:18:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As suggested by Tejun, the debug controller will be activated only when the "cgroup_debug" option is specified in the kernel boot command line. Hopefully, that will discourage people from using the debug controller for any purpose other than cgroup core debugging. Signed-off-by: Waiman Long --- kernel/cgroup/debug.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kernel/cgroup/debug.c b/kernel/cgroup/debug.c index 82e5cbd..be901c0 100644 --- a/kernel/cgroup/debug.c +++ b/kernel/cgroup/debug.c @@ -320,3 +320,23 @@ struct cgroup_subsys debug_cgrp_subsys = { .dfl_cftypes = debug_files, .threaded = true, }; + +/* + * Disable the debug controller by hiding the debug cgroup control files + * if the kernel boot parameter "cgroup_debug" isn't set. + */ +static bool cgroup_debug_enable __initdata; +static int __init enable_cgroup_debug(char *str) +{ + cgroup_debug_enable = true; + return 1; +} +__setup("cgroup_debug", enable_cgroup_debug); + +static int __init debug_init(void) +{ + if (!cgroup_debug_enable) + debug_files[0].name[0] = '\0'; + return 0; +} +core_initcall(debug_init); -- 1.8.3.1