linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jann Horn <jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org>
Cc: "Michael Kerrisk (man-pages)"
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Andrey Vagin <avagin-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org>
Subject: Re: [PATCH] proc.5: document /proc/[pid]/task/[tid]/children
Date: Mon, 15 Aug 2016 15:34:29 +0300	[thread overview]
Message-ID: <20160815123429.GF1857@uranus.lan> (raw)
In-Reply-To: <20160815115333.GA11115-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>

On Mon, Aug 15, 2016 at 01:53:33PM +0200, Jann Horn wrote:
> > 
> > I happen to know how this code work, i've been writting it. And it's the same
> > as reading plain pids: you might miss freshly created pids completely until
> > the re-read. The rule of thumb is to re-validate the results, always, or
> > stop the processes first.
> 
> Ah, I think maybe I understad what you're saying. If you want a list of PIDs that
> includes all stable children of a given running process, you have to read the
> "children" file in a loop until two reads return the same list, using the fact
> that the children are ordered by the time they became children of the target
> process and therefore the read following a read that triggered the slowpath
> always returns something different unless all children following the position
> that triggered the slowpath are replaced? Or something like that?

Exactly. In criu (if freezer cgroup is not used) we do check if the children
we've read are still valid when we start operating with the PIDs. In short
it's like: seize task and fetch its children (no new children may apprer since
task is seized) and then iterate over each children and check the parent pid is not
changed (simultaneously each children get seized). Run-time application should
compare output to be the same if they are not seizing processes, just like you
said.

> (If you just read "children" without the loop-until-stable rule, as far as I can
> tell, no amount of revalidation will prevent you from missing dropped children.)

Yeah. For tools like top/htop the reader should make a few reads if it needs
more-less precise results. In turn if only a rough picture is needed plain
single read is enough. Look, the read of @children it extremelly fast and
may be combined with traditional walk over procfs. IIRC someone been lookin
into using this feature in top-like utility. But I don't remember the
details if they successed.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2016-08-15 12:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02  0:25 [PATCH] proc.5: document /proc/[pid]/task/[tid]/children Jann Horn
     [not found] ` <b97bbf47-1180-0d32-ba08-1482020cc883@gmail.com>
     [not found]   ` <b97bbf47-1180-0d32-ba08-1482020cc883-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-03 22:52     ` Jann Horn
     [not found]       ` <20160803225254.GA14948-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-08-14  8:40         ` Cyrill Gorcunov
     [not found]           ` <20160814084026.GA1857-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-08-14 10:48             ` Jann Horn
     [not found]               ` <20160814104856.GA12246-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-08-14 20:14                 ` Cyrill Gorcunov
     [not found]                   ` <20160814201441.GC1857-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-08-14 20:46                     ` Jann Horn
     [not found]                       ` <20160814204635.GA2803-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-08-14 22:13                         ` Cyrill Gorcunov
     [not found]                           ` <20160814221359.GD1857-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-08-14 22:45                             ` Jann Horn
     [not found]                               ` <20160814224546.GA32168-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-08-15  8:50                                 ` Cyrill Gorcunov
     [not found]                                   ` <20160815085004.GE1857-ZmlpmtaulQd+urZeOPWqwQ@public.gmane.org>
2016-08-15 11:53                                     ` Jann Horn
     [not found]                                       ` <20160815115333.GA11115-J1fxOzX/cBvk1uMJSBkQmQ@public.gmane.org>
2016-08-15 12:34                                         ` Cyrill Gorcunov [this message]

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=20160815123429.GF1857@uranus.lan \
    --to=gorcunov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=avagin-5HdwGun5lf+gSpxsJD1C4w@public.gmane.org \
    --cc=jann-XZ1E9jl8jIdeoWH0uzbU5w@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@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).