Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpuinfo: fixes and enhancements #297

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Commits on May 18, 2020

  1. cpuinfo_test: fix test data

    Real /proc/cpuinfo files do not contain empty lines at the start
    or at the end of file.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed May 18, 2020
    Configuration menu
    Copy the full SHA
    0174b24 View commit details
    Browse the repository at this point in the history

Commits on May 19, 2020

  1. parseCPUInfoARM: fix for kernel 3.8+

    Since Linux kernel 3.8-rc1 (commit b4b8f770eb10a "ARM: kernel:
    update cpuinfo to print all online CPUs features", Sep 10 2012)
    the kernel does not print "Processor" as the first line of
    /proc/cpuinfo. Instead, it adds a line named "model name"
    with similar contents.
    
    Fix the code for this case, and add more tests.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed May 19, 2020
    Configuration menu
    Copy the full SHA
    928d8ea View commit details
    Browse the repository at this point in the history
  2. parseCPUInfoARM: only parse Features once

    The `Features` line is the same for all CPUs, and yet it is assigned to
    and parsed many times.
    
    Optimize the code so it is only parsed once and assigned in place.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed May 19, 2020
    Configuration menu
    Copy the full SHA
    611c664 View commit details
    Browse the repository at this point in the history
  3. parseCPUInfo: optimize line scan

    Avoid double check of each line for ":" -- since we're splitting the line anyway,
    we can reuse the result.
    
    This also prevents a potential panic of referencing non-existen field[1]
    in case input contains a ":" with no space after.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed May 19, 2020
    Configuration menu
    Copy the full SHA
    c2b7b68 View commit details
    Browse the repository at this point in the history
  4. cpuinfo: read data in place

    Instead of reading the data to the buffer, then making a reader and a
    scanner out of that buffer, let's analyze the data as we read it line by
    line.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed May 19, 2020
    Configuration menu
    Copy the full SHA
    a175916 View commit details
    Browse the repository at this point in the history
  5. parseCPUInfo*: add error checking

    In case the input can't be read, scanner.Scan() stops and the code is
    supposed to check for error using scanner.Err(). Do that.
    
    In other words, instead of returning half-read cpuinfo, return an error.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed May 19, 2020
    Configuration menu
    Copy the full SHA
    a6effd3 View commit details
    Browse the repository at this point in the history
  6. cpuinfo: rm GetFirstNonEmptyLine, simplify scan

    There is no sense to skip empty lines at the beginning of the file since
    there are none (there were in test data but it is fixed by an earlier
    commit).
    
    Logic is simpler now.
    
    Signed-off-by: Kir Kolyshkin <[email protected]>
    kolyshkin committed May 19, 2020
    Configuration menu
    Copy the full SHA
    e1d29d8 View commit details
    Browse the repository at this point in the history