12:30 "[ISA] do not matter very much"

By: rwessel (rwessel.delete@this.yahoo.com), February 23, 2021 1:21 pm
Room: Moderated Discussions
Linus Torvalds (torvalds.delete@this.linux-foundation.org) on February 23, 2021 11:44 am wrote:
> rwessel (rwessel.delete@this.yahoo.com) on February 23, 2021 9:33 am wrote:
> > No one would object to rep/movsb being slow if the operands overlap.
>
> Noe that one problem with rep/movsb is that "overlap" is hard to figure out.
>
> They might not overlap in virtual memory, but still overlap in physical pages.
>
> And while that doesn't matter for memcpy, it does matter for
> movsb, which is technically defined even for that case.


Is that really a problem? Just check for aliasing at startup, and as each operand crosses page boundaries.


> Same goes for MMIO memory. If you do memcpy() on MMIO memory, you get whatever random
> end results. But for movsb it's actually acrhitecturally defined, and usually not
> what you want (ie the definition is the "go slow, one byte at a time").


I don't know how you get around that. If you do a byte access to MMIO memory, the hardware *has* to do byte accesses. Using movsq* instead will help some, as would something that supported a bigger word than that (a hypothetical movs128 or movs256 wouldn't require any tricks - the moved word is never exposed, but something like a stos128 might need to reference register pair of one of the vector registers).


> So when memcpy can make decisions based on just comparing addresses and can say "screw
> it" to both physical aliasing and MMIO, movsb needs to actually do a TLB probe.


That has to happen anyway, or at least once movsb tries to actually read or write the data being moved. And the CPU already has to back that sort of thing out in the case of an exception. If overlap is detected there, it backs up and restarts in slow mode. Again, that has to be redone as each operand crosses a page boundary. And that should all happen in the load/store unit.


> I think "rep movsb" is really really close to being the perfect hardware interface for "memcpy", but the
> above issues and the DF bit do make for it being much harder to just generate simpler optimal ucode.
>
> So the best option might be to specify a new instruction that looks exactly like "rep movsb"
> but specifies that DF is ignored, and that it might be moving things in bigger chunks (so that
> MMIO and physical aliases get the "memcpy" semantics, not the "byte at a time" ones).
>
> One potential way would be to say "doubled-up rep prefix
> means new semantics", and have a bit in CR4 enable it.

I could see that helping a bit, particularly on short operands, but I don't think it's necessary (except, perhaps, the DF part). Maybe an eeee!vex prefix to specify different registers as well, if we're dreaming.

I'd also like an instruction with two proper addresses, and a limited register or constant based length (IOW, S/360 MVC). But then I also want a date with Jennifer Aniston. The latter might be more realistic.



