summaryrefslogtreecommitdiffstats
path: root/doc/24x7EventAndGroupCatalogFormatProposals.tex
blob: aa3c47edd4d30055cb1bfeacee5a074c020cb58f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
% Latex version of the original catalog proposal document by santosiv@in.ibm.com,
% (C) 2015 IBM Corporation
% Confidential - Internal Use only

\documentclass[14]{article}
\usepackage[a4paper]{geometry}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{placeins}
\usepackage[T1]{fontenc}

\makeatletter
\AtBeginDocument{%
  \expandafter\renewcommand\expandafter\subsection\expandafter
    {\expandafter\@fb@secFB\subsection}%
  \newcommand\@fb@secFB{\FloatBarrier
    \gdef\@fb@afterHHook{\@fb@topbarrier \gdef\@fb@afterHHook{}}}%
  \g@addto@macro\@afterheading{\@fb@afterHHook}%
  \gdef\@fb@afterHHook{}%
}
\makeatother

% with this we ensure that the chapter and section
% headings are in lowercase.
\renewcommand{\sectionmark}[1]{\markright{#1}}

\usepackage[colorlinks]{hyperref}
\usepackage[figure,table]{hypcap} % Correct a problem with hyperref

\hypersetup {
  colorlinks = true,
  urlcolor = black,
  pdfauthor = {Santosh Sivaraj <santosiv@in.ibm.com},
  pdfkeywords = {24x7, catalog, format},
  pdftitle = {24x7 Event and Group Catalog Formats Proposal},
  pdfsubject = {24x7 catalog},
  pdfpagemode = UseNone
}

\newgeometry{left=2cm,right=2cm,bottom=2cm}

\setlength{\parskip}{\baselineskip}%
\setlength{\parindent}{0pt}%

\begin{document}

\begin{center}

{ \huge \bfseries 24x7 Event and Group Catalog Formats Proposal \\[0.4cm] }

\end{center}
\noindent
\emph{Authors:}\\
Jim Benson (\texttt{jeben@us.ibm.com}) \\
Phil Vitale (\texttt{vit@us.ibm.com}) \\

\begin{center}
\emph{Approved on} 2013-05-14 (by common consent, version: v0.15) \\
\emph{Current Version:} v0.16 \\
\emph{Last Update:} \today
\end{center}

\pagebreak
\tableofcontents
\pagebreak

\section{Introduction}
The 24x7 Event and Group catalog is the performance counter consumer's
translator from ``Event Name'' to ``Counter Data'' through the PowerVM
H\_Get24x7Data hcall. Data available in the event entry or group entry in the
catalog is passed through the hcall so that the PowerVM can return the correct
data from the 24x7 ``In Memory Accumulators''.

Clients looking for a specific counter's data, search the events array for a
matching event name. When found, the event entry will contain an IMA Group
Record Offset and an IMA Group Record Length. These two values, along with some
configuration specifics are passed to the PowerVM through the H\_Get24x7Data
hcall to retrieve the Event Group Record. The event entry also contains an
offset into the Event Group Record where the desired counter can be found.

Often clients want a group of event counters so that together more complex
metrics can be computed. Clients will search the groups array for a matching
group name. When found the group entry will, like the event entry, contain an
IMA Group Record Offset and an IBM Group Record Length. These two values, along
with some configuration specifics are passed to the PowerVM through the
H\_Get24x7Data hcall to retrieve the Event Group Record. The group entry also
contains a list of event entry indexes so that the offsets (found through the
event entry) can be use to retrieve desired counters from the Event Group
Record.

The figure below illustrates these relationships.

\includegraphics[scale=0.6]{primary_catalog_relationships.jpeg}

\pagebreak

\section{Catalog Page 0}
\begin{tabular}[l]{|p{5cm}|c|p{7cm}|}
\hline
\textbf{Field} & \textbf{Byte Offset} & \textbf{Attributes} \\
\hline
Descriptor & 0x00 & uint32 "24x7" in ASCII \\
\hline
Length & 0x04 & uint32 (in 4096 byte pages) \\
\hline
Version Number & 0x08 & uint64 \\
\hline
Build Date-stamp & 0x10 & char[16] Zero-terminated ASCII string → YYYYMMDDHHMMSS \\
\hline
Reserved & 0x20 & char[32] \\
\hline
Offset to Schema Data & 0x40 & uint16 (in 4096 byte pages) \\
\hline
Length of Schema Data & 0x42 & uint16 (in 4096 byte pages) \\
\hline
Schema Entry Count & 0x44 & uint16 \\
\hline
Reserved & 0x46 & char[2] \\
\hline
Offset to Event Data & 0x48 & uint16 (in 4096 byte pages) \\
\hline
Length of Event Data & 0x4A & uint16 (in 4096 byte pages) \\
\hline
Event Entry Count & 0x4C & uint16 \\
\hline
Reserved & 0x4E & char[2] \\
\hline
Offset to Group Data & 0x50 & uint16 (in 4096 byte pages) \\
\hline
Length of Group Data & 0x52 & uint16 (in 4096 byte pages) \\
\hline
Group Entry Count & 0x54 & uint16 \\
\hline
Reserved & 0x56 & char[2] \\
\hline
Offset to Formula Data & 0x58 & uint16 (in 4096 byte pages) \\
\hline
Length of Formula Data & 0x5A & uint16 (in 4096 byte pages) \\
\hline
Formula Entry Count & 0x5C & uint16 \\
\hline
Reserved & 0x5E & char[2] \\
\hline
Offset to core events & 0x60 & u32 Offset relative to the main event group (0x48)\\
\hline
Offset to thread events & 0x64 & u32 Offset relative to the main event group (0x48)\\
\hline
Offset to chip events & 0x68 & u32 Offset relative to the main event group (0x48)\\
\hline
Offset to core group & 0x6C & u32 Offset relative to the main group data (0x50) \\
\hline
Offset to thread group & 0x70 & u32 Offset relative to the main group data (0x50) \\
\hline
Offset to chip group & 0x74 & u32 Offset relative to the main group data (0x50) \\
\hline
Reserved & 0x78 & char[8] \\
\hline
\end{tabular}

\textit{Design Note:} The ``Length'' field and ``Version Number'' size and offset is fixed
since the hypervisor will fill in the Length when the catalog is read from the
fsp flash lid table and will compare the Version Number for consistency on each
hypervisor call. The offset to the events and groups are relative to the main
event group page and the group data page. In cases where there are no group for
particular sub-group (like thread or chip), the offset at such field will be
filled with '0xffffffff' to mark it as invalid.

\subsection{Example Catalog Page0 Raw Data}
\includegraphics[scale=0.6]{page0_raw.png}

\pagebreak

\section{Event Data}
\begin{tabular}[l]{|p{5cm}|c|p{7cm}|}
  \hline
  \textbf{Field} & \textbf{Byte Offset} & \textbf{Attributes} \\
  \hline
  Event Structure Length (in bytes) & 0x00 & uint16 - Structure will be padded 
                                             with zeros to create a structure
                                             with a length which is an even
                                             multiple of 16 \\
  \hline
  Formula Index & 0x02 & uint16 The index to the corresponding formula \\
  \hline
  IMA Group Record Domain & 0x04 & uint8 - ( Chip = 1 / Core = 2 / Thread PMU = 3
                                   ) \\
  \hline
  Reserved & 0x05 & char[1] \\
  \hline
  Byte offset to Start of Event Group Record & 0x06 & uint16 - (must be 8-byte
                                                      aligned) \\
  \hline
  Byte length of entire Event Group Record & 0x08 & uint16 \\
  \hline
  Byte offset in Event Group Record to Event Counter & 0x0A & uint16 \\
  \hline
  \parbox[t]{5cm} {
  Flag:
  \begin{itemize}
    \renewcommand\labelitemi{--}
    \setlength\itemsep{-0.4em}
    \item Verified-State
    \item Unverified-State
    \item Caveat-State
    \item Broken-State
    \item Mask Bits ("gated-by" MSR states, info only)
    \end{itemize}
  } & 0x0C & uint32 - (binary composition) \\
  \hline
  Primary Group Index & 0x10 & uint16 - Index into the Group Data array where
                               either the first or best group which contains this
                               event can be found \\
  \hline
  Group Count & 0x12 & uint16 - Number of groups which this event is a part of \\
  \hline
  Event Name Field Length & 0x14 & uint16 - (n1) This length includes the length
                                   of the Event Name Field Length field \\
  \hline
  Event Name & 0x14 + 2 & char[] - Variable (zero-terminated ASCII padded to
                          half-word length) \\
  \hline
  Event Description Field Length & 0x14 + n1 & uint16 - (n2) If there there is no
                                               Event Description or the Event
                                               Description is the same as the
                                               Event Name, then this length
                                               will be 2 (length of length
                                               field). \\
  \hline
  Event Description & 0x14 + n1 + 2 & char[] - Variable (zero-terminated ASCII
                                      padded to half-word length) \\
  \hline
  Event Detailed Description Field Length & 0x14 + n1 + n2 & uint16 - (n3) If
                                                             there there is no
                                                             Event Detailed
                                                             Description or the
                                                             Event Detailed
                                                             Description is the
                                                             same as the Event
                                                             Description, then
                                                             this length will be
                                                             2 (length of length
                                                             field). \\
  \hline
  Event Detailed Description & 0x14 + n1 + n2 + 2 & char[] - Variable (zero-
                                                    terminated ASCII padded to
                                                    half-word length) \\
  \hline
\end{tabular}

\subsection{Event Data Entry Notes}
\begin{itemize}
\item The ``Event Name Field Length'', ``Event Description Field Length'' and ``Event
  Detailed Description Field Length'' fields INCLUDE the length of the length
  field. To point to the start of the next field's length add the current
  field's length. Thus a field length value of 2 indicates the text string is
  empty.
\item For events that are being accumulated in chip groups, each event will have
  an accumulated counter value and a ``Last Sample Increment'' value. The short
  name for the event which returns the ``Last Sample Increment'' will merely be
  the accumulated counter's Event Name with the ``\_SAMPLE'' suffix added. The
  ``Last Sample Increment'' event data will not have an event description or a
  detailed event description.
\item There are two, special core level events: HPM\_NON\_IDLE\_INST and
  HPMC\_NON\_IDLE\_PCYC which are available in all core groups in the
  GRS\_COUNTER\_3 and GRS\_COUNTER\_4 schema ENUM positions.
\item For some events that are being accumulated in core groups, those events
  will have counter versions available which are filtered by ``context
  state''. For those events with a ``filtered by user'' state counter available,
  the event name will have the suffix \_USER appended. For those events with a
  ``filtered by kernel'' state counter available, the event name will have the
  suffix \_KERNEL appended. The ``filtered'' event data will not have an event
  description or a detailed event description.
\end{itemize}

\subsection{Example Event Entry Raw Data}
\includegraphics[scale=0.6]{events_raw.png}

\pagebreak

\section{Group Data}
\begin{tabular}[l]{|p{5cm}|c|p{7cm}|}
  \hline
  \textbf{Field} & \textbf{Byte Offset} & \textbf{Attributes} \\
  \hline
  Group Structure Length (in bytes) & 0x00 & uint16 - Structure will be padded
                                             with zeros to create a structure
                                             with a length which is an even
                                             multiple of 16 \\
  \hline
  Reserved & 0x02 & char[2] \\
  \hline
  \parbox[t]{5cm} {
  Flag:
  \begin{itemize}
    \renewcommand\labelitemi{--}
    \setlength\itemsep{-0.4em}
  \item Verified-State
  \item Unverified-State
  \item Caveat-State
  \item Broken-State
  \end{itemize}
  } & 0x04 & uint32 - (binary composition) NOTE: The ``State'' flags are merely
               a composite of the events in this group. The ``worst'' event will
               dictate the state of this group. \\
  \hline
  IMA Group Record Domain & 0x08 & uint8 - ( Chip = 1 / Core = 2 ) \\
  \hline
  Reserved & 0x09 & char[1] \\
  \hline
  Byte offset to Start of Event Group Record & 0x0A & uint16 - (must be 8-byte
                                                      aligned) \\
  \hline
  Byte length of entire Event Group Record & 0x0C & uint16 \\
  \hline
  Group Schema Index & 0x0E & uint8 - Use this index to find the schema which
                              describes the layout of this group's structure. \\
  \hline
  Event Count & 0x0F & uint8 - ( between 1 and 16 ) \\
  \hline
  Event Indexes & 0x10 & uint16[16] - (Index into Event Data array) \\
  \hline
  Group Name Field Length & 0x30 & uint16 - (n1) This length includes the length
                                   of the Group Name Field Length field \\
  \hline
  Group Name & 0x30 + 2 & char[] - Variable (zero-terminated ASCII padded to
                          half-word length) \\
  \hline
  Group Description Field Length & 0x30 + n1 & uint16 - (n2) If there there is no
                                               Group Description or the Group
                                               Description is the same as the
                                               Group Name, then this length
                                               will be 2 (length of length
                                               field). \\
  \hline
  Group Description & 0x30 + n1 + 2 & char[] - Variable (zero-terminated ASCII
                                      padded to half-word length) \\
  \hline
\end{tabular}

\subsection{Group Data Entry Notes}
\begin{itemize}
\item The ``Group Name Field Length'' and ``Group Description Field Length'' fields
  INCLUDE the length of the length field. To point to the start of the next
  field's length add the current field's length. Thus a field length value of 2
  indicates the text string is empty.
\item The Event Indexes array may contain ``FREE'' or ``Unassigned'' slots for
  future events. These slots will be recognized by the value -1 (0xFFFF) as the
  Event Index.
\end{itemize}

\subsection{Example Group Entry Raw Data}
\includegraphics[scale=0.6]{groups_raw.png}

\textit{NOTE:} At the moment, the core (HPMC) groups have not been named... these
group names are merely the name of the first event of the group.

\pagebreak

\section{Schema Data}
These schemas are the same ones proposed in the 24x7 Requirements Document.

\subsection{Core and Chip Event Counter Group Record}
The Event Counter Group Record is a structure in memory containing the event
counters and administrative data accumulated by the hardware. The layout of this
structure is fixed in hardware, but is not guaranteed to be common across all
hardware processor versions or families.

Refer to the PORE/SLW workbook for the exact definition of this structure, but
examples of these structures can be found below.

\begin{table}
  \parbox{.45\linewidth}{
    \centering
    \begin{tabular}[l]{|c|c|}
      \hline
      \multicolumn{2}{|c|}{Timebase} \\ \hline
      \multicolumn{2}{|c|}{Number of Updates} \\ \hline
      \multicolumn{2}{|c|}{Group Measurement Period} \\ \hline
      \multicolumn{2}{|c|}{HPMC1} \\ \hline
      \multicolumn{2}{|c|}{HPMC2} \\ \hline
      \multicolumn{2}{|c|}{HPMC3 (sum NON\_IDLE\_INST)} \\ \hline
      \multicolumn{2}{|c|}{HPMC4 (sum NON\_IDLE\_PCYC)} \\ \hline
      Status [0:15] & Timebase [16:63] \\
      \hline
    \end{tabular}
    \caption{HPMC-IMA Core Domain Record (One "HPMC Group")}
  }
  \hfill
  \parbox{.45\linewidth}{
    \centering
    \begin{tabular}[l]{|c|}
      \hline
      Time-Of-Day (SCOM) \\ \hline
      Update Count \\ \hline
      Accumulated Measurement Period \\ \hline
      Accumulated pmulet-0 \\ \hline
      \dots \\ \hline
      Accumulated pmulet-N \\ \hline
      Last Update Period \\ \hline
      Last pmulet-0 Increment \\ \hline
      \dots \\ \hline
      Last pmulet-N Increment \\ \hline
      Time-Of-Day \\ \hline
    \end{tabular}
    \caption{PRE-SLW-IMA Chip Domain Record (One "pmulet Group")}
  }
\end{table}

The layout of an event counter group record is communicated dynamically through
a structure returned in the Get Event Counter Group Schema interface called the
Event Counter Group Schema. The structure used to accumulate counters in core
event group records differs from the structure used to accumulate counters in
chip event group records. Among the chip event group records, structure sizes
may differ. The Group Schema Index in the catalog group data entry indicates
which schema to use.

\subsection{Core and Chip Event Counter Group Record Schema
(GRS)}
The Event Counter Group Record Schema is a structure returned by the Get Event
Counter Group Record Schema hypervisor interface. This structure indirectly
defines the Event Counter Group Record using architected ENUMs, offsets and
lengths.

\begin{table}[hd]
  \begin{tabular}[l]{|p{5cm}|c|p{7cm}|}
    \hline
    \textbf{Field} & \textbf{Byte Offset} & \textbf{Attributes} \\
    \hline
    Schema Structure Length in bytes & 0x00 & uint16 - Structure will be padded
                                              with zeros to create a structure
                                              with a length which is an even
                                              multiple of 16 \\ \hline
    Reserved & 0x02 & char[2] \\ \hline
    Schema Descriptor & 0x04 & uint16 \\ \hline
    Schema Version Id & 0x06 & uint16 \\ \hline
    Reserved & 0x08 & char[6] \\ \hline
    Field Entry Count & 0x0E & uint16 \\ \hline
    Field Entries & 0x10 & char[0] - (first Group Record Schema Field begins here)
    \\ \hline
  \end{tabular}
  \caption{Group Record Schema}

  \begin{tabular}[l]{|p{5cm}|c|p{7cm}|}
    \hline
    \textbf{Field} & \textbf{Byte Offset} & \textbf{Attributes} \\
    \hline
    Field Enum & 0x00 & uint16 \\ \hline
    Offset into Event Counter Group Record & 0x02 & uint16 \\ \hline
    Field Length in Bytes & 0x04 & uint16 \\ \hline
    Flags/Reserved & 0x06 & uint16 - (binary composition) \\ \hline
  \end{tabular}
  \caption{Group Record Schema Field}
\end{table}

The ``Field Enum'' values will be consistent as the hardware design changes. If
any part of the structure changes, the Schema Version Id will change.

OS implementations are free to define fixed structures that will only apply to
known schema versions.

\subsection{Group Record Schema Field Content ENUMs}
\begin{tabular}[l]{lr}
  GRS\_COUNTER\_1 & 1 \\
  GRS\_COUNTER\_2 & 2 \\
  GRS\_COUNTER\_3 & 3 \\
  GRS\_COUNTER\_4 & 4 \\
  GRS\_COUNTER\_5 & 5 \\
  GRS\_COUNTER\_6 & 6 \\
  \multicolumn{2}{c}{\dots} \\
  GRS\_COUNTER\_31 & 31 \\
  GRS\_TIMEBASE\_UPDATE & 48 \\
  GRS\_TIMEBASE\_FENCE & 49 \\
  GRS\_UPDATE\_COUNT & 50 \\
  GRS\_MEASUREMENT\_PERIOD & 51 \\
  GRS\_ACCUMULATED\_MEASUREMENT\_PERIOD & 52 \\
  GRS\_LAST\_UPDATE\_PERIOD & 53 \\
  GRS\_STATUS\_FLAGS & 54 \\
\end{tabular}

\subsection{Group Record Schema ENUMs}
\begin{tabular}[l]{lr}
  GRS\_CORE\_SCHEMA\_INDEX & 0 \\
\end{tabular}

\subsection{Example Group Record Schema Entry Raw Data}
\includegraphics[scale=0.6]{group_schema_raw.png}

\pagebreak

\section{Formula Data}
\begin{tabular}[l]{|p{5cm}|c|p{7cm}|}
  \hline
  \textbf{Field} & \textbf{Byte Offset} & \textbf{Attributes} \\
  \hline
  
  Formula Structure Length (in bytes) & 0x00 & uint16 Structure will be padded with
                                               zeros to create a structure with
                                               a length which is an even
                                               multiple of 16 \\ \hline
  Reserved & 0x02 & char[2] \\ \hline
  \parbox[t]{5cm} {
  Flag:
  \begin{itemize}
    \renewcommand\labelitemi{--}
    \setlength\itemsep{-0.4em}
  \item Verified-State
  \item Unverified-State
  \item Caveat-State
  \item Broken-State
  \item Grouped
  \item Reserved
  \end{itemize}
  } & 0x04 & uint32 (binary composition) NOTE: The ``State'' flags are
             merely a composite of the events in this formula. The ``worst''
             event will dictate the state of thisformula. \\ \hline
  Group & 0x08 & uint16 (if flag Grouped is TRUE) This is the group index where
                 all the formula's dependent events can be found. \\ \hline
  Reserved & 0x0A & char[6] \\ \hline
  Formula Name Field Length & 0x10 & uint16 (n1) - This length includes the
                                     length of the Formula Name Field Length
                                     field \\ \hline
  Formula Name & 0x10 + 2 & char[] Variable (zero-terminated ASCII padded to
                        half-word length) \\ \hline
  Formula Description Field Length & 0x10 + n1 & uint16 (n2) - This length
                                            includes the length of the Formula
                                            Description Field Length field \\
  \hline
  Formula Description & 0x10 + n1 + 2 & char[] Variable (zero-terminated ASCII
                                        padded to half-word length) \\ \hline
  Formula Field Length & 0x10 + n1 + n2 & uint16 (n3) - This length includes the
                                          length of the Formula Field Length
                                          field \\ \hline
  Formula & 0x10 + n1 + n2 + 2 & char[] Variable (zero-terminated ASCII padded to
                                 half-word length) NOTE: This formula field is
                                 intended to comply with a formula syntax that
                                 should make parsing and interpretation
                                 easier... see Formula Syntax below \\ \hline
  Unit Field Length & 0x10 + n1 + n2 + n3 & uint16 (n4) - This length includes
                                            the length of the Unit Length field
  \\ \hline
  Unit & 0x10 + n1 + n2 + n3 + 2 & char[] Variable (zero-terminated ASCII padded to
                                   half-word length) This is the unit of the
                                   result of the formula \\ \hline

\end{tabular}

\subsection{Formula Entry Notes}
\begin{itemize}
\item The ``Formula Name Field Length'', ``Formula Description Field Length'' and
  ``Formula Field Length'' fields INCLUDE the length of the length field. To point
  to the start of the next field's length add the current field's length. Thus a
  field length value of 2 indicates the text string is empty.
\end{itemize}

\subsection{Formula Syntax}
The Formula Field of a Formula Data Record will contain text that complies with
a simple syntax that should make parsing and interpretation easier.

The text will follow a general ``stack-based'', ``Reverse Polish Notation'' (or
``Post-fix Notation'' evaluation model generalized this way:

\begin{center}
  \texttt{
    operand [ operand | operator [ operand | operator ] [ \dots ] ]
  }
\end{center}

Where:
\begin{itemize}
\item Operand is either a text Event Name which can be found among the Event
  Data records, another Formula Name, a constant in standard floating point
  representation or a symbolic constant familiar to performance analysts such as
  `delta-timebase', `delta-cycles', `delta-instructions', and `delta-seconds'.
\item Operator is any of the standard mathematical text characters: `+', `-',
  `*', or `/', or these lowercase, three-character mathematical abbreviations:
  `mod', `rem', `sqr', or `x\^{}y', or these three-character stack manipulators:
  `swp', `rot', and `dup'.

\end{itemize}
Note that most operators require two operands, but some only require one.

Also be aware that most formulas can be extended to aggregate chips or cores if
the operands are first properly summed across all the domain resources of
interest.

To evaluate a formula, the interpreter implements a push-up operand stack where
new operands are added to the bottom of the stack (the x register) and operators
consume or manipulate the bottom-most operand and potentially (in the case of
two-operand operators) the operand immediately above the bottom (the y
register), placing the result back on the bottom of the stack. When the formula
interpretation is complete, the final result will be left at the bottom of the
stack.

\textit{Note:} Existing pmlist data represents formulas using standard ``infix''
notation. For example:

\begin{verbatim}
# pmlist -DPMD_CPU_UTIL
Derived Metric: PMD_CPU_UTIL (unit:%) (CPU Utilization)
Formula : PM_RUN_CYC / PM_CYC * 100
Description :
Metric Groups : General
Groups : 0
\end{verbatim}

\subsubsection{Formula Operands}
\begin{center}
\begin{tabular}[l]{|l|p{7cm}|}
\hline
\textbf{Operand} & \textbf{Description} \\ \hline
Event Name & The value of this operand is a 24x7 counter accessed using data
             found in the Event Data table \\ \hline
Formula Name & The value of the operand is a computed metric derived using a
               formula found in the Formula Data table \\ \hline
Constant & A standard floating point constant \\ \hline
delta-timebase & The elapsed time in partition timebase ticks \\ \hline
delta-cycles & The elapsed clock cycles \\ \hline
delta-instructions & The elapsed instruction cycles \\ \hline
delta-seconds & The elapsed wall-time in seconds \\ \hline
\end{tabular}
\end{center}

\subsubsection{Formula Operators}
\begin{center}
\begin{tabular}[l]{|l|l|l|}
\hline
\textbf{Operator} & \textbf{Operands Consumed} & \textbf{Result} \\ \hline
+ & 2 (x, y) & x <= y + x \\ \hline
- & 2 (x, y) & x <= y - x \\ \hline
* & 2 (x, y) & x <= y * x \\ \hline
/ & 2 (x, y) & x <= y / x \\ \hline
mod & 2 (x, y) & x <= y \% x \\ \hline
rem & 2 (x, y) & x <= y // x \\ \hline
sqr & 1 (x) & x <= sqrt( x ) \\ \hline
x \^{} y & 2 (x, y) & x <= x \^{} y \\ \hline
swp & 2 (x, y) & x <= y, y <= x \\ \hline
rot & n (x..n) & x <= y, y <= z, ... n <= x (stack rotation) \\ \hline
dup & 1 (x) y & <=x, x <= x (duplicate bottom of stack) \\ \hline


\end{tabular}
\end{center}

\section{Related Documents}
\begin{center}
\begin{tabular}[l]{|p{7cm}|l|}
  \hline
  \href{https://mcdoc.boeblingen.de.ibm.com/out/out.Login.php?forward=/out/out.ViewDocument.php?documentid=2944}{P8
  Hypervisor 24x7 Interfaces} & Mike Vance \\
  \hline
\end{tabular}
\end{center}
Click on the document name to open the document in the web browser.

\pagebreak

\section{Change History}
\begin{center}
\begin{tabular}[l]{|l|l|p{10cm}|}
\hline
\textbf{Version} & \textbf{Date} & \textbf{Description} \\ \hline
  v0.10 & 2013-03-12 & Original draft \\ \hline
  v0.11 & 2013-03-20 & 
                       \parbox[t]{7cm} {
                       Corrections from John Attinella \\
  Addition of several flags similar to those used in PMC Event filtering \\
  Addition of the Group Index and Group Count fields to the Eventdata catalog
  record \\
  } \\ \hline
  v012 & 2013-03-28 & Added the concept of ``derived metrics'' through ``named
                      formulas'' using an additional ``Formula Data'' table. \\ \hline
  v0.13 & 2013-04-22 & Added build date-stamp to catalog. Clarified that there
                       may be several schemas to describe the various chip event
                       group records. Added a group record length to the event
                       data to save having to look up the length. \\ \hline
  v0.14 & 2013-04-24 & Added the same domain, group offset and length data
                       necessary to locate individual events to the group table
                       entry. Moved entry counts to Page 0 \\ \hline
  v0.15 & 2013-05-21 & Ooops! Mike Vance corrected me on the catalog version length.
                       Removed Questions section and marked as approved by common
                       consent. Typos. \\ \hline

  v0.16 & 2015-04-27 & santosiv@in.ibm.com - New fields in Page 0 structure and
                       a new domain for the thread groups \\ \hline
  v0.17 & 2015-05-20 & Make the char reserved[2] field in the event structure to
                       hold the corresponding formula indices. \\ \hline
\end{tabular}
\end{center}
\end{document}
OpenPOWER on IntegriCloud