Re: Updated rusage patch



On Fri, 1 Jun 2007, Bruce Evans wrote:

On Fri, 1 Jun 2007, Bruce Evans wrote:

Hmm, this is confusing. Normal locking is not used for thread-local
fields. Instead, a side effect of spinlocking is used:
mtx_lock_spin(&any) in non-interrupt code has the side effect of
masking interrupts on the current CPU, so statclock() can access
anything on the current CPU without acquiring any locks, just like
an interrupt handler on a UP system. This is used for td_*ticks.
It doesn't work for ru_*rss since since exit1() doesn't hold a
spinlock when copying td_ru. The sched_locking of ru_*rss in
statclock() doesn't help -- I think it now does nothing except
waste time, since these fields are now thread-local so they need
the same locking as td_*ticks, which is null in statclock() but
non-null elsewhere.

Related bugs:
- td_[usip]ticks are still under (j) (sched_lock) in proc.h.
- td_(uu,us}ticks have always (?) been under (k) (thread-local). That
is more correct than (j), but they are updated by an interrupt handler
and seem to be accessed without disabling interrupts elsewhere.

Oops, it's more confusing than that. It is not a bug for td_[usip]ticks
to be under sched_lock, since they must be under a more specific lock
than `any' for when they are reset in ruxagg(). That lock has the dual
purpose of locking out interrupts as a side effect and locking out other
threads explicitly.

Please add a lock assertion in ruxagg() and friends that the relevant
lock is held.

I have such an assert in a threadlock.diff that I will post tomorrow. I could add it in before as well, but I suspect threadlock is going in next week and there are different locks involved there anyway.

Jeff


Bruce

_______________________________________________
freebsd-arch@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Updated rusage patch
    ... masking interrupts on the current CPU, so statclock() can access ... anything on the current CPU without acquiring any locks, ... and seem to be accessed without disabling interrupts elsewhere. ... That lock has the dual ...
    (freebsd-arch)
  • Re: [parisc-linux] [patch 15/23] Add cmpxchg_local to parisc
    ... non-SMP-safe counter that protects updates against interrupts. ... could be vastely used in the kernel. ... "Local atomic operations only guarantee variable modification atomicity ... that only one CPU writes to the local_t data. ...
    (Linux-Kernel)
  • Re: program runs almost twice as slow on 2 CPU machine when 1 CPU
    ... As I said, from the system management tool's perspective, the term 'CPU ... load' means system and user threads vs idle thread - interrupts and DPC ... interrupts - only port and miniport drivers do it. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: [PATCH] kexec: force x86_64 arches to boot kdump kernels on boot cpu
    ... Thats what I'm doing at the moment. ... unicast interrupts delivered accross the ht bus to a single cpu, ... that that broadcast bit was set. ...
    (Linux-Kernel)
  • Re: how can i disble irq15 through C/assembly programming.
    ... Well, these machines do not run Windows, do they? ... This condition is enforced by the CPU itself, ... interrupts as a whole, but the OP wants to disable interrupts only for ... disable interrupts on CPU Y..... ...
    (microsoft.public.win32.programmer.kernel)