ping .... On 2014/10/14 10:20, Weng Meiling wrote: > hi Ivana, Dhaval > > What do you think about this problem? > > On 2014/10/8 8:50, Weng Meiling wrote: >> >> On 2014/10/2 2:51, Balbir Singh wrote: >>> Do you have any debug logs with traces of what cgred is doing? My best >>> guess is cgred will need to be enhanced, feel free to send a patch >>> >>> Balbir Singh >>> >> I think the attached cgred log in debug mode has already shown what cgred is >> doing, it >> just can't detected runnning threads from /proc when cgred starts. A patch >> has been >> sent in before mails as following, but not sure whether it is optimal: >> >> The following patch maybe can deal with this situation, another way to deal >> with this situation is >> to use cgroup.procs file then tasks in cgroup_attach_task_pid() according to >> some conditions, >> but this need to modify many apis, so I think the following patch is more >> suitable, just modify one >> api. What do you think about this? >> >> Subject: [PATCH] cgred: cgred should deal with threads when starts >> >> Signed-off-by: Weng Meiling <wengmeiling.w...@huawei.com> >> --- >> src/api.c | 44 ++++++++++++++++++++++++++++++++------------ >> 1 file changed, 32 insertions(+), 12 deletions(-) >> >> diff --git a/src/api.c b/src/api.c >> index 8106eff..951cafb 100644 >> --- a/src/api.c >> +++ b/src/api.c >> @@ -3189,25 +3189,45 @@ int cgroup_change_all_cgroups(void) >> >> while ((pid_dir = readdir(dir)) != NULL) { >> int err, pid; >> - uid_t euid; >> - gid_t egid; >> - char *procname = NULL; >> + DIR *subdir; >> + struct dirent *subpid_dir = NULL; >> + char subpath[FILENAME_MAX]; >> >> err = sscanf(pid_dir->d_name, "%i", &pid); >> if (err < 1) >> continue; >> - err = cgroup_get_uid_gid_from_procfs(pid, &euid, &egid); >> - if (err) >> - continue; >> + /* sscanf the task directory to deal with threads */ >> + memset(subpath, 0, FILENAME_MAX); >> + sprintf(subpath, "/proc/%d/task", pid); >> + subdir = opendir(subpath); >> + if (!subdir) { >> + closedir(dir); >> + return -ECGOTHER; >> + } >> >> - err = cgroup_get_procname_from_procfs(pid, &procname); >> - if (err) >> - continue; >> + while ((subpid_dir = readdir(subdir)) != NULL) { >> + int subpid; >> + gid_t egid; >> + uid_t euid; >> + char *procname = NULL; >> + err = sscanf(subpid_dir->d_name, "%i", &subpid); >> + if (err < 1) >> + continue; >> >> - err = cgroup_change_cgroup_flags(euid, egid, procname, pid, 0); >> - if (err) >> - cgroup_dbg("cgroup change pid %i failed\n", pid); >> + err = cgroup_get_uid_gid_from_procfs(subpid, &euid, >> &egid); >> + if (err) >> + continue; >> + >> + err = cgroup_get_procname_from_procfs(subpid, >> &procname); >> + if (err) >> + continue; >> + >> + err = cgroup_change_cgroup_flags(euid, egid, procname, >> subpid, 0); >> + if (err) >> + cgroup_dbg("cgroup change pid %i failed\n", >> subpid); >> + } >> + closedir(subdir); >> } >> >> closedir(dir); >> >> >> >
------------------------------------------------------------------------------ _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel