From patchwork Fri Aug 24 13:12:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Whitchurch X-Patchwork-Id: 10575323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFB0B174C for ; Fri, 24 Aug 2018 13:12:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B96142C33B for ; Fri, 24 Aug 2018 13:12:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB68E2C42A; Fri, 24 Aug 2018 13:12:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7116F2C33B for ; Fri, 24 Aug 2018 13:12:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 501E66B2FDB; Fri, 24 Aug 2018 09:12:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4D9196B2FDC; Fri, 24 Aug 2018 09:12:40 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EFA86B2FDD; Fri, 24 Aug 2018 09:12:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by kanga.kvack.org (Postfix) with ESMTP id C1B426B2FDB for ; Fri, 24 Aug 2018 09:12:39 -0400 (EDT) Received: by mail-lj1-f199.google.com with SMTP id t18-v6so1151521ljb.6 for ; Fri, 24 Aug 2018 06:12:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=HhfUvmldem/bW9PfCrLyE0Fox8HADWDt254hdTva/Ec=; b=QpZgI5jIwyNq31XVnmG/2rFTfTFI57UUDA5wJ55s2IxvK5o7q3T6UDIcSV7Og6QpJJ 293yJYTZLkXCpGhrn/nMZ29UnEO3terR5314OIkf81pCa6crBmYt6SY/BoLGN5MUlxEp jePSteQTHQ3/CSAiLzx5D6d11ACs2EQQrrml77qp/F+Eom36MHp+/2F9EaUAE6zn+jZb Kh2lSHS6UlnPecD4NHx0Ml64xXHQb68ZDlr9d2UEhHtvUJ4THVgBjlv30TC2JRQN7zPc Vt/IyyQ5QmmP8JipHZ/DK2Yo1QQOYJJyGQz6ZSPnxHLiylXHr9sgisAlB2XEcEZZ13lr XUcQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincent.whitchurch@axis.com designates 195.60.68.11 as permitted sender) smtp.mailfrom=vincent.whitchurch@axis.com X-Gm-Message-State: APzg51ATMXPSye6jBdN+Htox5VihplUMaftESTRliJ3o6yyVVIh9aRg1 PQLRh9egJQBtWKE9l/fjjpmWgHlScNlP0xuk/O9SIWhiY6mzlZvezZWtn+DmH95XAaVoDCRFjSV 6WARXcK6iym8SiXO8WjOKaK2jH2p76LYS5BwEl540If0I7nQukbhXEbHi0tq2JGo+Mg== X-Received: by 2002:a19:73c5:: with SMTP id h66-v6mr1350386lfk.22.1535116359209; Fri, 24 Aug 2018 06:12:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbYPGGstF1nGDYQ9nB15bvrqS58uKDv7/AayevrgaYL1ozG4DVDrOL0Kd0naaRQ27U4d3AQ X-Received: by 2002:a19:73c5:: with SMTP id h66-v6mr1350335lfk.22.1535116358203; Fri, 24 Aug 2018 06:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535116358; cv=none; d=google.com; s=arc-20160816; b=RF8h27BDTaRY79etGDV5Pxxy15JVlHJdV1P3wL8qaPsU7LJcqyLQ4FfPYyWZaVAGp/ N+6GmiD5mKLlYWIR4H6+N3bR7nr5Js8SeWEINFIKUeHFBgh93koIbxbPbDWKgzXFCpJB NqZkkzyzqsmrvDOoC6gYZkqyit6hYVv9LDRRBm/YQXUtLlXJknYPLjIM0deTu+y/rCK7 ZtGoOYTnaXrx6YSM2/Wd8ctN2PhdnH7i2GL6ULDzb6Pfx29pFkuhjbBNSsvO6q3XQHOA ZNlr++JhjL0XAF02NiYOMvyxuEwY1J+1GAWfnCTFB/Bcim+9OkTGr9r9aQkG/j/rNVCz HpwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=HhfUvmldem/bW9PfCrLyE0Fox8HADWDt254hdTva/Ec=; b=D1Q3P1jyN0MiNPPeNzs3Ju7DR51wrhMHD8ZSlPn4otdxmaZ/c8MOrMIAN+t1Qrl8Ef ZW5OwJht2aR9wBW1zOX5gLpFtvnZPuK8dhyMe7wDRb95W6p1dbpyLJ1MY0XooWm3XmcP I0H2CJAjK8suMUFXOruLXjDDPt7cjcKZ/PU/Sd3VvmtJf66fMoKDo9CTkSdzX8idRXQZ nsX7AcNUvBUZZyp7p/Lr+cnTUzRak1vWKd0QzQEuKgVeGJfW875QPQyJGqoiCNEjpp12 Qsw3RegMM2npBvchUM+30Os8HZtjAmGV2uNE8fxXsBavTXPbccIj+lzNxuYv1YU2fnK3 lzHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of vincent.whitchurch@axis.com designates 195.60.68.11 as permitted sender) smtp.mailfrom=vincent.whitchurch@axis.com Received: from bastet.se.axis.com (bastet.se.axis.com. [195.60.68.11]) by mx.google.com with ESMTPS id q21-v6si3442525ljh.146.2018.08.24.06.12.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Aug 2018 06:12:38 -0700 (PDT) Received-SPF: pass (google.com: domain of vincent.whitchurch@axis.com designates 195.60.68.11 as permitted sender) client-ip=195.60.68.11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of vincent.whitchurch@axis.com designates 195.60.68.11 as permitted sender) smtp.mailfrom=vincent.whitchurch@axis.com Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 7DBB1184C7; Fri, 24 Aug 2018 15:12:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id k8ZXcun8HrAW; Fri, 24 Aug 2018 15:12:36 +0200 (CEST) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id CDEF5184D8; Fri, 24 Aug 2018 15:12:36 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D1C21A06D; Fri, 24 Aug 2018 15:12:36 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61E871A06B; Fri, 24 Aug 2018 15:12:36 +0200 (CEST) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Fri, 24 Aug 2018 15:12:36 +0200 (CEST) Received: from lnxartpec.se.axis.com (lnxartpec.se.axis.com [10.88.4.9]) by seth.se.axis.com (Postfix) with ESMTP id 554CF1E7F; Fri, 24 Aug 2018 15:12:36 +0200 (CEST) Received: by lnxartpec.se.axis.com (Postfix, from userid 10564) id 501B78016F; Fri, 24 Aug 2018 15:12:36 +0200 (CEST) From: Vincent Whitchurch To: catalin.marinas@arm.com, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Vincent Whitchurch Subject: [PATCH] kmemleak: Always register debugfs file Date: Fri, 24 Aug 2018 15:12:20 +0200 Message-Id: <20180824131220.19176-1-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.11.0 X-TM-AS-GCONF: 00 X-Bogosity: Ham, tests=bogofilter, spamicity=0.011013, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP If kmemleak built in to the kernel, but is disabled by default, the debugfs file is never registered. Because of this, it is not possible to find out if the kernel is built with kmemleak support by checking for the presence of this file. To allow this, always register the file. After this patch, if the file doesn't exist, kmemleak is not available in the kernel. If writing "scan" or any other value than "clear" to this file results in EBUSY, then kmemleak is available but is disabled by default and can be activated via the kernel command line. Signed-off-by: Vincent Whitchurch Acked-by: Catalin Marinas --- mm/kmemleak.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 9a085d525bbc..17dd883198ae 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -2097,6 +2097,11 @@ static int __init kmemleak_late_init(void) kmemleak_initialized = 1; + dentry = debugfs_create_file("kmemleak", 0644, NULL, NULL, + &kmemleak_fops); + if (!dentry) + pr_warn("Failed to create the debugfs kmemleak file\n"); + if (kmemleak_error) { /* * Some error occurred and kmemleak was disabled. There is a @@ -2108,10 +2113,6 @@ static int __init kmemleak_late_init(void) return -ENOMEM; } - dentry = debugfs_create_file("kmemleak", 0644, NULL, NULL, - &kmemleak_fops); - if (!dentry) - pr_warn("Failed to create the debugfs kmemleak file\n"); mutex_lock(&scan_mutex); start_scan_thread(); mutex_unlock(&scan_mutex);