RAS daemon: Easter Eggs Edition
Subsystems (5)
cover RAS daemon: Easter Eggs Edition
From: Borislav Petkov <[email protected]>
Ok, here's yet another version of the RAS daemon patchset. This one changes all the event handling to how it is done in test__basic_mmap(), as acme suggested. Patchset is against tip/perf/core from today.
With this I can inject an mce using the python script below (yeah, work in progress in itself):
$ mcegen.py -i sw
[ this will inject a random MCE using the mce_amd_inj.ko module ]
and in /var/log/ras.log I get:
MCE on cpu 0, status: 0xf200210000000853, addr: 0x0000000000000000 MCE on cpu 0, status: 0x9800400000000015, addr: 0x0000000000000000 MCE on cpu 0, status: 0xfc00200000050e0f, addr: 0x0000000000000000 MCE on cpu 0, status: 0x98004100001c010b, addr: 0x0000000000000000 MCE on cpu 0, status: 0xbc00200000000843, addr: 0x0000000000000000 MCE on cpu 0, status: 0xda00410000080e0f, addr: 0x0000000000000000
Yep, it is still raw info but you can do almost anything with that info in userspace.
Next on the TODO list is changing the tracepoint to convey the decoded info too which should be a fairly simple task to do.
So we've got the basic design hammered out methinks, the persistent event is off by default for now and since rebasing this pile is always a great PITA for me due to other developments in tools/perf, I'd like it very much if I could offload it in -tip soon.
Also, last time there was a concern raised in the LWN article on the RAS daemon that the library split is kinda questionable. Well, the argument I use was the specific topic each piece of the code belongs to:
lib/lk/ is generic stuff which could very well be used by other tools in the growing tools/ directory (hurray!).
lib/trace/ is the trace event parsing stuff from Steven
lib/perf/ is all the perf-related functionality that other tools might use too when they need perf events, like this very same RAS daemon does.
Also, the expectation is that trace and perf should merge some day (for arbitrary meaning of "some day" :)).
Also, I've exported only the stuff I need for the daemon and not everything, like acme suggested at the time.
Anyway, I'm open to all suggestions and comments, as always.
Thanks.
--
#!/usr/bin/python
import os
import sys
import struct
import inspect
import subprocess
from random import *
from optparse import OptionParser
eecs = ['ECC/Resv', 'CRC', 'Sync', 'Mst Abort', 'Tgt Abort', #0-4
'GART', 'RMW', 'WDT', 'ECC', 'DEV', 'Link Data', #5-10
'Protocol', 'NB Array', 'DRAM Parity', 'Link Retry', #11-14
'GART/DEV Table Walk', 'Resv', 'Resv', 'Resv', 'Resv', 'Resv', #15-20
'Resv', 'Resv', 'Resv', 'Resv', 'Resv', 'Resv', #21-26
'Resv', 'L3 Cache Data', 'L3 Cache Tag', 'L3 Cache LRU', 'Probe Filter'] #27-31r4s = ['GEN', 'RD', 'WR', 'DRD', 'DWR', 'IRD', 'PRF', 'EV', 'SNP'] lls = ['RESV', 'L1', 'L2', 'LG' ]
iis = ['MEM', 'RESV', 'IO', 'GEN' ]
tts = ['INSN', 'DATA', 'GEN', 'RESV' ]
pps = ['SRC', 'RES', 'OBS', 'GEN' ]
fus = {'DC': 0, 'IC': 1, 'BU': 2, 'CU': 2, 'LS': 3, 'NB': 4, 'FR': 5, 'EX': 5, 'FP': 6} error_types = ['TLB', 'MEM', 'BUS']
families = ['k8', 'f10h', 'f11h', 'f12h', 'f14h', 'f15h']
# MSRsMSR_K7_HWCR = 0xc0010015
MSR_IA32_MC0_CTL = 0x00000400MSR_IA32_MC0_STATUS = 0x00000401MSR_IA32_MC0_ADDR = 0x00000402MSR_IA32_MC0_MISC = 0x00000403
def MSR_IA32_MCx_CTL(x): return MSR_IA32_MC0_CTL + 4*x def MSR_IA32_MCx_STATUS(x): return MSR_IA32_MC0_STATUS + 4*x def MSR_IA32_MCx_ADDR(x): return MSR_IA32_MC0_ADDR + 4*x def MSR_IA32_MCx_MISC(x): return MSR_IA32_MC0_MISC + 4*x
def __func__(lvl=1):
return inspect.stack()[lvl][3]
def err(s):
sys.stderr.write(("%s: Error %s\n" % (__func__(2), s)))def dbg(s):
if opts.dbg:
sys.stderr.write(("%s: %s\n" % (__func__(2), s)))def bit(b):
if b < 0 or b > 63:
return 0
return 1L << b
class MCE(object):
""" Class representing a Machine Check Exception signature
"""
mci_status = 0
syndrome = 0
fu = 'DC' # DC MCE by default
err_type = 'BUS'
def __init__(self, val=0, fu='DC', err_type='BUS'):
self.err_type = err_type
self.fu = fu
if val:
self.mci_status = val
else:
self.gen_mce()
def eec(self, mce=None):
if mce:
return (mce >> 16) & 0x1f
return (self.mci_status >> 16) & 0x1f
def __is_ecc(self, mce=None):
return self.eec(mce) == 0x8
def _sanitize_error_type(self, mce):
ec = mce & 0xffff
# TLB
if ec & bit(4):
mce &= 0xffffffffffff001f
# MEM
elif ec & bit(8):
mce &= 0xffffffffffff01ffL
# RRRR is max 8
if mce & bit(7):
mce &= ~(0x7 << 4)
# BUS
elif ec & bit(11):
mce &= 0xffffffffffff0fffL
# RRRR is max 8
if mce & bit(7):
mce &= ~(0x7 << 4)
else:
# fallback to a BUS error (those are most common: DRAM ECC)
mce &= 0xffffffffffff0fffL
mce |= bit(11)
return mce
def __prep_TLB(self, mce):
# cleanup fields first
mce &= 0xffffffffffe00010L
# ErrorCodeExt[19:16] selects between TLB error types
# BD introduces a locked TLB miss with EEC=0x2
eec = randint(0,2)
return mce | eec << 16
def __prep_MEM(self, mce):
# cleanup fields
mce &= 0xffffffffffe00100L
return mce
def __prep_BUS(self, mce):
# cleanup bytes first
mce &= 0xffffffffffe00800L
return mce
def __gen_dc_mce(self, mce):
""" Generate a DC MCE signature. Some of the fields are overlapping and
not valid for all families but this is ok since we want to check the
error path too when generating an invalid MCE or the MCi_STATUS
somehow got corrupted
"""
ec = mce & 0xffff
# TLB
if ec & bit(4):
mce = self.__prep_TLB(mce)
ll = lls.index(choice(['L1' , 'L2']))
mce |= 0x1 << 2 | ll # TT=Data
# MEM
elif ec & bit(8):
mce = self.__prep_MEM(mce)
# BD introduces a bunch of EECs != 0
eec = choice(range(0, 4) + range(16, 20))
r4 = r4s.index(choice(['GEN', 'DRD', 'DWR', 'EV', 'SNP']))
ll = lls.index(choice(['LG', 'L1' , 'L2']))
mce |= eec << 16 | r4 << 4 | 0x1 << 2 | ll # TT=Data
# BUS
elif ec & bit(11):
mce = self.__prep_BUS(mce)
eec = randint(0, 2)
pp = pps.index(choice(['SRC', 'GEN']))
r4 = r4s.index(choice(['GEN', 'RD', 'DRD', 'DWR']))
ii = iis.index(choice(['MEM', 'IO', 'GEN']))
mce |= eec << 16 | pp << 9 | randint(0, 1) << 8 | r4 << 4 | ii << 2 | 0x3 # LL=LG
return mce
def __gen_ic_mce(self, mce):
""" Generate an IC MCE signature.
"""
ec = mce & 0xffff
# TLB
if ec & bit(4):
mce = self.__prep_TLB(mce)
mce |= lls.index(choice(['L1' , 'L2'])) # TT=Instr, already 0
# MEM
elif ec & bit(8):
mce = self.__prep_MEM(mce)
eec = choice(range(0, 11) + [13] + range(16, 21))
r4 = r4s.index(choice(['IRD', 'SNP', 'EV']))
ll = lls.index(choice(['L1' , 'L2', 'LG']))
mce |= eec << 16 | r4 << 4 | ll # TT=Instr
# BUS
elif ec & bit(11):
mce = self.__prep_BUS(mce)
# eec,pp,t,ii already 0
# IRD, 5
mce |= 5 << 4 | 3
return mce
def __gen_bu_mce(self, mce):
""" Generate an BU MCE signature
F12h has all three types based on ErrorCode: TLB, MEM and BUS
"""
ec = mce & 0xffff
# TLB
if ec & bit(4):
mce = self.__prep_TLB(mce)
tt = tts.index(choice(['INSN', 'DATA']))
mce |= tt << 2 | 0x1 # LL=L1
# MEM
elif ec & bit(8):
mce = self.__prep_MEM(mce)
eec = randint(0, 3)
r4 = r4s.index(choice(['GEN', 'RD', 'WR', 'DRD', 'IRD', 'EV', 'SNP']))
tt = tts.index(choice(['GEN', 'INSN', 'DATA']))
ll = lls.index(choice(['LG' , 'L2']))
mce |= eec << 16 | r4 << 4 | tt << 2 | ll
# BUS
elif ec & bit(11):
mce = self.__prep_BUS(mce)
r4 = r4s.index(choice(['RD', 'PRF']))
ii = iis.index(choice(['MEM', 'IO']))
mce |= r4 << 4 | ii << 2 | 0x3 # LL=LG
return mce
def __gen_cu_mce(self, mce):
""" Generate an OR Combined Unit MCE
"""
ec = mce & 0xffff
# TLB
if ec & bit(4):
mce = self.__prep_TLB(mce)
mce |= 0x2 << 2 | 0x2 # TT=GEN, LL=L2
# MEM
elif ec & bit(8):
mce = self.__prep_MEM(mce)
eec = choice(range(4, 13) + range(16, 21))
r4 = r4s.index(choice(['DRD', 'IRD', 'PRF' 'DWR', 'SNP', 'EV', 'GEN']))
tt = tts.index(choice(['GEN', 'INSN', 'DATA']))
ll = lls.index(choice(['LG' , 'L1', 'L2']))
mce |= eec << 16 | r4 << 4 | tt << 2 | ll
# BUS
elif ec & bit(11):
mce = self.__prep_BUS(mce)
eec = randint(0, 2)
r4 = r4s.index(choice(['RD', 'DWR']))
ii = iis.index(choice(['MEM', 'IO']))
ll = lls.index(choice(['L1', 'L2']))
mce |= eec << 16 | r4 << 4 | ii << 2 | ll # PP=SRC, T=0
return mce
def __gen_ls_mce(self, mce):
""" Generate an LS MCE signature
"""
# LS MCEs are only of type BUS so set bit 11
mce |= bit(11)
mce = self.__prep_BUS(mce)
r4 = r4s.index(choice(['DRD', 'DWR']))
ii = iis.index(choice(['MEM', 'IO']))
mce |= r4 << 4 | ii << 2 | 0x3 # LL=LG
return mce
def __gen_nb_mce(self, mce):
""" Generate an NB MCE signature
"""
ec = mce & 0xffff
# TLB
if ec & bit(4):
mce = self.__prep_TLB(mce)
eec = choice([5, 15]) # GART Err, GART TLB Walk Data Err
mce |= eec << 16 | 0x2 << 2 | 0x3 # GEN, LG
# MEM
elif ec & bit(8):
mce = self.__prep_MEM(mce)
eec = choice([25, 28, 29, 30, 31])
r4 = r4s.index(choice(['GEN', 'RD', 'WR', 'EV', 'SNP']))
tt = tts.index(choice(['GEN', 'DATA']))
mce |= eec << 16 | r4 << 4 | tt << 2 | 0x3 # LG
# BUS
elif ec & 0x0080:
mce = self.__prep_BUS(mce)
eec = choice(range(1, 5) + range(6, 16))
pp = pps.index(choice(pps)) # yes, all 4 are possible
r4 = r4s.index(choice(['GEN', 'RD', 'WR', 'DWR']))
ii = iis.index(choice(['MEM', 'IO', 'GEN']))
mce |= eec << 16 | pp << 9 | randint(0, 1) << 8 | r4 << 4 | ii << 2 | 0x3 # LL=LG
return mce
def __gen_fr_mce(self, mce):
""" Generate a FR MCE signature
"""
# FR/EX MCEs are only of type BUS so set bit 11
mce |= bit(11)
# BD-specific
eec = randint(0, 12)
mce = self.__prep_BUS(mce)
mce |= eec << 16 | 0x3 << 9 | randint(0,1) << 8 | 0x3 << 2 | 0x3 # PP=GEN, R4=GEN, II=GEN, LL=LG
return mce
def gen_mce(self):
mce = getrandbits(64)
# remove reserved stuff, along with clearing syndrome bits[54:47,31:24]
mce &= 0xfe006100000fffff
# Valid
mce |= bit(63)
# set CECC, UECC according to bit 61, UC: error couldn't be corrected by hw
if mce & bit(61):
mce &= ~bit(46)
mce |= bit(45)
else:
mce |= bit(46)
mce &= ~bit(45)
# EN should be always set, otherwise moot
mce |= bit(60)
if self.err_type:
# Clear error type bits so that later we don't get confused
mce &= 0xfffffffffffff6ef
if self.err_type == 'TLB':
mce |= bit(4)
elif self.err_type == 'MEM':
mce |= bit(8)
else:
mce |= bit(11)
if self.__is_ecc(mce):
syndrome = getrandbits(16)
mce |= ((syndrome & 0x0f) << 47)
mce |= ((syndrome & 0xf0) << 20)
self.syndrome = syndrome
if self.fu == 'DC':
mce = self._sanitize_error_type(mce)
mce = self.__gen_dc_mce(mce)
elif self.fu == 'IC':
mce = self._sanitize_error_type(mce)
mce = self.__gen_ic_mce(mce)
elif self.fu == 'BU':
mce = self._sanitize_error_type(mce)
mce = self.__gen_bu_mce(mce)
elif self.fu == 'CU':
mce = self._sanitize_error_type(mce)
mce = self.__gen_cu_mce(mce)
elif self.fu == 'LS':
mce = self.__gen_ls_mce(mce)
elif self.fu == 'NB':
mce = self._sanitize_error_type(mce)
mce = self.__gen_nb_mce(mce)
elif self.fu == 'FR' or self.fu == 'EX' or self.fu == 'FP':
mce = self.__gen_fr_mce(mce)
self.mci_status = mce
def __is_bit_set(self, bit):
if bit < 0 or bit > 63:
return False
if self.mci_status & (1 << bit):
return True
return False
def valid(self): return self.__is_bit_set(63)
def overflow(self): return self.__is_bit_set(62)
def uncorrected(self): return self.__is_bit_set(61)
def err_enabled(self): return self.__is_bit_set(60)
def miscv(self): return self.__is_bit_set(59)
def addrv(self): return self.__is_bit_set(58)
def pcc(self): return self.__is_bit_set(57)
def cecc(self): return self.__is_bit_set(46)
def uecc(self): return self.__is_bit_set(45)
def scrub(self): return self.__is_bit_set(40)
def decode_eec(self):
return eecs[self.eec()]
def decode_tt(self): return tts[(self.mci_status >> 2) & 0x3]
def decode_ll(self): return lls[self.mci_status & 0x3]
def decode_pp(self): return pps[(self.mci_status >> 9) & 0x3]
def decode_ii(self): return iis[(self.mci_status >> 2) & 0x3]
def decode_r4(self):
r4 = (self.mci_status >> 4) & 0xf
if r4 > 8:
return "-"
return r4s[r4]
def decode_t(self):
t = (self.mci_status >> 8) & 0x1
if t:
return "TIMOUT"
return "NOTIMOUT"
def error_type(self):
ec = self.mci_status & 0xffff
if (ec & 0xfff0) == bit(4):
return "TLB(tt:" + self.decode_tt() + ";ll:" + self.decode_ll() + ")"
elif (ec & 0xff00) == bit(8):
return "MEM(r4:" + self.decode_r4() + ";tt:" + self.decode_tt() + \
";ll:" + self.decode_ll() + ")"
elif (ec & 0xF800) == bit(11):
return "BUS(pp:" + self.decode_pp() + ";t:" + self.decode_t() + \
";r4:" + self.decode_r4() + ";ii:" + self.decode_ii() + \
";ll:" + self.decode_ll() + ")"
else:
return "WTF?!"
def __repr__(self):
ret = []
if self.valid(): ret.append("Val")
if self.overflow(): ret.append("Over")
if self.uncorrected(): ret.append("UC")
if self.err_enabled(): ret.append("EN")
if self.miscv(): ret.append("MiscV")
if self.addrv(): ret.append("AddrV")
if self.pcc(): ret.append("PCC")
if self.cecc(): ret.append("CECC")
if self.uecc(): ret.append("UECC")
if self.scrub(): ret.append("Scrub")
dec_bits = '|'.join(ret)
dec_bits += "|EEC: " + self.decode_eec() + (" (0x%02x)" % (self.eec()))
if self.__is_ecc():
dec_bits += (" (synd=0x%04x)" % (self.syndrome))
dec_bits += "|ET: " + self.error_type()
return ("MC%d_STATUS[%s]: 0x%016x" % (fus[self.fu], dec_bits, self.mci_status))def _rw_file(fname, off, flags):
""" Open and advance into @fname. Don't forget
to close the fd which this function returns.
"""
dbg("open %s" % fname)
try:
fd = open(fname, flags)
except:
err("opening %s" % (fname))
return -1
try:
fd.seek(off, 0)
except:
err("skipping to offset %d" % (off))
close(fd)
return -1
return fd
def read_file(fname, off, size):
fd = _rw_file(fname, off, "rb")
if fd < 0:
return -1
try:
ret = fd.read(size)
except:
err("reading from %s" % fname)
ret = -1
fd.close()
return retdef write_file(fname, off, value):
fd = _rw_file(fname, off, "wb")
if fd < 0:
return -1
fd.write(value)
fd.close()
return 0def rdmsr_on_cpu(cpu, msr):
""" Use kernel /dev/cpu/*/msr interface to access an MSR
"""
path = "/dev/cpu/%d/msr" % (cpu, )
val = read_file(path, msr, 8)
if not val or val < 0:
err("Unable to read %s." % (path))
return None
if len(val) == 8:
val = struct.unpack("Q", val)[0]
else:
err("MSR value truncated")
return None
return valdef wrmsr_on_cpu(cpu, msr, val):
""" Use kernel /dev/cpu/%d/msr interface to write a MSR """
path = "/dev/cpu/%d/msr" % (cpu, )
packed_val = struct.pack('Q', val)
if write_file(path, msr, packed_val):
err("writing 0x%016x to MSR_0x%08x" % (val, msr))
def __toggle_raw_mce_inject(cpu, enable):
val = rdmsr_on_cpu(cpu, MSR_K7_HWCR)
if not val:
return
dbg("Pre: 0x%016x" % val)
if enable:
val |= bit(18)
else:
val &= ~bit(18)
dbg("Post: 0x%016x" % val)
wrmsr_on_cpu(cpu, MSR_K7_HWCR, val)def _inject_raw_mce(cpu, mce):
""" Inject a raw MCE by writing the MCA registers directly
"""
bank = fus[mce.fu]
dbg("bank %d on cpu %d" % (bank, cpu))
__toggle_raw_mce_inject(cpu, True)
wrmsr_on_cpu(cpu, MSR_IA32_MCx_STATUS(bank), mce.mci_status)
wrmsr_on_cpu(cpu, MSR_IA32_MCx_ADDR(bank), 0xbabedeaddeadbeef)
wrmsr_on_cpu(cpu, MSR_IA32_MCx_MISC(bank), 0xdead57ac1ba0babe)
if write_file("/sys/inject/cpu", 0, str(cpu)):
err("injecting RAW MCE")
__toggle_raw_mce_inject(cpu, False)def _inject_ecc():
""" DRAM ECC injection over PCI config space
"""
# ArraySelect=1000b | ArrayAddress[2:1]
array_addr = bit(31) | randint(0, 4) << 1
# ErrInjEn[28:20] | EccWrReq | EccVector[15:0] - single-bit errors only for CECC
array_data = bit(randint(20, 29)) | bit(17) | bit(randint(0, 16))
cmd_arr = ['setpci', '-s 18.3', ("0xb8.l=0x%08x" % array_addr)]
dbg(cmd_arr)
cmd_dat = ['setpci', '-s 18.3', ("0xbc.l=0x%08x" % array_data)]
dbg(cmd_dat)
try:
subprocess.check_call(cmd_arr)
except:
sys.stderr.write("Error running %s\n" % (cmd_arr, ))
return
try:
subprocess.check_call(cmd_dat)
except:
sys.stderr.write("Error running %s\n" % (cmd_dat, ));def _inject_mce(cpu, mce, hw=False):
""" Injects and MCE error over EDAC's /sysfs
"""
sysfs_prefix = '/sys/devices/system/edac/mce'
mce_hw_inject_file = sysfs_prefix + '/hw_inject'
mce_status_file = sysfs_prefix + '/status'
mce_bank_file = sysfs_prefix + '/bank'
if write_file(mce_status_file, 0, ("0x%016x" % (mce.mci_status))):
print "Cannot open %s" % (mce_status_file)
print "Have you forgotten modprobing mce_amd_inj.ko?" return
if hw:
if write_file(mce_hw_inject_file, 0, '1'):
err("Cannot write to %s" % (mce_hw_inject_file)) return
if write_file(mce_bank_file, 0, ("%d" % (fus[mce.fu]))):
err("Cannot write to %s" % (mce_bank_file))
def inject_mce(opts, mce):
if opts.i == 'hw':
_inject_mce(opts.cpu, mce, True)
elif opts.i == 'ecc':
_inject_ecc()
elif opts.i == 'raw':
_inject_raw_mce(opts.cpu, mce)
elif opts.i == 'sw':
_inject_mce(opts.cpu, mce)
else:
err("Unknown injection method: %s" % (opts.i, ))def init_parser():
""" Read cmdline options
returns:
options:dict -- config options
"""
global opts
parser = OptionParser()
parser.add_option(
"-c",
"--cpu",
type="int",
dest="cpu",
default=0,
help="CPU to inject the MCE on",
)
parser.add_option(
"-d",
"--decode",
type="string",
action="store",
dest="d",
help="Decode 64-bit MCi_STATUS value representing an MCE"
)
parser.add_option(
"",
"--dbg",
dest="dbg",
action="store_true",
default=False,
help="Enable debugging",
)
def fam_callback(option, opt_str, value, parser):
if value == 'R':
parser.values.f = choice(families)
elif value in families:
parser.values.f = value
else:
# generate F10h MCEs per default
parser.values.f = 'f10h'
parser.add_option(
"-f",
"--family",
dest="f",
type="string",
action="callback",
callback=fam_callback,
help=("Family to generate MCE for %s" % (families))
)
parser.add_option(
"-i",
"--inject",
dest="i",
type="string",
help="Inject the error: 'hw' for hardware MCE injection\
'sw' for software-only\
'ecc' for DRAM ECC error\
'raw' for raw MCE injection (needs kernel mod)"
)
def et_callback(option, opt_str, value, parser):
value = value.upper()
if value not in error_types:
sys.stderr.write(("WARNING: wrong error type: %s\n" % (value)))
parser.values.et = value
parser.add_option(
"-t",
"--error-type",
dest="et",
type="string",
action="callback",
callback=et_callback,
help=("Generate a specific error type: %s" % (error_types))
)
def fu_callback(option, opt_str, value, parser):
# supplied string could be lowercase
value = value.upper()
# randomize FUs
if value == 'R':
# don't generate FP MCE yet
k = fus.keys()
k.remove('FP')
parser.values.fu = choice(k)
elif value in fus.keys():
parser.values.fu = value
parser.add_option(
"-u",
"--functional-unit",
dest="fu",
type="string",
action="callback",
callback=fu_callback,
help=("Functional unit to generate MCE for %s" % (fus.keys())),
)
opts = parser.parse_args()[0]
return optsdef main():
opts = init_parser()
if opts.d:
if opts.fu:
m = MCE(val=int(opts.d, 16), fu=opts.fu)
print m
else:
err("You need to supply the functional unit this signature belongs to.\n") sys.exit(-1)
else:
if not opts.fu:
opts.fu = choice(fus.keys())
print "Selecting FU at random:", opts.fu
m = MCE(fu=opts.fu, err_type=opts.et) sys.stderr.write(("Generating an %s MCE:\n%s\n" % (opts.fu, m)))
if opts.i:
inject_mce(opts, m)
if __name__ == "__main__":
main()
PATCH 1/18 perf: Start the restructuring
From: Borislav Petkov <[email protected]>
mv kernel/perf_event.c -> kernel/events/core.c. From there, all further sensible splitting can happen.
---
kernel/Makefile | 5 +++--
kernel/events/Makefile | 5 +++++
kernel/{perf_event.c => events/core.c} | 0
3 files changed, 8 insertions(+), 2 deletions(-)
create mode 100644 kernel/events/Makefile
rename kernel/{perf_event.c => events/core.c} (100%)kernel/Makefile +3 -2
@@ -21,7 +21,6 @@ CFLAGS_REMOVE_mutex-debug.o = -pg CFLAGS_REMOVE_rtmutex-debug.o = -pg CFLAGS_REMOVE_cgroup-debug.o = -pg CFLAGS_REMOVE_sched_clock.o = -pg -CFLAGS_REMOVE_perf_event.o = -pg CFLAGS_REMOVE_irq_work.o = -pg endif
@@ -103,7 +102,9 @@ obj-$(CONFIG_RING_BUFFER) += trace/ obj-$(CONFIG_TRACEPOINTS) += trace/ obj-$(CONFIG_SMP) += sched_cpupri.o obj-$(CONFIG_IRQ_WORK) += irq_work.o -obj-$(CONFIG_PERF_EVENTS) += perf_event.o + +obj-$(CONFIG_PERF_EVENTS) += events/ + obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_USER_RETURN_NOTIFIER) += user-return-notifier.o obj-$(CONFIG_PADATA) += padata.o
kernel/events/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +ifdef CONFIG_FUNCTION_TRACER +CFLAGS_REMOVE_core.o = -pg +endif + +obj-y += core.o
kernel/events/core.c renamed from kernel/perf_event.c +0 -0
Signature · 1 line
1.7.4.rc2
PATCH 2/18 perf: Add persistent event facilities
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Add a barebones implementation for registering persistent events with perf. For that, we don't destroy the buffers when they're unmapped and we map them read-only so that multiple agents can access them.
--- include/linux/perf_event.h | 22 ++++++++++++++++- kernel/events/Makefile | 2 +- kernel/events/core.c | 30 ++++++++++++++++++---- kernel/events/persistent.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 kernel/events/persistent.c
include/linux/perf_event.h +21 -1
@@ -216,8 +216,9 @@ struct perf_event_attr { precise_ip : 2, /* skid constraint */ mmap_data : 1, /* non-exec mmap data */ sample_id_all : 1, /* sample_type all events */ + persistent : 1, /* event always on */ - __reserved_1 : 45; + __reserved_1 : 44;union {__u32 wakeup_events;/* wakeup every n events */
@@ -1159,6 +1160,15 @@ extern void perf_swevent_put_recursion_context(int rctx);extern void perf_event_enable (struct perf_event *event);extern void perf_event_disable (struct perf_event *event);extern void perf_event_task_tick (void ); +extern struct perf_buffer * +perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags); +extern void perf_buffer_put (struct perf_buffer *buffer); +extern struct perf_event * +perf_enable_persistent_event (struct perf_event_attr *attr, +int cpu,unsigned bufsz); +extern void perf_disable_persistent_event (struct perf_event *event,int cpu); +extern int perf_persistent_open (struct inode *inode,struct file *file); +extern const struct file_operations perf_pers_fops;#else static inline void perf_event_task_sched_in (struct task_struct *task) { }
@@ -1193,6 +1203,16 @@ static inline void perf_swevent_put_recursion_context(int rctx) { }static inline void perf_event_enable (struct perf_event *event) { }static inline void perf_event_disable (struct perf_event *event) { }static inline void perf_event_task_tick (void ) { } +static inline struct perf_buffer * +perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags) {return NULL ; } +static inline void perf_buffer_put (struct perf_buffer *buffer) {} +static inline struct perf_event * +perf_enable_persistent_event (struct perf_event_attr *attr,int cpu, +unsigned bufsz) {return -EINVAL ; } +static inline void +perf_disable_persistent_event (struct perf_event *event,int cpu) {} +static inline int +perf_persistent_open (struct inode *inode,struct file *file) {return -1 ; }#endif #define perf_output_put (handle, x) \
kernel/events/Makefile +1 -1
@@ -2,4 +2,4 @@ ifdef CONFIG_FUNCTION_TRACER CFLAGS_REMOVE_core.o = -pg endif -obj-y += core.o +obj-y += core.o persistent.o
kernel/events/core.c +24 -6
@@ -2898,7 +2898,7 @@ static void free_event_rcu(struct rcu_head *head)kfree (event); } -static void perf_buffer_put (struct perf_buffer *buffer); +void perf_buffer_put (struct perf_buffer *buffer);static void free_event (struct perf_event *event) {
@@ -3458,7 +3458,7 @@ static void *perf_mmap_alloc_page(int cpu)return page_address (page); } -static struct perf_buffer * +struct perf_buffer *perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags) {struct perf_buffer *buffer;
@@ -3575,7 +3575,7 @@ static void perf_buffer_free(struct perf_buffer *buffer)schedule_work (&buffer->work); } -static struct perf_buffer * +struct perf_buffer *perf_buffer_alloc (int nr_pages,long watermark,int cpu,int flags) {struct perf_buffer *buffer;
@@ -3676,7 +3676,7 @@ static struct perf_buffer *perf_buffer_get(struct perf_event *event)return buffer; } -static void perf_buffer_put (struct perf_buffer *buffer) +void perf_buffer_put (struct perf_buffer *buffer) {if (!atomic_dec_and_test (&buffer->refcount))return ;
@@ -3695,6 +3695,11 @@ static void perf_mmap_close(struct vm_area_struct *vma) {struct perf_event *event = vma->vm_file->private_data; +if (event->attr.persistent) { +atomic_dec (&event->mmap_count); +return ; + } +if (atomic_dec_and_mutex_lock (&event->mmap_count, &event->mmap_mutex)) {unsigned long size =perf_data_size (event->buffer);struct user_struct *user = event->mmap_user;
@@ -3737,7 +3742,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)if (event->cpu ==-1 && event->attr.inherit)return -EINVAL ; -if (!(vma->vm_flags &VM_SHARED )) +if (!(vma->vm_flags &VM_SHARED ) && !event->attr.persistent)return -EINVAL ; vma_size = vma->vm_end - vma->vm_start;
@@ -3846,6 +3851,16 @@ static const struct file_operations perf_fops = { .fasync = perf_fasync, }; +const struct file_operations perf_pers_fops = { + .llseek = no_llseek, + .open = perf_persistent_open, + .poll = perf_poll, + .unlocked_ioctl = perf_ioctl, + .compat_ioctl = perf_ioctl, + .mmap = perf_mmap, + .fasync = perf_fasync, +}; +/* * Perf event wakeup *
@@ -6702,7 +6717,6 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,mutex_unlock (&ctx->mutex);return event; - err_free:free_event (event); err:
@@ -6756,6 +6770,10 @@ __perf_event_exit_task(struct perf_event *child_event,raw_spin_unlock_irq (&child_ctx->lock); } +/* do not remove persistent events on task exit */ +if (child_event->attr.persistent) +return ; +perf_remove_from_context (child_event);/*
kernel/events/persistent.c new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
1.7.4.rc2
Peter Zijlstra
maintainerRe: [PATCH 02/18] perf: Add persistent event facilities
Quoted 20 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Add a barebones implementation for registering persistent events with perf. For that, we don't destroy the buffers when they're unmapped and we map them read-only so that multiple agents can access them.
Signed-off-by Borislav Petkov <[email protected]>--- include/linux/perf_event.h | 22 ++++++++++++++++- kernel/events/Makefile | 2 +- kernel/events/core.c | 30 ++++++++++++++++++---- kernel/events/persistent.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 kernel/events/persistent.cinclude/linux/perf_event.h +0
-0
include/linux/perf_event.h struct perf_event_attr { · line 219
Quoted 4 lines
include/linux/perf_event.h +1
-0@@ -216,8 +216,9 @@ struct perf_event_attr { precise_ip : 2, /* skid constraint */ mmap_data : 1, /* non-exec mmap data */ sample_id_all : 1, /* sample_type all events */ + persistent : 1, /* event always on */
But how will you find it again?
Persistent yells filesystem to me, and while we didn't use relayfs for various reasons, I think we do need something like it at the current stage.
Re: [PATCH 02/18] perf: Add persistent event facilities
Quoted 28 lines · Peter Zijlstra
Quoted 20 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Add a barebones implementation for registering persistent events with perf. For that, we don't destroy the buffers when they're unmapped and we map them read-only so that multiple agents can access them.
Signed-off-by Borislav Petkov <[email protected]>--- include/linux/perf_event.h | 22 ++++++++++++++++- kernel/events/Makefile | 2 +- kernel/events/core.c | 30 ++++++++++++++++++---- kernel/events/persistent.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 kernel/events/persistent.cinclude/linux/perf_event.h +0
-0include/linux/perf_event.h struct perf_event_attr { · line 219
Quoted 4 lines
include/linux/perf_event.h +1
-0@@ -216,8 +216,9 @@ struct perf_event_attr { precise_ip : 2, /* skid constraint */ mmap_data : 1, /* non-exec mmap data */ sample_id_all : 1, /* sample_type all events */ + persistent : 1, /* event always on */But how will you find it again?
Quoted 2 lines
Persistent yells filesystem to me, and while we didn't use relayfs for various reasons, I think we do need something like it at the current stage.
eventfs or sysfs?
We need VFS space for event hierarchy enumeration anyway (and move the current debugfs bits there). Persistent events could show up in that hiearachy as well.
Thanks,
Ingo
Re: [PATCH 02/18] perf: Add persistent event facilities
Quoted 31 lines · Ingo Molnar
Quoted 28 lines · Peter Zijlstra
Quoted 20 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Add a barebones implementation for registering persistent events with perf. For that, we don't destroy the buffers when they're unmapped and we map them read-only so that multiple agents can access them.
Signed-off-by Borislav Petkov <[email protected]>--- include/linux/perf_event.h | 22 ++++++++++++++++- kernel/events/Makefile | 2 +- kernel/events/core.c | 30 ++++++++++++++++++---- kernel/events/persistent.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 kernel/events/persistent.cinclude/linux/perf_event.h +0
-0include/linux/perf_event.h struct perf_event_attr { · line 219
Quoted 4 lines
include/linux/perf_event.h +1
-0@@ -216,8 +216,9 @@ struct perf_event_attr { precise_ip : 2, /* skid constraint */ mmap_data : 1, /* non-exec mmap data */ sample_id_all : 1, /* sample_type all events */ + persistent : 1, /* event always on */But how will you find it again?
Quoted 7 lines
Quoted 2 lines
Persistent yells filesystem to me, and while we didn't use relayfs for various reasons, I think we do need something like it at the current stage.
eventfs or sysfs?
We need VFS space for event hierarchy enumeration anyway (and move the current debugfs bits there). Persistent events could show up in that hiearachy as well.
I think we talked about this already in conjunction with moving event hierarchy to sysfs - there you can have a "persistent" node too so you can find it.
Here's what we talked about then:
https://lkml.org/lkml/2010/11/11/10
this and the following messages.
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
PATCH 3/18 x86, mce: Add persistent MCE event
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Add the necessary glue to enable the mce_record tracepoint on boot, turning it into a persistent event. This exports the MCE buffer through a debugfs per-CPU file which a userspace daemon can read and process the error data further.
--- arch/x86/include/asm/mce.h | 8 +++ arch/x86/kernel/cpu/mcheck/mce.c | 89 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 0 deletions(-)
arch/x86/include/asm/mce.h +8 -0
@@ -115,6 +115,14 @@ struct mce_log {#ifdef __KERNEL__ +/* +* a per-cpu descriptor of the persistent MCE tracepoint +*/ +struct mce_tp_desc { +struct perf_event *event; +struct dentry *debugfs_entry; +}; +extern struct atomic_notifier_head x86_mce_decoder_chain;#include <linux/percpu.h>
arch/x86/kernel/cpu/mcheck/mce.c +89 -0
119 lines not on this page · raw message
Signature · 1 line
1.7.4.rc2
PATCH 4/18 x86, mce: Have MCE persistent event off by default for now
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Since this is a pretty new functionality and since it affects all x86, we want to have it off by default for now, in case something goes awry. You can always enable it by supplying "ras" on your kernel command line.
Also, depending on whether it is enabled or not, we emit the tracepoint from a different place in the code to pick up any decoded info.
--- Documentation/kernel-parameters.txt | 2 ++ arch/x86/include/asm/mce.h | 1 + arch/x86/kernel/cpu/mcheck/mce.c | 32 ++++++++++++++++++++++++++++++-- drivers/edac/mce_amd.c | 5 +++++ 4 files changed, 38 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +2 -0
@@ -2165,6 +2165,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ramdisk_size= [RAM] Sizes of RAM disks in kilobytes See Documentation/blockdev/ramdisk.txt. + ras [X86] Enable RAS daemon supporting functionality. + rcupdate.blimit= [KNL,BOOT] Set maximum number of finished RCU callbacks to process in one batch.
arch/x86/include/asm/mce.h +1 -0
@@ -131,6 +131,7 @@ extern struct atomic_notifier_head x86_mce_decoder_chain;extern int mce_disabled;extern int mce_p5_enabled; +extern int ras;#ifdef CONFIG_X86_MCE int mcheck_init (void );
arch/x86/kernel/cpu/mcheck/mce.c +30 -2
@@ -59,6 +59,8 @@ static DEFINE_MUTEX(mce_read_mutex);#define CREATE_TRACE_POINTS #include <trace/events/mce.h> +EXPORT_TRACEPOINT_SYMBOL_GPL (mce_record); +int mce_disabled__read_mostly ;#define MISC_MCELOG_MINOR 227
@@ -86,6 +88,7 @@ static int mce_dont_log_ce __read_mostly;int mce_cmci_disabled__read_mostly ;int mce_ignore_ce__read_mostly ;int mce_ser__read_mostly ; +int ras__read_mostly ;struct mce_bank *mce_banks__read_mostly ;
@@ -105,6 +108,7 @@ static int cpu_missing;*/ ATOMIC_NOTIFIER_HEAD (x86_mce_decoder_chain);EXPORT_SYMBOL_GPL (x86_mce_decoder_chain); +EXPORT_SYMBOL_GPL (ras);static int default_decode_mce (struct notifier_block *nb,unsigned long val,void *data)
@@ -163,8 +167,9 @@ void mce_log(struct mce *mce) {unsigned next, entry; -/* Emit the trace record: */ -trace_mce_record (mce); +if (!ras) +/* Emit the trace record: */ +trace_mce_record (mce); mce->finished =0 ;wmb ();
@@ -1721,6 +1726,19 @@ static int __init mcheck_enable(char *str) }__setup ("mce" , mcheck_enable); +static int __init ras_enable (char *str) +{ +/* +* We enable the persistent event only if "ras" is supplied on the +* command line. We still can add further options to parameter later. +*/ + ras =1 ; + +return 0 ; +} + +__setup ("ras" , ras_enable); +int __init mcheck_init (void ) {atomic_notifier_chain_register (&x86_mce_decoder_chain, &mce_dec_nb);
@@ -2081,6 +2099,9 @@ static int mce_enable_perf_event_on_cpu(int cpu)struct mce_tp_desc *d = &per_cpu (mce_event, cpu);int err = -EINVAL ; +if (!ras) +return 0 ; + d->event =perf_enable_persistent_event (&pattr, cpu,MCE_BUF_PAGES );if (IS_ERR (d->event)) {printk (KERN_ERR "MCE: Error enabling event on cpu %d\n" , cpu);
@@ -2105,6 +2126,10 @@ ret:static void mce_disable_perf_event_on_cpu (int cpu) {struct mce_tp_desc *d = &per_cpu (mce_event, cpu); + +if (!ras) +return ; +debugfs_remove (d->debugfs_entry);perf_disable_persistent_event (d->event, cpu); }
@@ -2113,6 +2138,9 @@ static __init int mcheck_init_persistent_event(void) {int cpu, err =0 ; +if (!ras) +return -EBUSY ; +get_online_cpus (); pattr.config = event_mce_record.event.type;
drivers/edac/mce_amd.c +5 -0
@@ -1,5 +1,7 @@#include <linux/module.h> #include <linux/slab.h> +#include <asm/mce.h> +#include <trace/events/mce.h> #include "mce_amd.h"
@@ -829,6 +831,9 @@ int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)amd_decode_err_code (m->status &0xffff ); +if (ras) +trace_mce_record (m); +return NOTIFY_STOP ; }EXPORT_SYMBOL_GPL (amd_decode_mce);
Signature · 1 line
1.7.4.rc2
PATCH 5/18 perf: Add Makefile.lib
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Put build settings which will be reused by other tools into a common .lib file.
--- tools/perf/Makefile | 45 +------------------------------------------ tools/scripts/Makefile.lib | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 44 deletions(-) create mode 100644 tools/scripts/Makefile.lib
tools/perf/Makefile +1 -44
@@ -1,18 +1,10 @@ -ifeq ("$(origin O)", "command line") - OUTPUT := $(O)/ -endif +include ../scripts/Makefile.lib # The default target of this Makefile is... all: include config/utilities.mak -ifneq ($(OUTPUT),) -# check that the output directory actually exists -OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) -$(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) -endif - # Define V to have a more verbose compile. # # Define PYTHON to point to the python binary if the default
@@ -54,31 +46,6 @@ ifeq ($(ARCH),x86_64) ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S endif -# -# Include saner warnings here, which can catch bugs: -# - -EXTRA_WARNINGS := -Wformat -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-security -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wformat-y2k -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wshadow -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Winit-self -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wpacked -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wredundant-decls -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-aliasing=3 -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-default -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wswitch-enum -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wno-system-headers -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wundef -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wwrite-strings -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wbad-function-cast -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-declarations -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wmissing-prototypes -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wnested-externs -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes -EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement - ifeq ("$(origin DEBUG)", "command line") PERF_DEBUG = $(DEBUG) endif
@@ -597,16 +564,6 @@ else endif endif -ifneq ($(findstring $(MAKEFLAGS),s),s) -ifndef V - QUIET_CC = @echo ' ' CC $@; - QUIET_AR = @echo ' ' AR $@; - QUIET_LINK = @echo ' ' LINK $@; - QUIET_MKDIR = @echo ' ' MKDIR $@; - QUIET_GEN = @echo ' ' GEN $@; -endif -endif - ifdef ASCIIDOC8 export ASCIIDOC8 endif
tools/scripts/Makefile.lib new file +46 -0
46 lines not on this page · raw message
Signature · 1 line
1.7.4.rc2
PATCH 6/18 tools: Add a toplevel Makefile
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Add a Makefile with all the targets under tools/. Make perf the default one and add a minimalistic Makefile to slub/ for completeness.
--- tools/Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++ tools/scripts/Makefile.lib | 14 ++++++++++++-- tools/slub/Makefile | 4 ++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tools/Makefile create mode 100644 tools/slub/Makefile
tools/Makefile new file +42 -0
@@ -0,0 +1,42 @@ +include scripts/Makefile.lib + +PERF_TOP_DIR := $(CURDIR) +export PERF_TOP_DIR + +BASIC_CFLAGS = -I$(CURDIR)/lib + +# temporary for lib/trace/ +BASIC_CFLAGS += -I$(CURDIR)/perf/util/include +export BASIC_CFLAGS + +perf: .FORCE + $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) + +firewire: .FORCE + $(QUIET_SUBDIR0)firewire/ $(QUIET_SUBDIR1) + +slabinfo: .FORCE + $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1) + +turbostat: .FORCE + $(QUIET_SUBDIR0)power/x86/turbostat/ $(QUIET_SUBDIR1) + +usb: .FORCE + $(QUIET_SUBDIR0)usb/ $(QUIET_SUBDIR1) + +virtio: .FORCE + $(QUIET_SUBDIR0)virtio/ $(QUIET_SUBDIR1) + +x86_energy: .FORCE + $(QUIET_SUBDIR0)power/x86/x86_energy_perf_policy/ $(QUIET_SUBDIR1) + +clean: + $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)firewire/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)power/x86/turbostat/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)usb/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)virtio/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)power/x86/x86_energy_perf_policy/ $(QUIET_SUBDIR1) clean + +.PHONY: clean .FORCE
tools/scripts/Makefile.lib +12 -2
@@ -33,6 +33,15 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement +QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir +QUIET_SUBDIR1 = + +ifneq ($(findstring $(MAKEFLAGS),w),w) +PRINT_DIR = --no-print-directory +else # "make -w" +NO_SUBDIR = : +endif + ifneq ($(findstring $(MAKEFLAGS),s),s) ifndef V QUIET_CC = @echo ' ' CC $@;
@@ -40,7 +49,8 @@ ifndef V QUIET_LINK = @echo ' ' LINK $@; QUIET_MKDIR = @echo ' ' MKDIR $@; QUIET_GEN = @echo ' ' GEN $@; + QUIET_SUBDIR0 = +@subdir= + QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ + $(MAKE) $(PRINT_DIR) -C $$subdir endif endif - -
tools/slub/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +slabinfo: slabinfo.c + +clean: + rm -rf slabinfo
Signature · 1 line
1.7.4.rc2
PATCH 7/18 perf: Export trace-event utils
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Export trace-event* utils into a sub-lib for wider use. While at it, export functions for use by other entities later.
---
tools/Makefile | 6 ++-
tools/lib/trace/Makefile | 59 ++++++++++++++++++++
.../trace-event-info.c => lib/trace/event-info.c} | 20 +++----
.../trace/event-parse.c} | 16 +++---
.../trace-event-read.c => lib/trace/event-read.c} | 4 +-
tools/{perf/util => lib/trace}/trace-event.h | 22 +++++--
tools/perf/Makefile | 11 ++--
tools/perf/bench/bench.h | 2 +
tools/perf/builtin-kmem.c | 2 +-
tools/perf/builtin-kvm.c | 2 +-
tools/perf/builtin-lock.c | 2 +-
tools/perf/builtin-sched.c | 2 +-
tools/perf/builtin-script.c | 2 +-
tools/perf/scripts/perl/Perf-Trace-Util/Context.c | 2 +-
.../perf/scripts/python/Perf-Trace-Util/Context.c | 2 +-
tools/perf/util/cache.h | 1 +
tools/perf/util/header.c | 2 +-
tools/perf/util/probe-event.c | 2 +-
.../perf/util/scripting-engines/trace-event-perl.c | 2 +-
.../util/scripting-engines/trace-event-python.c | 2 +-
tools/perf/util/trace-event-scripting.c | 2 +-
tools/scripts/Makefile.lib | 4 +
22 files changed, 123 insertions(+), 46 deletions(-)
create mode 100644 tools/lib/trace/Makefile
rename tools/{perf/util/trace-event-info.c => lib/trace/event-info.c} (97%)
rename tools/{perf/util/trace-event-parse.c => lib/trace/event-parse.c} (99%)
rename tools/{perf/util/trace-event-read.c => lib/trace/event-read.c} (99%)
rename tools/{perf/util => lib/trace}/trace-event.h (91%)tools/Makefile +5 -1
@@ -9,12 +9,15 @@ BASIC_CFLAGS = -I$(CURDIR)/lib BASIC_CFLAGS += -I$(CURDIR)/perf/util/include export BASIC_CFLAGS -perf: .FORCE +perf: libtrace .FORCE $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) firewire: .FORCE $(QUIET_SUBDIR0)firewire/ $(QUIET_SUBDIR1) +libtrace: .FORCE + $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) + slabinfo: .FORCE $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1)
@@ -33,6 +36,7 @@ x86_energy: .FORCE clean: $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)firewire/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)power/x86/turbostat/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)usb/ $(QUIET_SUBDIR1) clean
tools/lib/trace/Makefile new file +59 -0
59 lines not on this page · raw message
tools/lib/trace/event-info.c renamed from tools/perf/util/trace-event-info.c +9 -11
@@ -37,10 +37,10 @@#include <linux/list.h> #include <linux/kernel.h> -#include "../perf.h" +#include "../../perf/perf.h" #include "trace-event.h" -#include "debugfs.h" -#include "evsel.h" +#include "../perf/util/debugfs.h" +#include "../perf/util/evsel.h" #define VERSION "0.5"
@@ -72,8 +72,6 @@ struct events {char *name; }; - -static void die (const char *fmt, ...) {va_list ap;
@@ -136,7 +134,7 @@ static const char *find_tracing_dir(void)return tracing; } -static char *get_tracing_file (const char *name) +char *get_tracing_file (const char *name) {const char *tracing;char *file;
@@ -151,7 +149,7 @@ static char *get_tracing_file(const char *name)return file; } -static void put_tracing_file (char *file) +void put_tracing_file (char *file) {free (file); }
@@ -231,7 +229,7 @@ static unsigned long get_size_fd(int fd)return size; } -static unsigned long get_size (const char *file) +unsigned long get_filesize (const char *file) {unsigned long long size =0 ;int fd;
@@ -340,7 +338,7 @@ static void copy_event_system(const char *sys, struct tracepoint_path *tps)if (ret >=0 ) {/* unfortunately, you can not stat debugfs files for size */ - size =get_size (format); + size =get_filesize (format);write_or_die (&size,8 ); check_size =copy_file (format);if (size != check_size)
@@ -438,7 +436,7 @@ static void read_proc_kallsyms(void)write_or_die (&size,4 );return ; } - size =get_size (path); + size =get_filesize (path);write_or_die (&size,4 ); check_size =copy_file (path);if (size != check_size)
@@ -461,7 +459,7 @@ static void read_ftrace_printk(void)write_or_die (&size,4 ); goto out; } - size =get_size (path); + size =get_filesize (path);write_or_die (&size,4 ); check_size =copy_file (path);if (size != check_size)
tools/lib/trace/event-parse.c renamed from tools/perf/util/trace-event-parse.c +8 -8
@@ -29,8 +29,8 @@#include <errno.h> #undef _GNU_SOURCE -#include "../perf.h" -#include "util.h" +#include "../../perf/perf.h" +#include "../../perf/util/util.h" #include "trace-event.h" int header_page_ts_offset;
@@ -44,7 +44,7 @@ int header_page_data_size;bool latency_format; -static char *input_buf; +static const char *input_buf;static unsigned long long input_buf_ptr;static unsigned long long input_buf_siz;
@@ -56,7 +56,7 @@ static int is_symbolic_field;static struct format_field *find_any_field (struct event *event,const char *name); -static void init_input_buf (char *buf,unsigned long long size) +void init_input_buf (const char *buf,unsigned long long size) { input_buf = buf; input_buf_siz = size;
@@ -338,7 +338,7 @@ void print_printk(void) } } -static struct event *alloc_event (void ) +struct event *alloc_event (void ) {struct event *event;
@@ -701,7 +701,7 @@ static int read_expected_item(enum event_type expect, const char *str)return __read_expected (expect, str,0 , true); } -static char *event_read_name (void ) +char *event_read_name (void ) {char *token;
@@ -721,7 +721,7 @@ static char *event_read_name(void)return NULL ; } -static int event_read_id (void ) +int event_read_id (void ) {char *token;int id;
@@ -986,7 +986,7 @@ fail_expect:return -1 ; } -static int event_read_format (struct event *event) +int event_read_format (struct event *event) {char *token;int ret;
tools/lib/trace/event-read.c renamed from tools/perf/util/trace-event-read.c +2 -2
@@ -36,8 +36,8 @@#include <ctype.h> #include <errno.h> -#include "../perf.h" -#include "util.h" +#include "../../perf/perf.h" +#include "../../perf/util/util.h" #include "trace-event.h" static int input_fd;
tools/lib/trace/trace-event.h renamed from tools/perf/util/trace-event.h +16 -6
@@ -1,12 +1,13 @@ -#ifndef __PERF_TRACE_EVENTS_H -#define __PERF_TRACE_EVENTS_H +#ifndef __LIB_TRACE_EVENTS_H +#define __LIB_TRACE_EVENTS_H#include <stdbool.h> -#include "parse-events.h" -#include "session.h" +#include <linux/compiler.h> -#define __unused __attribute__((unused)) +#include "../../perf/util/session.h" +#include "../../perf/util/parse-events.h" +#define __unused __attribute__((unused))#ifndef PAGE_MASK #define PAGE_MASK (page_size - 1)
@@ -265,6 +266,15 @@ unsigned long long eval_flag(const char *flag);int read_tracing_data (int fd,struct list_head *pattrs);ssize_t read_tracing_data_size (int fd,struct list_head *pattrs); +extern struct event *alloc_event (void ); +extern void init_input_buf (const char *buf,unsigned long long size); +extern char *event_read_name (void ); +extern int event_read_id (void ); +extern int event_read_format (struct event *event); +unsigned long get_filesize (const char *file); +char *get_tracing_file (const char *name); +void put_tracing_file (char *file); +/* taken from kernel/trace/trace.h */ enum trace_flag_type {TRACE_FLAG_IRQS_OFF =0x01 ,
@@ -299,4 +309,4 @@ int common_pc(struct scripting_context *context);int common_flags (struct scripting_context *context);int common_lock_depth (struct scripting_context *context); -#endif /* __PERF_TRACE_EVENTS_H */ +#endif /* __LIB_TRACE_EVENTS_H */
tools/perf/Makefile +5 -6
@@ -124,7 +124,7 @@ endif # Those must not be GNU-specific; they are shared with perl/ which may # be built by a different compiler. (Note that this is an artifact now # but it still might be nice to keep that distinction.) -BASIC_CFLAGS = -Iutil/include -Iarch/$(ARCH)/include +BASIC_CFLAGS += -Iutil/include -Iarch/$(ARCH)/include BASIC_LDFLAGS = # Guard against environment variables
@@ -133,6 +133,7 @@ LIB_H = LIB_OBJS = PYRF_OBJS = SCRIPT_SH = +EXTRA_LIBS = SCRIPT_SH += perf-archive.sh
@@ -175,6 +176,8 @@ export PERL_PATH LIB_FILE=$(OUTPUT)libperf.a +EXTRA_LIBS=$(LIB_OUTPUT)libtrace.a + LIB_H += ../../include/linux/perf_event.h LIB_H += ../../include/linux/rbtree.h LIB_H += ../../include/linux/list.h
@@ -238,7 +241,6 @@ LIB_H += util/sort.h LIB_H += util/hist.h LIB_H += util/thread.h LIB_H += util/thread_map.h -LIB_H += util/trace-event.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h LIB_H += util/pstack.h
@@ -289,9 +291,6 @@ LIB_OBJS += $(OUTPUT)util/pstack.o LIB_OBJS += $(OUTPUT)util/session.o LIB_OBJS += $(OUTPUT)util/thread.o LIB_OBJS += $(OUTPUT)util/thread_map.o -LIB_OBJS += $(OUTPUT)util/trace-event-parse.o -LIB_OBJS += $(OUTPUT)util/trace-event-read.o -LIB_OBJS += $(OUTPUT)util/trace-event-info.o LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o
@@ -334,7 +333,7 @@ BUILTIN_OBJS += $(OUTPUT)builtin-kvm.o BUILTIN_OBJS += $(OUTPUT)builtin-test.o BUILTIN_OBJS += $(OUTPUT)builtin-inject.o -PERFLIBS = $(LIB_FILE) +PERFLIBS = $(LIB_FILE) $(EXTRA_LIBS) # Files needed for the python binding, perf.so # pyrf is just an internal name needed for all those wrappers.
tools/perf/bench/bench.h +2 -0
@@ -1,6 +1,8 @@#ifndef BENCH_H #define BENCH_H +#include <linux/compiler.h> +extern int bench_sched_messaging (int argc,const char **argv,const char *prefix);extern int bench_sched_pipe (int argc,const char **argv,const char *prefix);extern int bench_mem_memcpy (int argc,const char **argv,const char *prefix__used );
tools/perf/builtin-kmem.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h"
tools/perf/builtin-kvm.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h"
tools/perf/builtin-lock.c +1 -1
@@ -8,7 +8,7 @@#include "util/header.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h" #include "util/session.h"
tools/perf/builtin-sched.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include "util/parse-options.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/debug.h"
tools/perf/builtin-script.c +1 -1
@@ -9,7 +9,7 @@#include "util/session.h" #include "util/symbol.h" #include "util/thread.h" -#include "util/trace-event.h" +#include <trace/trace-event.h> #include "util/parse-options.h" #include "util/util.h" #include "util/evlist.h"
tools/perf/scripts/perl/Perf-Trace-Util/Context.c +1 -1
@@ -32,7 +32,7 @@#include "perl.h" #include "XSUB.h" #include "../../../perf.h" -#include "../../../util/trace-event.h" +#include <trace/trace-event.h> #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR (var) if (0) var = var
tools/perf/scripts/python/Perf-Trace-Util/Context.c +1 -1
@@ -21,7 +21,7 @@#include <Python.h> #include "../../../perf.h" -#include "../../../util/trace-event.h" +#include <trace/trace-event.h> PyMODINIT_FUNC initperf_trace_context (void );
tools/perf/util/cache.h +1 -0
@@ -5,6 +5,7 @@#include "util.h" #include "strbuf.h" #include "../perf.h" +#include <linux/compiler.h> #define CMD_EXEC_PATH "--exec-path"#define CMD_PERF_DIR "--perf-dir="
tools/perf/util/header.c +1 -1
@@ -13,7 +13,7 @@#include "util.h" #include "header.h" #include "../perf.h" -#include "trace-event.h" +#include <trace/trace-event.h> #include "session.h" #include "symbol.h" #include "debug.h"
tools/perf/util/probe-event.c +1 -1
@@ -44,7 +44,7 @@#include "symbol.h" #include "thread.h" #include "debugfs.h" -#include "trace-event.h" /* For __unused */ +#include <trace/trace-event.h> /* For __unused */ #include "probe-event.h" #include "probe-finder.h"
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
@@ -27,7 +27,7 @@#include "../../perf.h" #include "../util.h" -#include "../trace-event.h" +#include <trace/trace-event.h> #include <EXTERN.h> #include <perl.h>
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -29,7 +29,7 @@#include "../../perf.h" #include "../util.h" -#include "../trace-event.h" +#include <trace/trace-event.h> PyMODINIT_FUNC initperf_trace_context (void );
tools/perf/util/trace-event-scripting.c +1 -1
@@ -27,7 +27,7 @@#include "../perf.h" #include "util.h" -#include "trace-event.h" +#include <trace/trace-event.h> struct scripting_context *scripting_context;
tools/scripts/Makefile.lib +4 -0
@@ -1,5 +1,9 @@ ifeq ("$(origin O)", "command line") OUTPUT := $(O)/ + LIB_OUTPUT := $(O)/generic-lib/ + __dummy := $(shell if [ ! -d $(LIB_OUTPUT) ]; then mkdir -p $(LIB_OUTPUT); fi) +else + LIB_OUTPUT := $(PERF_TOP_DIR)/lib/ endif ifneq ($(OUTPUT),)
Signature · 1 line
1.7.4.rc2
PATCH 8/18 perf: Remove duplicate enum trace_flag_type
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Merge the two definitions.
--- tools/lib/trace/trace-event.h | 10 +++++++++- tools/perf/builtin-timechart.c | 21 ++------------------- 2 files changed, 11 insertions(+), 20 deletions(-)
tools/lib/trace/trace-event.h +9 -1
@@ -275,7 +275,15 @@ unsigned long get_filesize(const char *file);char *get_tracing_file (const char *name);void put_tracing_file (char *file); -/* taken from kernel/trace/trace.h */ +/* +* trace_flag_type is an enumeration that holds different +* states when a trace occurs. These are: +* IRQS_OFF - interrupts were disabled +* IRQS_NOSUPPORT - arch does not support irqs_disabled_flags +* NEED_RESCED - reschedule is requested +* HARDIRQ - inside an interrupt handler +* SOFTIRQ - inside a softirq handler +*/ enum trace_flag_type {TRACE_FLAG_IRQS_OFF =0x01 ,TRACE_FLAG_IRQS_NOSUPPORT =0x02 ,
tools/perf/builtin-timechart.c +2 -19
@@ -32,6 +32,8 @@#include "util/session.h" #include "util/svghelper.h" +#include <trace/trace-event.h> +#define SUPPORT_OLD_POWER_EVENTS 1#define PWR_EVENT_EXIT -1
@@ -330,25 +332,6 @@ struct wakeup_entry {int success; }; -/* -* trace_flag_type is an enumeration that holds different -* states when a trace occurs. These are: -* IRQS_OFF - interrupts were disabled -* IRQS_NOSUPPORT - arch does not support irqs_disabled_flags -* NEED_RESCED - reschedule is requested -* HARDIRQ - inside an interrupt handler -* SOFTIRQ - inside a softirq handler -*/ -enum trace_flag_type { -TRACE_FLAG_IRQS_OFF =0x01 , -TRACE_FLAG_IRQS_NOSUPPORT =0x02 , -TRACE_FLAG_NEED_RESCHED =0x04 , -TRACE_FLAG_HARDIRQ =0x08 , -TRACE_FLAG_SOFTIRQ =0x10 , -}; - - -struct sched_switch {struct trace_entry te;char prev_comm[TASK_COMM_LEN ];
Signature · 1 line
1.7.4.rc2
PATCH 9/18 perf: Drop redundant FD macro definitions
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Put a single define in the util/util.h header which should be generic enough and included by all builtin commands.
--- tools/perf/builtin-record.c | 2 -- tools/perf/builtin-top.c | 2 -- tools/perf/util/evlist.c | 3 --- tools/perf/util/evsel.c | 2 -- tools/perf/util/util.h | 3 +++ 5 files changed, 3 insertions(+), 9 deletions(-)
tools/perf/builtin-record.c +0 -2
@@ -30,8 +30,6 @@#include <sched.h> #include <sys/mman.h> -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -enum write_mode_t {WRITE_FORCE ,WRITE_APPEND
tools/perf/builtin-top.c +0 -2
@@ -62,8 +62,6 @@#include <linux/unistd.h> #include <linux/types.h> -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -static struct perf_top top = { .count_filter =5 , .delay_secs =2 ,
tools/perf/util/evlist.c +0 -3
@@ -19,9 +19,6 @@#include <linux/bitops.h> #include <linux/hash.h> -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) -void perf_evlist__init (struct perf_evlist *evlist,struct cpu_map *cpus,struct thread_map *threads) {
tools/perf/util/evsel.c +0 -2
@@ -13,8 +13,6 @@#include "cpumap.h" #include "thread_map.h" -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr,int idx) {
tools/perf/util/util.h +3 -0
@@ -39,6 +39,9 @@/* Approximation of the length of the decimal representation of this type. */ #define decimal_length (x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) +#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) +#define _ALL_SOURCE 1#define _GNU_SOURCE 1#define _BSD_SOURCE 1
Signature · 1 line
1.7.4.rc2
Re: [PATCH 09/18] perf: Drop redundant FD macro definitions
Em Sat, Apr 23, 2011 at 06:28:11PM +0200, Borislav Petkov escreveu:
Quoted 4 lines
From: Borislav Petkov <[email protected]>
Put a single define in the
util/util.hheader which should be generic enough and included by all builtin commands.
I'll apply this one, but will move those definitions to evsel.h, as they operate on an evlist instance (e->fd).
- Arnaldo
Quoted 78 lines
Signed-off-by Borislav Petkov <[email protected]>--- tools/perf/builtin-record.c | 2 -- tools/perf/builtin-top.c | 2 -- tools/perf/util/evlist.c | 3 --- tools/perf/util/evsel.c | 2 -- tools/perf/util/util.h | 3 +++ 5 files changed, 3 insertions(+), 9 deletions(-)tools/perf/builtin-record.c +0
-2@@ -30,8 +30,6 @@#include <sched.h> #include <sys/mman.h> -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -enum write_mode_t {WRITE_FORCE ,WRITE_APPEND tools/perf/builtin-top.c +0
-2@@ -62,8 +62,6 @@#include <linux/unistd.h> #include <linux/types.h> -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -static struct perf_top top = { .count_filter =5 , .delay_secs =2 ,tools/perf/util/evlist.c +0
-3@@ -19,9 +19,6 @@#include <linux/bitops.h> #include <linux/hash.h> -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) -void perf_evlist__init (struct perf_evlist *evlist,struct cpu_map *cpus,struct thread_map *threads) {tools/perf/util/evsel.c +0
-2@@ -13,8 +13,6 @@#include "cpumap.h" #include "thread_map.h" -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) -void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr,int idx) {tools/perf/util/util.h +3
-0@@ -39,6 +39,9 @@/* Approximation of the length of the decimal representation of this type. */ #define decimal_length (x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) +#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) +#define _ALL_SOURCE 1#define _GNU_SOURCE 1#define _BSD_SOURCE 1Signature · 1 line
1.7.4.rc2
PATCH 10/18 perf: Export debugfs utilities
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Export /proc/mounts parser and other debugfs-related helpers for general use.
---
tools/Makefile | 9 ++++-
tools/lib/lk/Makefile | 41 ++++++++++++++++++++
tools/{perf/util => lib/lk}/debugfs.c | 2 +-
tools/{perf/util => lib/lk}/debugfs.h | 7 ++-
tools/{perf/util => lib/lk}/types.h | 6 +-
tools/{perf/util => lib/lk}/usage.c | 0
tools/{perf/util => lib/lk}/util.c | 2 +-
tools/{perf/util => lib/lk}/util.h | 0
tools/lib/perf/shared.h | 9 ++++
tools/lib/trace/event-info.c | 2 +-
tools/lib/trace/event-parse.c | 2 +-
tools/lib/trace/event-read.c | 2 +-
tools/perf/Makefile | 9 +----
tools/perf/bench/mem-memcpy.c | 2 +-
tools/perf/bench/sched-messaging.c | 2 +-
tools/perf/bench/sched-pipe.c | 2 +-
tools/perf/builtin-annotate.c | 4 +-
tools/perf/builtin-bench.c | 2 +-
tools/perf/builtin-diff.c | 2 +-
tools/perf/builtin-evlist.c | 3 +-
tools/perf/builtin-kmem.c | 2 +-
tools/perf/builtin-kvm.c | 2 +-
tools/perf/builtin-lock.c | 2 +-
tools/perf/builtin-probe.c | 4 +-
tools/perf/builtin-record.c | 2 +-
tools/perf/builtin-report.c | 2 +-
tools/perf/builtin-sched.c | 2 +-
tools/perf/builtin-script.c | 2 +-
tools/perf/builtin-stat.c | 2 +-
tools/perf/builtin-timechart.c | 2 +-
tools/perf/builtin-top.c | 2 +-
tools/perf/builtin.h | 2 +-
tools/perf/perf.c | 21 +++++++---
tools/perf/perf.h | 2 +-
tools/perf/util/annotate.c | 2 +-
tools/perf/util/annotate.h | 2 +-
tools/perf/util/build-id.c | 2 +-
tools/perf/util/cache.h | 3 +-
tools/perf/util/callchain.c | 2 +-
tools/perf/util/cgroup.c | 4 +-
tools/perf/util/config.c | 2 +-
tools/perf/util/cpumap.c | 2 +-
tools/perf/util/debug.c | 2 +-
tools/perf/util/evlist.c | 2 +-
tools/perf/util/evsel.c | 2 +-
tools/perf/util/evsel.h | 2 +-
tools/perf/util/header.c | 2 +-
tools/perf/util/header.h | 2 +-
tools/perf/util/hist.c | 2 +-
tools/perf/util/include/linux/ctype.h | 2 +-
tools/perf/util/map.h | 2 +-
tools/perf/util/parse-events.c | 4 +-
tools/perf/util/parse-options.c | 2 +-
tools/perf/util/probe-event.c | 4 +-
tools/perf/util/probe-finder.c | 2 +-
tools/perf/util/probe-finder.h | 2 +-
tools/perf/util/pstack.c | 2 +-
.../perf/util/scripting-engines/trace-event-perl.c | 2 +-
.../util/scripting-engines/trace-event-python.c | 2 +-
tools/perf/util/session.c | 2 +-
tools/perf/util/setup.py | 2 +-
tools/perf/util/sort.h | 2 +-
tools/perf/util/strfilter.c | 2 +-
tools/perf/util/string.c | 2 +-
tools/perf/util/svghelper.h | 2 +-
tools/perf/util/thread.c | 2 +-
tools/perf/util/top.h | 2 +-
tools/perf/util/trace-event-scripting.c | 2 +-
tools/perf/util/ui/browser.c | 2 +-
tools/perf/util/ui/browser.h | 2 +-
tools/perf/util/ui/browsers/hists.c | 2 +-
tools/perf/util/values.c | 2 +-
tools/perf/util/values.h | 2 +-
tools/perf/util/xyarray.c | 2 +-
74 files changed, 150 insertions(+), 94 deletions(-)
create mode 100644 tools/lib/lk/Makefile
rename tools/{perf/util => lib/lk}/debugfs.c (99%)
rename tools/{perf/util => lib/lk}/debugfs.h (85%)
rename tools/{perf/util => lib/lk}/types.h (83%)
rename tools/{perf/util => lib/lk}/usage.c (100%)
rename tools/{perf/util => lib/lk}/util.c (98%)
rename tools/{perf/util => lib/lk}/util.h (100%)
create mode 100644 tools/lib/perf/shared.htools/Makefile +8 -1
@@ -9,12 +9,18 @@ BASIC_CFLAGS = -I$(CURDIR)/lib BASIC_CFLAGS += -I$(CURDIR)/perf/util/include export BASIC_CFLAGS -perf: libtrace .FORCE +PYRF_OBJS = +export PYRF_OBJS + +perf: libtrace liblk .FORCE $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) firewire: .FORCE $(QUIET_SUBDIR0)firewire/ $(QUIET_SUBDIR1) +liblk: .FORCE + $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) + libtrace: .FORCE $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1)
@@ -36,6 +42,7 @@ x86_energy: .FORCE clean: $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)firewire/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)power/x86/turbostat/ $(QUIET_SUBDIR1) clean
tools/lib/lk/Makefile new file +41 -0
41 lines not on this page · raw message
tools/lib/lk/debugfs.c renamed from tools/perf/util/debugfs.c +1 -1
@@ -1,6 +1,6 @@#include "util.h" #include "debugfs.h" -#include "cache.h" +#include <perf/shared.h> static int debugfs_premounted;static char debugfs_mountpoint[MAX_PATH +1 ];
tools/lib/lk/debugfs.h renamed from tools/perf/util/debugfs.h +4 -3
@@ -1,7 +1,8 @@ -#ifndef __DEBUGFS_H__ -#define __DEBUGFS_H__ +#ifndef __LK_DEBUGFS_H__ +#define __LK_DEBUGFS_H__#include <sys/mount.h> +#include <sys/types.h> #ifndef MAX_PATH # define MAX_PATH 256
@@ -22,4 +23,4 @@ extern int debugfs_read(const char *entry, char *buffer, size_t size);extern void debugfs_force_cleanup (void );extern int debugfs_make_path (const char *element,char *buffer,int size); -#endif /* __DEBUGFS_H__ */ +#endif /* __LK_DEBUGFS_H__ */
tools/lib/lk/types.h renamed from tools/perf/util/types.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef __PERF_TYPES_H -#define __PERF_TYPES_H +#ifndef __LK_TYPES_H +#define __LK_TYPES_H#include <stdint.h>
@@ -16,4 +16,4 @@ typedef signed short s16;typedef unsigned char u8 ;typedef signed char s8 ; -#endif /* __PERF_TYPES_H */ +#endif /* __LK_TYPES_H */
tools/lib/lk/usage.c renamed from tools/perf/util/usage.c +0 -0
tools/lib/lk/util.c renamed from tools/perf/util/util.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include <sys/mman.h> int mkdir_p (char *path,mode_t mode)
tools/lib/lk/util.h renamed from tools/perf/util/util.h +0 -0
tools/lib/perf/shared.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __PERF_SHARED_H +#define __PERF_SHARED_H + +/* +* Common defines shared between perf and the libs +*/ +#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" + +#endif /* __PERF_SHARED_H */
tools/lib/trace/event-info.c +1 -1
@@ -39,7 +39,7 @@#include "../../perf/perf.h" #include "trace-event.h" -#include "../perf/util/debugfs.h" +#include <lk/debugfs.h> #include "../perf/util/evsel.h" #define VERSION "0.5"
tools/lib/trace/event-parse.c +1 -1
@@ -30,7 +30,7 @@#undef _GNU_SOURCE#include "../../perf/perf.h" -#include "../../perf/util/util.h" +#include <lk/util.h> #include "trace-event.h" int header_page_ts_offset;
tools/lib/trace/event-read.c +1 -1
@@ -37,7 +37,7 @@#include <errno.h> #include "../../perf/perf.h" -#include "../../perf/util/util.h" +#include <lk/util.h> #include "trace-event.h" static int input_fd;
tools/perf/Makefile +1 -8
@@ -176,7 +176,7 @@ export PERL_PATH LIB_FILE=$(OUTPUT)libperf.a -EXTRA_LIBS=$(LIB_OUTPUT)libtrace.a +EXTRA_LIBS=$(LIB_OUTPUT)libtrace.a $(LIB_OUTPUT)liblk.a LIB_H += ../../include/linux/perf_event.h LIB_H += ../../include/linux/rbtree.h
@@ -212,18 +212,15 @@ LIB_H += util/cache.h LIB_H += util/callchain.h LIB_H += util/build-id.h LIB_H += util/debug.h -LIB_H += util/debugfs.h LIB_H += util/event.h LIB_H += util/evsel.h LIB_H += util/evlist.h LIB_H += util/exec_cmd.h -LIB_H += util/types.h LIB_H += util/levenshtein.h LIB_H += util/map.h LIB_H += util/parse-options.h LIB_H += util/parse-events.h LIB_H += util/quote.h -LIB_H += util/util.h LIB_H += util/xyarray.h LIB_H += util/header.h LIB_H += util/help.h
@@ -255,7 +252,6 @@ LIB_OBJS += $(OUTPUT)util/annotate.o LIB_OBJS += $(OUTPUT)util/build-id.o LIB_OBJS += $(OUTPUT)util/config.o LIB_OBJS += $(OUTPUT)util/ctype.o -LIB_OBJS += $(OUTPUT)util/debugfs.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/evlist.o
@@ -276,7 +272,6 @@ LIB_OBJS += $(OUTPUT)util/string.o LIB_OBJS += $(OUTPUT)util/strlist.o LIB_OBJS += $(OUTPUT)util/strfilter.o LIB_OBJS += $(OUTPUT)util/top.o -LIB_OBJS += $(OUTPUT)util/usage.o LIB_OBJS += $(OUTPUT)util/wrapper.o LIB_OBJS += $(OUTPUT)util/sigchain.o LIB_OBJS += $(OUTPUT)util/symbol.o
@@ -296,7 +291,6 @@ LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o LIB_OBJS += $(OUTPUT)util/hist.o LIB_OBJS += $(OUTPUT)util/probe-event.o -LIB_OBJS += $(OUTPUT)util/util.o LIB_OBJS += $(OUTPUT)util/xyarray.o LIB_OBJS += $(OUTPUT)util/cpumap.o LIB_OBJS += $(OUTPUT)util/cgroup.o
@@ -346,7 +340,6 @@ PYRF_OBJS += $(OUTPUT)util/evlist.o PYRF_OBJS += $(OUTPUT)util/evsel.o PYRF_OBJS += $(OUTPUT)util/python.o PYRF_OBJS += $(OUTPUT)util/thread_map.o -PYRF_OBJS += $(OUTPUT)util/util.o PYRF_OBJS += $(OUTPUT)util/xyarray.o #
tools/perf/bench/mem-memcpy.c +1 -1
@@ -8,7 +8,7 @@#include <ctype.h> #include "../perf.h" -#include "../util/util.h" +#include <lk/util.h> #include "../util/parse-options.h" #include "../util/header.h" #include "bench.h"
tools/perf/bench/sched-messaging.c +1 -1
@@ -10,7 +10,7 @@*/ #include "../perf.h" -#include "../util/util.h" +#include <lk/util.h> #include "../util/parse-options.h" #include "../builtin.h" #include "bench.h"
tools/perf/bench/sched-pipe.c +1 -1
@@ -11,7 +11,7 @@*/ #include "../perf.h" -#include "../util/util.h" +#include <lk/util.h> #include "../util/parse-options.h" #include "../builtin.h" #include "bench.h"
tools/perf/builtin-annotate.c +2 -2
@@ -7,9 +7,9 @@*/ #include "builtin.h" -#include "util/util.h" +#include <lk/util.h> -#include "util/util.h" +#include <lk/util.h> #include "util/color.h" #include <linux/list.h> #include "util/cache.h"
tools/perf/builtin-bench.c +1 -1
@@ -17,7 +17,7 @@*/ #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/parse-options.h" #include "builtin.h" #include "bench/bench.h"
tools/perf/builtin-diff.c +1 -1
@@ -12,7 +12,7 @@#include "util/session.h" #include "util/sort.h" #include "util/symbol.h" -#include "util/util.h" +#include <lk/util.h> #include <stdlib.h>
tools/perf/builtin-evlist.c +1 -2
@@ -4,8 +4,7 @@*/ #include "builtin.h" -#include "util/util.h" - +#include <lk/util.h> #include <linux/list.h> #include "perf.h"
tools/perf/builtin-kmem.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-kvm.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-lock.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-probe.c +2 -2
@@ -34,12 +34,12 @@#undef _GNU_SOURCE#include "perf.h" #include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/strlist.h" #include "util/strfilter.h" #include "util/symbol.h" #include "util/debug.h" -#include "util/debugfs.h" +#include <lk/debugfs.h> #include "util/parse-options.h" #include "util/probe-finder.h" #include "util/probe-event.h"
tools/perf/builtin-record.c +1 -1
@@ -12,7 +12,7 @@#include "perf.h" #include "util/build-id.h" -#include "util/util.h" +#include <lk/util.h> #include "util/parse-options.h" #include "util/parse-events.h"
tools/perf/builtin-report.c +1 -1
@@ -7,7 +7,7 @@*/ #include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/annotate.h" #include "util/color.h"
tools/perf/builtin-sched.c +1 -1
@@ -1,7 +1,7 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" +#include <lk/util.h> #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
tools/perf/builtin-script.c +1 -1
@@ -11,7 +11,7 @@#include "util/thread.h" #include <trace/trace-event.h> #include "util/parse-options.h" -#include "util/util.h" +#include <lk/util.h> #include "util/evlist.h" #include "util/evsel.h"
tools/perf/builtin-stat.c +1 -1
@@ -39,7 +39,7 @@#include "perf.h" #include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/parse-options.h" #include "util/parse-events.h" #include "util/event.h"
tools/perf/builtin-timechart.c +1 -1
@@ -14,7 +14,7 @@#include "builtin.h" -#include "util/util.h" +#include <lk/util.h> #include "util/color.h" #include <linux/list.h>
tools/perf/builtin-top.c +1 -1
@@ -30,7 +30,7 @@#include "util/thread.h" #include "util/thread_map.h" #include "util/top.h" -#include "util/util.h" +#include <lk/util.h> #include <linux/rbtree.h> #include "util/parse-options.h" #include "util/parse-events.h"
tools/perf/builtin.h +1 -1
@@ -1,7 +1,7 @@#ifndef BUILTIN_H #define BUILTIN_H -#include "util/util.h" +#include <lk/util.h> #include "util/strbuf.h" extern const char perf_version_string[];
tools/perf/perf.c +14 -7
@@ -13,7 +13,8 @@#include "util/quote.h" #include "util/run-command.h" #include "util/parse-events.h" -#include "util/debugfs.h" +#include <lk/debugfs.h> +#include <perf/shared.h> const char perf_usage_string[] ="perf [--version] [--help] COMMAND [ARGS]" ;
@@ -417,14 +418,17 @@ static int run_argv(int *argcp, const char ***argv) }/* mini /proc/mounts parser: searching for "^blah /mount/point debugfs" */ -static void get_debugfs_mntpt (void ) +static bool get_debugfs_mntpt (void ) {const char *path =debugfs_mount (NULL ); -if (path) +if (path) {strncpy (debugfs_mntpt, path,sizeof (debugfs_mntpt)); -else - debugfs_mntpt[0 ] ='\0' ; +return true; + } + + debugfs_mntpt[0 ] ='\0' ; +return false; }int main (int argc,const char **argv)
@@ -434,8 +438,11 @@ int main(int argc, const char **argv) cmd =perf_extract_argv0_path (argv[0 ]);if (!cmd) cmd ="perf-help" ; -/* get debugfs mount point from /proc/mounts */ -get_debugfs_mntpt (); + +/* Establish a debugfs mountpoint */ +if (!get_debugfs_mntpt ()) +die ("cannot find valid debugfs mountpoint" ); +/* * "perf-xxxx" is the same as "perf xxxx", but we obviously: *
tools/perf/perf.h +1 -1
@@ -91,7 +91,7 @@ void get_term_dimensions(struct winsize *ws);#include <sys/syscall.h> #include "../../include/linux/perf_event.h" -#include "util/types.h" +#include <lk/types.h> #include <stdbool.h> struct perf_mmap {
tools/perf/util/annotate.c +1 -1
@@ -7,7 +7,7 @@* Released under the GPL v2. (and only v2, not any later version) */ -#include "util.h" +#include <lk/util.h> #include "build-id.h" #include "color.h" #include "cache.h"
tools/perf/util/annotate.h +1 -1
@@ -2,7 +2,7 @@#define __PERF_ANNOTATE_H#include <stdbool.h> -#include "types.h" +#include <lk/types.h> #include "symbol.h" #include <linux/list.h> #include <linux/rbtree.h>
tools/perf/util/build-id.c +1 -1
@@ -6,7 +6,7 @@* Copyright (C) 2009, 2010 Red Hat Inc. * Copyright (C) 2009, 2010 Arnaldo Carvalho de Melo <[email protected]> */ -#include "util.h" +#include <lk/util.h> #include <stdio.h> #include "build-id.h" #include "event.h"
tools/perf/util/cache.h +1 -2
@@ -2,7 +2,7 @@#define __PERF_CACHE_H#include <stdbool.h> -#include "util.h" +#include <lk/util.h> #include "strbuf.h" #include "../perf.h" #include <linux/compiler.h>
@@ -16,7 +16,6 @@#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf" -#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"typedef int (*config_fn_t )(const char *,const char *,void *);extern int perf_default_config (const char *,const char *,void *);
tools/perf/util/callchain.c +1 -1
@@ -15,7 +15,7 @@#include <errno.h> #include <math.h> -#include "util.h" +#include <lk/util.h> #include "callchain.h" bool ip_callchain__valid(struct ip_callchain *chain,
tools/perf/util/cgroup.c +2 -2
@@ -1,9 +1,9 @@ -#include "util.h" +#include <lk/util.h> #include "../perf.h" #include "parse-options.h" #include "evsel.h" #include "cgroup.h" -#include "debugfs.h" /* MAX_PATH, STR() */ +#include <lk/debugfs.h> /* MAX_PATH, STR() */ #include "evlist.h" int nr_cgroups;
tools/perf/util/config.c +1 -1
@@ -5,7 +5,7 @@* Copyright (C) Johannes Schindelin, 2005 * */ -#include "util.h" +#include <lk/util.h> #include "cache.h" #include "exec_cmd.h"
tools/perf/util/cpumap.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "../perf.h" #include "cpumap.h" #include <assert.h>
tools/perf/util/debug.c +1 -1
@@ -10,7 +10,7 @@#include "color.h" #include "event.h" #include "debug.h" -#include "util.h" +#include <lk/util.h> int verbose;bool dump_trace = false, quiet = false;
tools/perf/util/evlist.c +1 -1
@@ -11,8 +11,8 @@#include "thread_map.h" #include "evlist.h" #include "evsel.h" -#include "util.h" #include "debug.h" +#include <lk/util.h> #include <sys/mman.h>
tools/perf/util/evsel.c +1 -1
@@ -9,7 +9,7 @@#include "evsel.h" #include "evlist.h" -#include "util.h" +#include <lk/util.h> #include "cpumap.h" #include "thread_map.h"
tools/perf/util/evsel.h +1 -1
@@ -4,7 +4,7 @@#include <linux/list.h> #include <stdbool.h> #include "../../../include/linux/perf_event.h" -#include "types.h" +#include <lk/types.h> #include "xyarray.h" #include "cgroup.h" #include "hist.h"
tools/perf/util/header.c +1 -1
@@ -10,7 +10,7 @@#include "evlist.h" #include "evsel.h" -#include "util.h" +#include <lk/util.h> #include "header.h" #include "../perf.h" #include <trace/trace-event.h>
tools/perf/util/header.h +1 -1
@@ -4,7 +4,7 @@#include "../../../include/linux/perf_event.h" #include <sys/types.h> #include <stdbool.h> -#include "types.h" +#include <lk/types.h> #include "event.h" #include <linux/bitmap.h>
tools/perf/util/hist.c +1 -1
@@ -1,5 +1,5 @@#include "annotate.h" -#include "util.h" +#include <lk/util.h> #include "build-id.h" #include "hist.h" #include "session.h"
tools/perf/util/include/linux/ctype.h +1 -1
@@ -1 +1 @@ -#include "../util.h" +#include <lk/util.h>
tools/perf/util/map.h +1 -1
@@ -6,7 +6,7 @@#include <linux/rbtree.h> #include <stdio.h> #include <stdbool.h> -#include "types.h" +#include <lk/types.h> enum map_type {MAP__FUNCTION =0 ,
tools/perf/util/parse-events.c +2 -2
@@ -1,5 +1,5 @@#include "../../../include/linux/hw_breakpoint.h" -#include "util.h" +#include <lk/util.h> #include "../perf.h" #include "evlist.h" #include "evsel.h"
@@ -10,7 +10,7 @@#include "symbol.h" #include "cache.h" #include "header.h" -#include "debugfs.h" +#include <lk/debugfs.h> struct event_symbol {u8 type;
tools/perf/util/parse-options.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "parse-options.h" #include "cache.h"
tools/perf/util/probe-event.c +2 -2
@@ -34,7 +34,7 @@#include <elf.h> #undef _GNU_SOURCE -#include "util.h" +#include <lk/util.h> #include "event.h" #include "string.h" #include "strlist.h"
@@ -43,7 +43,7 @@#include "color.h" #include "symbol.h" #include "thread.h" -#include "debugfs.h" +#include <lk/debugfs.h> #include <trace/trace-event.h> /* For __unused */ #include "probe-event.h" #include "probe-finder.h"
tools/perf/util/probe-finder.c +1 -1
@@ -36,7 +36,7 @@#include <linux/bitops.h> #include "event.h" #include "debug.h" -#include "util.h" +#include <lk/util.h> #include "symbol.h" #include "probe-finder.h"
tools/perf/util/probe-finder.h +1 -1
@@ -2,7 +2,7 @@#define _PROBE_FINDER_H#include <stdbool.h> -#include "util.h" +#include <lk/util.h> #include "probe-event.h" #define MAX_PATH_LEN 256
tools/perf/util/pstack.c +1 -1
@@ -4,7 +4,7 @@* (c) 2010 Arnaldo Carvalho de Melo <[email protected]> */ -#include "util.h" +#include <lk/util.h> #include "pstack.h" #include <linux/kernel.h> #include <stdlib.h>
tools/perf/util/scripting-engines/trace-event-perl.c +1 -1
@@ -26,7 +26,7 @@#include <errno.h> #include "../../perf.h" -#include "../util.h" +#include <lk/util.h> #include <trace/trace-event.h> #include <EXTERN.h>
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -28,7 +28,7 @@#include <errno.h> #include "../../perf.h" -#include "../util.h" +#include <lk/util.h> #include <trace/trace-event.h> PyMODINIT_FUNC initperf_trace_context (void );
tools/perf/util/session.c +1 -1
@@ -11,7 +11,7 @@#include "evsel.h" #include "session.h" #include "sort.h" -#include "util.h" +#include <lk/util.h> static int perf_session__open (struct perf_session *self,bool force) {
tools/perf/util/setup.py +1 -1
@@ -9,7 +9,7 @@ cflags += getenv('CFLAGS', '').split() perf = Extension('perf', sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', 'util/evsel.c', 'util/cpumap.c', 'util/thread_map.c', - 'util/util.c', 'util/xyarray.c', 'util/cgroup.c'], + '../lib/lk/util.c', 'util/xyarray.c', 'util/cgroup.c'], include_dirs = ['util/include'], extra_compile_args = cflags, )
tools/perf/util/sort.h +1 -1
@@ -2,7 +2,7 @@#define __PERF_SORT_H#include "../builtin.h" -#include "util.h" +#include <lk/util.h> #include "color.h" #include <linux/list.h>
tools/perf/util/strfilter.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "string.h" #include "strfilter.h"
tools/perf/util/string.c +1 -1
@@ -1,4 +1,4 @@ -#include "util.h" +#include <lk/util.h> #include "string.h" #define K 1024LL
tools/perf/util/svghelper.h +1 -1
@@ -1,7 +1,7 @@#ifndef __PERF_SVGHELPER_H#define __PERF_SVGHELPER_H -#include "types.h" +#include <lk/types.h> extern void open_svg (const char *filename,int cpus,int rows,u64 start,u64 end);extern void svg_box (int Yslot,u64 start,u64 end,const char *type);
tools/perf/util/thread.c +1 -1
@@ -4,7 +4,7 @@#include <string.h> #include "session.h" #include "thread.h" -#include "util.h" +#include <lk/util.h> #include "debug.h" static struct thread *thread__new (pid_t pid)
tools/perf/util/top.h +1 -1
@@ -1,7 +1,7 @@#ifndef __PERF_TOP_H#define __PERF_TOP_H 1 -#include "types.h" +#include <lk/types.h> #include "../perf.h" #include <stddef.h> #include <pthread.h>
tools/perf/util/trace-event-scripting.c +1 -1
@@ -26,7 +26,7 @@#include <errno.h> #include "../perf.h" -#include "util.h" +#include <lk/util.h> #include <trace/trace-event.h> struct scripting_context *scripting_context;
tools/perf/util/ui/browser.c +1 -1
@@ -8,7 +8,7 @@#include "browser.h" #include "helpline.h" #include "../color.h" -#include "../util.h" +#include <lk/util.h> #include <stdio.h> static int ui_browser__percent_color (double percent,bool current)
tools/perf/util/ui/browser.h +1 -1
@@ -4,7 +4,7 @@#include <stdbool.h> #include <newt.h> #include <sys/types.h> -#include "../types.h" +#include <lk/types.h> #define HE_COLORSET_TOP 50#define HE_COLORSET_MEDIUM 51
tools/perf/util/ui/browsers/hists.c +1 -1
@@ -12,7 +12,7 @@#include "../../hist.h" #include "../../pstack.h" #include "../../sort.h" -#include "../../util.h" +#include <lk/util.h> #include "../browser.h" #include "../helpline.h"
tools/perf/util/values.c +1 -1
@@ -1,6 +1,6 @@#include <stdlib.h> -#include "util.h" +#include <lk/util.h> #include "values.h" void perf_read_values_init (struct perf_read_values *values)
tools/perf/util/values.h +1 -1
@@ -1,7 +1,7 @@ #ifndef __PERF_VALUES_H #define __PERF_VALUES_H -#include "types.h" +#include <lk/types.h> struct perf_read_values { int threads;
tools/perf/util/xyarray.c +1 -1
@@ -1,5 +1,5 @@#include "xyarray.h" -#include "util.h" +#include <lk/util.h> struct xyarray *xyarray__new (int xlen,int ylen,size_t entry_size) {
Signature · 1 line
1.7.4.rc2
PATCH 11/18 perf: Export cpumap.[ch]
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Put it into the generic part of the lib since it is tool-agnostic.
---
tools/lib/lk/Makefile | 3 +++
tools/{perf/util => lib/lk}/cpumap.c | 2 +-
tools/{perf/util => lib/lk}/cpumap.h | 6 +++---
tools/perf/Makefile | 4 ----
tools/perf/builtin-record.c | 2 +-
tools/perf/builtin-stat.c | 2 +-
tools/perf/builtin-test.c | 2 +-
tools/perf/builtin-top.c | 2 +-
tools/perf/util/evlist.c | 2 +-
tools/perf/util/evsel.c | 2 +-
tools/perf/util/python.c | 2 +-
tools/perf/util/setup.py | 4 ++--
tools/perf/util/top.c | 2 +-
13 files changed, 17 insertions(+), 18 deletions(-)
rename tools/{perf/util => lib/lk}/cpumap.c (99%)
rename tools/{perf/util => lib/lk}/cpumap.h (70%)tools/lib/lk/Makefile +3 -0
@@ -7,12 +7,15 @@ LIB_OBJS= LIB_H += debugfs.h LIB_H += util.h LIB_H += types.h +LIB_H += cpumap.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o LIB_OBJS += util.o +LIB_OBJS += cpumap.o PYRF_OBJS += util.o +PYRF_OBJS += cpumap.o LIBFILE = $(LIB_OUTPUT)liblk.a
tools/lib/lk/cpumap.c renamed from tools/perf/util/cpumap.c +1 -1
@@ -1,5 +1,5 @@#include <lk/util.h> -#include "../perf.h" +#include "../../perf/perf.h" #include "cpumap.h" #include <assert.h> #include <stdio.h>
tools/lib/lk/cpumap.h renamed from tools/perf/util/cpumap.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef __PERF_CPUMAP_H -#define __PERF_CPUMAP_H +#ifndef __LK_CPUMAP_H +#define __LK_CPUMAP_H struct cpu_map { int nr;
@@ -10,4 +10,4 @@ struct cpu_map *cpu_map__new(const char *cpu_list);struct cpu_map *cpu_map__dummy_new (void );void cpu_map__delete (struct cpu_map *map); -#endif /* __PERF_CPUMAP_H */ +#endif /* __LK_CPUMAP_H */
tools/perf/Makefile +0 -4
@@ -131,7 +131,6 @@ BASIC_LDFLAGS = BUILTIN_OBJS = LIB_H = LIB_OBJS = -PYRF_OBJS = SCRIPT_SH = EXTRA_LIBS =
@@ -241,7 +240,6 @@ LIB_H += util/thread_map.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h LIB_H += util/pstack.h -LIB_H += util/cpumap.h LIB_H += util/top.h LIB_H += $(ARCH_INCLUDE) LIB_H += util/cgroup.h
@@ -292,7 +290,6 @@ LIB_OBJS += $(OUTPUT)util/sort.o LIB_OBJS += $(OUTPUT)util/hist.o LIB_OBJS += $(OUTPUT)util/probe-event.o LIB_OBJS += $(OUTPUT)util/xyarray.o -LIB_OBJS += $(OUTPUT)util/cpumap.o LIB_OBJS += $(OUTPUT)util/cgroup.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
@@ -334,7 +331,6 @@ PERFLIBS = $(LIB_FILE) $(EXTRA_LIBS) # This has to be in sync with what is in the 'sources' variable in # tools/perf/util/setup.py -PYRF_OBJS += $(OUTPUT)util/cpumap.o PYRF_OBJS += $(OUTPUT)util/ctype.o PYRF_OBJS += $(OUTPUT)util/evlist.o PYRF_OBJS += $(OUTPUT)util/evsel.o
tools/perf/builtin-record.c +1 -1
@@ -23,7 +23,7 @@#include "util/debug.h" #include "util/session.h" #include "util/symbol.h" -#include "util/cpumap.h" +#include <lk/cpumap.h> #include "util/thread_map.h" #include <unistd.h>
tools/perf/builtin-stat.c +1 -1
@@ -47,7 +47,7 @@#include "util/evsel.h" #include "util/debug.h" #include "util/header.h" -#include "util/cpumap.h" +#include <lk/cpumap.h> #include "util/thread.h" #include "util/thread_map.h"
tools/perf/builtin-test.c +1 -1
@@ -235,7 +235,7 @@ out:return err; } -#include "util/cpumap.h" +#include <lk/cpumap.h> #include "util/evsel.h" #include <sys/types.h>
tools/perf/builtin-top.c +1 -1
@@ -34,7 +34,7 @@#include <linux/rbtree.h> #include "util/parse-options.h" #include "util/parse-events.h" -#include "util/cpumap.h" +#include <lk/cpumap.h> #include "util/xyarray.h" #include "util/debug.h"
tools/perf/util/evlist.c +1 -1
@@ -7,7 +7,7 @@* Released under the GPL v2. (and only v2, not any later version) */ #include <poll.h> -#include "cpumap.h" +#include <lk/cpumap.h> #include "thread_map.h" #include "evlist.h" #include "evsel.h"
tools/perf/util/evsel.c +1 -1
@@ -10,7 +10,7 @@#include "evsel.h" #include "evlist.h" #include <lk/util.h> -#include "cpumap.h" +#include <lk/cpumap.h> #include "thread_map.h" void perf_evsel__init(struct perf_evsel *evsel,
tools/perf/util/python.c +1 -1
@@ -5,7 +5,7 @@#include "evlist.h" #include "evsel.h" #include "event.h" -#include "cpumap.h" +#include <lk/cpumap.h> #include "thread_map.h" /* Define PyVarObject_HEAD_INIT for python 2.5 */
tools/perf/util/setup.py +2 -2
@@ -8,9 +8,9 @@ cflags += getenv('CFLAGS', '').split() perf = Extension('perf', sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', - 'util/evsel.c', 'util/cpumap.c', 'util/thread_map.c', + 'util/evsel.c', '../lib/lk/cpumap.c', 'util/thread_map.c', '../lib/lk/util.c', 'util/xyarray.c', 'util/cgroup.c'], - include_dirs = ['util/include'], + include_dirs = ['util/include', '../lib'], extra_compile_args = cflags, )
tools/perf/util/top.c +1 -1
@@ -6,7 +6,7 @@* Released under the GPL v2. (and only v2, not any later version) */ -#include "cpumap.h" +#include <lk/cpumap.h> #include "event.h" #include "evlist.h" #include "evsel.h"
Signature · 1 line
1.7.4.rc2
PATCH 12/18 perf: Export thread_map.[ch]
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Export into generic code since tool-agnostic and reusable.
---
tools/lib/lk/Makefile | 3 +++
tools/{perf/util => lib/lk}/thread_map.c | 0
tools/{perf/util => lib/lk}/thread_map.h | 6 +++---
tools/perf/Makefile | 3 ---
tools/perf/builtin-record.c | 2 +-
tools/perf/builtin-stat.c | 2 +-
tools/perf/builtin-test.c | 2 +-
tools/perf/builtin-top.c | 2 +-
tools/perf/util/event.c | 2 +-
tools/perf/util/evlist.c | 2 +-
tools/perf/util/evsel.c | 2 +-
tools/perf/util/python.c | 2 +-
tools/perf/util/setup.py | 2 +-
13 files changed, 15 insertions(+), 15 deletions(-)
rename tools/{perf/util => lib/lk}/thread_map.c (100%)
rename tools/{perf/util => lib/lk}/thread_map.h (76%)tools/lib/lk/Makefile +3 -0
@@ -8,14 +8,17 @@ LIB_H += debugfs.h LIB_H += util.h LIB_H += types.h LIB_H += cpumap.h +LIB_H += thread_map.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o LIB_OBJS += util.o LIB_OBJS += cpumap.o +LIB_OBJS += thread_map.o PYRF_OBJS += util.o PYRF_OBJS += cpumap.o +PYRF_OBJS += thread_map.o LIBFILE = $(LIB_OUTPUT)liblk.a
tools/lib/lk/thread_map.c renamed from tools/perf/util/thread_map.c +0 -0
tools/lib/lk/thread_map.h renamed from tools/perf/util/thread_map.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef __PERF_THREAD_MAP_H -#define __PERF_THREAD_MAP_H +#ifndef __LK_THREAD_MAP_H +#define __LK_THREAD_MAP_H#include <sys/types.h>
@@ -12,4 +12,4 @@ struct thread_map *thread_map__new_by_pid(pid_t pid);struct thread_map *thread_map__new_by_tid (pid_t tid);struct thread_map *thread_map__new (pid_t pid,pid_t tid);void thread_map__delete (struct thread_map *threads); -#endif /* __PERF_THREAD_MAP_H */ +#endif /* __LK_THREAD_MAP_H */
tools/perf/Makefile +0 -3
@@ -236,7 +236,6 @@ LIB_H += util/values.h LIB_H += util/sort.h LIB_H += util/hist.h LIB_H += util/thread.h -LIB_H += util/thread_map.h LIB_H += util/probe-finder.h LIB_H += util/probe-event.h LIB_H += util/pstack.h
@@ -283,7 +282,6 @@ LIB_OBJS += $(OUTPUT)util/map.o LIB_OBJS += $(OUTPUT)util/pstack.o LIB_OBJS += $(OUTPUT)util/session.o LIB_OBJS += $(OUTPUT)util/thread.o -LIB_OBJS += $(OUTPUT)util/thread_map.o LIB_OBJS += $(OUTPUT)util/trace-event-scripting.o LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o
@@ -335,7 +333,6 @@ PYRF_OBJS += $(OUTPUT)util/ctype.o PYRF_OBJS += $(OUTPUT)util/evlist.o PYRF_OBJS += $(OUTPUT)util/evsel.o PYRF_OBJS += $(OUTPUT)util/python.o -PYRF_OBJS += $(OUTPUT)util/thread_map.o PYRF_OBJS += $(OUTPUT)util/xyarray.o #
tools/perf/builtin-record.c +1 -1
@@ -24,7 +24,7 @@#include "util/session.h" #include "util/symbol.h" #include <lk/cpumap.h> -#include "util/thread_map.h" +#include <lk/thread_map.h> #include <unistd.h> #include <sched.h>
tools/perf/builtin-stat.c +1 -1
@@ -49,7 +49,7 @@#include "util/header.h" #include <lk/cpumap.h> #include "util/thread.h" -#include "util/thread_map.h" +#include <lk/thread_map.h> #include <sys/prctl.h> #include <math.h>
tools/perf/builtin-test.c +1 -1
@@ -11,7 +11,7 @@#include "util/parse-options.h" #include "util/parse-events.h" #include "util/symbol.h" -#include "util/thread_map.h" +#include <lk/thread_map.h> static long page_size;
tools/perf/builtin-top.c +1 -1
@@ -28,7 +28,7 @@#include "util/session.h" #include "util/symbol.h" #include "util/thread.h" -#include "util/thread_map.h" +#include <lk/thread_map.h> #include "util/top.h" #include <lk/util.h> #include <linux/rbtree.h>
tools/perf/util/event.c +1 -1
@@ -6,7 +6,7 @@#include "string.h" #include "strlist.h" #include "thread.h" -#include "thread_map.h" +#include <lk/thread_map.h> static const char *perf_event__names[] = { [0 ] ="TOTAL" ,
tools/perf/util/evlist.c +1 -1
@@ -8,7 +8,7 @@*/ #include <poll.h> #include <lk/cpumap.h> -#include "thread_map.h" +#include <lk/thread_map.h> #include "evlist.h" #include "evsel.h" #include "debug.h"
tools/perf/util/evsel.c +1 -1
@@ -11,7 +11,7 @@#include "evlist.h" #include <lk/util.h> #include <lk/cpumap.h> -#include "thread_map.h" +#include <lk/thread_map.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr,int idx)
tools/perf/util/python.c +1 -1
@@ -6,7 +6,7 @@#include "evsel.h" #include "event.h" #include <lk/cpumap.h> -#include "thread_map.h" +#include <lk/thread_map.h> /* Define PyVarObject_HEAD_INIT for python 2.5 */ #ifndef PyVarObject_HEAD_INIT
tools/perf/util/setup.py +1 -1
@@ -8,7 +8,7 @@ cflags += getenv('CFLAGS', '').split() perf = Extension('perf', sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', - 'util/evsel.c', '../lib/lk/cpumap.c', 'util/thread_map.c', + 'util/evsel.c', '../lib/lk/cpumap.c', '../lib/lk/thread_map.c', '../lib/lk/util.c', 'util/xyarray.c', 'util/cgroup.c'], include_dirs = ['util/include', '../lib'], extra_compile_args = cflags,
Signature · 1 line
1.7.4.rc2
PATCH 13/18 perf: Export evsel.[ch]
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This is needed by other tools dealing with perf events. Pull in xyarray.[ch] with it.
---
tools/Makefile | 6 +++++-
tools/lib/lk/Makefile | 3 +++
tools/{perf/util => lib/lk}/xyarray.c | 0
tools/{perf/util => lib/lk}/xyarray.h | 6 +++---
tools/lib/{lk => perf}/Makefile | 24 +++++++-----------------
tools/{perf/util => lib/perf}/evsel.c | 2 +-
tools/{perf/util => lib/perf}/evsel.h | 14 +++++++-------
tools/lib/trace/event-info.c | 2 +-
tools/perf/Makefile | 8 +-------
tools/perf/builtin-annotate.c | 2 +-
tools/perf/builtin-evlist.c | 2 +-
tools/perf/builtin-record.c | 2 +-
tools/perf/builtin-report.c | 2 +-
tools/perf/builtin-script.c | 2 +-
tools/perf/builtin-stat.c | 2 +-
tools/perf/builtin-test.c | 2 +-
tools/perf/builtin-top.c | 4 ++--
tools/perf/util/cgroup.c | 2 +-
tools/perf/util/evlist.c | 2 +-
tools/perf/util/header.c | 2 +-
tools/perf/util/parse-events.c | 2 +-
tools/perf/util/python.c | 2 +-
tools/perf/util/session.c | 2 +-
tools/perf/util/setup.py | 4 ++--
tools/perf/util/top.c | 2 +-
tools/perf/util/ui/browsers/hists.c | 2 +-
26 files changed, 47 insertions(+), 56 deletions(-)
rename tools/{perf/util => lib/lk}/xyarray.c (100%)
rename tools/{perf/util => lib/lk}/xyarray.h (81%)
copy tools/lib/{lk => perf}/Makefile (69%)
rename tools/{perf/util => lib/perf}/evsel.c (99%)
rename tools/{perf/util => lib/perf}/evsel.h (96%)tools/Makefile +5 -1
@@ -12,7 +12,7 @@ export BASIC_CFLAGS PYRF_OBJS = export PYRF_OBJS -perf: libtrace liblk .FORCE +perf: libtrace liblkperf liblk .FORCE $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) firewire: .FORCE
@@ -21,6 +21,9 @@ firewire: .FORCE liblk: .FORCE $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) +liblkperf: .FORCE + $(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) + libtrace: .FORCE $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1)
@@ -43,6 +46,7 @@ clean: $(QUIET_SUBDIR0)perf/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)firewire/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)power/x86/turbostat/ $(QUIET_SUBDIR1) clean
tools/lib/lk/Makefile +3 -0
@@ -9,16 +9,19 @@ LIB_H += util.h LIB_H += types.h LIB_H += cpumap.h LIB_H += thread_map.h +LIB_H += xyarray.h LIB_OBJS += debugfs.o LIB_OBJS += usage.o LIB_OBJS += util.o LIB_OBJS += cpumap.o LIB_OBJS += thread_map.o +LIB_OBJS += xyarray.o PYRF_OBJS += util.o PYRF_OBJS += cpumap.o PYRF_OBJS += thread_map.o +PYRF_OBJS += xyarray.o LIBFILE = $(LIB_OUTPUT)liblk.a
tools/lib/lk/xyarray.c renamed from tools/perf/util/xyarray.c +0 -0
tools/lib/lk/xyarray.h renamed from tools/perf/util/xyarray.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef _PERF_XYARRAY_H_ -#define _PERF_XYARRAY_H_ 1 +#ifndef __LK_XYARRAY_H_ +#define __LK_XYARRAY_H_ 1#include <sys/types.h>
@@ -17,4 +17,4 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y) return &xy->contents[x * xy->row_size + y * xy->entry_size]; } -#endif /* _PERF_XYARRAY_H_ */ +#endif /* __LK_XYARRAY_H_ */
tools/lib/perf/Makefile renamed from tools/lib/lk/Makefile +7 -17
@@ -4,23 +4,13 @@ include ../../scripts/Makefile.lib LIB_H= LIB_OBJS= -LIB_H += debugfs.h -LIB_H += util.h -LIB_H += types.h -LIB_H += cpumap.h -LIB_H += thread_map.h - -LIB_OBJS += debugfs.o -LIB_OBJS += usage.o -LIB_OBJS += util.o -LIB_OBJS += cpumap.o -LIB_OBJS += thread_map.o - -PYRF_OBJS += util.o -PYRF_OBJS += cpumap.o -PYRF_OBJS += thread_map.o - -LIBFILE = $(LIB_OUTPUT)liblk.a +LIB_H += evsel.h + +LIB_OBJS += evsel.o + +PYRF_OBJS += evsel.o + +LIBFILE = $(LIB_OUTPUT)liblkperf.a CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) EXTLIBS = -lpthread -lrt -lelf -lm
tools/lib/perf/evsel.c renamed from tools/perf/util/evsel.c +1 -1
@@ -8,7 +8,7 @@*/ #include "evsel.h" -#include "evlist.h" +#include "../../perf/util/evlist.h" #include <lk/util.h> #include <lk/cpumap.h> #include <lk/thread_map.h>
tools/lib/perf/evsel.h renamed from tools/perf/util/evsel.h +7 -7
@@ -5,10 +5,10 @@#include <stdbool.h> #include "../../../include/linux/perf_event.h" #include <lk/types.h> -#include "xyarray.h" -#include "cgroup.h" -#include "hist.h" - +#include <lk/xyarray.h> +#include "../../perf/util/cgroup.h" +#include "../../perf/util/hist.h" + struct perf_counts_values { union { struct {
@@ -21,7 +21,7 @@ struct perf_counts_values { };struct perf_counts { -s8 scaled; +s8 scaled;struct perf_counts_values aggr;struct perf_counts_values cpu[]; };
@@ -33,8 +33,8 @@ struct perf_evsel;* more than one entry in the evlist. */ struct perf_sample_id { -struct hlist_node node; -u64 id; +struct hlist_node node; +u64 id;struct perf_evsel *evsel; };
tools/lib/trace/event-info.c +1 -1
@@ -40,7 +40,7 @@#include "../../perf/perf.h" #include "trace-event.h" #include <lk/debugfs.h> -#include "../perf/util/evsel.h" +#include <perf/evsel.h> #define VERSION "0.5"
tools/perf/Makefile +1 -7
@@ -175,7 +175,7 @@ export PERL_PATH LIB_FILE=$(OUTPUT)libperf.a -EXTRA_LIBS=$(LIB_OUTPUT)libtrace.a $(LIB_OUTPUT)liblk.a +EXTRA_LIBS=$(LIB_OUTPUT)libtrace.a $(LIB_OUTPUT)liblk.a $(LIB_OUTPUT)liblkperf.a LIB_H += ../../include/linux/perf_event.h LIB_H += ../../include/linux/rbtree.h
@@ -212,7 +212,6 @@ LIB_H += util/callchain.h LIB_H += util/build-id.h LIB_H += util/debug.h LIB_H += util/event.h -LIB_H += util/evsel.h LIB_H += util/evlist.h LIB_H += util/exec_cmd.h LIB_H += util/levenshtein.h
@@ -220,7 +219,6 @@ LIB_H += util/map.h LIB_H += util/parse-options.h LIB_H += util/parse-events.h LIB_H += util/quote.h -LIB_H += util/xyarray.h LIB_H += util/header.h LIB_H += util/help.h LIB_H += util/session.h
@@ -252,7 +250,6 @@ LIB_OBJS += $(OUTPUT)util/ctype.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/evlist.o -LIB_OBJS += $(OUTPUT)util/evsel.o LIB_OBJS += $(OUTPUT)util/exec_cmd.o LIB_OBJS += $(OUTPUT)util/help.o LIB_OBJS += $(OUTPUT)util/levenshtein.o
@@ -287,7 +284,6 @@ LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o LIB_OBJS += $(OUTPUT)util/hist.o LIB_OBJS += $(OUTPUT)util/probe-event.o -LIB_OBJS += $(OUTPUT)util/xyarray.o LIB_OBJS += $(OUTPUT)util/cgroup.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
@@ -331,9 +327,7 @@ PERFLIBS = $(LIB_FILE) $(EXTRA_LIBS) PYRF_OBJS += $(OUTPUT)util/ctype.o PYRF_OBJS += $(OUTPUT)util/evlist.o -PYRF_OBJS += $(OUTPUT)util/evsel.o PYRF_OBJS += $(OUTPUT)util/python.o -PYRF_OBJS += $(OUTPUT)util/xyarray.o # # Platform specific tweaks
tools/perf/builtin-annotate.c +1 -1
@@ -20,7 +20,7 @@#include "util/debug.h" #include "util/evlist.h" -#include "util/evsel.h" +#include <perf/evsel.h> #include "util/annotate.h" #include "util/event.h" #include "util/parse-options.h"
tools/perf/builtin-evlist.c +1 -1
@@ -9,7 +9,7 @@#include "perf.h" #include "util/evlist.h" -#include "util/evsel.h" +#include <perf/evsel.h> #include "util/parse-events.h" #include "util/parse-options.h" #include "util/session.h"
tools/perf/builtin-record.c +1 -1
@@ -19,7 +19,7 @@#include "util/header.h" #include "util/event.h" #include "util/evlist.h" -#include "util/evsel.h" +#include <perf/evsel.h> #include "util/debug.h" #include "util/session.h" #include "util/symbol.h"
tools/perf/builtin-report.c +1 -1
@@ -22,7 +22,7 @@#include "perf.h" #include "util/debug.h" #include "util/evlist.h" -#include "util/evsel.h" +#include <perf/evsel.h> #include "util/header.h" #include "util/session.h"
tools/perf/builtin-script.c +1 -1
@@ -13,7 +13,7 @@#include "util/parse-options.h" #include <lk/util.h> #include "util/evlist.h" -#include "util/evsel.h" +#include <perf/evsel.h> static char const *script_name;static char const *generate_script_lang;
tools/perf/builtin-stat.c +1 -1
@@ -44,7 +44,7 @@#include "util/parse-events.h" #include "util/event.h" #include "util/evlist.h" -#include "util/evsel.h" +#include <perf/evsel.h> #include "util/debug.h" #include "util/header.h" #include <lk/cpumap.h>
tools/perf/builtin-test.c +1 -1
@@ -236,7 +236,7 @@ out: }#include <lk/cpumap.h> -#include "util/evsel.h" +#include <perf/evsel.h> #include <sys/types.h> static int trace_event__id (const char *evname)
tools/perf/builtin-top.c +2 -2
@@ -24,7 +24,7 @@#include "util/cache.h" #include "util/color.h" #include "util/evlist.h" -#include "util/evsel.h" +#include <perf/evsel.h> #include "util/session.h" #include "util/symbol.h" #include "util/thread.h"
@@ -35,7 +35,7 @@#include "util/parse-options.h" #include "util/parse-events.h" #include <lk/cpumap.h> -#include "util/xyarray.h" +#include <lk/xyarray.h> #include "util/debug.h"
tools/perf/util/cgroup.c +1 -1
@@ -1,7 +1,7 @@#include <lk/util.h> #include "../perf.h" #include "parse-options.h" -#include "evsel.h" +#include <perf/evsel.h> #include "cgroup.h" #include <lk/debugfs.h> /* MAX_PATH, STR() */ #include "evlist.h"
tools/perf/util/evlist.c +1 -1
@@ -10,7 +10,7 @@#include <lk/cpumap.h> #include <lk/thread_map.h> #include "evlist.h" -#include "evsel.h" +#include <perf/evsel.h> #include "debug.h" #include <lk/util.h>
tools/perf/util/header.c +1 -1
@@ -9,7 +9,7 @@#include <linux/kernel.h> #include "evlist.h" -#include "evsel.h" +#include <perf/evsel.h> #include <lk/util.h> #include "header.h" #include "../perf.h"
tools/perf/util/parse-events.c +1 -1
@@ -2,7 +2,7 @@#include <lk/util.h> #include "../perf.h" #include "evlist.h" -#include "evsel.h" +#include <perf/evsel.h> #include "parse-options.h" #include "parse-events.h" #include "exec_cmd.h"
tools/perf/util/python.c +1 -1
@@ -3,7 +3,7 @@#include <inttypes.h> #include <poll.h> #include "evlist.h" -#include "evsel.h" +#include <perf/evsel.h> #include "event.h" #include <lk/cpumap.h> #include <lk/thread_map.h>
tools/perf/util/session.c +1 -1
@@ -8,7 +8,7 @@#include <sys/mman.h> #include "evlist.h" -#include "evsel.h" +#include <perf/evsel.h> #include "session.h" #include "sort.h" #include <lk/util.h>
tools/perf/util/setup.py +2 -2
@@ -8,8 +8,8 @@ cflags += getenv('CFLAGS', '').split() perf = Extension('perf', sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', - 'util/evsel.c', '../lib/lk/cpumap.c', '../lib/lk/thread_map.c', - '../lib/lk/util.c', 'util/xyarray.c', 'util/cgroup.c'], + '../lib/perf/evsel.c', '../lib/lk/cpumap.c', '../lib/lk/thread_map.c', + '../lib/lk/util.c', '../lib/lk/xyarray.c', 'util/cgroup.c'], include_dirs = ['util/include', '../lib'], extra_compile_args = cflags, )
tools/perf/util/top.c +1 -1
@@ -9,7 +9,7 @@#include <lk/cpumap.h> #include "event.h" #include "evlist.h" -#include "evsel.h" +#include <perf/evsel.h> #include "parse-events.h" #include "symbol.h" #include "top.h"
tools/perf/util/ui/browsers/hists.c +1 -1
@@ -7,7 +7,7 @@#include <newt.h> #include <linux/rbtree.h> -#include "../../evsel.h" +#include <perf/evsel.h> #include "../../evlist.h" #include "../../hist.h" #include "../../pstack.h"
Signature · 1 line
1.7.4.rc2
PATCH 14/18 perf: Export cgroup.[ch]
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This is pulled in by the previous evsel.[ch] export.
---
tools/lib/perf/Makefile | 2 ++
tools/{perf/util => lib/perf}/cgroup.c | 6 +++---
tools/{perf/util => lib/perf}/cgroup.h | 6 +++---
tools/lib/perf/evsel.h | 2 +-
tools/perf/Makefile | 2 --
5 files changed, 9 insertions(+), 9 deletions(-)
rename tools/{perf/util => lib/perf}/cgroup.c (96%)
rename tools/{perf/util => lib/perf}/cgroup.h (76%)tools/lib/perf/Makefile +2 -0
@@ -5,8 +5,10 @@ LIB_H= LIB_OBJS= LIB_H += evsel.h +LIB_H += cgroup.h LIB_OBJS += evsel.o +LIB_OBJS += cgroup.o PYRF_OBJS += evsel.o
tools/lib/perf/cgroup.c renamed from tools/perf/util/cgroup.c +3 -3
@@ -1,10 +1,10 @@#include <lk/util.h> -#include "../perf.h" -#include "parse-options.h" +#include "../../perf/perf.h" +#include "../../perf/util/parse-options.h" #include <perf/evsel.h> #include "cgroup.h" #include <lk/debugfs.h> /* MAX_PATH, STR() */ -#include "evlist.h" +#include "../../perf/util/evlist.h" int nr_cgroups;
tools/lib/perf/cgroup.h renamed from tools/perf/util/cgroup.h +3 -3
@@ -1,5 +1,5 @@ -#ifndef __CGROUP_H__ -#define __CGROUP_H__ +#ifndef __PERF_CGROUP_H__ +#define __PERF_CGROUP_H__struct option ;
@@ -14,4 +14,4 @@ extern int nr_cgroups; /* number of explicit cgroups defined */extern void close_cgroup (struct cgroup_sel *cgrp);extern int parse_cgroups (const struct option *opt,const char *str,int unset); -#endif /* __CGROUP_H__ */ +#endif /* __PERF_CGROUP_H__ */
tools/lib/perf/evsel.h +1 -1
@@ -6,7 +6,7 @@#include "../../../include/linux/perf_event.h" #include <lk/types.h> #include <lk/xyarray.h> -#include "../../perf/util/cgroup.h" +#include "cgroup.h" #include "../../perf/util/hist.h" struct perf_counts_values {
tools/perf/Makefile +0 -2
@@ -239,7 +239,6 @@ LIB_H += util/probe-event.h LIB_H += util/pstack.h LIB_H += util/top.h LIB_H += $(ARCH_INCLUDE) -LIB_H += util/cgroup.h LIB_OBJS += $(OUTPUT)util/abspath.o LIB_OBJS += $(OUTPUT)util/alias.o
@@ -284,7 +283,6 @@ LIB_OBJS += $(OUTPUT)util/svghelper.o LIB_OBJS += $(OUTPUT)util/sort.o LIB_OBJS += $(OUTPUT)util/hist.o LIB_OBJS += $(OUTPUT)util/probe-event.o -LIB_OBJS += $(OUTPUT)util/cgroup.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o
Signature · 1 line
1.7.4.rc2
PATCH 15/18 perf: Export evlist.[ch]
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
Export for other tools to use too. Also, add a weak ui_warning version when using evlist outside of perf.
---
tools/lib/perf/Makefile | 3 +++
tools/lib/perf/cgroup.c | 6 +++---
tools/{perf/util => lib/perf}/evlist.c | 11 ++++++++++-
tools/{perf/util => lib/perf}/evlist.h | 4 ++--
tools/lib/perf/evsel.c | 2 +-
tools/perf/Makefile | 3 ---
tools/perf/builtin-annotate.c | 2 +-
tools/perf/builtin-evlist.c | 2 +-
tools/perf/builtin-record.c | 2 +-
tools/perf/builtin-report.c | 2 +-
tools/perf/builtin-script.c | 2 +-
tools/perf/builtin-stat.c | 2 +-
tools/perf/builtin-test.c | 2 +-
tools/perf/builtin-top.c | 2 +-
tools/perf/util/header.c | 2 +-
tools/perf/util/include/linux/compiler.h | 1 +
tools/perf/util/parse-events.c | 2 +-
tools/perf/util/python.c | 2 +-
tools/perf/util/session.c | 2 +-
tools/perf/util/setup.py | 2 +-
tools/perf/util/top.c | 2 +-
tools/perf/util/ui/browsers/hists.c | 2 +-
tools/perf/util/ui/browsers/top.c | 2 +-
23 files changed, 36 insertions(+), 26 deletions(-)
rename tools/{perf/util => lib/perf}/evlist.c (98%)
rename tools/{perf/util => lib/perf}/evlist.h (96%)tools/lib/perf/Makefile +3 -0
@@ -6,11 +6,14 @@ LIB_OBJS= LIB_H += evsel.h LIB_H += cgroup.h +LIB_H += evlist.h LIB_OBJS += evsel.o LIB_OBJS += cgroup.o +LIB_OBJS += evlist.o PYRF_OBJS += evsel.o +PYRF_OBJS += evlist.o LIBFILE = $(LIB_OUTPUT)liblkperf.a
tools/lib/perf/cgroup.c +3 -3
@@ -1,10 +1,10 @@#include <lk/util.h> +#include <lk/debugfs.h> /* MAX_PATH, STR() */ #include "../../perf/perf.h" #include "../../perf/util/parse-options.h" -#include <perf/evsel.h> +#include "evsel.h" #include "cgroup.h" -#include <lk/debugfs.h> /* MAX_PATH, STR() */ -#include "../../perf/util/evlist.h" +#include "evlist.h" int nr_cgroups;
tools/lib/perf/evlist.c renamed from tools/perf/util/evlist.c +10 -1
@@ -11,7 +11,7 @@#include <lk/thread_map.h> #include "evlist.h" #include <perf/evsel.h> -#include "debug.h" +#include "../../perf/util/debug.h" #include <lk/util.h> #include <sys/mman.h>
@@ -248,6 +248,15 @@ int perf_evlist__alloc_mmap(struct perf_evlist *evlist)return evlist->mmap !=NULL ?0 : -ENOMEM ; } +void __weak ui__warning (const char *format, ...) +{ +va_list params; + +va_start (params, format); +warning (format, params); +va_end (params); +} +static int __perf_evlist__mmap (struct perf_evlist *evlist,struct perf_evsel *evsel,int cpu,int prot,int mask,int fd) {
tools/lib/perf/evlist.h renamed from tools/perf/util/evlist.h +2 -2
@@ -2,8 +2,8 @@#define __PERF_EVLIST_H 1#include <linux/list.h> -#include "../perf.h" -#include "event.h" +#include "../../perf/perf.h" +#include "../../perf/util/event.h" struct pollfd ;struct thread_map ;
tools/lib/perf/evsel.c +1 -1
@@ -8,7 +8,7 @@*/ #include "evsel.h" -#include "../../perf/util/evlist.h" +#include "evlist.h" #include <lk/util.h> #include <lk/cpumap.h> #include <lk/thread_map.h>
tools/perf/Makefile +0 -3
@@ -212,7 +212,6 @@ LIB_H += util/callchain.h LIB_H += util/build-id.h LIB_H += util/debug.h LIB_H += util/event.h -LIB_H += util/evlist.h LIB_H += util/exec_cmd.h LIB_H += util/levenshtein.h LIB_H += util/map.h
@@ -248,7 +247,6 @@ LIB_OBJS += $(OUTPUT)util/config.o LIB_OBJS += $(OUTPUT)util/ctype.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o -LIB_OBJS += $(OUTPUT)util/evlist.o LIB_OBJS += $(OUTPUT)util/exec_cmd.o LIB_OBJS += $(OUTPUT)util/help.o LIB_OBJS += $(OUTPUT)util/levenshtein.o
@@ -324,7 +322,6 @@ PERFLIBS = $(LIB_FILE) $(EXTRA_LIBS) # tools/perf/util/setup.py PYRF_OBJS += $(OUTPUT)util/ctype.o -PYRF_OBJS += $(OUTPUT)util/evlist.o PYRF_OBJS += $(OUTPUT)util/python.o #
tools/perf/builtin-annotate.c +1 -1
@@ -19,7 +19,7 @@#include "perf.h" #include "util/debug.h" -#include "util/evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "util/annotate.h" #include "util/event.h"
tools/perf/builtin-evlist.c +1 -1
@@ -8,7 +8,7 @@#include <linux/list.h> #include "perf.h" -#include "util/evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "util/parse-events.h" #include "util/parse-options.h"
tools/perf/builtin-record.c +1 -1
@@ -18,7 +18,7 @@#include "util/header.h" #include "util/event.h" -#include "util/evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "util/debug.h" #include "util/session.h"
tools/perf/builtin-report.c +1 -1
@@ -21,7 +21,7 @@#include "perf.h" #include "util/debug.h" -#include "util/evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "util/header.h" #include "util/session.h"
tools/perf/builtin-script.c +1 -1
@@ -12,7 +12,7 @@#include <trace/trace-event.h> #include "util/parse-options.h" #include <lk/util.h> -#include "util/evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> static char const *script_name;
tools/perf/builtin-stat.c +1 -1
@@ -43,7 +43,7 @@#include "util/parse-options.h" #include "util/parse-events.h" #include "util/event.h" -#include "util/evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "util/debug.h" #include "util/header.h"
tools/perf/builtin-test.c +1 -1
@@ -7,7 +7,7 @@#include "util/cache.h" #include "util/debug.h" -#include "util/evlist.h" +#include <perf/evlist.h> #include "util/parse-options.h" #include "util/parse-events.h" #include "util/symbol.h"
tools/perf/builtin-top.c +1 -1
@@ -23,7 +23,7 @@#include "util/annotate.h" #include "util/cache.h" #include "util/color.h" -#include "util/evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "util/session.h" #include "util/symbol.h"
tools/perf/util/header.c +1 -1
@@ -8,7 +8,7 @@#include <linux/list.h> #include <linux/kernel.h> -#include "evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include <lk/util.h> #include "header.h"
tools/perf/util/include/linux/compiler.h +1 -0
@@ -8,5 +8,6 @@#define __attribute_const__#define __used __attribute__((__unused__)) +#define __weak __attribute__((weak))#endif
tools/perf/util/parse-events.c +1 -1
@@ -1,7 +1,7 @@#include "../../../include/linux/hw_breakpoint.h" #include <lk/util.h> #include "../perf.h" -#include "evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "parse-options.h" #include "parse-events.h"
tools/perf/util/python.c +1 -1
@@ -2,7 +2,7 @@#include <structmember.h> #include <inttypes.h> #include <poll.h> -#include "evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "event.h" #include <lk/cpumap.h>
tools/perf/util/session.c +1 -1
@@ -7,7 +7,7 @@#include <sys/types.h> #include <sys/mman.h> -#include "evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "session.h" #include "sort.h"
tools/perf/util/setup.py +1 -1
@@ -7,7 +7,7 @@ cflags = ['-fno-strict-aliasing', '-Wno-write-strings'] cflags += getenv('CFLAGS', '').split() perf = Extension('perf', - sources = ['util/python.c', 'util/ctype.c', 'util/evlist.c', + sources = ['util/python.c', 'util/ctype.c', '../lib/perf/evlist.c', '../lib/perf/evsel.c', '../lib/lk/cpumap.c', '../lib/lk/thread_map.c', '../lib/lk/util.c', '../lib/lk/xyarray.c', 'util/cgroup.c'], include_dirs = ['util/include', '../lib'],
tools/perf/util/top.c +1 -1
@@ -8,7 +8,7 @@#include <lk/cpumap.h> #include "event.h" -#include "evlist.h" +#include <perf/evlist.h> #include <perf/evsel.h> #include "parse-events.h" #include "symbol.h"
tools/perf/util/ui/browsers/hists.c +1 -1
@@ -8,7 +8,7 @@#include <linux/rbtree.h> #include <perf/evsel.h> -#include "../../evlist.h" +#include <perf/evlist.h> #include "../../hist.h" #include "../../pstack.h" #include "../../sort.h"
tools/perf/util/ui/browsers/top.c +1 -1
@@ -11,7 +11,7 @@#include "../helpline.h" #include "../libslang.h" #include "../util.h" -#include "../../evlist.h" +#include <perf/evlist.h> #include "../../hist.h" #include "../../sort.h" #include "../../symbol.h"
Signature · 1 line
1.7.4.rc2
PATCH 16/18 perf: Export ctype.c
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This is needed when linking against libtrace.a
---
tools/lib/lk/Makefile | 1 +
tools/{perf/util => lib/lk}/ctype.c | 2 +-
tools/perf/Makefile | 1 -
3 files changed, 2 insertions(+), 2 deletions(-)
rename tools/{perf/util => lib/lk}/ctype.c (98%)tools/lib/lk/Makefile +1 -0
@@ -11,6 +11,7 @@ LIB_H += cpumap.h LIB_H += thread_map.h LIB_H += xyarray.h +LIB_OBJS += ctype.o LIB_OBJS += debugfs.o LIB_OBJS += usage.o LIB_OBJS += util.o
tools/lib/lk/ctype.c renamed from tools/perf/util/ctype.c +1 -1
@@ -3,7 +3,7 @@* * No surprises, and works with signed and unsigned chars. */ -#include "cache.h" +#include "util.h" enum {S =GIT_SPACE ,
tools/perf/Makefile +0 -1
@@ -244,7 +244,6 @@ LIB_OBJS += $(OUTPUT)util/alias.o LIB_OBJS += $(OUTPUT)util/annotate.o LIB_OBJS += $(OUTPUT)util/build-id.o LIB_OBJS += $(OUTPUT)util/config.o -LIB_OBJS += $(OUTPUT)util/ctype.o LIB_OBJS += $(OUTPUT)util/environment.o LIB_OBJS += $(OUTPUT)util/event.o LIB_OBJS += $(OUTPUT)util/exec_cmd.o
Signature · 1 line
1.7.4.rc2
PATCH 17/18 perf: Export tracepoint_id_to_path
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This is needed when linking against libtrace.a so move it to <lib/trace/trace-event-info.c> and adjust all headers accordingly.
--- tools/lib/trace/event-info.c | 120 +++++++++++++++++++++++++++++++++------ tools/lib/trace/trace-event.h | 19 ++++++ tools/perf/util/parse-events.c | 104 +-------------------------------- tools/perf/util/parse-events.h | 1 - tools/perf/util/parse-options.h | 1 + 5 files changed, 126 insertions(+), 119 deletions(-)
tools/lib/trace/event-info.c +103 -17
@@ -18,7 +18,6 @@* * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ -#define _GNU_SOURCE#include <dirent.h> #include <mntent.h> #include <stdio.h>
@@ -26,6 +25,7 @@#include <string.h> #include <stdarg.h> #include <sys/types.h> +#include <sys/param.h> #include <sys/stat.h> #include <sys/wait.h> #include <pthread.h>
@@ -40,6 +40,7 @@#include "../../perf/perf.h" #include "trace-event.h" #include <lk/debugfs.h> +#include <lk/util.h> #include <perf/evsel.h> #define VERSION "0.5"
@@ -58,6 +59,7 @@unsigned int page_size;static const char *output_file ="trace.info" ; +static const char *dfs_path;static int output_fd;struct event_list {
@@ -72,7 +74,7 @@ struct events {char *name; }; -static void die (const char *fmt, ...) +static void t_die (const char *fmt, ...) {va_list ap;int ret = errno;
@@ -97,7 +99,7 @@ void *malloc_or_die(unsigned int size) data =malloc (size);if (!data) -die ("malloc" ); +t_die ("malloc" );return data; }
@@ -106,7 +108,7 @@ static const char *find_debugfs(void)const char *path =debugfs_mount (NULL );if (!path) -die ("Your kernel not support debugfs filesystem" ); +t_die ("Your kernel not support debugfs filesystem" );return path; }
@@ -167,7 +169,7 @@ static ssize_t write_or_die(const void *buf, size_t len) ret =write (output_fd, buf, len);if (ret <0 ) -die ("writing to '%s'" , output_file); +t_die ("writing to '%s'" , output_file);return ret; }
@@ -205,7 +207,7 @@ static unsigned long long copy_file(const char *file) fd =open (file,O_RDONLY );if (fd <0 ) -die ("Can't read '%s'" , file); +t_die ("Can't read '%s'" , file); size =copy_file_fd (fd);close (fd);
@@ -236,7 +238,7 @@ unsigned long get_filesize(const char *file) fd =open (file,O_RDONLY );if (fd <0 ) -die ("Can't read '%s'" , file); +t_die ("Can't read '%s'" , file); size =get_size_fd (fd);close (fd);
@@ -252,7 +254,7 @@ static void read_header_files(void) path =get_tracing_file ("events/header_page" ); fd =open (path,O_RDONLY );if (fd <0 ) -die ("can't read '%s'" , path); +t_die ("can't read '%s'" , path);/* unfortunately, you can not stat debugfs files for size */ size =get_size_fd (fd);
@@ -263,14 +265,14 @@ static void read_header_files(void)close (fd);if (size != check_size) -die ("wrong size for '%s' size=%lld read=%lld" , +t_die ("wrong size for '%s' size=%lld read=%lld" , path, size, check_size);put_tracing_file (path); path =get_tracing_file ("events/header_event" ); fd =open (path,O_RDONLY );if (fd <0 ) -die ("can't read '%s'" , path); +t_die ("can't read '%s'" , path); size =get_size_fd (fd);
@@ -278,7 +280,7 @@ static void read_header_files(void)write_or_die (&size,8 ); check_size =copy_file_fd (fd);if (size != check_size) -die ("wrong size for '%s'" , path); +t_die ("wrong size for '%s'" , path);put_tracing_file (path);close (fd); }
@@ -306,7 +308,7 @@ static void copy_event_system(const char *sys, struct tracepoint_path *tps) dir =opendir (sys);if (!dir) -die ("can't read directory '%s'" , sys); +t_die ("can't read directory '%s'" , sys);while ((dent =readdir (dir))) { if (dent->d_type != DT_DIR ||
@@ -342,7 +344,7 @@ static void copy_event_system(const char *sys, struct tracepoint_path *tps)write_or_die (&size,8 ); check_size =copy_file (format);if (size != check_size) -die ("error in size of file '%s'" , format); +t_die ("error in size of file '%s'" , format); }free (format);
@@ -386,7 +388,7 @@ static void read_event_files(struct tracepoint_path *tps) dir =opendir (path);if (!dir) -die ("can't read directory '%s'" , path); +t_die ("can't read directory '%s'" , path);while ((dent =readdir (dir))) { if (dent->d_type != DT_DIR ||
@@ -440,7 +442,7 @@ static void read_proc_kallsyms(void)write_or_die (&size,4 ); check_size =copy_file (path);if (size != check_size) -die ("error in size of file '%s'" , path); +t_die ("error in size of file '%s'" , path); }
@@ -463,11 +465,95 @@ static void read_ftrace_printk(void)write_or_die (&size,4 ); check_size =copy_file (path);if (size != check_size) -die ("error in size of file '%s'" , path); +t_die ("error in size of file '%s'" , path); out:put_tracing_file (path); } +int tp_event_has_id (struct dirent *sys_dir,struct dirent *evt_dir) +{ +char evt_path[MAXPATHLEN ]; +int fd; + +snprintf (evt_path,MAXPATHLEN ,"%s/%s/%s/id" , dfs_path, + sys_dir->d_name, evt_dir->d_name); + fd =open (evt_path,O_RDONLY ); +if (fd <0 ) +return -EINVAL ; +close (fd); + +return 0 ; +} + +struct tracepoint_path *tracepoint_id_to_path (u64 config) +{ +struct tracepoint_path *path =NULL ; +DIR *sys_dir, *evt_dir; +struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; +char id_buf[4 ]; +int fd; +u64 id; +char evt_path[MAXPATHLEN ]; +char dir_path[MAXPATHLEN ]; + + dfs_path =debugfs_mount (NULL ); +if (!dfs_path) +return NULL ; + + sys_dir =opendir (dfs_path); +if (!sys_dir) +return NULL ; + +for_each_subsystem (sys_dir, sys_dirent, sys_next) { + +snprintf (dir_path,MAXPATHLEN ,"%s/%s" , dfs_path, + sys_dirent.d_name); + evt_dir =opendir (dir_path); +if (!evt_dir) +continue ; + +for_each_event (sys_dirent, evt_dir, evt_dirent, evt_next) { + +snprintf (evt_path,MAXPATHLEN ,"%s/%s/id" , dir_path, + evt_dirent.d_name); + fd =open (evt_path,O_RDONLY ); +if (fd <0 ) +continue ; +if (read (fd, id_buf,sizeof (id_buf)) <0 ) { +close (fd); +continue ; + } +close (fd); + id =atoll (id_buf); +if (id == config) { +closedir (evt_dir); +closedir (sys_dir); + path =zalloc (sizeof (*path)); + path->system =malloc (MAX_EVENT_LENGTH ); +if (!path->system) { +free (path); +return NULL ; + } + path->name =malloc (MAX_EVENT_LENGTH ); +if (!path->name) { +free (path->system); +free (path); +return NULL ; + } +strncpy (path->system, sys_dirent.d_name, +MAX_EVENT_LENGTH ); +strncpy (path->name, evt_dirent.d_name, +MAX_EVENT_LENGTH ); +return path; + } + } +closedir (evt_dir); + } + +closedir (sys_dir); +return NULL ; +} +static struct tracepoint_path *get_tracepoints_path (struct list_head *pattrs) {
@@ -481,7 +567,7 @@ get_tracepoints_path(struct list_head *pattrs) ++nr_tracepoints; ppath->next =tracepoint_id_to_path (pos->attr.config);if (!ppath->next) -die ("%s\n" ,"No memory to alloc tracepoints list" ); +t_die ("%s\n" ,"No memory to alloc tracepoints list" ); ppath = ppath->next; }
tools/lib/trace/trace-event.h +19 -0
@@ -2,6 +2,7 @@#define __LIB_TRACE_EVENTS_H#include <stdbool.h> +#include <dirent.h> #include <linux/compiler.h> #include "../../perf/util/session.h"
@@ -317,4 +318,22 @@ int common_pc(struct scripting_context *context);int common_flags (struct scripting_context *context);int common_lock_depth (struct scripting_context *context); +#define MAX_EVENT_LENGTH 512 +#define TP_PATH_LEN (MAX_EVENT_LENGTH * 2 + 1) + +#define for_each_subsystem (sys_dir, sys_dirent, sys_next) \ + while (!readdir_r(sys_dir, &sys_dirent, &sys_next) && sys_next) \ + if (sys_dirent.d_type == DT_DIR && \ + (strcmp(sys_dirent.d_name, ".")) && \ + (strcmp(sys_dirent.d_name, ".."))) + +#define for_each_event (sys_dirent, evt_dir, evt_dirent, evt_next) \ + while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \ + if (evt_dirent.d_type == DT_DIR && \ + (strcmp(evt_dirent.d_name, ".")) && \ + (strcmp(evt_dirent.d_name, "..")) && \ + (!tp_event_has_id(&sys_dirent, &evt_dirent))) + +extern int tp_event_has_id (struct dirent *sys_dir,struct dirent *evt_dir); +extern struct tracepoint_path *tracepoint_id_to_path (u64 config);#endif /* __LIB_TRACE_EVENTS_H */
tools/perf/util/parse-events.c +3 -101
121 lines not on this page · raw message
tools/perf/util/parse-events.h +0 -1
@@ -17,7 +17,6 @@ struct tracepoint_path {struct tracepoint_path *next; }; -extern struct tracepoint_path *tracepoint_id_to_path (u64 config);extern bool have_tracepoints (struct list_head *evlist);const char *event_type (int type);
tools/perf/util/parse-options.h +1 -0
@@ -3,6 +3,7 @@#include <linux/kernel.h> #include <stdbool.h> +#include <lk/util.h> enum parse_opt_type {/* special types */
Signature · 1 line
1.7.4.rc2
PATCH 18/18 ras: Add RAS daemon
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
--- tools/Makefile | 4 + tools/ras/Makefile | 16 ++ tools/ras/rasd.c | 440 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 460 insertions(+), 0 deletions(-) create mode 100644 tools/ras/Makefile create mode 100644 tools/ras/rasd.c
tools/Makefile +4 -0
@@ -27,6 +27,9 @@ liblkperf: .FORCE libtrace: .FORCE $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) +ras: libtrace liblkperf liblk .FORCE + $(QUIET_SUBDIR0)ras/ $(QUIET_SUBDIR1) + slabinfo: .FORCE $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1)
@@ -48,6 +51,7 @@ clean: $(QUIET_SUBDIR0)lib/lk/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)lib/perf/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)lib/trace/ $(QUIET_SUBDIR1) clean + $(QUIET_SUBDIR0)ras/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)slub/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)power/x86/turbostat/ $(QUIET_SUBDIR1) clean $(QUIET_SUBDIR0)usb/ $(QUIET_SUBDIR1) clean
tools/ras/Makefile new file +16 -0
@@ -0,0 +1,16 @@ +include ../scripts/Makefile.lib + +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 -DNO_NEWT_SUPPORT $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) +ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +ALL_LDFLAGS = $(LDFLAGS) + +RASLIBS=$(LIB_OUTPUT)liblkperf.a $(LIB_OUTPUT)libtrace.a $(LIB_OUTPUT)liblk.a + +rasd: rasd.o + $(QUIET_CC)$(CC) $(ALL_CFLAGS) -o $@ $^ $(RASLIBS) + +%.o: %.c + $(QUIET_CC)$(CC) $(ALL_CFLAGS) -c $< + +clean: + rm -rf *.o rasd
tools/ras/rasd.c new file +440 -0
440 lines not on this page · raw message
Signature · 1 line
1.7.4.rc2
Quoted 25 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
Ok, here's yet another version of the RAS daemon patchset. This one changes all the event handling to how it is done in
test__basic_mmap(), as acme suggested. Patchset is against tip/perf/core from today.With this I can inject an mce using the python script below (yeah, work in progress in itself):
$ mcegen.py -i sw[ this will inject a random MCE using the mce_amd_inj.ko module ]
and in
/var/log/ras.logI get:MCE on cpu 0, status:
0xf200210000000853, addr:0x0000000000000000MCE on cpu 0, status:0x9800400000000015, addr:0x0000000000000000MCE on cpu 0, status:0xfc00200000050e0f, addr:0x0000000000000000MCE on cpu 0, status:0x98004100001c010b, addr:0x0000000000000000MCE on cpu 0, status:0xbc00200000000843, addr:0x0000000000000000MCE on cpu 0, status:0xda00410000080e0f, addr:0x0000000000000000Yep, it is still raw info but you can do almost anything with that info in userspace.
Quoted 7 lines
Next on the TODO list is changing the tracepoint to convey the decoded info too which should be a fairly simple task to do.
So we've got the basic design hammered out methinks, the persistent event is off by default for now and since rebasing this pile is always a great PITA for me due to other developments in
tools/perf, I'd like it very much if I could offload it in -tip soon.
If you want to accelerate that, I suggest you cut your patchset into smaller sets and focus on merging them piece by piece. Few people are going to review 18 patches at once. They may plan to scatter their review over days but that doesn't scale well, and it naturally reduces the number of reviewers.
You could start with exporting trace things into tools/trace, post the few concerned patches and iterate them until everyone is happy. Then switch to another subset of the big thing.
Hm?
Quoted 9 lines · Frederic Weisbecker
If you want to accelerate that, I suggest you cut your patchset into smaller sets and focus on merging them piece by piece. Few people are going to review 18 patches at once. They may plan to scatter their review over days but that doesn't scale well, and it naturally reduces the number of reviewers.
You could start with exporting trace things into
tools/trace, post the few concerned patches and iterate them until everyone is happy. Then switch to another subset of the big thing.
Hi Frederic,
I can definitely do that. I just wanted to know before I do it though, whether the general direction is ok and whether people are fine with the changes, i.e. Arnaldo, Ingo, Peter, Steven, any reactions? If yes, I can get to work and split the big pile into more digestible pieces.
Thanks.
Signature · 8 lines
Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Quoted 12 lines · Borislav Petkov
Quoted 10 lines · Frederic Weisbecker
If you want to accelerate that, I suggest you cut your patchset into smaller sets and focus on merging them piece by piece. Few people are going to review 18 patches at once. They may plan to scatter their review over days but that doesn't scale well, and it naturally reduces the number of reviewers.
You could start with exporting trace things into
tools/trace, post the few concerned patches and iterate them until everyone is happy. Then switch to another subset of the big thing.
Quoted 6 lines
Hi Frederic,
I can definitely do that. I just wanted to know before I do it though, whether the general direction is ok and whether people are fine with the changes, i.e. Arnaldo, Ingo, Peter, Steven, any reactions? If yes, I can get to work and split the big pile into more digestible pieces.
I definitely like the general approach, it's a big step forward from mcelog. Might make sense to progress to the small digestible patches stage to get out the detailed reviews?
Thanks,
Ingo
Em Fri, Apr 29, 2011 at 04:31:45PM +0200, Ingo Molnar escreveu:
Quoted 17 lines · Borislav Petkov
Quoted 15 lines · Frederic Weisbecker
Quoted 10 lines
If you want to accelerate that, I suggest you cut your patchset into smaller sets and focus on merging them piece by piece. Few people are going to review 18 patches at once. They may plan to scatter their review over days but that doesn't scale well, and it naturally reduces the number of reviewers.
You could start with exporting trace things into
tools/trace, post the few concerned patches and iterate them until everyone is happy. Then switch to another subset of the big thing.Hi Frederic,
Quoted 8 lines
Quoted 4 lines
I can definitely do that. I just wanted to know before I do it though, whether the general direction is ok and whether people are fine with the changes, i.e. Arnaldo, Ingo, Peter, Steven, any reactions? If yes, I can get to work and split the big pile into more digestible pieces.
I definitely like the general approach, it's a big step forward from mcelog. Might make sense to progress to the small digestible patches stage to get out the detailed reviews?
+1
Quoted 3 lines
Thanks,
Ingo
Quoted 6 lines · Frederic Weisbecker
On Sat, Apr 23, 2011 at 06:28:02PM +0200, Borislav Petkov wrote:
If you want to accelerate that, I suggest you cut your patchset into smaller sets and focus on merging them piece by piece. Few people are going to review 18 patches at once. They may plan to scatter their review over days but that doesn't scale well, and it naturally reduces the number of reviewers.
True, I tend to ignore almost anything more than 8 patches. Or I'll start reviewing them, get 5 patches into it and then have to work on other things, and never finish the rest.
-- Steve