A method for pseudo-randomly, without bias, selecting instructions for
marking in a microprocessor. Responsive to reading an instruction from an
instruction cache, an instruction tag associated with the instruction is
compared against a pseudo-randomly generated value in a linear feedback
shift register (LFSR). If the instruction tag matches the value in the
LFSR, a mark bit, indicating the instruction is a marked instruction, is
sent with the instruction to an execution unit. Responsive to an
indication from the performance monitor, the value in the LFSR is
incremented prior to selecting a next instruction to mark. If the value
equals a predetermined prime number of increments, the value is reset to
all ones to avoid any harmonics with the code stream being executed. Upon
receiving the marked instruction, the execution unit combines the marked
bit with a selected event and reports the marked event to the performance
monitor.