linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2
@ 2016-12-20 16:10 Tejun Heo
  2016-12-20 16:10 ` [PATCH 1/5] kernfs: make kernfs_open_file->mmapped a bitfield Tejun Heo
  2016-12-20 16:17 ` [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2 Tejun Heo
  0 siblings, 2 replies; 7+ messages in thread
From: Tejun Heo @ 2016-12-20 16:10 UTC (permalink / raw)
  To: gregkh, lizefan, hannes; +Cc: linux-kernel, cgroups, kernel-team

On cgroup v1, the pid listings in "cgroup.procs" and "tasks" are
sorted which adds a lot of complications and overhead.  v2 doesn't
have such requirement and has been intentionally using a modified
sorting order so that the output doesn't look sorted to users.

This patchset re-implements "cgroup.procs" reading for v2 which simply
keeps a css_task_iter open while the file is being read.  Keeping the
iterator open makes it unnecessary to skip to the right position on
each read segment and associated errors - e.g. incorrectly skipping
over pids because earlier pids disappeared between the reads.

Using persistent iterator across multiple read calls requires
->release() callback to clean it up.  kernfs operations
->open/release() are added and piped through cftype.

This patchset contains the following five patches.

 0001-kernfs-make-kernfs_open_file-mmapped-a-bitfield.patch
 0002-kernfs-add-kernfs_ops-open-release-callbacks.patch
 0003-cgroup-add-cftype-open-release-callbacks.patch
 0004-cgroup-reimplement-reading-cgroup.procs-on-cgroup-v2.patch
 0005-cgroup-remove-cgroup_pid_fry-and-friends.patch

0001 is a misc kernfs patch and 0002 adds ->open/release() to kernfs.
0003 pipes ->open/release() through cftype.  0004 implements the new
cgroup.procs for v2 and 0005 removes the now unused sort order frying
logic.

Greg, would it be okay to route the kernfs patches through
cgroup/for-4.11?

The patches are also available in the following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git review-cgroup2-procs

diffstat follows.  Thanks.

 fs/kernfs/dir.c             |    2 
 fs/kernfs/file.c            |   53 +++++++++++++++--
 fs/kernfs/kernfs-internal.h |    2 
 include/linux/cgroup-defs.h |    3 +
 include/linux/kernfs.h      |   12 +++-
 kernel/cgroup.c             |  130 +++++++++++++++++++++++++++++---------------
 6 files changed, 148 insertions(+), 54 deletions(-)

--
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] kernfs: make kernfs_open_file->mmapped a bitfield
  2016-12-20 16:10 [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2 Tejun Heo
@ 2016-12-20 16:10 ` Tejun Heo
  2016-12-20 16:17 ` [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2 Tejun Heo
  1 sibling, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2016-12-20 16:10 UTC (permalink / raw)
  To: gregkh, lizefan, hannes; +Cc: linux-kernel, cgroups, kernel-team, Tejun Heo

More kernfs_open_file->mutex synchronized flags are planned to be
added.  Convert ->mmapped to a bitfield in preparation.

While at it, make kernfs_fop_mmap() use "true" instead of "1" on
->mmapped.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 fs/kernfs/file.c       | 2 +-
 include/linux/kernfs.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 78219d5..d0b6fb1 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -516,7 +516,7 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma)
 		goto out_put;
 
 	rc = 0;
-	of->mmapped = 1;
+	of->mmapped = true;
 	of->vm_ops = vma->vm_ops;
 	vma->vm_ops = &kernfs_vm_ops;
 out_put:
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
index 7056238..afd4e5a 100644
--- a/include/linux/kernfs.h
+++ b/include/linux/kernfs.h
@@ -185,7 +185,7 @@ struct kernfs_open_file {
 	char			*prealloc_buf;
 
 	size_t			atomic_write_len;
-	bool			mmapped;
+	bool			mmapped:1;
 	const struct vm_operations_struct *vm_ops;
 };
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2
  2016-12-20 16:10 [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2 Tejun Heo
  2016-12-20 16:10 ` [PATCH 1/5] kernfs: make kernfs_open_file->mmapped a bitfield Tejun Heo
@ 2016-12-20 16:17 ` Tejun Heo
  1 sibling, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2016-12-20 16:17 UTC (permalink / raw)
  To: gregkh, lizefan, hannes; +Cc: linux-kernel, cgroups, kernel-team

On Tue, Dec 20, 2016 at 11:10:48AM -0500, Tejun Heo wrote:
> On cgroup v1, the pid listings in "cgroup.procs" and "tasks" are
> sorted which adds a lot of complications and overhead.  v2 doesn't
> have such requirement and has been intentionally using a modified
> sorting order so that the output doesn't look sorted to users.

Please ignore this thread.  git-send-email failed in the middle and I
resent the series.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2
  2016-12-20 16:12 Tejun Heo
  2016-12-21  9:59 ` Greg KH
  2016-12-26  6:22 ` Zefan Li
@ 2016-12-27 19:53 ` Tejun Heo
  2 siblings, 0 replies; 7+ messages in thread
From: Tejun Heo @ 2016-12-27 19:53 UTC (permalink / raw)
  To: gregkh, lizefan, hannes; +Cc: linux-kernel, cgroups, kernel-team

On Tue, Dec 20, 2016 at 11:12:17AM -0500, Tejun Heo wrote:
> On cgroup v1, the pid listings in "cgroup.procs" and "tasks" are
> sorted which adds a lot of complications and overhead.  v2 doesn't
> have such requirement and has been intentionally using a modified
> sorting order so that the output doesn't look sorted to users.
> 
> This patchset re-implements "cgroup.procs" reading for v2 which simply
> keeps a css_task_iter open while the file is being read.  Keeping the
> iterator open makes it unnecessary to skip to the right position on
> each read segment and associated errors - e.g. incorrectly skipping
> over pids because earlier pids disappeared between the reads.
> 
> Using persistent iterator across multiple read calls requires
> ->release() callback to clean it up.  kernfs operations
> ->open/release() are added and piped through cftype.

Applied to cgroup/for-4.11.

-- 
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2
  2016-12-20 16:12 Tejun Heo
  2016-12-21  9:59 ` Greg KH
@ 2016-12-26  6:22 ` Zefan Li
  2016-12-27 19:53 ` Tejun Heo
  2 siblings, 0 replies; 7+ messages in thread
From: Zefan Li @ 2016-12-26  6:22 UTC (permalink / raw)
  To: Tejun Heo, gregkh, hannes; +Cc: linux-kernel, cgroups, kernel-team

On 2016/12/21 0:12, Tejun Heo wrote:
> On cgroup v1, the pid listings in "cgroup.procs" and "tasks" are
> sorted which adds a lot of complications and overhead.  v2 doesn't
> have such requirement and has been intentionally using a modified
> sorting order so that the output doesn't look sorted to users.
> 
> This patchset re-implements "cgroup.procs" reading for v2 which simply
> keeps a css_task_iter open while the file is being read.  Keeping the
> iterator open makes it unnecessary to skip to the right position on
> each read segment and associated errors - e.g. incorrectly skipping
> over pids because earlier pids disappeared between the reads.
> 
> Using persistent iterator across multiple read calls requires
> ->release() callback to clean it up.  kernfs operations
> ->open/release() are added and piped through cftype.
> 
> This patchset contains the following five patches.
> 
>  0001-kernfs-make-kernfs_open_file-mmapped-a-bitfield.patch
>  0002-kernfs-add-kernfs_ops-open-release-callbacks.patch
>  0003-cgroup-add-cftype-open-release-callbacks.patch
>  0004-cgroup-reimplement-reading-cgroup.procs-on-cgroup-v2.patch
>  0005-cgroup-remove-cgroup_pid_fry-and-friends.patch
> 
> 0001 is a misc kernfs patch and 0002 adds ->open/release() to kernfs.
> 0003 pipes ->open/release() through cftype.  0004 implements the new
> cgroup.procs for v2 and 0005 removes the now unused sort order frying
> logic.
> 
> Greg, would it be okay to route the kernfs patches through
> cgroup/for-4.11?
> 
> The patches are also available in the following git branch.
> 
>  git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git review-cgroup2-procs
> 
> diffstat follows.  Thanks.
> 
>  fs/kernfs/dir.c             |    2 
>  fs/kernfs/file.c            |   53 +++++++++++++++--
>  fs/kernfs/kernfs-internal.h |    2 
>  include/linux/cgroup-defs.h |    3 +
>  include/linux/kernfs.h      |   12 +++-
>  kernel/cgroup.c             |  130 +++++++++++++++++++++++++++++---------------
>  6 files changed, 148 insertions(+), 54 deletions(-)
> 

Acked-by: Zefan Li <lizefan@huawei.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2
  2016-12-20 16:12 Tejun Heo
@ 2016-12-21  9:59 ` Greg KH
  2016-12-26  6:22 ` Zefan Li
  2016-12-27 19:53 ` Tejun Heo
  2 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2016-12-21  9:59 UTC (permalink / raw)
  To: Tejun Heo; +Cc: lizefan, hannes, linux-kernel, cgroups, kernel-team

On Tue, Dec 20, 2016 at 11:12:17AM -0500, Tejun Heo wrote:
> On cgroup v1, the pid listings in "cgroup.procs" and "tasks" are
> sorted which adds a lot of complications and overhead.  v2 doesn't
> have such requirement and has been intentionally using a modified
> sorting order so that the output doesn't look sorted to users.
> 
> This patchset re-implements "cgroup.procs" reading for v2 which simply
> keeps a css_task_iter open while the file is being read.  Keeping the
> iterator open makes it unnecessary to skip to the right position on
> each read segment and associated errors - e.g. incorrectly skipping
> over pids because earlier pids disappeared between the reads.
> 
> Using persistent iterator across multiple read calls requires
> ->release() callback to clean it up.  kernfs operations
> ->open/release() are added and piped through cftype.
> 
> This patchset contains the following five patches.
> 
>  0001-kernfs-make-kernfs_open_file-mmapped-a-bitfield.patch
>  0002-kernfs-add-kernfs_ops-open-release-callbacks.patch
>  0003-cgroup-add-cftype-open-release-callbacks.patch
>  0004-cgroup-reimplement-reading-cgroup.procs-on-cgroup-v2.patch
>  0005-cgroup-remove-cgroup_pid_fry-and-friends.patch
> 
> 0001 is a misc kernfs patch and 0002 adds ->open/release() to kernfs.
> 0003 pipes ->open/release() through cftype.  0004 implements the new
> cgroup.procs for v2 and 0005 removes the now unused sort order frying
> logic.
> 
> Greg, would it be okay to route the kernfs patches through
> cgroup/for-4.11?

No objection from me at all:

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2
@ 2016-12-20 16:12 Tejun Heo
  2016-12-21  9:59 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Tejun Heo @ 2016-12-20 16:12 UTC (permalink / raw)
  To: gregkh, lizefan, hannes; +Cc: linux-kernel, cgroups, kernel-team

On cgroup v1, the pid listings in "cgroup.procs" and "tasks" are
sorted which adds a lot of complications and overhead.  v2 doesn't
have such requirement and has been intentionally using a modified
sorting order so that the output doesn't look sorted to users.

This patchset re-implements "cgroup.procs" reading for v2 which simply
keeps a css_task_iter open while the file is being read.  Keeping the
iterator open makes it unnecessary to skip to the right position on
each read segment and associated errors - e.g. incorrectly skipping
over pids because earlier pids disappeared between the reads.

Using persistent iterator across multiple read calls requires
->release() callback to clean it up.  kernfs operations
->open/release() are added and piped through cftype.

This patchset contains the following five patches.

 0001-kernfs-make-kernfs_open_file-mmapped-a-bitfield.patch
 0002-kernfs-add-kernfs_ops-open-release-callbacks.patch
 0003-cgroup-add-cftype-open-release-callbacks.patch
 0004-cgroup-reimplement-reading-cgroup.procs-on-cgroup-v2.patch
 0005-cgroup-remove-cgroup_pid_fry-and-friends.patch

0001 is a misc kernfs patch and 0002 adds ->open/release() to kernfs.
0003 pipes ->open/release() through cftype.  0004 implements the new
cgroup.procs for v2 and 0005 removes the now unused sort order frying
logic.

Greg, would it be okay to route the kernfs patches through
cgroup/for-4.11?

The patches are also available in the following git branch.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git review-cgroup2-procs

diffstat follows.  Thanks.

 fs/kernfs/dir.c             |    2 
 fs/kernfs/file.c            |   53 +++++++++++++++--
 fs/kernfs/kernfs-internal.h |    2 
 include/linux/cgroup-defs.h |    3 +
 include/linux/kernfs.h      |   12 +++-
 kernel/cgroup.c             |  130 +++++++++++++++++++++++++++++---------------
 6 files changed, 148 insertions(+), 54 deletions(-)

--
tejun

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-12-27 20:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 16:10 [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2 Tejun Heo
2016-12-20 16:10 ` [PATCH 1/5] kernfs: make kernfs_open_file->mmapped a bitfield Tejun Heo
2016-12-20 16:17 ` [PATCHSET] kernfs, cgroup: reimplement "cgroup.procs" reading for v2 Tejun Heo
2016-12-20 16:12 Tejun Heo
2016-12-21  9:59 ` Greg KH
2016-12-26  6:22 ` Zefan Li
2016-12-27 19:53 ` Tejun Heo

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).