Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Frederic Weisbecker
On Fri, Aug 15, 2014 at 04:26:01PM +0200, Oleg Nesterov wrote: > On 08/15, Frederic Weisbecker wrote: > > > > 2014-08-14 16:39 GMT+02:00 Oleg Nesterov : > > > On 08/14, Frederic Weisbecker wrote: > > >> > > >> I mean the read side doesn't use a lock with seqlocks. It's only made > > >> of barriers

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Oleg Nesterov
On 08/15, Rik van Riel wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 08/15/2014 12:49 PM, Oleg Nesterov wrote: > > > Just in case... Yes, sure, "seqlock_t stats_lock" is more scalable. > > Just I do not know it's worth the trouble. > > If we don't know whether it is worth the tr

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Rik van Riel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/15/2014 12:49 PM, Oleg Nesterov wrote: > Just in case... Yes, sure, "seqlock_t stats_lock" is more scalable. > Just I do not know it's worth the trouble. If we don't know whether it is worth the trouble, it is probably best to stick to a well-k

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Oleg Nesterov
On 08/15, Oleg Nesterov wrote: > > However, if we only want to make sys_times() more scalable(), then > perhaps the "lockless" version of thread_group_cputime() makes more > sense. And given that do_sys_times() uses current we can simplify it; > is_dead is not possible and we do not need to take ->

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Oleg Nesterov
On 08/15, Peter Zijlstra wrote: > > Also; why do we care about PROCESS_CPUTIME? People should really not use > it. What are the 'valid' usecases you guys care about? I do not really know. IIUC, the problematic usecase is sys_times(). I agree with Mike, "don't do this if you have a lot of threads"

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Oleg Nesterov
On 08/14, Rik van Riel wrote: > > @@ -288,18 +288,31 @@ void thread_group_cputime(struct task_struct *tsk, > struct task_cputime *times) > struct signal_struct *sig = tsk->signal; > cputime_t utime, stime; > struct task_struct *t; > - > - times->utime = sig->utime; > - ti

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Oleg Nesterov
On 08/15, Frederic Weisbecker wrote: > > 2014-08-14 16:39 GMT+02:00 Oleg Nesterov : > > On 08/14, Frederic Weisbecker wrote: > >> > >> I mean the read side doesn't use a lock with seqlocks. It's only made > >> of barriers and sequence numbers to ensure the reader doesn't read > >> some half-complet

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Peter Zijlstra
On Fri, Aug 15, 2014 at 11:37:33AM +0200, Mike Galbraith wrote: > On Fri, 2014-08-15 at 08:28 +0200, Peter Zijlstra wrote: > > On Fri, Aug 15, 2014 at 07:19:31AM +0200, Mike Galbraith wrote: > > > For the N threads doing this on N cores case, seems rq->lock hammering > > > will still be a source o

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-15 Thread Mike Galbraith
On Fri, 2014-08-15 at 08:28 +0200, Peter Zijlstra wrote: > On Fri, Aug 15, 2014 at 07:19:31AM +0200, Mike Galbraith wrote: > > For the N threads doing this on N cores case, seems rq->lock hammering > > will still be a source of major box wide pain. Is there any correctness > > reason to add up un

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Peter Zijlstra
On Fri, Aug 15, 2014 at 07:19:31AM +0200, Mike Galbraith wrote: > For the N threads doing this on N cores case, seems rq->lock hammering > will still be a source of major box wide pain. Is there any correctness > reason to add up unaccounted ->on_cpu beans, or is that just value > added? That d

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Mike Galbraith
On Thu, 2014-08-14 at 19:48 +0200, Oleg Nesterov wrote: > On 08/14, Oleg Nesterov wrote: > > > > OK, lets forget about alternative approach for now. We can reconsider > > it later. At least I have to admit that seqlock is more straighforward. > > Yes. > > But just for record, the "lockless" vers

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Frederic Weisbecker
2014-08-14 16:39 GMT+02:00 Oleg Nesterov : > On 08/14, Frederic Weisbecker wrote: >> >> 2014-08-14 3:57 GMT+02:00 Rik van Riel : >> > -BEGIN PGP SIGNED MESSAGE- >> > Hash: SHA1 >> > >> > On 08/13/2014 08:43 PM, Frederic Weisbecker wrote: >> >> On Wed, Aug 13, 2014 at 05:03:24PM -0400, Rik v

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Rik van Riel
On Thu, 14 Aug 2014 18:12:47 +0200 Oleg Nesterov wrote: > Or you can expand the scope of write_seqlock/write_sequnlock, so that > __unhash_process in called from inside the critical section. This looks > simpler at first glance. > > Hmm, wait, it seems there is yet another problem ;) Afaics, you

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/14, Rik van Riel wrote: > > On 08/14/2014 02:15 PM, Oleg Nesterov wrote: > > On 08/14, Rik van Riel wrote: > >> > >> On 08/14/2014 12:12 PM, Oleg Nesterov wrote: > >>> > >>> Or you can expand the scope of write_seqlock/write_sequnlock, so that > >>> __unhash_process in called from inside the

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Rik van Riel
On 08/14/2014 02:15 PM, Oleg Nesterov wrote: > On 08/14, Rik van Riel wrote: >> >> On 08/14/2014 12:12 PM, Oleg Nesterov wrote: >>> >>> Or you can expand the scope of write_seqlock/write_sequnlock, so that >>> __unhash_process in called from inside the critical section. This looks >>> simpler at fi

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/14, Oleg Nesterov wrote: > > But just for record, the "lockless" version doesn't look that bad to me, > > void thread_group_cputime(struct task_struct *tsk, struct task_cputime > *times) > { > struct signal_struct *sig = tsk->signal; > bool lockless, i

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/14, Rik van Riel wrote: > > On 08/14/2014 12:12 PM, Oleg Nesterov wrote: > > > > Or you can expand the scope of write_seqlock/write_sequnlock, so that > > __unhash_process in called from inside the critical section. This looks > > simpler at first glance. > > The problem with that is that wai

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/14, Oleg Nesterov wrote: > > OK, lets forget about alternative approach for now. We can reconsider > it later. At least I have to admit that seqlock is more straighforward. Yes. But just for record, the "lockless" version doesn't look that bad to me, void thread_group_cputime(struc

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Rik van Riel
On 08/14/2014 12:12 PM, Oleg Nesterov wrote: > On 08/14, Rik van Riel wrote: >> >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> On 08/14/2014 10:24 AM, Oleg Nesterov wrote: >>> On 08/13, Rik van Riel wrote: @@ -862,11 +862,9 @@ void do_sys_times(struct tms *tms) { cputime_t

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/14, Rik van Riel wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 08/14/2014 10:24 AM, Oleg Nesterov wrote: > > On 08/13, Rik van Riel wrote: > >> > >> @@ -862,11 +862,9 @@ void do_sys_times(struct tms *tms) { > >> cputime_t tgutime, tgstime, cutime, cstime; > >> > >> - spin

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Rik van Riel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/14/2014 10:24 AM, Oleg Nesterov wrote: > On 08/13, Rik van Riel wrote: >> >> @@ -862,11 +862,9 @@ void do_sys_times(struct tms *tms) { >> cputime_t tgutime, tgstime, cutime, cstime; >> >> -spin_lock_irq(¤t->sighand->siglock); >> thread_gr

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/14, Frederic Weisbecker wrote: > > 2014-08-14 3:57 GMT+02:00 Rik van Riel : > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > On 08/13/2014 08:43 PM, Frederic Weisbecker wrote: > >> On Wed, Aug 13, 2014 at 05:03:24PM -0400, Rik van Riel wrote: > >> > >> I'm worried about such lock

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/13, Rik van Riel wrote: > > @@ -862,11 +862,9 @@ void do_sys_times(struct tms *tms) > { > cputime_t tgutime, tgstime, cutime, cstime; > > - spin_lock_irq(¤t->sighand->siglock); > thread_group_cputime_adjusted(current, &tgutime, &tgstime); > cutime = current->signal->cut

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/14, Frederic Weisbecker wrote: > > 2014-08-14 15:22 GMT+02:00 Oleg Nesterov : > > On 08/13, Rik van Riel wrote: > >> > >> @@ -646,6 +646,7 @@ struct signal_struct { > >>* Live threads maintain their own counters and add to these > >>* in __exit_signal, except for the group lea

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Frederic Weisbecker
2014-08-14 15:22 GMT+02:00 Oleg Nesterov : > On 08/13, Rik van Riel wrote: >> >> On Wed, 13 Aug 2014 20:45:11 +0200 >> Oleg Nesterov wrote: >> >> > That said, it is not that I am really sure that seqcount_t in ->signal >> > is actually worse, not to mention that this is subjective anyway. IOW, >>

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Frederic Weisbecker
2014-08-14 3:57 GMT+02:00 Rik van Riel : > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 08/13/2014 08:43 PM, Frederic Weisbecker wrote: >> On Wed, Aug 13, 2014 at 05:03:24PM -0400, Rik van Riel wrote: >>> --- a/kernel/time/posix-cpu-timers.c +++ >>> b/kernel/time/posix-cpu-timers.c @@ -27

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-14 Thread Oleg Nesterov
On 08/13, Rik van Riel wrote: > > On Wed, 13 Aug 2014 20:45:11 +0200 > Oleg Nesterov wrote: > > > That said, it is not that I am really sure that seqcount_t in ->signal > > is actually worse, not to mention that this is subjective anyway. IOW, > > I am not going to really fight with your approach

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-13 Thread Rik van Riel
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/13/2014 08:43 PM, Frederic Weisbecker wrote: > On Wed, Aug 13, 2014 at 05:03:24PM -0400, Rik van Riel wrote: >> --- a/kernel/time/posix-cpu-timers.c +++ >> b/kernel/time/posix-cpu-timers.c @@ -272,22 +272,8 @@ static int >> posix_cpu_clock_get_ta

Re: [PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-13 Thread Frederic Weisbecker
On Wed, Aug 13, 2014 at 05:03:24PM -0400, Rik van Riel wrote: > --- a/kernel/time/posix-cpu-timers.c > +++ b/kernel/time/posix-cpu-timers.c > @@ -272,22 +272,8 @@ static int posix_cpu_clock_get_task(struct task_struct > *tsk, > if (same_thread_group(tsk, current)) >

[PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-13 Thread Rik van Riel
On Wed, 13 Aug 2014 20:45:11 +0200 Oleg Nesterov wrote: > That said, it is not that I am really sure that seqcount_t in ->signal > is actually worse, not to mention that this is subjective anyway. IOW, > I am not going to really fight with your approach ;) This is what it looks like, on top of y

[PATCH RFC] time,signal: protect resource use statistics with seqlock

2014-08-13 Thread Rik van Riel
On Wed, 13 Aug 2014 20:45:11 +0200 Oleg Nesterov wrote: > That said, it is not that I am really sure that seqcount_t in ->signal > is actually worse, not to mention that this is subjective anyway. IOW, > I am not going to really fight with your approach ;) This is what it looks like, on top of y