Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.arch Subject: Re: MSI interrupts Date: Mon, 24 Mar 2025 23:45:49 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: References: Injection-Date: Mon, 24 Mar 2025 23:45:49 -0000 (UTC) Injection-Info: reader1.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="24449"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross) In article , MitchAlsup1 wrote: >On Mon, 24 Mar 2025 20:11:46 +0000, Dan Cross wrote: > >> In article , >> EricP wrote: >>>Dan Cross wrote: >>>> In article , >>>> MitchAlsup1 wrote: >------------------- >>>This is why I mentioned the terminology thing: threads do not hold >>>spinlocks, they hold mutexes. >> >> See above. Threads can certainly "hold" a spin lock, as they >> can hold any kind of lock. To quote from sec 7.6.1 of [Val96], >> page 202: >> >> |On a uniprocessor, if a thread tries to acquire a spin lock >> |that is already held, it will loop forever. Multiprocessor >> |algorithms, however, must operate correctly regardless of the >> |number of processors, which means that they should handle the >> |uniprocessor case as well. This requires strict adherence to >> |the rule that threads not relinquish control of the CPU while >> |holding a spin lock. > >My 66000 ATOMIC stuff is designed such that if control has to leave >the ATOMIC event, all HW knowledge of being in that event disappears >and IP is modified (prior to control transfer) such that upon return >SW knows the event failed (or never started), and that no update of >participating data in the event ever becomes visible. > >HW can do this with address-based events, but not with data-based >events. LDL-STC are address-based events used to manipulate data- >based events. Mine just allow more LDs and STs in the event than 1. > >So, if you want the property whereby the lock disappears on any >control transfer out of the event {exception, interrupt, SVC, SVR, ...}; >then you want to use my ATOMIC stuff; otherwise, you can use the >normal ATOMIC primitives everyone and his brother provide. I definitely do Not want that property. Having a lock "disappear" on delivery of an interrupt seems like it would be a great way to introduce silent corruption. If your atomic primitives are not sufficient to cover an entire critical section, as I believe we have established, and are mostly intended to be used for building concurrency primitives like locks, then I expect that software would take the lock, see that it succeeded, and enter the critical section. If at that point the lock were silently discarded on receipt of an interrupt, then potentially some other thread could subsequently take the lock, enter the critical section, and observe a data structure in an inconsistent state (leading to a crash in the best case). This is precisely the sort of thing we build mutual exclusion primitives to wrap around critical sections to avoid. If, on the other hand, the atomic primitives are just meant for the spin loop, then I don't really see how that's all that useful compared to LL/SC. And you still need some way to ensure that the critical section is not interrupted. - Dan C.