From patchwork Fri May 22 12:47:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Iago_L=C3=B3pez_Galeiras?= X-Patchwork-Id: 6464171 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4480E9F399 for ; Fri, 22 May 2015 12:48:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4508120328 for ; Fri, 22 May 2015 12:48:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB8162024D for ; Fri, 22 May 2015 12:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757277AbbEVMsU (ORCPT ); Fri, 22 May 2015 08:48:20 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:36487 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757271AbbEVMsT (ORCPT ); Fri, 22 May 2015 08:48:19 -0400 Received: by wizk4 with SMTP id k4so46410218wiz.1 for ; Fri, 22 May 2015 05:48:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=BlmPhKd5dB0ljQiRLExmP1Ey1ipVox3VIho72L/HFms=; b=YTWzciidpfq27dBm4VSWTQ6KF/dy+DFhD+Xzz9BPg4UU+4l9ckMmji1IKYADv8KyVL Sv3CjkKNjIksH8p+XF1w27rzkDbmpqArQsEVGNTAaL624gntowARzl9JQ3FBLEsA6T4f Ue7fIZhnqUhxUMKh1eI1rrZAGBW7yTPUBx9Cnwu8uZ0viNYMq5g5tgZBdKxlxguJFzZ1 CIy7zj8x1wseqiAinEbtwGdcZN0Mppwuo7BAZDzRNbnXDskBJakn82tz8sv/fN9wyy3i SDiSobvERhGgwsY0FGh3HF5ntRBYeO+FCtZOtdHsRx2MyqF4XYiQgid36uEwGie3ax9C fzhQ== X-Gm-Message-State: ALoCoQnuJLxPA5YlgbFP04et7DGCnR9JqiERtgtmFkJqbAtTgLET7ueIE+bQjK2zTiU4LlDfqhdG X-Received: by 10.194.176.201 with SMTP id ck9mr14857628wjc.108.1432298897530; Fri, 22 May 2015 05:48:17 -0700 (PDT) Received: from localhost.localdomain (128.Red-80-38-104.staticIP.rima-tde.net. [80.38.104.128]) by mx.google.com with ESMTPSA id n2sm1426566wiv.3.2015.05.22.05.48.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 May 2015 05:48:16 -0700 (PDT) From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= To: Cyrill Gorcunov Cc: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= , Oleg Nesterov , Kees Cook , Pavel Emelyanov , Serge Hallyn , KAMEZAWA Hiroyuki , linux-api@vger.kernel.org, Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton , Andy Lutomirski , Alban Crequy Subject: [PATCH] fs, proc: introduce CONFIG_PROC_CHILDREN Date: Fri, 22 May 2015 14:47:39 +0200 Message-Id: <1432298859-2059-1-git-send-email-iago@endocode.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <20150521135703.22af370fdd0799101a6a1b91@linux-foundation.org> References: <20150521135703.22af370fdd0799101a6a1b91@linux-foundation.org> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP commit 818411616baf ("fs, proc: introduce /proc//task//children entry") introduced the children entry for checkpoint restore and the file is only available on kernels configured with CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE. This is available in most distributions (Fedora, Debian, Ubuntu, CoreOS) because they usually enable CONFIG_EXPERT and CONFIG_CHECKPOINT_RESTORE. But Arch does not enable CONFIG_EXPERT or CONFIG_CHECKPOINT_RESTORE. However, the children proc file is useful outside of checkpoint restore. I would like to use it in rkt. The rkt process exec() another program it does not control, and that other program will fork()+exec() a child process. I would like to find the pid of the child process from an external tool without iterating in /proc over all processes to find which one has a parent pid equal to rkt. This commit introduces CONFIG_PROC_CHILDREN and makes CONFIG_CHECKPOINT_RESTORE depend on it. This allows enabling /proc//task//children without needing to enable CONFIG_CHECKPOINT_RESTORE and CONFIG_EXPERT. Alban tested that /proc//task//children is present when the kernel is configured with CONFIG_PROC_CHILDREN=y but without CONFIG_CHECKPOINT_RESTORE Signed-off-by: Iago López Galeiras Cc: Alban Crequy Tested-by: Alban Crequy --- fs/proc/Kconfig | 4 ++++ fs/proc/array.c | 4 ++-- fs/proc/base.c | 2 +- init/Kconfig | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig index 2183fcf..d751fcb 100644 --- a/fs/proc/Kconfig +++ b/fs/proc/Kconfig @@ -71,3 +71,7 @@ config PROC_PAGE_MONITOR /proc/pid/smaps, /proc/pid/clear_refs, /proc/pid/pagemap, /proc/kpagecount, and /proc/kpageflags. Disabling these interfaces will reduce the size of the kernel by approximately 4kb. + +config PROC_CHILDREN + bool "Include /proc//task//children file" + default n diff --git a/fs/proc/array.c b/fs/proc/array.c index fd02a9e..ddc4b2c 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -569,7 +569,7 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, return 0; } -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_PROC_CHILDREN static struct pid * get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos) { @@ -692,4 +692,4 @@ const struct file_operations proc_tid_children_operations = { .llseek = seq_lseek, .release = children_seq_release, }; -#endif /* CONFIG_CHECKPOINT_RESTORE */ +#endif /* CONFIG_PROC_CHILDREN */ diff --git a/fs/proc/base.c b/fs/proc/base.c index 093ca14..5477a4a 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2922,7 +2922,7 @@ static const struct pid_entry tid_base_stuff[] = { ONE("stat", S_IRUGO, proc_tid_stat), ONE("statm", S_IRUGO, proc_pid_statm), REG("maps", S_IRUGO, proc_tid_maps_operations), -#ifdef CONFIG_CHECKPOINT_RESTORE +#ifdef CONFIG_PROC_CHILDREN REG("children", S_IRUGO, proc_tid_children_operations), #endif #ifdef CONFIG_NUMA diff --git a/init/Kconfig b/init/Kconfig index dc24dec..daa7941 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1145,6 +1145,7 @@ endif # CGROUPS config CHECKPOINT_RESTORE bool "Checkpoint/restore support" if EXPERT + depends on PROC_CHILDREN default n help Enables additional kernel features in a sake of checkpoint/restore.