On Mon, Jul 09, 2007 at 11:14:18PM -0700, Alexander Kolbasov wrote:
> Hi Brendan,
> 
> can I summarize your point as a proposal to extend kstat framework
> instead of providing filesystem-based representation for CPU-related
> information?

Yes, as a suggestion moving to a prototype. If this approach fails for
some reason, then move to /CPUfs or even /kstatfs etc.

I have nothing against statistic filesystems (I suggested a /connfs in my
talk at CEC2006 :), so long as it can be shown that the existing 
infrastructure is inadequate and can't be fixed.

I've spent about 15 minutes typing it what such a kstat based CPU info
implementation may look like for an example system, attached below. If
someone can show how this would fail for a particular CPU type, that
would be good to know (and even better if they could suggest a fix :).

Naturally I'm eager to see such stable information available, somehow,
as I can imagine the sort of tools that this would make possible.

cheers,

Brendan

-- 
Brendan
[CA, USA]


kstat example
-------------

Our fictitious system has 2 sockets, each socket having 8 cores, each core
having 4 hardware threads. The L1 cache is shared between pairs of
cores, the L2 cache is shared across all cores on a single socket, and the
L3 cache is shared across both sockets.

CPU layout with kstat names,

    +-- socket0
    |      |
    |      +--- core0
    |      |      |
    |      |      +--- thread0
    |      |      |
    |      |      +--- thread1
    |      |      |
    |      |      +--- thread2
    |      |      |
    |      |      +--- thread3
    |      |
    |      +--- core1
    |      |      |
    |      |      +--- thread4
    |      |      ...
    |      |
    |      +--- core2
    |      |      |
    |      |      +--- thread8
    |      |      ...
    |      |
    |      +--- core3
    |             |
    |             +--- thread12
    |             ...
    |   
    +-- socket1
    |      |
    |      +--- core4
    |      |      |
    |      |      +--- thread32
    |      |      |
   ...    ...    ...

Cache layout with kstat names,

    +-- l1cache_0
    |
    +-- l1cache_1
    |
    +-- l1cache_2
    |
    +-- l1cache_3
   ...

    +-- l2cache_0
    |
    +-- l2cache_1

    +-- l3cache_0

kstat cpu_info module classes,

    Class       | Name      |  Desc
    ------------+-----------+---------------------
    misc        | cpu_info# | virtual CPU info (sockets or cores or threads,
                |           | depending on architecture)
    socket      | socket#   | socket info
    core        | core#     | core info (if they exist)
    thread      | thread#   | thread info (if they exist)
    l1cache     | l1cache#  | L1 cache info
    l2cache     | l2cache#  | L2 cache info
    l3cache     | l3cache#  | L3 cache info (if they exist)

Identifying relationships,

    Relationship         | How To
    ---------------------+------------
    cores to sockets     | core stats have the socket_id
    threads to cores     | thread stats have the core_id
    threads to sockets   | threads stats have the socket_id
    L1 caches to cores   | core stats have l1cache_id
    L2 caches to cores   | core stats have l2cache_id
    L3 caches to cores   | core stats have l3cache_id
    who shares L1 caches | cpu_info stats with identical l1cache_ids
    cpus to psets        | cpu_info stats have pset_id
    etc...

Identifier tree,

    socket
     ^   ^      l1cache    l2cache   l3cache
     ||   |       ^          ^        ^
     | |   |       |        /       /
     |  |  core     |      /      /
     |   |  ^  ^    |     /     /
     |    |  |  |    |   /    /
     |  thread  |    |  /   /
     |   ^     /    | /   /
     |   |   /     / /  /
    cpu_info ----------

Either socket, core or thread can also identify the caches, depending on
who is the addressable unit of CPU that the system uses.

Example (fictional) kstat output, interesting lines prefixed with '!',

$ kstat -m cpu_info
module: cpu_info                        instance: 0     
name:   cpu_info0                       class:    misc
        brand                           AMD Galactic(tm) Processor 2000
        clock_MHz                       6842
        clog_id                         0
