No conflict between theory and practice

By: dmcq (dmcq.delete@this.fano.co.uk), April 7, 2021 2:32 pm
Room: Moderated Discussions
Andrey (andrey.semashev.delete@this.gmail.com) on April 7, 2021 2:32 pm wrote:
> Linus Torvalds (torvalds.delete@this.linux-foundation.org) on April 7, 2021 1:20 pm wrote:
> >
> > I personally would expect that the most likely actual true fix to the HTM problems is to only allow
> > small transactions in the first place, prove statically
> > that they can complete (kind of like the constrained
> > s390 transactions), and avoid the whole software-visible abort/fallback situation entirely.
> >
> > IOW, make HTM act like any other CPU speculation fault where the
> > hardware will retry and know it can complete it eventually.
> >
> > IOW, take the "RISC approach" to HTM. Make it simple, make it stupid, but
> > make that simple and stupid case go really really fast, exactly because it
> > doesn't handle all the complexities, and doesn't involve a lot of state.
> >
> > Don't do any "register state rollback" garbage: the transactional register state is limited to the normal
> > register renames, and it's basically all done by the existing OoO speculative execution engine.
> >
> > Don't do any "transactional L1 cache contents" garbage.
> > Transactional stores are limited to the store queue,
> > and the cache conflict tracing is done using the existing memory reordering speculation hardware.
> >
> > Don't do any "software retry" garbage: the architected HTM size is guaranteed to make
> > forward progress because it is of limited size (exactly like "ll/sc" sequences).
>
> LL/SC is a very restricted version of HTM. You do have to retry in software if SC fails, although you
> normally don't implement a fallback path hoping that it will eventually succeed. Note that forward progress
> is not guaranteed with LL/SC. That is unlike regular atomics, which makes them superior.
>
> I think the "forward progress" arguments that are made throughout this discussion are missing that
> you can't have a forward progress guarantee as long as you have (a) preemption and (b) virtual memory
> and paging. Basically, if your thread can be interrupted at an arbitrary point and that can cause
> an abort, you don't have forward progress guarantee. That doesn't mean that transactions will abort
> often, but it does mean that aborts will happen regardless of the programmer's effort and you have
> to have some sort of a retry and possibly a fallback path that is less likely to fail. And yes,
> as you noted, this requirement is the more emphasized the larger the transaction.

Aborts due to paging certainly will happen, but there certainly is no reason for asynchronous aborts of short code sequences. Such interrupts should be deferred and vectoring to a proceeeor for the task can be used f the nterrupt time is absolutely critical.


