1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

unaligned_instructions counter in Shibby's v105 release

Discussion in 'Tomato Firmware' started by rioachim, Feb 15, 2013.

  1. rioachim

    rioachim Addicted to LI Member

    I have just noticed this info when doing cat /proc/cpuinfo:

    - on WRT54GL (Tomato Firmware 1.28.0000 MIPSR1-105 K26 USB Big-VPN)
    system type : Broadcom BCM5352 chip rev 0 pkg 2
    processor : 0
    cpu model : Broadcom BCM3302 V0.8
    BogoMIPS : 249.03
    cpu MHz : 250
    wait instruction : no
    microsecond timers : yes
    tlb_entries : 32
    extra interrupt vector : no
    hardware watchpoint : no
    ASEs implemented :
    shadow register sets : 1
    VCED exceptions : not available
    VCEI exceptions : not available
    unaligned_instructions : 183322 (and increasing)

    - on RT-N10U (Tomato Firmware 1.28.0000 MIPSR2-105 K26 USB BT-VPN)
    system type : Broadcom BCM5357 chip rev 2 pkg 8
    processor : 0
    cpu model : MIPS 74K V4.9
    BogoMIPS : 179.81
    cpu MHz : 360
    wait instruction : no
    microsecond timers : yes
    tlb_entries : 64
    extra interrupt vector : no
    hardware watchpoint : yes
    ASEs implemented : mips16 dsp
    shadow register sets : 1
    VCED exceptions : not available
    VCEI exceptions : not available
    unaligned_instructions : 30

    Why is the value of unaligned_instructions increasing on the first router only? Is it a problem and can I help with some logs?
  2. koitsu

    koitsu Network Guru Member

    Google's your friend. Note: below is highly technical and expects that you understand CPU architecture (particularly MIPS, but instruction alignment for optimal L1/L2 cache performance is a universal thing):


    Read the entire wiki page -- slowly. If it's over your head, then either turn off OCD mode in your brain (no offence intended -- this is what I'd recommend, i.e. stop worrying about it), or learn more about it.

    The reason one of your routers sees it while the other does not depends on too many variables (CPU architecture differs between the two, amount of traffic flowing across both, what features are used within the kernels, etc.). It's not worth getting into -- in fact, if you ask to narrow it down, I will ignore the rest of the thread because it's impossible/not worth the time.

    The issue has plagued other firmwares, and was caused by two (2) Linux kernel issues in the mac80211 layer on MIPS architectures Again: read these tickets, and view all the links referenced within:


    Normally this would be fixed by a kernel upgrade, but that can't be done given the underlying ABI semantics or KBI semantics may change, and in doing so that breaks full compatibility with the actual wireless closed-source binary-only drivers provided by Broadcom. The risks are very, very high. That said, two mac80211 kernel patches are available, and you're welcome to backport them to TomatoUSB and test them fully if you wish. Let us know how that goes!
    shibby20, PBandJ and rioachim like this.
  3. rioachim

    rioachim Addicted to LI Member

    Thank you for the reply. I was able to trigger the continuous increase also on RT-N10U.
    So far I suspect the setting nvram set manual_boot_nv=1 , but the strange thing is even after setting it to 0 again and rebooting, unaligned_instructions is still increasing.

    The WRT54GL has its RAM upgraded to 64Mb (which Tomato does not recognise by default, only sees 32Mb) and I used that setting to get all 64 (by the way, is this the right way to do it?). On RT-N10U I still have to do some tests with an older setting/NVRAM dump in order to be able to reproduce the behavior and be 100% sure.
  4. koitsu

    koitsu Network Guru Member

    Respectively: please re-read what I wrote. The root cause of the counter increasing is described, and has nothing to do with NVRAM variables.
  5. rioachim

    rioachim Addicted to LI Member

    Of course you are right. Kernel reports misaligned load or store instruction calls which are triggered by function calls of a certain module, which has to be influenced by settings/firmware. I am no longer trying to solve it or investigate kernel, I just find it odd that I did something to start the counter increase. Indeed, my basic knowledge of linux/kernel limits my understanding.

    Thank you for support, I do not want to waste anybody's time. I only wanted to report a strange behavior to someone who can decide if it is worth looking into.
  6. koitsu

    koitsu Network Guru Member

    What causes the counter to increase are bugs in the mac80211 layer, like I said. The patches/diffs referenced in the OpenWRT threads can be examined and see if they can be backported to work on TomatoUSB, but need to be done so very very carefully and with very thorough/extensive testing, as breaking mac80211 could cause the wireless layer to break (remember: we cannot recompile the wireless driver from Broadcom because it's closed-source / binary only).
  7. RMerlin

    RMerlin Network Guru Member

    As far as I can tell, these two patches OpenWRT refers to don't apply to our kernel. One of the patched function for instance doesn't even exist in the kernel tree.

    The alignment issue can be pretty much anywhere in the code, both kernel and user-space (AFAIK).
  8. koitsu

    koitsu Network Guru Member

    Our version of mac80211 is older/different, correct? The underlying API probably differs between the two versions, which would explain missing functions in ours vs. what OpenWRT has. The issue could still exist regardless of that fact. I'm not sure there's an easy way to track this one down though (in fact I'm not even sure how the Linux/mac80211 folks figured it out without having extensive familiarity with the architecture *and* the existing code).
  9. mstombs

    mstombs Network Guru Member

    Is tomato K26 even stable on old mipsR1 hardware? Does OpenWRT support that hardware with usable wireless drivers yet?Where did the wireless drivers in Tomato come from? Definitely not Linksys/Cisco/Belkin since the last original firmwares were kernel 2.4.20 IIRC, so possibly Asus, via Oleg?

    I've seen kernel routines called 'unaligned', so presumably it would be possible for some kernel debug print messages to be added to find out what calls are responsible for the counts, if anyone could be bothered...
  10. RMerlin

    RMerlin Network Guru Member

    I'm not sure anymore if ours is older, newer, or just from an alternate universe. Our kernel got so many backported patches over the years that it's a mixture of pretty much every kernel versions between 2.6.22 and 3.x. :) The wl500g kernel for instance has no less than 680 patches (and some of these patches apply multiple patches on their own). Tomato and Asuswrt(-Merlin) have a lot of these patches applied too (pretty much most of them up to 2010, and maybe a few cherrypicks afterward).

Share This Page