!       core_id                         0
        cpu_type                        i386
        crtime                          62.321739839
        family                          15
        fpu_type                        i387 compatible
        implementation                  x86 (AuthenticAMD ...
!       l1cache_id                      0
!       l2cache_id                      0
!       l3cache_id                      0
        model                           37
!       pset_id                         0
        snaptime                        5444553.88212403
!       socket_id                       0
        state                           on-line
        state_begin                     1178664366
        stepping                        1
!       type                            thread
!       thread_id                       0
        vendor_id                       AuthenticAMD

[cpu_info0 ... cpu_info63]

module: cpu_info                        instance: 0     
name:   socket0                         class:    socket
        brand                           AMD Galactic(tm) Processor 2000
        clock_MHz                       6842
        cpu_type                        i386
        crtime                          62.321739839
!       ncores                          8
!       nthreads                        32
        snaptime                        5441324.10476323
!       socket_id                       0
        state                           on-line
        state_begin                     1178664366

module: cpu_info                        instance: 0     
name:   socket1                         class:    socket
        brand                           AMD Galactic(tm) Processor 2000
        clock_MHz                       6842
        cpu_type                        i386
        crtime                          62.321739839
!       ncores                          8
!       nthreads                        32
        snaptime                        5441324.10476323
!       socket_id                       1
        state                           on-line
        state_begin                     1178664366

module: cpu_info                        instance: 0     
name:   core0                           class:    core
        clock_MHz                       6842
!       core_id                         0
!       l1cache_id                      0
!       l2cache_id                      0
!       l3cache_id                      0
!       nthreads                        4
        snaptime                        11214398.1110444
        state                           on-line
!       socket_id                       0
        state_begin                     1172889991

module: cpu_info                        instance: 0     
name:   core1                           class:    core
        clock_MHz                       6842
!       core_id                         1
!       l1cache_id                      0
!       l2cache_id                      0
!       l3cache_id                      0
!       nthreads                        4
        snaptime                        11214398.1110444
        state                           on-line
!       socket_id                       0
        state_begin                     1172889991

module: cpu_info                        instance: 0     
name:   core2                           class:    core
        clock_MHz                       6842
!       core_id                         2
!       l1cache_id                      1
!       l2cache_id                      0
!       l3cache_id                      0
!       nthreads                        4
        snaptime                        11214398.1110444
        state                           on-line
!       socket_id                       0
        state_begin                     1172889991

[core3 ... core7]

module: cpu_info                        instance: 0     
name:   core8                           class:    core
        clock_MHz                       6842
!       core_id                         8
!       l1cache_id                      1
!       l2cache_id                      4
!       l3cache_id                      0
!       nthreads                        4
        snaptime                        11214398.1110444
        state                           on-line
!       socket_id                       1
        state_begin                     1172889991

module: cpu_info                        instance: 0     
name:   core9                           class:    core
        clock_MHz                       6842
!       core_id                         9
!       l1cache_id                      1
!       l2cache_id                      4
!       l3cache_id                      0
!       nthreads                        4
        snaptime                        11214398.1110444
        state                           on-line
!       socket_id                       1
        state_begin                     1172889991

[core10 ... core15]

module: cpu_info                        instance: 0     
name:   thread0                         class:    thread
        clock_MHz                       6842
!       core_id                         0
        snaptime                        11214398.1110444
        state                           on-line
!       socket_id                       0
        state_begin                     1172889991
!       thread_id                       0

[thread1 ... thread63]

module: cpu_info                        instance: 0     
name:   l1cache_0                       class:    l1cache
!       l1cache_id                      0
!       ncores                          2
!       nthreads                        8
!       size                            32768
        snaptime                        11214398.1110444
!       socket_id                       0

module: cpu_info                        instance: 0     
name:   l1cache_1                       class:    l1cache
!       l1cache_id                      1
!       ncores                          2
!       nthreads                        8
!       size                            32768
        snaptime                        11214398.1110444
!       socket_id                       0

[l1cache_2 .. l1cache_7]

module: cpu_info                        instance: 0     
name:   l2cache_0                       class:    l2cache
!       l2cache_id                      0
!       ncores                          8
!       nthreads                        32
!       size                            8388608
        snaptime                        11214398.1110444
!       socket_id                       0

module: cpu_info                        instance: 0     
name:   l2cache_1                       class:    l2cache
!       l2cache_id                      1
!       ncores                          8
!       nthreads                        32
!       size                            8388608
        snaptime                        11214398.1110444
!       socket_id                       1

module: cpu_info                        instance: 0     
name:   l3cache_0                       class:    l3cache
!       l3cache_id                      0
!       ncores                          16
!       nsockets                        2
!       nthreads                        64
!       size                            33554432
        snaptime                        11214398.1110444



_______________________________________________
perf-discuss mailing list
perf-discuss@opensolaris.org

Reply via email to