From: Jeff Liu <jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: Serge Hallyn <serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH] cgroup: don't show pid list on tasks/procs in ascending order
Date: Tue, 15 Jan 2013 14:30:05 +0800 [thread overview]
Message-ID: <50F4F76D.2050409@oracle.com> (raw)
In-Reply-To: <20130115062507.GA21358@sergelap>
On 01/15/2013 02:25 PM, Serge Hallyn wrote:
> Quoting Jeff Liu (jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org):
>> Hello,
>>
>> Currently, the pid list shown on cgroup->procs & tasks is in ascending order. However, this list is not
>> guaranteed to be sorted according to the following records mentioned at Documentation/cgroups/cgroups.txt.
>>
>> - tasks: list of tasks (by PID) attached to that cgroup. This list
>> is not guaranteed to be sorted.
>> - cgroup.procs: list of thread group IDs in the cgroup. This list is
>> not guaranteed to be sorted or free of duplicate TGIDs, and userspace
>> should sort/uniquify the list if this property is required.
>>
>> This patch remove the sorting function to make the default behavior of pid list be consistent with
>> the document.
>>
>> Without patch:
>> # echo 2942 >> /cgroup/test/tasks
>> # echo 2803 >> /cgroup/test/tasks
>> # echo 2911 >> /cgroup/test/tasks
>> # echo 2761 >> /cgroup/test/tasks
>> # cat /cgroup/test/tasks
>> 2761
>> 2803
>> 2911
>> 2942
>> # cat /cgroup/test/cgroup.procs
>> 2761
>> 2803
>> 2911
>> 2942
>>
>> Patch applied:
>> # echo 3042 >> /cgroup/testfixed/tasks
>> # echo 2916 >> /cgroup/testfixed/tasks
>> # echo 2781 >> /cgroup/testfixed/tasks
>> # echo 2527 >> /cgroup/testfixed/tasks
>> # cat /cgroup/testfixed/tasks
>> 2916
>> 3042
>> 2527
>> 2781
>> # cat /cgroup/testfixed/cgroup.procs
>> 2916
>> 3042
>> 2527
>> 2781
>>
>>
>> Signed-off-by: Jie Liu <jeff.liu-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
>>
>> ---
>> kernel/cgroup.c | 9 +--------
>> 1 file changed, 1 insertion(+), 8 deletions(-)
>>
>> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
>> index f24f724..2b5b477 100644
>> --- a/kernel/cgroup.c
>> +++ b/kernel/cgroup.c
>> @@ -47,7 +47,6 @@
>> #include <linux/magic.h>
>> #include <linux/spinlock.h>
>> #include <linux/string.h>
>> -#include <linux/sort.h>
>> #include <linux/kmod.h>
>> #include <linux/module.h>
>> #include <linux/delayacct.h>
>> @@ -3374,11 +3373,6 @@ after:
>> return dest;
>> }
>>
>> -static int cmppid(const void *a, const void *b)
>> -{
>> - return *(pid_t *)a - *(pid_t *)b;
>> -}
>> -
>> /*
>> * find the appropriate pidlist for our purpose (given procs vs tasks)
>> * returns with the lock on that pidlist already held, and takes care
>> @@ -3463,8 +3457,7 @@ static int pidlist_array_load(struct cgroup *cgrp, enum cgroup_filetype type,
>> }
>> cgroup_iter_end(cgrp, &it);
>> length = n;
>> - /* now sort & (if procs) strip out duplicates */
>> - sort(array, length, sizeof(pid_t), cmppid, NULL);
>> + /* if procs, strip out duplicates */
>> if (type == CGROUP_FILE_PROCS)
>> length = pidlist_uniq(&array, length);
>
> But... pidlist_uniq() depends on array being sorted
Yes, I forgot removing this function according to cgroup.procs documents.
cgroup.procs: list of thread group IDs in the cgroup. This list is
not guaranteed to be sorted or free of duplicate TGIDs
We should remove pidlist_uniq() as well.
Thanks,
-Jeff
next prev parent reply other threads:[~2013-01-15 6:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 5:28 [PATCH] cgroup: don't show pid list on tasks/procs in ascending order Jeff Liu
[not found] ` <50F4E902.20202-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2013-01-15 6:23 ` Jeff Liu
2013-01-15 6:25 ` Serge Hallyn
2013-01-15 6:30 ` Jeff Liu [this message]
[not found] ` <50F4F76D.2050409-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2013-01-15 6:34 ` Serge Hallyn
2013-01-15 6:56 ` Jeff Liu
[not found] ` <50F4FD99.7070406-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2013-01-15 14:08 ` Serge Hallyn
2013-01-15 15:43 ` Tejun Heo
[not found] ` <20130115154332.GA2598-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-01-15 16:14 ` Serge E. Hallyn
[not found] ` <20130115161420.GA6885-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2013-01-15 16:17 ` Tejun Heo
2013-01-16 1:50 ` Jeff Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=50F4F76D.2050409@oracle.com \
--to=jeff.liu-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).