Next Previous Contents

3. Questions related to any architectures

3.1 Kernel side

  1. Does Linux support multi-threading? If I start two or more processes, will they be distributed among the available CPUs?

    Yes.

  2. What kind of architectures are supported in SMP?

    From Alan Cox:

    SMP is supported in 2.0 on the hypersparc (SS20, etc.) systems and Intel 486, Pentium or higher machines which are Intel MP1.1/1.4 compliant. Richard Jelinek adds: right now, systems have been tested up to 4 CPUs and the MP standard (and so Linux) theoretically allows up to 16 CPUs.

    SMP support for UltraSparc, SparcServer, Alpha and PowerPC machines is in progress in 2.1.x.

    From Ralf Bächle:

    MIPS, m68k and ARM does not support SMP; the latter two probly won't ever.

    That is, I'm going to hack on MIPS-SMP as soon as I get a SMP box ...

  3. How do I make a Linux SMP kernel?

    Uncomment the SMP=1 line in the main Makefile (/usr/src/linux/Makefile).

    AND

    enable "RTC support" (from Robert G. Brown). Note that inserting RTC support actually doesn't afaik prevent drift, but according to a discussion [Robert G. Brown] remember from a year ago or so it can prevent lockup when the clock is read at boot time. A note from Richard Jelinek says also that activating the Enhanced RTC is necessary to get the second CPU working (identified) on some original Intel Mainboards.

    AND

    do NOT enable APM! APM and SMP are not compatible, and your system will almost certainly (or at least probably ;)) crash under boot if APM is enabled (Jakob Oestergaard). Alan Cox confirms this : 2.1.x turns APM off for SMP boxes. Basically APM is undefined in the presence of SMP systems, and anything could occur.

    You must rebuild all your kernel and kernel modules when changing to and from SMP mode. Remember to make modules and make modules_install (from Alan Cox).

  4. How do I make a Linux non-SMP kernel?

    Comment the SMP=1 line in the Makefile (and not set SMP to 0).

    You must rebuild all your kernel and kernel modules when changing to and from SMP mode. Remember to make modules and make modules_install.

  5. How can I tell if it worked?

     cat /proc/cpuinfo 
    

    Typical output (dual PentiumII):


    processor       : 0
    cpu             : 686
    model           : 3
    vendor_id       : GenuineIntel
    stepping        : 3
    fdiv_bug        : no
    hlt_bug         : no
    fpu             : yes
    fpu_exception   : yes
    cpuid           : yes
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic 11 mtrr pge mca cmov mmx
    bogomips        : 267.06
     
    processor       : 1
    cpu             : 686
    model           : 3
    vendor_id       : GenuineIntel
    stepping        : 3
    fdiv_bug        : no
    hlt_bug         : no
    fpu             : yes
    fpu_exception   : yes
    cpuid           : yes
    wp              : yes
    flags           : fpu vme de pse tsc msr pae mce cx8 apic 11 mtrr pge mca cmov mmx
    bogomips        : 267.06
    

  6. What is the status of converting the kernel toward finer grained locking and multithreading?

    2.1.x has signal handling, interrupts and some I/O stuff fine grain locked. The rest is gradually migrating. All the scheduling is SMP safe

  7. Does Linux SMP support processor affinity?

    No and Yes. There is no way to force a process onto specific CPU's but the linux scheduler has a processor bias for each process, which tends to keep processes tied to a specific CPU.

3.2 User side

  1. Do I really need SMP?

    If you have to ask, you probably don't. :)

  2. How does one display mutiple cpu performance?

    Thanks to Samuel S. Chessman, here is some useful utilities:

    Character based:

    http://www.cs.inf.ethz.ch/~rauch/procps.html

    Basically, it's procps v1.12.2 (top, ps, et. al.) and some patches to support SMP.

    Graphic:

    xosview-1.5.1 supports SMP. And kernels above 2.1.85 (included) have the /proc/stat/cpuX entry.

    The official homepage for xosview is: http://lore.ece.utexas.edu/~bgrayson/xosview.html

    The various forissier's kernel patches are at: http://www-isia.cma.fr/~forissie/smp_kernel_patch/

  3. How can I program to use two (or more CPUs) ?

    Use a kernel-thread library. A good library, the pthread library made by Xavier Leroy.

    LinuxThread is now integrated with glibc2 (aka libc6).

    From Jakob Oestergaard: Also consider using MPI. It's the industry standard message passing interface. It doesn't give you shared memory like threads, but it allows you to use your program in a cluster too.

  4. What has changed in the threads packages, linuxthread, etc.

    Glibc is the big change. glibc is threadsafe and includes linuxthreads Posix.4 threads by default. Real time signals are also in glibc so POSIX AIO should also be in glibc2.1 (I hope).

  5. How can I enable more than 1 process for my kernel compile?

    use:


            # make [modules|zImage|bzImages] MAKE="make -jX"
            where X=max number of processes.
            WARNING: This won't work for "make dep".
    

    With a 2.1.x like kernel, see also the file /usr/src/linux/Documentation/smp for specific instruction.

    BTW, since running multiple compilers allows a machine with sufficient memory to use use the otherwise wasted CPU time during I/O caused delays make MAKE="make -j 2" -j 2 actually even helps on uniprocessor boxes (from Ralf Bächle).

  6. Why the time given by the time command is false ? (from Joel Marchand)

    In the 2.0 series, the result given by the time command is false. The sum user+system is right *but* the spreading between user and system time is false.

    This bug in corrected in 2.1 series.

  7. How will my application perform under SMP?

    Look at SMP Performance of Linux which gives useful hints how to bench a specific machine (from a post made by Cameron MacKinnon).

  8. Where can I found more information about parallel programming?

    Look at the Linux Parallel Processing HOWTO

    Lots of useful information can be found at Parallel Processing using Linux


Next Previous Contents