From patchwork Wed May 18 01:41:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1515 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:52:39 -0000 Delivered-To: patches@linaro.org Received: by 10.224.54.134 with SMTP id q6cs52492qag; Tue, 17 May 2011 18:41:18 -0700 (PDT) Received: by 10.151.59.19 with SMTP id m19mr1042733ybk.349.1305682877676; Tue, 17 May 2011 18:41:17 -0700 (PDT) Received: from e2.ny.us.ibm.com (e2.ny.us.ibm.com [32.97.182.142]) by mx.google.com with ESMTPS id u5si9873212yba.54.2011.05.17.18.41.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 May 2011 18:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.142 as permitted sender) client-ip=32.97.182.142; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.142 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e2.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4I1LNIv005204; Tue, 17 May 2011 21:21:23 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4I1fFF21343686; Tue, 17 May 2011 21:41:15 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4HLf3GY029310; Tue, 17 May 2011 18:41:04 -0300 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4HLf293029303; Tue, 17 May 2011 18:41:02 -0300 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id E6E9F1E7510; Tue, 17 May 2011 18:41:13 -0700 (PDT) From: John Stultz To: LKML Cc: John Stultz , Joe Perches , Ingo Molnar , Michal Nazarewicz , Andy Whitcroft , Jiri Slaby , KOSAKI Motohiro , David Rientjes , Dave Hansen , Andrew Morton , linux-mm@kvack.org Subject: [PATCH 2/4] comm: Add lock-free task->comm accessor Date: Tue, 17 May 2011 18:41:03 -0700 Message-Id: <1305682865-27111-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1305682865-27111-1-git-send-email-john.stultz@linaro.org> References: <1305682865-27111-1-git-send-email-john.stultz@linaro.org> This patch adds __get_task_comm() which returns the task->comm value without taking the comm_lock. This function may return null or incomplete comm values, and is only present for performance critical paths that can handle these pitfalls. CC: Joe Perches CC: Ingo Molnar CC: Michal Nazarewicz CC: Andy Whitcroft CC: Jiri Slaby CC: KOSAKI Motohiro CC: David Rientjes CC: Dave Hansen CC: Andrew Morton CC: linux-mm@kvack.org Signed-off-by: John Stultz --- fs/exec.c | 13 +++++++++++++ include/linux/sched.h | 1 + 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index 34fa611..7e79c97 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -996,6 +996,19 @@ static void flush_old_files(struct files_struct * files) spin_unlock(&files->file_lock); } +/** + * __get_task_comm - Unlocked accessor to task comm value + * + * This function returns the task->comm value without + * taking the comm_lock. This method is only for performance + * critical paths, and may return a null or incomplete comm + * value. + */ +char *__get_task_comm(struct task_struct *tsk) +{ + return tsk->comm; +} + char *get_task_comm(char *buf, struct task_struct *tsk) { unsigned long flags; diff --git a/include/linux/sched.h b/include/linux/sched.h index f8a7cdf..5e3c25a 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2189,6 +2189,7 @@ struct task_struct *fork_idle(int); extern void set_task_comm(struct task_struct *tsk, char *from); extern char *get_task_comm(char *to, struct task_struct *tsk); +extern char *__get_task_comm(struct task_struct *tsk); #ifdef CONFIG_SMP extern unsigned long wait_task_inactive(struct task_struct *, long match_state);