Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4552465ybl; Tue, 21 Jan 2020 23:44:57 -0800 (PST) X-Google-Smtp-Source: APXvYqyv7CbbWuo4tgNuYASGQgUcobGLpXbvhFH7ckDkjvTi0j62XUTVcRNTck6LVJ9Lnmd2dmCr X-Received: by 2002:a05:6830:2014:: with SMTP id e20mr6234245otp.272.1579679097232; Tue, 21 Jan 2020 23:44:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579679097; cv=none; d=google.com; s=arc-20160816; b=rjf7u5Q73y+eyDF/JEhUrNWMxDyNnvZHmndfkx2rOoQKYlSpOuaRBh12M/A9crK0mk 5LiRNvIeXOnn/POd0vph1ncOuscQy2rtu5C7BM+omgveZS5K6T9h0awv83XyYeOsS18p SCIg2a9+vSuMOqui2pBwfc7jarL352bAR0QpvpdWSrmfbpT/mqoeb4bara/EebNKzNCE u1M7xdEePxoFImaa++uOdd+qFToeAAlf0n/yRoF/0STZp+PqphCYcbC5/yLFDQiHBn6+ gheQBJtCOZCz6DVP9F05GXmhfj9Kkvqtp266nIVJo06Lj+SQH71CUvSoOi/zwfDJ6rcS b5nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=LB+N1t2qjMLt74p7vmqF1K76S7vVzwDDzPlH/SwxTdQ=; b=gx1f9px2xQJFZVrZ+zwAygcUsaDcOHZwT25Dpj1KSNOM+QRDfJAZYiWSwwW2IqPh3k cgfg6nqL4l6nrE3fmEDIDuF9zaynuSFi6YpdpbTKUCVWnDXwztgXunsjTPOw7d4nKYbP jcjGfpNOssRnK5uaZLfmS2Hc+VE0l3EnCDm8AWgkjxj1PbfwDWVPd3NGNXH2rPJ+MlUx sDRlFsoMoFyIWKp1QrfOba6ELqQxa4izGivaTrr+zXi1uWi5JsI5Vp9VYfILjguLNEgm AjFhjDYZzYx189JcP8Xte4QfNlVdwdJJftpGz5Vw5xB7rTyYcqPWoF+3VpXGtPKPbURh z5rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yb6xsOrG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si26088667otf.66.2020.01.21.23.44.45; Tue, 21 Jan 2020 23:44:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yb6xsOrG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgAVHnq (ORCPT + 99 others); Wed, 22 Jan 2020 02:43:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:60462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbgAVHnq (ORCPT ); Wed, 22 Jan 2020 02:43:46 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C8A524655; Wed, 22 Jan 2020 07:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579679025; bh=/whmBYaC4rMnY2P9A7GfcDIpf7X1/9zZdmRFzlm610M=; h=Date:From:To:Cc:Subject:From; b=yb6xsOrGMvzG3Ptwiwt/om1+S/5rfFSIWAUUR4f6pNNliLpiYvtmiXhWU584zGew/ jYUHjCUYcFNzB1fHhY7G2jxFpxnPyiAa7+YfKOgXKE8FY4k/MDosdiCM9UBrEMua3s GMvEFqwbJY+50BUM2pyEYrGCIcdNe8TSu1o3ixa8= Date: Wed, 22 Jan 2020 08:43:43 +0100 From: Greg Kroah-Hartman To: Jason Baron Cc: linux-kernel@vger.kernel.org, kernel-team@android.com Subject: [PATCH] dynamic_debug: allow to work if debugfs is disabled Message-ID: <20200122074343.GA2099098@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the realization that having debugfs enabled on "production" systems is generally not a good idea, debugfs is being disabled from more and more platforms over time. However, the functionality of dynamic debugging still is needed at times, and since it relies on debugfs for its user api, having debugfs disabled also forces dynamic debug to be disabled. To get around this, move the "control" file for dynamic_debug to procfs IFF debugfs is disabled. This lets people turn on debugging as needed at runtime for individual driverfs and subsystems. Reported-by: many different companies Cc: Jason Baron Signed-off-by: Greg Kroah-Hartman --- .../admin-guide/dynamic-debug-howto.rst | 3 +++ lib/Kconfig.debug | 2 +- lib/dynamic_debug.c | 17 ++++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/dynamic-debug-howto.rst b/Documentation/admin-guide/dynamic-debug-howto.rst index 252e5ef324e5..41f43a373a6a 100644 --- a/Documentation/admin-guide/dynamic-debug-howto.rst +++ b/Documentation/admin-guide/dynamic-debug-howto.rst @@ -54,6 +54,9 @@ If you make a mistake with the syntax, the write will fail thus:: /dynamic_debug/control -bash: echo: write error: Invalid argument +Note, for systems without 'debugfs' enabled, the control file can be +also found in ``/proc/dynamic_debug/control``. + Viewing Dynamic Debug Behaviour =============================== diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 5ffe144c9794..01d4add8b963 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -98,7 +98,7 @@ config DYNAMIC_DEBUG bool "Enable dynamic printk() support" default n depends on PRINTK - depends on DEBUG_FS + depends on (DEBUG_FS || PROC_FS) help Compiles debug level messages into the kernel, which would not diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c60409138e13..077b2d6623ac 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -993,13 +993,24 @@ static __initdata int ddebug_init_success; static int __init dynamic_debug_init_debugfs(void) { - struct dentry *dir; + struct dentry *debugfs_dir; + struct proc_dir_entry *procfs_dir; if (!ddebug_init_success) return -ENODEV; - dir = debugfs_create_dir("dynamic_debug", NULL); - debugfs_create_file("control", 0644, dir, NULL, &ddebug_proc_fops); + /* Create the control file in debugfs if it is enabled */ + if (debugfs_initialized) { + debugfs_dir = debugfs_create_dir("dynamic_debug", NULL); + debugfs_create_file("control", 0644, debugfs_dir, NULL, + &ddebug_proc_fops); + return 0; + } + + /* No debugfs so put it in procfs instead */ + procfs_dir = proc_mkdir("dynamic_debug", NULL); + if (procfs_dir) + proc_create("control", 0x644, procfs_dir, &ddebug_proc_fops); return 0; } -- 2.25.0