Bug 1284091 - ps showing the wrong cgroup/cpuset for threads
Summary: ps showing the wrong cgroup/cpuset for threads
Alias: None
Product: Fedora
Classification: Fedora
Component: procps-ng
Version: 23
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Jaromír Cápík
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2015-11-20 19:40 UTC by Daniel Bristot de Oliveira
Modified: 2016-12-20 16:08 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2016-12-20 16:08:48 UTC

Attachments (Terms of Use)

Description Daniel Bristot de Oliveira 2015-11-20 19:40:25 UTC
Description of problem:

  ps is showing all threads in the same cgroup/cpuset when they are on different cgroup/cpuset.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
  On a Fedora, with auditd installed (just to show an example):

1. Create a cpuset:
  # cd /sys/fs/cgroup/cpuset
  # mkdir app
  # cd app/
  # echo 0 > cpuset.cpus 
  # echo 0 > cpuset.mems 

3. select a multi-threaded proc (e.g auditd):
# ps -eLo pid,lwp,comm,cgroup | grep audit
  922   922 auditd          6:devices:/system.slice/auditd.service,1:name=systemd:/system.slice/auditd.service
  922   930 auditd          6:devices:/system.slice/auditd.service,1:name=systemd:/system.slice/auditd.service

4. Insert the thread with the same pid/lwp in this new cgroup/cpuset:
  # echo 922 > tasks 
  # cat tasks 

5. List the threads showing its cgroup/cpuset:
  # ps -eLo pid,lwp,comm,cgroup | grep auditd
    922   922 auditd          6:devices:/system.slice/auditd.service,4:cpuset:/app,1:name=systemd:/system.slice/auditd.service
    922   930 auditd          6:devices:/system.slice/auditd.service,4:cpuset:/app,1:name=systemd:/system.slice/auditd.service

Actual results:
ps shows all threads in the same cgroup/cpuset, but they are not all in the same cgroup/cpuset.

Expected results:
ps showing the correct cgroup/cpuset for threads.

Additional info:

  Stracing ps:

  It opens the proc/PID/ dir and checks the status of the proc.

	stat("/proc/922", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
	open("/proc/922/stat", O_RDONLY)        = 7
	read(7, "922 (auditd) S 1 922 922 0 -1 42"..., 2048) = 358
	close(7)                                = 0
	open("/proc/922/status", O_RDONLY)      = 7
	read(7, "Name:\tauditd\nState:\tS (sleeping)"..., 2048) = 990
	close(7)                                = 0

  It reads the proc cgroup (but never the threads cgroup file):
	open("/proc/922/cgroup", O_RDONLY)      = 7
	read(7, "10:blkio:/\n9:freezer:/\n8:net_cls"..., 131072) = 195
	read(7, "", 130877)                     = 0
	close(7)                                = 0
	close(6)                                = 0
	stat("/proc/922/task", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
	open("/proc/922/task", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 6
	fstat(6, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
	getdents(6, /* 4 entries */, 32768)     = 96
	stat("/proc/922/task/922", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
	open("/proc/922/task/922/stat", O_RDONLY) = 7
	read(7, "922 (auditd) S 1 922 922 0 -1 42"..., 2048) = 357
	close(7)                                = 0
	open("/proc/922/task/922/status", O_RDONLY) = 7
	read(7, "Name:\tauditd\nState:\tS (sleeping)"..., 2048) = 990
	close(7)                                = 0
	stat("/proc/922/task/930", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
	open("/proc/922/task/930/stat", O_RDONLY) = 7
	read(7, "930 (auditd) S 1 922 922 0 -1 10"..., 2048) = 362
	close(7)                                = 0
	open("/proc/922/task/930/status", O_RDONLY) = 7
	read(7, "Name:\tauditd\nState:\tS (sleeping)"..., 2048) = 989

Comment 1 Fedora End Of Life 2016-11-24 13:37:14 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 2 Fedora End Of Life 2016-12-20 16:08:48 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.