* [PATCH] sched: share task comm length value to userspace @ 2011-09-05 18:38 Vladimir Zapolskiy 2011-09-05 19:47 ` Arjan van de Ven 0 siblings, 1 reply; 6+ messages in thread From: Vladimir Zapolskiy @ 2011-09-05 18:38 UTC (permalink / raw) To: linux-kernel; +Cc: Ingo Molnar, Peter Zijlstra, Linus Torvalds This change allows to get a defined length of task comm in userspace. For a moment this value is implied at least in two cases: * max length of comm value got from /proc/$pid/stat * max string length argument of prctl(PR_[SG]ET_NAME, ...) For these reasons it becomes desirable to impart task comm max length value to userspace. Signed-off-by: Vladimir Zapolskiy <vz@mleia.com> --- include/linux/sched.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 4ac2c05..21d300b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -42,6 +42,9 @@ /* Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork */ #define SCHED_RESET_ON_FORK 0x40000000 +/* Task command name length */ +#define TASK_COMM_LEN 16 + #ifdef __KERNEL__ struct sched_param { @@ -242,9 +245,6 @@ extern char ___assert_task_state[1 - 2*!!( #define set_current_state(state_value) \ set_mb(current->state, (state_value)) -/* Task command name length */ -#define TASK_COMM_LEN 16 - #include <linux/spinlock.h> /* -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] sched: share task comm length value to userspace 2011-09-05 18:38 [PATCH] sched: share task comm length value to userspace Vladimir Zapolskiy @ 2011-09-05 19:47 ` Arjan van de Ven 2011-09-05 20:17 ` Vladimir Zapolskiy 0 siblings, 1 reply; 6+ messages in thread From: Arjan van de Ven @ 2011-09-05 19:47 UTC (permalink / raw) To: Vladimir Zapolskiy Cc: linux-kernel, Ingo Molnar, Peter Zijlstra, Linus Torvalds On Mon, 5 Sep 2011 21:38:01 +0300 Vladimir Zapolskiy <vz@mleia.com> wrote: > This change allows to get a defined length of task comm in > userspace. For a moment this value is implied at least in two cases: > * max length of comm value got from /proc/$pid/stat > * max string length argument of prctl(PR_[SG]ET_NAME, ...) > > For these reasons it becomes desirable to impart task comm max length > value to userspace. I'm sorry but I don't like doing this. The moment we do this, we never can increase it anymore since userspace might be using it for its own uses and we'd break it if we changed this value. If we need to export this, we should export it in /proc or /sys somewhere as a dynamic value..... -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched: share task comm length value to userspace 2011-09-05 19:47 ` Arjan van de Ven @ 2011-09-05 20:17 ` Vladimir Zapolskiy 2011-09-05 20:39 ` Arjan van de Ven 0 siblings, 1 reply; 6+ messages in thread From: Vladimir Zapolskiy @ 2011-09-05 20:17 UTC (permalink / raw) To: Arjan van de Ven Cc: linux-kernel, Ingo Molnar, Peter Zijlstra, Linus Torvalds On 05.09.2011 22:47, Arjan van de Ven wrote: > On Mon, 5 Sep 2011 21:38:01 +0300 > Vladimir Zapolskiy<vz@mleia.com> wrote: > >> This change allows to get a defined length of task comm in >> userspace. For a moment this value is implied at least in two cases: >> * max length of comm value got from /proc/$pid/stat >> * max string length argument of prctl(PR_[SG]ET_NAME, ...) >> >> For these reasons it becomes desirable to impart task comm max length >> value to userspace. > > I'm sorry but I don't like doing this. > > The moment we do this, we never can increase it anymore since userspace > might be using it for its own uses and we'd break it if we changed > this value. Thanks for a comment. Your objections are quite clear, and I don't like this solution as well, but eventually having that value in userspace is really desirable. However in assumption that this value is preserved fixed and won't be changed in reasonable perspective, the presented approach becomes the most evident and simple. > > If we need to export this, we should export it in /proc or /sys > somewhere as a dynamic value..... > Let's do it in a proper way. What's the common practice to export such limit values? I suppose via /proc/sys/kernel, please correct me, if I'm wrong. -- With best wishes, Vladimir ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched: share task comm length value to userspace 2011-09-05 20:17 ` Vladimir Zapolskiy @ 2011-09-05 20:39 ` Arjan van de Ven 2011-09-09 23:41 ` Andrew Morton 0 siblings, 1 reply; 6+ messages in thread From: Arjan van de Ven @ 2011-09-05 20:39 UTC (permalink / raw) To: Vladimir Zapolskiy Cc: linux-kernel, Ingo Molnar, Peter Zijlstra, Linus Torvalds On Mon, 05 Sep 2011 23:17:05 +0300 Vladimir Zapolskiy <vz@mleia.com> wrote: > but eventually having that value in > userspace is really desirable. However in assumption that this value > is preserved fixed and won't be changed in reasonable perspective, > the presented approach becomes the most evident and simple. yeah if it would never change, your change would be the most simple. but I really don't want to pin that thing down.... > > > > > If we need to export this, we should export it in /proc or /sys > > somewhere as a dynamic value..... > > > Let's do it in a proper way. What's the common practice to export > such limit values? I suppose via /proc/sys/kernel, please correct me, > if I'm wrong. that or /sys/kernel personally I like /proc/sys/kernel for this kind of thing more, but... ... others might disagree. -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched: share task comm length value to userspace 2011-09-05 20:39 ` Arjan van de Ven @ 2011-09-09 23:41 ` Andrew Morton 2011-09-09 23:49 ` Andrew Morton 0 siblings, 1 reply; 6+ messages in thread From: Andrew Morton @ 2011-09-09 23:41 UTC (permalink / raw) To: Arjan van de Ven Cc: Vladimir Zapolskiy, linux-kernel, Ingo Molnar, Peter Zijlstra, Linus Torvalds On Mon, 5 Sep 2011 13:39:03 -0700 Arjan van de Ven <arjan@infradead.org> wrote: > On Mon, 05 Sep 2011 23:17:05 +0300 > Vladimir Zapolskiy <vz@mleia.com> wrote: > > > but eventually having that value in > > userspace is really desirable. However in assumption that this value > > is preserved fixed and won't be changed in reasonable perspective, > > the presented approach becomes the most evident and simple. > > yeah if it would never change, your change would be the most simple. > but I really don't want to pin that thing down.... > > > > > > > > > If we need to export this, we should export it in /proc or /sys > > > somewhere as a dynamic value..... > > > > > Let's do it in a proper way. What's the common practice to export > > such limit values? I suppose via /proc/sys/kernel, please correct me, > > if I'm wrong. > > that or /sys/kernel > > personally I like /proc/sys/kernel for this kind of thing more, but... > ... others might disagree. > Run this: #include <sys/prctl.h> #include <errno.h> #include <string.h> #include <stdio.h> #include <stdlib.h> main() { char comm[512]; int len; memset(comm, 0, sizeof(comm)); for (len = 1; len < sizeof(comm) - 1; len++) { char comm2[512]; comm[len - 1] = 'a'; if (prctl(PR_SET_NAME, (unsigned long)comm, 0, 0, 0) < 0) { fprintf(stderr, "PR_SET_NAME failed with: %s\n", strerror(errno)); exit(1); } if (prctl(PR_GET_NAME, (unsigned long)comm2, 0, 0, 0) < 0) { fprintf(stderr, "PR_SET_NAME failed with: %s\n", strerror(errno)); exit(1); } if (strlen(comm2) != len) { printf("%d\n", len); break; } } exit(0); } once per boot, echoing the result into /etc/sizeof-comm. Sell resulting package to all vendors ;) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sched: share task comm length value to userspace 2011-09-09 23:41 ` Andrew Morton @ 2011-09-09 23:49 ` Andrew Morton 0 siblings, 0 replies; 6+ messages in thread From: Andrew Morton @ 2011-09-09 23:49 UTC (permalink / raw) To: Arjan van de Ven, Vladimir Zapolskiy, linux-kernel, Ingo Molnar, Peter Zijlstra, Linus Torvalds On Fri, 9 Sep 2011 16:41:30 -0700 Andrew Morton <akpm@linux-foundation.org> wrote: > if (prctl(PR_GET_NAME, (unsigned long)comm2, 0, 0, 0) < 0) { Actually, if we were ever to increase sizeof(task_struct.comm), existing code which does char comm[16]; prctl(PR_GET_NAME, comm, ...) will get its stack scribbled on. So we _could_ increase it, but we'd need to retain the old 16-char interfaces and add new prctl() modes. And if we did that, we'd design them in such a way that userspace wouldn't need to assume a fixed size.. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-09 23:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-09-05 18:38 [PATCH] sched: share task comm length value to userspace Vladimir Zapolskiy 2011-09-05 19:47 ` Arjan van de Ven 2011-09-05 20:17 ` Vladimir Zapolskiy 2011-09-05 20:39 ` Arjan van de Ven 2011-09-09 23:41 ` Andrew Morton 2011-09-09 23:49 ` Andrew Morton
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox