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."

4 of 20 comments (clear)

  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. 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.

  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.