Date: Tue, 26 Jan 2010 09:43:38 -0500 From: John Baldwin <jhb@freebsd.org> To: Attilio Rao <attilio@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Warner Losh <imp@freebsd.org> Subject: Re: svn commit: r202889 - head/sys/kern Message-ID: <201001260943.38609.jhb@freebsd.org> In-Reply-To: <3bbf2fe11001260058i65604619l664bd0e49c1dbbd@mail.gmail.com> References: <201001231554.o0NFsMbx049837@svn.freebsd.org> <201001251456.32459.jhb@freebsd.org> <3bbf2fe11001260058i65604619l664bd0e49c1dbbd@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 26 January 2010 3:58:45 am Attilio Rao wrote: > Finally, I really don't think the BLOCK_SPIN() performance improvement > you suggest should really make a difference (assuming how rarely it > should happen) because, please note, that the cmpxchg is necessary as > we need to enforce a memory barrier when doing the check in anyway (so > the first case should be however an atomic_cmpset_X_Y()). Note that Intel specifically mentions in the app note that introduced 'pause' that one should not sit in a spin loop that bangs on cmpxchg due to the extra cache contention it causes. Also, I did not say to remove the cmpxchg, but to only do it if a 'cmp' indicates it should work. We already do this now for mtx_lock_spin() in C with something like this: while (!atomic_cmpset_acq_ptr(...)) { while (m->mtx_lock != MTX_UNOWNED) { cpu_spinwait(); } } The idea is to do "cheap" compares that do not require an exclusive hold on the cache line until you have a reason to think that the cmpxchg will "work". > Last thinking: it is not a very good idea cpu_switch() is made > conditional in regard of schedulers, but there is not an easy way to > do that as long as the safe points for releasing blocked_lock happens > within cpu_switch(). I think that is one of the reasons why some > people (maybe you or Jeff) pushed for having cpu_switch() made in C. Would the complicated version of BLOCK_SWITCH() work ok for the sched_4bsd and ULE/UP case and just devolve into normally not spinning? -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001260943.38609.jhb>