> Regarding the abort semantics, i.e. whether the memory and register state is restored, I don't think this
> is a crucial part for a particular HTM implementation success. I mean, surely you want at least some
> memory accesses to be rolled back (or simply to not commit) in case of transactional abort, but it doesn't
> have to be all accesses, as in case of TSX. I could imagine a workable model where the particular accesses
> to be monitored and rolled back in case of abort would have to be done with special instructions (something
> like AMD ASF). This model would be less convenient to program, but still acceptable. Whether register
> state is restored is also not very important if there is a way to restore them upon retry.
>
> What is important for a HTM implementation success is (a) the cost of successful path and (b) the probability
> and cost of aborts. With (a) it's pretty clear - the cost must approach the cost of an atomic operation
> (I'm not counting the transaction body here, of course). With (b), you have to accept that aborts will
> happen, and that you have to program a retry and/or fallback path, but the implementation must minimize
> the probability of aborts due to hardware events and likely provide ways to minimize aborts on the software
> side as well. That is, a page fault, an interrupt, a thread preemption - all these must not cause an
> abort, unless the memory conflict actually happened during this event.

I don't think one can avoid having to save some registers but I don't see that as a major problem.


> > In that situation, a transaction that is bigger than the architected hardware resources would
> > not be an "abort" - it would just be a fatal error, like a divide-by-zero is, and would trap.
> > It would be very expensive indeed, but that would be ok - because there would be no "retry with
> > fallback" for that case. It would have been a programmer error to have generated such an instruction
> > sequence in the first place, exactly like it's a programmer error to divide by zero.
>
> Except that the programmer doesn't generate instructions usually. Unlike divide by zero, the programmer cannot
> ensure that a particular sequence of instructions is generated, unless he writes in assembler. And I doubt
> a technology that basically requires writing in assembler is going to succeed beyond a few niche cases.

I think it should be possible to gve some minimum figures for what is supported and run a computer check. If some mplementations provide more then they would be warned that they use more than some standard. It woud be much simpler than saying what a GPU supports. I don't think assembler would need to be used and assembler would only be for specific important optimisations.


> > Personally, I'd much rather see hardware companies try to start from that kind of very targeted
> > (and less ambitious) HTM. Maybe once you get the simple cases working, and learn from practice what
> > it helps and what small extensions to the model you could add to improve on things, you could expand
> > on the HTM architected limits in a controlled manner and do incremental improvements.
> >
> > Instead of the current crazy "let's do lock elision in hardware without knowing what the f*ck we're
> > doing, and let's make it so complex that it doesn't actually work" that everybody has done.
>
> Well, the incremental approach is certainly reasonable. But whatever small starting solution you implement,
> you still have to make sure it is generally useful. If it requires a domain expert level programmers or
> isn't usable in higher level languages or doesn't support widespread use cases then - however nice and
> simple it is - it will be just a toy technology with no wide use, and therefore not worth the cost and
> effort of implementing. You have to start with something more widely applicable and useful.

This whole area requires good programmers and well checked code. Atomics and locks require some care anyway and everyone should think twice, three or more times before coming anywhere near lock free code.

< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
Armv9 officially announcedJon Masters2021/03/30 10:41 AM
  Armv9 officially announcedGabriele Svelto2021/03/30 12:27 PM
    HTM and TLEFoo_2021/03/30 12:31 PM
      HTM and TLEdmcq2021/03/30 02:03 PM
      Intel RTM and HLE is a successGanon2021/03/30 04:22 PM
        Intel RTM and HLE is a success (is it?)Foo_2021/03/31 12:16 AM
          Intel RTM and HLE was an abject failureanonymou52021/03/31 02:04 AM
          Intel RTM and HLE is a success (is it?)Andrey2021/03/31 04:27 AM
            Intel RTM and HLE is a success (is it?)Foo_2021/03/31 04:58 AM
              Intel RTM and HLE is a success (is it?)Andrey2021/03/31 06:45 AM
                Intel RTM and HLE is a success (is it?)Foo_2021/03/31 08:32 AM
                  Intel RTM and HLE is a success (is it?)Andrey2021/03/31 08:57 AM
                    Intel RTM and HLE is a success (is it?)anonymou52021/03/31 09:39 AM
                      ^ feel free to delete this one -- broken HTML there (NT)anonymou52021/03/31 09:40 AM
                      Intel RTM and HLE is a success (is it?)Andrey2021/03/31 09:47 AM
                    Intel RTM and HLE is a success (is it?)anonymou52021/03/31 09:40 AM
                Intel RTM and HLE is a success (is it?)Ganon2021/03/31 08:58 AM
                  Intel RTM and HLE is a success (is it?)anonymou52021/03/31 09:42 AM
                  Intel RTM and HLE is a success (is it?)Linus Torvalds2021/03/31 10:54 AM
                    Intel RTM and HLE is a success (is it?)Linus Torvalds2021/03/31 11:00 AM
                      Any idea about IBM?Mark Roulo2021/03/31 11:15 AM
                        Any idea about IBM?Linus Torvalds2021/03/31 11:37 AM
                          Any idea about IBM?dmcq2021/03/31 02:04 PM
                            Any idea about IBM?Linus Torvalds2021/03/31 03:44 PM
                              A non straw man view of hardware transactional memoryGanon2021/03/31 06:52 PM
                                A non straw man view of hardware transactional memoryanon22021/03/31 10:03 PM
                                  A non straw man view of hardware transactional memoryCarson2021/04/02 12:11 AM
                                    A non straw man view of hardware transactional memoryanon22021/04/02 04:28 AM
                              IBM zArch TM - guaranteed progressDavid Kanter2021/03/31 07:37 PM
                              Any idea about IBM?Andrey2021/03/31 10:31 PM
                                Any idea about IBM?Linus Torvalds2021/04/01 09:54 AM
                                  Any idea about IBM?Andrey2021/04/02 11:50 AM
                        Any idea about IBM?someone2021/03/31 11:02 PM
                      Intel RTM and HLE is a success (is it?)anon22021/03/31 02:46 PM
                        Intel RTM and HLE is a success (is it?)Linus Torvalds2021/03/31 04:08 PM
                          Leaving it to software is tricky!David Kanter2021/03/31 07:41 PM
                            And a hardware predicttor needs access to fallback timingCarson2021/04/01 10:13 PM
                              Hardware fallback pathAnon2021/04/02 09:51 AM
                              And a hardware predicttor needs access to fallback timingLinus Torvalds2021/04/03 09:41 AM
                                And a hardware predicttor needs access to fallback timingLinus Torvalds2021/04/03 10:11 AM
                                  And a hardware predicttor needs access to fallback timingsr2021/04/03 10:30 AM
                                    And a hardware predicttor needs access to fallback timingLinus Torvalds2021/04/03 11:14 AM
                                      And a hardware predicttor needs access to fallback timingsr2021/04/03 11:39 AM
                                        And a hardware predicttor needs access to fallback timingAnon2021/04/03 01:08 PM
                                          And a hardware predicttor needs access to fallback timingsr2021/04/03 01:33 PM
                                            And a hardware predicttor needs access to fallback timingdmcq2021/04/04 04:35 AM
                                        And a hardware predicttor needs access to fallback timingLinus Torvalds2021/04/03 01:22 PM
                                          Transactional memory isn't exclusive to lockingsr2021/04/03 11:17 PM
                                            Transactional memory isn't exclusive to lockingAspect of Anonimity2021/04/04 02:49 AM
                                            Transactional memory isn't exclusive to lockingAndrey2021/04/04 03:58 AM
                                              Transactional memory isn't exclusive to lockingsr2021/04/04 09:10 AM
                                                Transactional memory isn't exclusive to lockingAndrey2021/04/04 09:33 AM
                                                  Transactional memory isn't exclusive to lockingsr2021/04/05 01:41 AM
                                      And a hardware predicttor needs access to fallback timingGeertB2021/04/04 06:08 PM
                            Leaving it to software is tricky!Andrey2021/04/02 02:00 PM
                          Intel RTM and HLE is a success (is it?)@never_released2021/04/01 07:21 AM
                            Intel RTM and HLE is a success (is it?)@never_released2021/04/01 07:30 AM
                            Intel RTM and HLE is a success (is it?)Linus Torvalds2021/04/01 09:00 AM
                              Intel RTM and HLE is a success (is it?)dmcq2021/04/01 09:35 AM
                                Intel RTM and HLE is a success (is it?)Linus Torvalds2021/04/01 09:59 AM
                                  Is HTM actually in ARMv9?dncq2021/04/01 10:26 AM
                                    Is HTM actually in ARMv9?Linus Torvalds2021/04/01 11:13 AM
                              Intel RTM and HLE is a success (is it?)Jörn Engel2021/04/01 08:15 PM
                          Intel RTM and HLE is a success (is it?)---2021/04/02 09:00 AM
                      Intel RTM and HLE is a success (is it?)Jon Masters2021/04/01 09:56 AM
                        RockMichael S2021/04/01 11:29 AM
            Intel RTM and HLE is a success (is it?)Linus Torvalds2021/03/31 10:50 AM
              Intel RTM and HLE is a success (is it?)anon22021/03/31 02:57 PM
                Intel RTM and HLE is a success (is it?)anon32021/03/31 03:09 PM
          Intel RTM and HLE is a success (is it?)someone2021/03/31 10:56 PM
            Intel RTM and HLE is a success (is it?)someone2021/03/31 11:21 PM
              Intel RTM and HLE is a success (is it?)none2021/04/01 03:31 AM
                Intel RTM and HLE is a success (is it?)anonymou52021/04/01 08:24 AM
                  Intel RTM and HLE is a success (is it?)anony2021/04/01 09:26 AM
                  Intel RTM and HLE is a success (is it?)none2021/04/01 10:20 AM
                Intel RTM and HLE is a success (is it?)Brendan2021/04/01 04:23 PM
                  Intel RTM and HLE is a success (is it?)Adrian2021/04/02 12:03 AM
      Transactional memory similarity to garbage collectionPaul A. Clayton2021/04/05 12:53 PM
        Maybe notMark Roulo2021/04/05 02:07 PM
        Transactional memory similarity to garbage collectionAnon2021/04/05 02:14 PM
        No conflict between theory and practiceAspect of Anonimity2021/04/05 06:57 PM
          No conflict between theory and practiceNoSpammer2021/04/05 08:38 PM
            No conflict between theory and practicedmcq2021/04/06 06:05 AM
              No conflict between theory and practicesr2021/04/06 08:22 AM
                No conflict between theory and practiceBen LaHaise2021/04/06 02:43 PM
                  No conflict between theory and practicesr2021/04/07 08:42 AM
                    No conflict between theory and practiceAnon2021/04/07 09:06 AM
                    No conflict between theory and practiceLinus Torvalds2021/04/07 09:35 AM
                      No conflict between theory and practicesr2021/04/07 11:34 AM
                        If HTM were well implemented, nobody would complain (NT)Anon2021/04/07 11:54 AM
                          If HTM were well implemented, nobody would complaindmcq2021/04/07 02:36 PM
                            If HTM were well implemented, nobody would complainAnon2021/04/07 03:04 PM
                          If HTM were well implemented, nobody would complain---2021/04/08 08:37 AM
                        No conflict between theory and practiceLinus Torvalds2021/04/07 12:20 PM
                          No conflict between theory and practiceAndrey2021/04/07 01:32 PM
                            No conflict between theory and practicedmcq2021/04/07 02:32 PM
                              No conflict between theory and practiceanonymou52021/04/07 03:26 PM
                              No conflict between theory and practiceAndrey2021/04/07 04:54 PM
                                No conflict between theory and practiceLinus Torvalds2021/04/08 07:41 AM
                                  No conflict between theory and practiceAndrey2021/04/08 08:12 AM
                                  No conflict between theory and practiceRobert Williams2021/04/08 08:15 AM
                                    No conflict between theory and practiceLinus Torvalds2021/04/08 08:56 AM
                                      No conflict between theory and practiceRobert Williams2021/04/08 06:50 PM
                                        No conflict between theory and practiceLinus Torvalds2021/04/09 08:25 AM
                                          TSX for all?Robert Williams2021/04/09 11:46 AM
                                            It helps adoption when developers can run the code an their machines.Mark Roulo2021/04/09 11:54 AM
                                              It helps adoption when developers can run the code an their machines.me2021/04/09 01:21 PM
                                                It helps adoption when developers can run the code an their machines.Andrey2021/04/10 06:08 AM
                                                  It helps adoption when developers can run the code an their machines.me2021/04/10 11:43 AM
                                                    It helps adoption when developers can run the code an their machines.Robert Williams2021/04/10 06:05 PM
                                                      It helps adoption when developers can run the code an their machines.Andrey2021/04/11 12:42 AM
                                                        It helps adoption when developers can run the code an their machines.Michael S2021/04/11 03:23 AM
                                              It helps adoption when developers can run the code an their machines.Robert Williams2021/04/10 07:24 AM
                                                It helps adoption when developers can run the code an their machines.Andrey2021/04/10 09:36 AM
                                                  It helps adoption when developers can run the code an their machines.Michael S2021/04/10 09:58 AM
                                                    It helps adoption when developers can run the code an their machines.Robert Williams2021/04/10 10:42 AM
                                                    It helps adoption when developers can run the code an their machines.Brendan2021/04/10 10:27 PM
                                                      It helps adoption when developers can run the code an their machines.Michael S2021/04/11 02:34 AM
                                                        It helps adoption when developers can run the code an their machines.Brendan2021/04/11 03:18 PM
                                            TSX for all?wumpus2021/04/09 12:10 PM
                                            TSX for all?Linus Torvalds2021/04/09 02:03 PM
                                              [CLICK BAIT?] Torvalds to recommend arm64!anonymous22021/04/09 02:17 PM
                                              TSX for all?Linus Torvalds2021/04/09 02:22 PM
                                                amen! (NT)anonymou52021/04/09 04:42 PM
                                            TSX for all?Emil Briggs2021/04/10 04:52 AM
                                              TSX for all?Michael S2021/04/10 10:13 AM
                                                TSX for all?Brendan2021/04/10 10:05 PM
                                          No conflict between theory and practiceanonymouse2021/04/09 02:02 PM
                            No conflict between theory and practiceLinus Torvalds2021/04/07 04:12 PM
                              No conflict between theory and practiceAndrey2021/04/07 04:33 PM
                                No conflict between theory and practiceanon22021/04/07 07:12 PM
                                  No conflict between theory and practiceAndrey2021/04/07 11:29 PM
                                    No conflict between theory and practiceAnon2021/04/07 11:50 PM
                                    No conflict between theory and practiceanon22021/04/07 11:52 PM
                                      No conflict between theory and practiceAndrey2021/04/08 01:41 AM
                                        No conflict between theory and practiceAdrian2021/04/08 02:09 AM
                                          No conflict between theory and practiceAndrey2021/04/08 02:50 AM
                                            No conflict between theory and practiceAdrian2021/04/08 04:07 AM
                                            No conflict between theory and practiceanon22021/04/08 04:18 AM
                                              No conflict between theory and practiceAndrey2021/04/08 07:18 AM
                                                No conflict between theory and practiceanon22021/04/08 08:11 AM
                                                  No conflict between theory and practiceAndrey2021/04/08 08:48 AM
                                                    No conflict between theory and practiceanon22021/04/08 03:10 PM
                                            No conflict between theory and practice---2021/04/08 07:30 PM
                                              No conflict between theory and practicedmcq2021/04/09 01:25 AM
                                                No conflict between theory and practiceLinus Torvalds2021/04/09 08:44 AM
                                        No conflict between theory and practiceanon22021/04/08 03:09 AM
                                          No conflict between theory and practicesr2021/04/10 12:22 AM
                                            No conflict between theory and practiceAnon2021/04/10 03:00 AM
                                              No conflict between theory and practiceEtienne Lorrain2021/04/11 11:56 PM
                                                No conflict between theory and practiceAnon2021/04/12 12:54 AM
                                                  No conflict between theory and practicedmcq2021/04/12 12:44 PM
                              No conflict between theory and practiceGabriele Svelto2021/04/08 12:03 AM
                                No conflict between theory and practicedmcq2021/04/12 12:53 PM
                                  No conflict between theory and practicedmcq2021/04/14 03:50 AM
                      transactional memory = memory lock/unlocksr2021/04/09 11:56 PM
                        transactional memory = memory lock/unlockAnon2021/04/10 03:05 AM
                    No conflict between theory and practiceanon22021/04/07 04:19 PM
                No conflict between theory and practicedmcq2021/04/07 12:16 PM
            No conflict between theory and practiceAnon2021/04/06 09:46 AM
            No conflict between theory and practiceAspect of Anonimity2021/04/06 01:16 PM
              No conflict between theory and practiceNoSpammer2021/04/09 11:02 PM
                No conflict between theory and practicesr2021/04/10 12:47 AM
                No conflict between theory and practiceAspect of Anonimity2021/04/10 10:30 PM
                  No conflict between theory and practiceAndrey2021/04/11 04:05 AM
                    HmAspect of Anonimity2021/04/12 06:29 PM
                      Special internal SRAM to store Mutex?Etienne Lorrain2021/04/13 12:01 AM
                        Special internal SRAM to store Mutex?Anon2021/04/13 12:26 AM
                        Special internal SRAM to store Mutex?Linus Torvalds2021/04/13 08:53 AM
                        Special internal SRAM to store Mutex?Dan Fay2021/04/13 11:03 AM
                          Special internal SRAM to store Mutex?Ben LaHaise2021/04/13 02:32 PM
                          Special internal SRAM to store Mutex?Gabriele Svelto2021/04/13 10:43 PM
                        Special internal SRAM to store Mutex?Carson2021/04/13 09:19 PM
          No conflict between theory and practicesr2021/04/06 06:12 AM
            No conflict between theory and practiceAnon2021/04/06 09:43 AM
            No conflict between theory and practiceAspect of Anonimity2021/04/06 02:20 PM
              No conflict between theory and practicesr2021/04/07 09:09 AM
                No conflict between theory and practiceanon22021/04/07 07:53 PM
  Armv9 officially announceddmcq2021/03/30 02:28 PM
    Totally backwads logic on compatibilityHeikki Kultala2021/03/30 02:44 PM
      Totally backwads logic on compatibilityDoug S2021/03/31 11:09 AM
        Totally backwads logic on compatibilitydmcq2021/03/31 02:15 PM
  Armv9 officially announcedv92021/04/12 02:57 PM
    Armv9 officially announcedj2021/04/13 04:07 AM
      Armv9 officially announcedDoug S2021/04/13 09:21 AM
        Armv9 officially announcedanonymou52021/04/13 10:06 AM
          Armv9 officially announcedDoug S2021/04/13 12:01 PM
        Armv9 officially announceddmcq2021/04/13 02:20 PM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell avocado?