Slashdot Mirror


Debugging SMP Code with UML

chromatic writes "It's easy to write code that works fine on single-processor systems but dies horribly on multi-processor boxes. Instead of spending thousands of dollars on a four- or eight-way system, you can use UML to emulate a multi-processor machine."

20 comments

  1. Not the final solution by mrblah · · Score: 5, Insightful

    Unless I'm missing something, while I believe that the simulation of multiple CPUS could certainly help find certain kinds of bugs (like those provided as examples in the article), a lot of the nastier issues will only manifest themselves when you really have multiple CPUs that are really doing work at the same time. Folks that work with threads see this a lot: where a multi-threaded application works great on a single-cpu box; but on a multi-cpu box where those threads are really running at the same time, problems occur. So while this is a nice tool, I can't see releasing code for production that has never been tested on a machine that actually has multiple CPUs.

    1. Re:Not the final solution by pstemari · · Score: 2, Interesting
      Depending on how the user-mode kernel is implemented, it may actually be better at reproducing SMP bugs than an actual SMP device. Typical SMP-only bugs are assumptions about cache operation that aren't seen on single processor machines with a single cache and synchronization issues on non-atomic memory access.

      An appropriately malicious emulation of SMP hardware can force these faults out much faster than they would appear in real life. One simple example would be cache emulation. IRL cache is limited and will be flushed automatically at some point. The emulation can treat cache as unlimited and only flush it on operations that guarantee cache flush. This will shake a lot of difficult-to-reproduce bugs out quickly.

    2. Re:Not the final solution by cheezfreek · · Score: 1

      Actually, I've seen plenty of race condition bugs that only manifest themselves on a multiprocessor machine running a particular version of an operating system. For example, AIX 4.3 and 5.1 use different scheduling algorithms, and many race conditions will only occur on 5.1 or above, because these versions of the operating system use a much more aggressive scheduler, and context switches tend to take less time. So, I am also skeptical about UML as a tool to "emulate" a multiprocessor box. If many bugs won't even manifest on a real multiprocessor box with a certain OS version, then it's highly unlikely that a uniprocessor box running some emulator will catch many bugs.

  2. Bochs also does this by mcgroarty · · Score: 4, Interesting
    Bochs will also emulate SMP machines. Bochs pretends to be an x86 machine with one or more processors, and runs on all Linux architectures, as well as Windows, Mac OS X and several BSDs.

    It's no speed demon, but it's about the nicest free tool for machine-level debugging.

    1. Re:Bochs also does this by khanyisa · · Score: 1

      However, note that it can't yet handle Windows running on a simulated SMP machine...

    2. Re:Bochs also does this by heh2k · · Score: 1

      i tried bochs recently and it was unbelievably slow. unusably slow. i ran it on a (dual) 833mhz ev68 alpha. even if it was twice as fast, it'd still be too slow. it took more than 20min to boot netbsd/i386 from a floppy image.

  3. solution in need of a problem by larry+bagina · · Score: 4, Insightful
    Actually, you can by a dual processor system for not much more than a singel processor system. And have the benefits of a dual processor system. I'd trust that over an emulator.

    And be able to use the -j flag to make

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

    1. Re:solution in need of a problem by smittyoneeach · · Score: 1

      After you 'by' said box, you have to give it a home and maintain it.
      Why not blow off all of the discussion with the management for the funding? You can thug some RAM from the manager's machine to support the extra address space requirements, and irritate his pointy-hair-edness at the same time.
      Only joking about the unethical behavior.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
  4. Limit to number of simulated processors? by cpeterso · · Score: 1


    I wonder if there is limit to the number of simulated processors. Now people can simulate Linux running on a 1,000,000 CPU computer.

    Imagine a Beowulf Cluster of these things!

    1. Re:Limit to number of simulated processors? by Anonymous Coward · · Score: 1, Funny

      imagines....

      why, you foul villian.

  5. Uhh by MisterFancypants · · Score: 1

    Surely they've heard of the Unified Modeling Language? Why do developers so often reuse acronyms that are already widely in use? I mean surely with only so many letters, you're going to get collisions, but with something as already well known as UML... jeez.

  6. UML Confusion by FPCat · · Score: 1

    They should really change the UML acronym... Unified Modeling Language is very commonly known among software professionals. Of course, it peaked my interest on how they were using UML as a debugger....

    1. Re:UML Confusion by Anonymous Coward · · Score: 0

      Yeah lets change that UML acronym to "Under Managed Language".

      What we need right now is a really good centralised language management administration.

      OK, I know what you are saying; but its better that folk realise TLA's are a limited namespace sooner and get over it.

    2. Re:UML Confusion by Anonymous Coward · · Score: 0

      Piqued mine, too.

    3. Re:UML Confusion by Anonymous Coward · · Score: 0

      Why should they? In my experience as a corporate drone, UML is only used by corporate drones. Why should linux pander to them?

  7. Way off topic by Anonymous Coward · · Score: 0

    Is there a way I can get gcc to tell me what flags it uses? I'd like to understand why -O2 produces correct results on my code while -O3 doesn't, so I can figure out what flag is causing it.

    1. Re:Way off topic by Anonymous Coward · · Score: 0

      man gcc:

      -O3 Optimize yet more. This turns on everything -O2 does, along with also turning on -finline-functions.

  8. SCO by Anonymous Coward · · Score: 0

    This just illustrates that it is perfectly possible to optimise for high-end SMP machines on a little box at home.

    Bye bye SCO. And good riddance

  9. Whats Your Favorite Kind of Cheese? by newtish · · Score: 1

    SO..;.. what is it?? My favorite is HAVARTI!!!!! yummy yummy yummy next best is sharp cheddar.