Re: [PATCH 6/6] Makes procs file writable to move all threads by tgid at once

Paul E. McKenney
2009-08-06T15:19:25Z

On Thu, Aug 06, 2009 at 01:39:21PM +0200, Peter Zijlstra wrote:
> On Thu, 2009-08-06 at 04:24 -0700, Paul Menage wrote:
> > On Thu, Aug 6, 2009 at 4:02 AM, Peter Zijlstra<a.p.zijlstra@chello.nl> wrote:
> > >
> > > Taking that many locks in general, some apps (JVM based usually) tend to
> > > be thread heavy and can easily have hundreds of them, even on relatively
> >
> > Oh, I'm well aware that apps can be heavily multi-threaded - we have
> > much worse cases at Google.
> >
> > >
> > > Now that's not real nice is it ;-)
> >
> > Not particularly - but who exactly is going to be moving processes
> > with thousands of threads between cgroups on a lockdep-enabled debug
> > kernel?
>
> All it takes are: 8 or 48 (or soon 2048) depending on your particular
> annotation. I might and then I'd have to come and kick you ;-)
>
> Really, lockdep not being able to deal with something is a strong
> indication that you're doing something wonky.
>
> Stronger, you can even do wonky things which lockdep thinks are
> absolutely fine.
>
> And doing wonky things should be avoided :-)
>
> Luckily we seem to have found a sensible solution.
>
> > What benefits does the additional complexity of SRCU give, over the
> > simple solution of putting an rwsem in the same cache line as
> > sighand->count ?
>
> I said:
>
> > Then again, clone() might already serialize on the process as a whole
> > (not sure though, Oleg/Ingo?), in which case you can indeed take a
> > process wide lock.
>
> Which looking up sighand->count seems to be the case:
>
> static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk)
> {
> struct sighand_struct *sig;
>
> if (clone_flags & CLONE_SIGHAND) {
> atomic_inc(&current->sighand->count);
> return 0;
> }
>
>
> So yes, putting a rwsem in there sounds fine, you're already bouncing
> it.

If the critical section is small, is an rwsem really better than a
straight mutex?

Thanx, Paul