*I am assuming that if movsb got fixed, the bigger variants would be fixed too.
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
New Lex Fridman interview with Jim KellerJohnG2021/02/20 12:25 AM
  12:30 "[ISA] do not matter very much" (NT)Moritz2021/02/20 10:45 AM
    AAARGH, what are we going to argue about then? (NT)j2021/02/20 03:43 PM
    Blasphemy! (NT):]2021/02/21 05:49 AM
    12:30 "[ISA] do not matter very much"anon22021/02/21 11:25 PM
      12:30 "[ISA] do not matter very much"Brett2021/02/22 12:59 AM
        12:30 "[ISA] do not matter very much"Etienne Lorrain2021/02/22 02:17 AM
      12:30 "[ISA] do not matter very much"Dummond D. Slow2021/02/22 09:57 AM
        12:30 "[ISA] do not matter very much"Anon2021/02/22 11:52 AM
          12:30 "[ISA] do not matter very much"juanrga2021/02/22 12:01 PM
          12:30 "[ISA] do not matter very much"Mark Roulo2021/02/22 12:54 PM
          ARM being a good idea doesn't mean it would have worked for AMDDummond D. Slow2021/02/22 02:34 PM
            ARM being a good idea doesn't mean it would have worked for AMDAnon2021/02/22 04:25 PM
              ARM being a good idea doesn't mean it would have worked for AMDDummond D. Slow2021/02/22 05:55 PM
                ARM being a good idea doesn't mean it would have worked for AMDDoug S2021/02/23 01:03 PM
                  ARM being a good idea doesn't mean it would have worked for AMDDummond D. Slow2021/02/23 01:27 PM
                    ARM being a good idea doesn't mean it would have worked for AMDBrett2021/02/23 04:57 PM
                      3rd parties licensing ARM coresAnon2021/02/25 05:01 AM
                        3rd parties licensing ARM coresAnon2021/02/25 05:48 AM
                        3rd parties licensing ARM coresdmcq2021/02/25 07:01 AM
                          3rd parties licensing ARM coresDummond D. Slow2021/02/25 10:17 AM
                            3rd parties licensing ARM coresAnon2021/02/25 11:11 AM
                              3rd parties licensing ARM coresAnon2021/02/26 03:54 AM
                              3rd parties licensing ARM coresDummond D. Slow2021/02/26 11:01 AM
            ARM being a good idea doesn't mean it would have worked for AMDLinus Torvalds2021/02/22 06:06 PM
              ARM being a good idea doesn't mean it would have worked for AMDDummond D. Slow2021/02/22 08:19 PM
              ARM being a good idea doesn't mean it would have worked for AMDanon22021/02/22 08:28 PM
              ARM being a good idea doesn't mean it would have worked for AMDdmcq2021/02/23 06:35 AM
                ARM being a good idea doesn't mean it would have worked for AMDJukka Larja2021/02/23 08:12 AM
                  ARM being a good idea doesn't mean it would have worked for AMDSimon Farnsworth2021/02/23 09:42 AM
                    ARM being a good idea doesn't mean it would have worked for AMDJukka Larja2021/02/24 07:03 AM
                ARM may have been a threat to Intelwumpus2021/02/23 09:30 AM
      12:30 "[ISA] do not matter very much"blaine2021/02/22 10:37 AM
        12:30 "[ISA] do not matter very much"anon22021/02/22 08:17 PM
          12:30 "[ISA] do not matter very much"Anon2021/02/23 04:05 AM
            12:30 "[ISA] do not matter very much"Wilco2021/02/23 04:48 AM
              12:30 "[ISA] do not matter very much"Bigos2021/02/23 04:55 AM
                12:30 "[ISA] do not matter very much"Wilco2021/02/23 05:15 AM
                  12:30 "[ISA] do not matter very much"Bigos2021/02/23 06:16 AM
                12:30 "[ISA] do not matter very much"Travis Downs2021/02/27 12:46 AM
              12:30 "[ISA] do not matter very much"Anon2021/02/23 07:26 AM
                12:30 "[ISA] do not matter very much"anon22021/02/23 05:35 PM
                  12:30 "[ISA] do not matter very much"Anon2021/02/24 08:57 AM
                12:30 "[ISA] do not matter very much"Wilco2021/02/24 05:37 AM
                  12:30 "[ISA] do not matter very much"Etienne Lorrain2021/02/24 07:24 AM
                    12:30 "[ISA] do not matter very much"Anon2021/02/24 09:11 AM
                    12:30 "[ISA] do not matter very much"rwessel2021/02/24 09:45 AM
                      12:30 "[ISA] do not matter very much"Etienne Lorrain2021/02/25 02:02 AM
                        12:30 "[ISA] do not matter very much"rwessel2021/02/25 05:51 AM
                        12:30 "[ISA] do not matter very much"Anon2021/02/25 05:53 AM
                  12:30 "[ISA] do not matter very much"Anon2021/02/24 09:07 AM
                    12:30 "[ISA] do not matter very much"Wilco2021/02/24 12:37 PM
                      runtime selection vs. heterogenous cores?Matt Sayler2021/02/24 07:10 PM
                        runtime selection vs. heterogenous cores?Wilco2021/02/26 06:22 AM
            12:30 "[ISA] do not matter very much"anon22021/02/23 05:20 AM
              12:30 "[ISA] do not matter very much"Anon2021/02/23 07:21 AM
                12:30 "[ISA] do not matter very much"none2021/02/23 08:37 AM
                  12:30 "[ISA] do not matter very much"rwessel2021/02/23 10:44 AM
                    12:30 "[ISA] do not matter very much"anon22021/02/23 05:30 PM
                      12:30 "[ISA] do not matter very much"Anon2021/02/24 09:25 AM
                        12:30 "[ISA] do not matter very much"anon.12021/02/25 07:13 AM
                  12:30 "[ISA] do not matter very much"Anon2021/02/24 09:44 AM
                12:30 "[ISA] do not matter very much"anon22021/02/23 04:51 PM
                  12:30 "[ISA] do not matter very much"Anon2021/02/24 09:31 AM
            12:30 "[ISA] do not matter very much"vvid2021/02/23 07:41 AM
              12:30 "[ISA] do not matter very much"Michael S2021/02/23 09:52 AM
                12:30 "[ISA] do not matter very much"rwessel2021/02/23 10:33 AM
                  12:30 "[ISA] do not matter very much"Linus Torvalds2021/02/23 12:44 PM
                    12:30 "[ISA] do not matter very much"rwessel2021/02/23 01:21 PM
                      12:30 "[ISA] do not matter very much"Linus Torvalds2021/02/23 01:30 PM
                        12:30 "[ISA] do not matter very much"Andrey2021/02/25 04:06 AM
                          12:30 "[ISA] do not matter very much"Anon2021/02/25 06:04 AM
                            12:30 "[ISA] do not matter very much"Andrey2021/02/25 06:54 AM
                              12:30 "[ISA] do not matter very much"Anon2021/02/25 07:33 AM
                          12:30 "[ISA] do not matter very much"Linus Torvalds2021/02/25 11:35 AM
                            12:30 "[ISA] do not matter very much"Andrey2021/02/25 02:34 PM
                              12:30 "[ISA] do not matter very much"Etienne Lorrain2021/02/26 02:18 AM
                              12:30 "[ISA] do not matter very much"dmcq2021/02/26 04:23 PM
                12:30 "[ISA] do not matter very much"Anon2021/02/24 09:45 AM
              12:30 "[ISA] do not matter very much"Gabriele Svelto2021/02/23 10:15 AM
          Context of ISA doesn't matterPaul A. Clayton2021/02/26 01:03 PM
  Is there a text version? (NT)Foo_2021/02/20 05:33 PM
    good question (NT)Michael S2021/02/21 05:31 AM
    Is there a text version?:]2021/02/21 11:34 AM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell tangerine? 🍊