* origin/tmp-dcb6110:
ANDROID: goldfish_sync: 32 max cmds to save stack
ANDROID: sched/walt: use div_u64 instead of do_div
Linux 4.9.9
drm/i915/execlists: Reset RING registers upon resume
fs: break out of iomap_file_buffered_write on fatal signals
iw_cxgb4: set correct FetchBurstMax for QPs
x86/irq: Make irq activate operations symmetric
irqdomain: Avoid activating interrupts more than once
iio: health: max30100: fixed parenthesis around FIFO count check
iio: dht11: Use usleep_range instead of msleep for start signal
iio: health: afe4403: retrieve a valid iio_dev in suspend/resume
iio: health: afe4404: retrieve a valid iio_dev in suspend/resume
iio: adc: palmas_gpadc: retrieve a valid iio_dev in suspend/resume
staging: greybus: timesync: validate platform state callback
USB: serial: option: add device ID for HP lt2523 (Novatel E371)
usb: gadget: f_fs: Assorted buffer overflow checks.
usb: musb: Fix host mode error -71 regression
USB: Add quirk for WORLDE easykey.25 MIDI keyboard
USB: serial: pl2303: add ATEN device ID
USB: serial: qcserial: add Dell DW5570 QDL
KVM: x86: do not save guest-unsupported XSAVE state
dmaengine: cppi41: Fix oops in cppi41_runtime_resume
dmaengine: cppi41: Fix runtime PM timeouts with USB mass storage
perf/x86/intel/uncore: Clean up hotplug conversion fallout
HID: wacom: Fix poor prox handling in 'wacom_pl_irq'
HID: hid-lg: Fix immediate disconnection of Logitech Rumblepad 2
HID: usbhid: Quirk a AMI virtual mouse and keyboard with ALWAYS_POLL
iwlwifi: mvm: avoid crash on restart w/o reserved queues
iwlwifi: fix double hyphen in MODULE_FIRMWARE for 8000
pinctrl: intel: merrifield: Add missed check in mrfld_config_set()
pinctrl: baytrail: Debounce register is one per community
Revert "vring: Force use of DMA API for ARM-based systems with legacy devices"
Revert "bcma: init serial console directly from ChipCommon code"
percpu-refcount: fix reference leak during percpu-atomic transition
regulator: axp20x: AXP806: Fix dcdcb being set instead of dcdce
vhost: fix initialization for vq->is_le
mmc: sdhci: Ignore unexpected CARD_INT interrupts
cgroup: don't online subsystems before cgroup_name/path() are operational
can: bcm: fix hrtimer/tasklet termination in bcm op removal
tracing: Fix hwlat kthread migration
mm, fs: check for fatal signals in do_generic_file_read()
base/memory, hotplug: fix a kernel oops in show_valid_zones()
mm/memory_hotplug.c: check start_pfn in test_pages_in_a_zone()
cifs: initialize file_info_lock
zswap: disable changing params if init fails
svcrpc: fix oops in absence of krb5 module
NFSD: Fix a null reference case in find_or_create_lock_stateid()
powerpc/mm: Use the correct pointer when setting a 2MB pte
powerpc: Fix build failure with clang due to BUILD_BUG_ON()
powerpc: Add missing error check to prom_find_boot_cpu()
powerpc/eeh: Fix wrong flag passed to eeh_unfreeze_pe()
libata: Fix ATA request sense
libata: apply MAX_SEC_1024 to all CX1-JB*-HP devices
ata: sata_mv:- Handle return value of devm_ioremap.
perf/core: Fix PERF_RECORD_MMAP2 prot/flags for anonymous memory
perf/core: Fix use-after-free bug
crypto: arm64/aes-blk - honour iv_out requirement in CBC and CTR modes
crypto: api - Clear CRYPTO_ALG_DEAD bit before registering an alg
drm/nouveau/nv1a,nv1f/disp: fix memory clock rate retrieval
drm/nouveau/disp/gt215: Fix HDA ELD handling (thus, HDMI audio) on gt215
drm/amdgpu/si: fix crash on headless asics
pinctrl: baytrail: Add missing spinlock usage in byt_gpio_irq_handler
HID: cp2112: fix gpio-callback error handling
HID: cp2112: fix sleep-while-atomic
xtensa: fix noMMU build on cores with MMU
efi/fdt: Avoid FDT manipulation after ExitBootServices()
x86/efi: Always map the first physical page into the EFI pagetables
ext4: validate s_first_meta_bg at mount time
PCI/ASPM: Handle PCI-to-PCIe bridges as roots of PCIe hierarchies
ANDROID: sched: Add Kconfig option DEFAULT_USE_ENERGY_AWARE to set ENERGY_AWARE feature flag
ANDROID: goldfish_sync: Fix sync_file_obj is NULL but dereferenced problem
ANDROID: goldfish_sync: Isolate single module to fix compilation
ANDROID: goldfish_sync: update defconfig for 4.9-compatible version
ANDROID: goldfish_sync: upgrade to new fence sync api
Linux 4.9.8
xfs: fix bmv_count confusion w/ shared extents
xfs: clear _XBF_PAGES from buffers when readahead page
xfs: extsize hints are not unlikely in xfs_bmap_btalloc
xfs: remove racy hasattr check from attr ops
xfs: verify dirblocklog correctly
xfs: fix COW writeback race
xfs: fix xfs_mode_to_ftype() prototype
xfs: don't wrap ID in xfs_dq_get_next_id
xfs: sanity check inode di_mode
xfs: sanity check inode mode when creating new dentry
xfs: replace xfs_mode_to_ftype table with switch statement
xfs: add missing include dependencies to xfs_dir2.h
xfs: sanity check directory inode di_size
xfs: make the ASSERT() condition likely
xfs: don't print warnings when xfs_log_force fails
xfs: don't rely on ->total in xfs_alloc_space_available
xfs: adjust allocation length in xfs_alloc_space_available
xfs: fix bogus minleft manipulations
xfs: bump up reserved blocks in xfs_alloc_set_aside
net: dsa: Bring back device detaching in dsa_slave_suspend()
lwtunnel: Fix oops on state free after encap module unload
net: Specify the owning module for lwtunnel ops
qmi_wwan/cdc_ether: add device ID for HP lt2523 (Novatel E371) WWAN card
af_unix: move unix_mknod() out of bindlock
r8152: don't execute runtime suspend if the tx is not empty
net: mpls: Fix multipath selection for LSR use case
bridge: netlink: call br_changelink() during br_dev_newlink()
net/mlx5e: Do not recycle pages from emergency reserve
tcp: initialize max window for a new fastopen socket
ipv6: addrconf: Avoid addrconf_disable_change() using RCU read-side lock
lwtunnel: fix autoload of lwt modules
net: phy: bcm63xx: Utilize correct config_intr function
net: fix harmonize_features() vs NETIF_F_HIGHDMA
vxlan: fix byte order of vxlan-gpe port number
virtio-net: restore VIRTIO_HDR_F_DATA_VALID on receiving
virtio: don't set VIRTIO_NET_HDR_F_DATA_VALID on xmit
net sched actions: fix refcnt when GETing of action after bind
ax25: Fix segfault after sock connection timeout
ip6_tunnel: Account for tunnel header in tunnel MTU
ravb: do not use zero-length alignment DMA descriptor
mlx4: do not call napi_schedule() without care
openvswitch: maintain correct checksum state in conntrack actions
tcp: fix tcp_fastopen unaligned access complaints on sparc
net: systemport: Decouple flow control from __bcm_sysport_tx_reclaim
net: ipv4: fix table id in getroute response
net: lwtunnel: Handle lwtunnel_fill_encap failure
mlxsw: pci: Fix EQE structure definition
mlxsw: switchx2: Fix memory leak at skb reallocation
mlxsw: spectrum: Fix memory leak at skb reallocation
netvsc: add rcu_read locking to netvsc callback
r8152: fix the sw rx checksum is unavailable
FROMLIST: 9p: fix a potential acl leak
ANDROID: sched/walt: use do_div instead of division operator
ANDROID: sched: fix wrong truncation of walt_avg
ANDROID: arm: Fix #if/#ifdef typo in topology.c
ANDROID: arm: Fix build error "conflicting types for 'scale_cpu_capacity'"
ANDROID: net: ipv6: remove unused variable ifindex in
ANDROID: DEBUG: cpufreq: fix cpu_capacity tracing build for non-smp systems
ANDROID: arm: topology: Define TC2 energy and provide it to the scheduler
ANDROID: binder: fix format specifier for type binder_size_t
Linux 4.9.7
drm/i915: Remove WaDisableLSQCROPERFforOCL KBL workaround.
perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race
mm, memcg: do not retry precharge charges
platform/x86: intel_mid_powerbtn: Set IRQ_ONESHOT
platform/x86: mlx-platform: free first dev on error
virtio_mmio: Set DMA masks appropriately
memory_hotplug: make zone_can_shift() return a boolean value
pinctrl: baytrail: Rectify debounce support
pinctrl: uniphier: fix Ethernet (RMII) pin-mux setting for LD20
pinctrl: broxton: Use correct PADCFGLOCK offset
s5k4ecgx: select CRC32 helper
IB/rxe: Prevent from completer to operate on non valid QP
IB/rxe: Fix rxe dev insertion to rxe_dev_list
IB/umem: Release pid in error and ODP flow
drm/i915: Check for NULL atomic state in intel_crtc_disable_noatomic()
drm/i915: Fix calculation of rotated x and y offsets for planar formats
drm/i915: Don't init hpd polling for vlv and chv from runtime_suspend()
drm/i915: Don't leak edid in intel_crt_detect_ddc()
drm/i915: prevent crash with .disable_display parameter
drm/i915: Clear ret before unbinding in i915_gem_evict_something()
v4l: tvp5150: Don't override output pinmuxing at stream on/off time
v4l: tvp5150: Fix comment regarding output pin muxing
v4l: tvp5150: Reset device at probe time, not in get/set format handlers
pctv452e: move buffer to heap, no mutex
iw_cxgb4: free EQ queue memory on last deref
SUNRPC: cleanup ida information when removing sunrpc module
NFSv4.0: always send mode in SETATTR after EXCLUSIVE4
NFSv4.1: Fix a deadlock in layoutget
nfs: Don't increment lock sequence ID after NFS4ERR_MOVED
parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header
ARC: [arcompact] handle unaligned access delay slot corner case
ARC: udelay: fix inline assembler by adding LP_COUNT to clobber list
can: ti_hecc: add missing prepare and unprepare of the clock
can: c_can_pci: fix null-pointer-deref in c_can_start() - set device pointer
IB/srp: fix invalid indirect_sg_entries parameter value
IB/srp: fix mr allocation when the device supports sg gaps
IB/iser: Fix sg_tablesize calculation
IB/cxgb3: fix misspelling in header guard
s390/ptrace: Preserve previous registers for short regset write
s390/mm: Fix cmma unused transfer from pgste into pte
RDMA/cma: Fix unknown symbol when CONFIG_IPV6 is not enabled
Btrfs: remove ->{get, set}_acl() from btrfs_dir_ro_inode_operations
Btrfs: disable xattr operations on subvolume directories
Btrfs: remove old tree_root case in btrfs_read_locked_inode()
ISDN: eicon: silence misleading array-bounds warning
xfs: prevent quotacheck from overloading inode lru
sysctl: fix proc_doulongvec_ms_jiffies_minmax()
userns: Make ucounts lock irq-safe
vring: Force use of DMA API for ARM-based systems with legacy devices
mm, page_alloc: fix premature OOM when racing with cpuset mems update
mm, page_alloc: move cpuset seqcount checking to slowpath
mm, page_alloc: fix fast-path race with cpuset update or removal
mm, page_alloc: fix check for NULL preferred_zone
mm/mempolicy.c: do not put mempolicy before using its nodemask
mm/huge_memory.c: respect FOLL_FORCE/FOLL_COW for thp
drm/atomic: clear out fence when duplicating state
Revert "drm/radeon: always apply pci shutdown callbacks"
drm/vc4: fix a bounds check
drm/vc4: Return -EINVAL on the overflow checks failing.
drm/vc4: Fix an integer overflow in temporary allocation layout.
drm/vc4: Fix memory leak of the CRTC state.
drm/i915: Ignore bogus plane coordinates on SKL when the plane is not visible
drm: Fix broken VT switch with video=1366x768 option
drm: Schedule the output_poll_work with 1s delay if we have delayed event
tile/ptrace: Preserve previous registers for short regset write
fbdev: color map copying bounds checking
ANDROID: sched/walt: Drop arch-specific timer access
ANDROID: sched/walt: include missing header for arm_timer_read_counter()
ANDROID: fs: Export vfs_rmdir2
ANDROID: fs: Export free_fs_struct and set_fs_pwd
ANDROID: cpufreq: interactive: Use idle-end notifiers
FROMLIST: cpufreq: Add android's 'interactive' governor
ANDROID: cpufreq: conservative: fix duplicate 'static' error
ANDROID: sdcardfs: eliminate the offset argument to ->direct_IO
ANDROID: sdcardfs: make it use new .rename i_op
ANDROID: sdcardfs: Propagate dentry down to inode_change_ok()
ANDROID: sdcardfs: get rid of 'parent' argument of ->d_compare()
ANDROID: sdcardfs: add parent pointer into dentry name hash
ANDROID: sdcardfs: use wrappers to access i_mutex
ANDROID: mnt: remount should propagate to slaves of slaves
ANDROID: sdcardfs: Fix locking issue with permision fix up
ANDROID: sdcardfs: Switch ->d_inode to d_inode()
ANDROID: sdcardfs: Change magic value
ANDROID: sdcardfs: Use per mount permissions
ANDROID: sdcardfs: Add gid and mask to private mount data
ANDROID: sdcardfs: User new permission2 functions
ANDROID: vfs: Add permission2 for filesystems with per mount permissions
ANDROID: vfs: Add setattr2 for filesystems with per mount permissions
ANDROID: vfs: Allow filesystems to access their private mount data
ANDROID: mnt: Add filesystem private data to mount points
ANDROID: sdcardfs: Move directory unlock before touch
ANDROID: sdcardfs: fix external storage exporting incorrect uid
ANDROID: sdcardfs: Added top to sdcardfs_inode_info
ANDROID: sdcardfs: Switch package list to RCU
ANDROID: sdcardfs: Fix locking for permission fix up
ANDROID: sdcardfs: Check for other cases on path lookup
ANDROID: sdcardfs: override umask on mkdir and create
ANDROID: sched/debug: Add energy procfs interface
ANDROID: cpufreq: sched: Fix kernel crash on accessing sysfs file
ANDROID: FIXUP: sched/tune: add fixes missing from a previous patch
ANDROID: sched: tune: Fix lacking spinlock initialization
ANDROID: cgroup: Remove leftover instances of allow_attach
ANDROID: FIXUP: sched: scheduler-driven cpu frequency selection
ANDROID: sched/rt: Add Kconfig option to enable panicking for RT throttling
ANDROID: sched/rt: print RT tasks when RT throttling is activated
ANDROID: sched/fair: Favor higher cpus only for boosted tasks
ANDROID: sched/fair: call OPP update when going idle after migration
ANDROID: sched/cpufreq_sched: fix thermal capping events
ANDROID: sched/fair: Picking cpus with low OPPs for tasks that prefer idle CPUs
ANDROID: FIXUP: sched/tune: do initialization as a postcore_initicall
ANDROID: DEBUG: sched: add tracepoint for RD overutilized
ANDROID: sched/tune: Introducing a new schedtune attribute prefer_idle
ANDROID: sched: use util instead of capacity to select busy cpu
ANDROID: arch_timer: add error handling when the MPM global timer is cleared
ANDROID: FIXUP: sched: Fix double-release of spinlock in move_queued_task
ANDROID: FIXUP: sched/fair: Fix hang during suspend in sched_group_energy
ANDROID: FIXUP: sched: fix SchedFreq integration for both PELT and WALT
ANDROID: sched: EAS: Avoid causing spikes to max-freq unnecessarily
ANDROID: FIXUP: sched: fix set_cfs_cpu_capacity when WALT is in use
ANDROID: sched/walt: Accounting for number of irqs pending on each core
ANDROID: sched: Introduce Window Assisted Load Tracking (WALT)
ANDROID: sched/tune: fix PB and PC cuts indexes definition
ANDROID: sched/fair: optimize idle cpu selection for boosted tasks
ANDROID: FIXUP: sched/tune: fix accounting for runnable tasks
ANDROID: sched/tune: use a single initialisation function
ANDROID: FIXUP: sched/tune: fix payoff calculation for boost region
ANDROID: sched/tune: Add support for negative boost values
ANDROID: FIX: sched/tune: move schedtune_nornalize_energy into fair.c
ANDROID: FIX: sched/tune: update usage of boosted task utilisation on CPU selection
ANDROID: sched/fair: add tunable to set initial task load
ANDROID: sched/fair: add tunable to force selection at cpu granularity
ANDROID: sched: EAS: take cstate into account when selecting idle core
ANDROID: sched/cpufreq_sched: Consolidated update
ANDROID: FIXUP: sched: fix build for non-SMP target
ANDROID: DEBUG: sched/tune: add tracepoint on P-E space filtering
ANDROID: DEBUG: sched/tune: add tracepoint for energy_diff() values
ANDROID: DEBUG: sched/tune: add tracepoint for task boost signal
CHROMIUM: sched: update the average of nr_running
ANDROID: DEBUG: schedtune: add tracepoint for schedtune_tasks_update() values
ANDROID: DEBUG: schedtune: add tracepoint for CPU boost signal
ANDROID: DEBUG: schedtune: add tracepoint for SchedTune configuration update
ANDROID: DEBUG: sched,cpufreq: add cpu_capacity change tracepoint
ANDROID: DEBUG: sched: add tracepoint for CPU load/util signals
ANDROID: DEBUG: sched: add tracepoint for task load/util signals
ANDROID: DEBUG: sched: add tracepoint for cpu/freq scale invariance
ANDROID: sched/fair: filter energy_diff() based on energy_payoff value
ANDROID: sched/tune: add support to compute normalized energy
ANDROID: sched/fair: keep track of energy/capacity variations
ANDROID: sched/fair: add boosted task utilization
ANDROID: sched/{fair,tune}: track RUNNABLE tasks impact on per CPU boost value
ANDROID: sched/tune: compute and keep track of per CPU boost value
ANDROID: sched/tune: add initial support for CGroups based boosting
ANDROID: sched/fair: add boosted CPU usage
ANDROID: sched/fair: add function to convert boost value into "margin"
ANDROID: sched/tune: add sysctl interface to define a boost value
ANDROID: sched/tune: add detailed documentation
ANDROID: fixup! sched: scheduler-driven cpu frequency selection
ANDROID: sched: remove call of sched_avg_update from sched_rt_avg_update
ANDROID: sched/cpufreq_sched: add trace events
ANDROID: sched/fair: jump to max OPP when crossing UP threshold
ANDROID: sched/fair: cpufreq_sched triggers for load balancing
ANDROID: sched/{core,fair}: trigger OPP change request on fork()
ANDROID: sched/fair: add triggers for OPP change requests
ANDROID: sched: scheduler-driven cpu frequency selection
ANDROID: cpufreq: introduce cpufreq_driver_is_slow
ANDROID: sched: Add group_misfit_task load-balance type
ANDROID: sched: Add per-cpu max capacity to sched_group_capacity
ANDROID: sched: Do eas idle balance regardless of the rq avg idle value
ANDROID: arm64: Enable max freq invariant scheduler load-tracking and capacity support
ANDROID: arm: Enable max freq invariant scheduler load-tracking and capacity support
ANDROID: sched: Update max cpu capacity in case of max frequency constraints
ANDROID: cpufreq: Max freq invariant scheduler load-tracking and cpu capacity support
ANDROID: sched: Disable energy-unfriendly nohz kicks
ANDROID: sched: Consider a not over-utilized energy-aware system as balanced
ANDROID: sched: Energy-aware wake-up task placement
ANDROID: sched: Determine the current sched_group idle-state
ANDROID: sched, cpuidle: Track cpuidle state index in the scheduler
ANDROID: sched: Add over-utilization/tipping point indicator
ANDROID: sched: Estimate energy impact of scheduling decisions
ANDROID: sched: Extend sched_group_energy to test load-balancing decisions
ANDROID: sched: Calculate energy consumption of sched_group
ANDROID: sched: Highest energy aware balancing sched_domain level pointer
ANDROID: sched: Relocated cpu_util() and change return type
ANDROID: sched: Compute cpu capacity available at current frequency
ANDROID: sched: Support for extracting EAS energy costs from DT
ANDROID: arm64, topology: Updates to use DT bindings for EAS costing data
ANDROID: arm64: Cpu invariant scheduler load-tracking and capacity support
ANDROID: arm: Cpu invariant scheduler load-tracking and capacity support
ANDROID: sched: Introduce SD_SHARE_CAP_STATES sched_domain flag
ANDROID: sched: Initialize energy data structures
ANDROID: sched: Make energy awareness a sched feature
ANDROID: sched: Documentation for scheduler energy cost model
ANDROID: sched: Prevent unnecessary active balance of single task in sched group
ANDROID: sched: Enable idle balance to pull single task towards cpu with higher capacity
ANDROID: sched: Consider spare cpu capacity at task wake-up
ANDROID: sched: Add cpu capacity awareness to wakeup balancing
ANDROID: arm: Update arch_scale_cpu_capacity() to reflect change to define
ANDROID: arm64: Enable frequency invariant scheduler load-tracking support
ANDROID: arm: Enable frequency invariant scheduler load-tracking support
ANDROID: cpufreq: Frequency invariant scheduler load-tracking support
ANDROID: [CPUFREQ] Don't export governors for default governor
ANDROID: kernel/configs: recommended: CONFIG_ARM64_SW_TTBR0_PAN=y
ANDROID: kernel/configs: base: Enable QUOTA related configs
ANDROID: kernel/configs: recommended: Enable MEMORY_STATE_TIME
FROMLIST: config: android-base: enable hardened usercopy and kernel ASLR
FROMLIST: config: android-recommended: disable aio support
ANDROID: kernel/configs: recommended: enable fstack-protector-strong
ANDROID: kernel/configs: base: enable UID_CPUTIME
ANDROID: kernel/configs: base: restrict access to perf events
ANDROID: configs: base: enable configfs gadget functions
ANDROID: configs: merge AOSP config fragments
ANDROID: Implement memory_state_time, used by qcom,cpubw
ANDROID: dm: rebase for 4.9
ANDROID: usb: otg-wakelock: Remove wakelock.h dependencies
ANDROID: gpio_matrix: Remove wakelock.h dependencies
ANDROID: fiq_debugger: Remove wakelock.h dependencies
UPSTREAM: net: socket: don't set sk_uid to garbage value in ->setattr()
ANDROID: trace: net: use %pK for kernel pointers
UPSTREAM: net: ipv4: Don't crash if passing a null sk to ip_rt_update_pmtu.
UPSTREAM: net: inet: Support UID-based routing in IP protocols.
UPSTREAM: net: core: add UID to flows, rules, and routes
UPSTREAM: net: core: Add a UID field to struct sock.
ANDROID: fs: FS tracepoints to track IO.
ANDROID: MMC/UFS IO Latency Histograms.
CHROMIUM: fix warning when releasing active sync point
ANDROID: goldfish_pipe: fix allmodconfig build
ANDROID: goldfish: goldfish_pipe: fix locking errors
ANDROID: goldfish_pipe: fix call_kern.cocci warnings
ANDROID: goldfish_pipe: An implementation of more parallel pipe
ANDROID: goldfish_pipe: bugfixes and performance improvements.
ANDROID: goldfish: disable GOLDFISH_SYNC
ANDROID: goldfish: enable CONFIG_INET_DIAG_DESTROY
ANDROID: build: fix build config kernel_dir
ANDROID: dm verity: add minimum prefetch size
ANDROID: build: add build server configs for goldfish
UPSTREAM: trace: Update documentation for mono, mono_raw and boot clock
UPSTREAM: trace: Add an option for boot clock as trace clock
UPSTREAM: timekeeping: Add a fast and NMI safe boot clock
ANDROID: video: goldfishfb: fix platform_no_drv_owner.cocci warnings
ANDROID: arm64: rename ranchu defconfig to ranchu64
ANDROID: arch: x86: disable pic for Android toolchain
ANDROID: goldfish: Add goldfish sync driver
ANDROID: goldfish: add ranchu defconfigs
ANDROID: goldfish_audio: Clear audio read buffer status after each read
ANDROID: goldfish_events: no extra EV_SYN; register goldfish
ANDROID: goldfish_fb: Set pixclock = 0
ANDROID: goldfish: Enable ACPI-based enumeration for goldfish audio
ANDROID: goldfish: Enable ACPI-based enumeration for goldfish framebuffer
ANDROID: video: goldfishfb: add devicetree bindings
ANDROID: usb: gadget: function: cleanup: Add blank line after declaration
ANDROID: usb: gadget: f_mtp: simplify ptp NULL pointer check
ANDROID: usb: gadget: audio_source: fix comparison of distinct pointer types
ANDROID: binder: support for file-descriptor arrays.
ANDROID: binder: support for scatter-gather.
ANDROID: binder: add extra size to allocator.
ANDROID: binder: refactor binder_transact()
ANDROID: binder: support multiple /dev instances.
ANDROID: binder: deal with contexts in debugfs.
ANDROID: binder: support multiple context managers.
ANDROID: binder: split flat_binder_object.
ANDROID: [RFC]cgroup: Change from CAP_SYS_NICE to CAP_SYS_RESOURCE for cgroup migration permissions
CHROMIUM: cgroups: relax permissions on moving tasks between cgroups
ANDROID: dm: android-verity: Remove fec_header location constraint
ANDROID: fiq_debugger: Pass task parameter to unwind_frame()
ANDROID: input: keyreset: switch to orderly_reboot
ANDROID: cpuset: Make cpusets restore on hotplug
ANDROID: Don't show empty tag stats for unprivileged uids
ANDROID: dm: android-verity: Allow android-verity to be compiled as an independent module
ANDROID: dm-verity: adopt changes made to dm callbacks
ANDROID: dm verity fec: pack the fec_header structure
ANDROID: dm: android-verity: Verify header before fetching table
ANDROID: dm: allow adb disable-verity only in userdebug
ANDROID: dm: mount as linear target if eng build
ANDROID: dm: use default verity public key
ANDROID: dm: fix signature verification flag
ANDROID: dm: use name_to_dev_t
ANDROID: dm: rename dm-linear methods for dm-android-verity
ANDROID: dm: Minor cleanup
ANDROID: dm: Mounting root as linear device when verity disabled
ANDROID: dm-android-verity: Rebase on top of 4.1
ANDROID: dm: Add android verity target
ANDROID: dm: fix dm_substitute_devices()
ANDROID: dm: Rebase on top of 4.9
CHROMIUM: dm: boot time specification of dm=
ANDROID: usb: gadget: f_accessory: remove duplicate endpoint alloc
ANDROID: sdcardfs: fix itnull.cocci warnings
ANDROID: sdcardfs: Truncate packages_gid.list on overflow
ANDROID: netfilter: xt_quota2: make quota2_log work well
ANDROID: cpu: send KOBJ_ONLINE event when enabling cpus
ANDROID: dm verity fec: initialize recursion level
ANDROID: dm verity fec: add missing release from fec_ktype
ANDROID: dm verity fec: limit error correction recursion
FROMLIST: security,perf: Allow further restriction of perf_event_open
ANDROID: ARM64: Ignore Image-dtb from git point of view
ANDROID: arm64: add option to build Image-dtb
ANDROID: usb: gadget: f_midi: set fi->f to NULL when free f_midi function
ANDROID: xt_qtaguid: Fix panic caused by processing non-full socket.
ANDROID: fiq_debugger: Add fiq_debugger.disable option
FROMLIST: wlcore: Disable filtering in AP role
ANDROID: fiq_debugger: Add option to apply uart overlay by FIQ_DEBUGGER_UART_OVERLAY
ANDROID: usb: dual-role: make stub functions inline
ANDROID: quick selinux support for tracefs
ANDROID: xt_qtaguid: Fix panic caused by synack processing
ANDROID: fuse: Add support for d_canonical_path
ANDROID: vfs: change d_canonical_path to take two paths
ANDROID: netfilter: xt_qtaguid: seq_printf fixes
ANDROID: mmc: Add CONFIG_MMC_SIMULATE_MAX_SPEED
ANDROID: dm verity fec: add sysfs attribute fec/corrected
ANDROID: mm: Export do_munmap
ANDROID: sdcardfs: remove unneeded __init and __exit
ANDROID: sdcardfs: Remove unused code
ANDROID: fs: Export d_absolute_path
ANDROID: sdcardfs: remove effectless config option
ANDROID: inotify: Fix erroneous update of bit count
ANDROID: fs: sdcardfs: Declare LOOKUP_CASE_INSENSITIVE unconditionally
ANDROID: trace: cpufreq: fix typo in min/max cpufreq
ANDROID: sdcardfs: Add support for d_canonical_path
ANDROID: vfs: add d_canonical_path for stacked filesystem support
ANDROID: sdcardfs: Bring up to date with Android M permissions:
ANDROID: Changed type-casting in packagelist management
ANDROID: Port of sdcardfs to 4.4
ANDROID: Included sdcardfs source code for kernel 3.0
ANDROID: usb: gadget: Add support for MTP OS desc
CHROMIUM: usb: gadget: f_accessory: add .raw_request callback
CHROMIUM: usb: gadget: audio_source: add .free_func callback
CHROMIUM: usb: gadget: f_mtp: fix usb_ss_ep_comp_descriptor
CHROMIUM: usb: gadget: f_mtp: Add SuperSpeed support
ANDROID: dm-crypt: run in a WQ_HIGHPRI workqueue
ANDROID: power: Provide dummy log_suspend_abort_reason() if SUSPEND is disabled
ANDROID: PM / suspend: Add dependency on RTC_LIB
ANDROID: net: pppolac/pppopns: Replace msg.msg_iov with iov_iter_kvec()
ANDROID: mmc: sdio: Disable retuning in sdio_reset_comm()
ANDROID: kernel/watchdog: fix unused variable warning
ANDROID: usb: gadget: f_mtp: don't use le16 for u8 field
ANDROID: lowmemorykiller: fix declaration order warnings
ANDROID: mmc: move to a SCHED_FIFO thread
ANDROID: skip building drivers as modules
ANDROID: wakeup: Add the guard condition for len in pm_get_active_wakeup_sources
ANDROID: goldfish: pipe: fix platform_no_drv_owner.cocci warnings
ANDROID: epoll: use freezable blocking call
ANDROID: Fix for in kernel emergency remount when loop mounts are used
ANDROID: kbuild: Makefile.clean: make Kbuild and Makefile optional
ANDROID: kbuild: make it possible to specify the module output dir
ANDROID: ext4: Add support for FIDTRIM, a best-effort ioctl for deep discard trim
ANDROID: hardlockup: detect hard lockups without NMIs using secondary cpus
ANDROID: rtc-palmas: correct for bcd year
ANDROID: w1: ds2482: Manage SLPZ pin sleep state
ANDROID: fuse: Freeze client on suspend when request sent to userspace
ANDROID: serial_core: Add wake_peer uart operation
ANDROID: mm: add a field to store names for private anonymous memory
ANDROID: pstore/ram: Add ramoops_console_write_buf api
ANDROID: pstore: Update Documentation/android.txt
ANDROID: initramfs: Add skip_initramfs command line option
ANDROID: of: Fix build warnings
ANDROID: of: fix CONFIG_CMDLINE_EXTEND
ANDROID: ARM64: copy CONFIG_CMDLINE_EXTEND from ARM
ANDROID: of: Support CONFIG_CMDLINE_EXTEND config option
ANDROID: ARM: decompressor: Flush tlb before swiching domain 0 to client mode
ANDROID: ARM64: add option to build Image.gz/dtb combo
ANDROID: ARM: convert build of appended dtb zImage to list of dtbs
ANDROID: ARM: add config option to build zImage/dtb combo
ANDROID: ARM: Fix dtb list when DTB_IMAGE_NAMES is empty
ANDROID: arm64: pass return address to dma_common_contiguous_remap
ANDROID: arch: arm64: force -fno-pic
ANDROID: arm64: process: dump memory around registers when displaying regs
ANDROID: arm64: check for upper PAGE_SHIFT bits in pfn_valid()
ANDROID: ARM: fault: assume no context when IRQs are disabled during data abort.
ANDROID: ARM: Fix "Make low-level printk work" to use a separate config option
ANDROID: ARM: add option to flush console before reboot
ANDROID: ARM: Make low-level printk work
ANDROID: Optionally flush entire dcache from v6_dma_flush_range
ANDROID: process: Add display of memory around registers when displaying regs.
ANDROID: security: Add proper checks for Android specific capability checks
ANDROID: uid_cputime: skip power reporting per uid for now
ANDROID: uid_cputime: Check for the range while removing range of UIDs.
ANDROID: uid_cputime: Iterates over all the threads instead of processes.
ANDROID: uid_cputime: fix cputime overflow
ANDROID: uid_cputime: Avoids double accounting of process stime, utime and cpu_power in task exit.
ANDROID: uid_cputime: Extends the cputime functionality to report power per uid
ANDROID: proc: uid_cputime: fix show_uid_stat permission
ANDROID: proc: uid_cputime: create uids from kuids
ANDROID: proc: uid: Adds accounting for the cputimes per uid.
ANDROID: fixup! proc: make oom adjustment files user read-only
ANDROID: proc: make oom adjustment files user read-only
ANDROID: proc: smaps: Allow smaps access for CAP_SYS_RESOURCE
ANDROID: wakeup_reason: use vsnprintf instead of snsprintf for vargs.
ANDROID: power: wakeup_reason: fix suspend time reporting
ANDROID: wakeup: Add last wake up source logging for suspend abort reason.
ANDROID: Power: Report suspend times from last_suspend_time
ANDROID: Make suspend abort reason logging depend on CONFIG_PM_SLEEP
ANDROID: power: Add check_wakeup_reason() to verify wakeup source irq
ANDROID: power: Adds functionality to log the last suspend abort reason.
ANDROID: power: Avoids bogus error messages for the suspend aborts.
ANDROID: power: Add property CHARGE_COUNTER_EXT and 64-bit precision properties
ANDROID: Power: Changes the permission to read only for sysfs file /sys/kernel/wakeup_reasons/last_resume_reason
ANDROID: power: wakeup_reason: rename irq_count to irqcount
ANDROID: Power: Add guard condition for maximum wakeup reasons
ANDROID: POWER: fix compile warnings in log_wakeup_reason
ANDROID: Power: add an API to log wakeup reasons
ANDROID: PM / Suspend: Print wall time at suspend entry and exit
ANDROID: power: power_supply: add POWER_SUPPLY_PROP_CHARGE_ENABLED
ANDROID: power: power_supply: add POWER_SUPPLY_PROP_USB_OTG
ANDROID: power: power_supply: move POWER_SUPPLY_PROP_USB_HC to type 'int' order
ANDROID: power_supply: Add custom property for USB High Current mode
ANDROID: trace: power: add trace_clock_set_parent
ANDROID: trace: cpufreq: Add tracing for min/max cpufreq
ANDROID: trace: fix compilation for 4.1
ANDROID: trace/events: fix gpu event timestamp formatting
ANDROID: trace: add non-hierarchical function_graph option
ANDROID: trace: Add an option to show tgids in trace output
ANDROID: trace/events: add gpu trace events
ANDROID: sync: add Documentation/sync.txt
ANDROID: ARM: Call idle notifiers
ANDROID: Move x86_64 idle notifiers to generic
ANDROID: cpuidle: governor: menu: don't use loadavg
ANDROID: sched: add sched blocked tracepoint which dumps out context of sleep.
ANDROID: sched: Enable might_sleep before initializing drivers.
ANDROID: fiq_debugger: Build fixes for 4.1
ANDROID: fiq_debugger: Add fiq_watchdog_triggered api
ANDROID: fiq_debugger: Call fiq_debugger_printf through a function pointer from cpu specific code
ANDROID: fiq_debugger: add ARM64 support
ANDROID: fiq_debugger: split arm support into fiq_debugger_arm.c
ANDROID: fiq_debugger: use pt_regs for registers
ANDROID: fiq_debugger: allow compiling without CONFIG_FIQ_GLUE
ANDROID: fiq_debugger: rename debug->fiq_debugger
ANDROID: fiq_debugger: move into drivers/staging/android/fiq_debugger/
ANDROID: ARM: fiq_glue: Add custom fiq return handler api.
ANDROID: ARM: kgdb: ignore breakpoint instructions from user mode
ANDROID: ARM: fiq_debugger: Update tty code for 3.9
ANDROID: ARM: fiq_debugger: Use kmsg_dumper to dump kernel logs
ANDROID: ARM: fiq_debugger: Fix to compile on 3.7
ANDROID: ARM: fiq_debugger: fix uninitialised spin_lock.
ANDROID: ARM: fiq_debugger: lock between tty and console writes
ANDROID: ARM: fiq_debugger: add process context reboot command
ANDROID: ARM: fiq_debugger: fix multiple consoles and make it a preferred console
ANDROID: kdb: support new lines without carriage returns
ANDROID: ARM: fiq_debugger: add support for kgdb
ANDROID: ARM: fiq_debugger: add debug_putc
ANDROID: ARM: fiq_debugger: add support for reboot commands
ANDROID: ARM: fiq_debugger: fix compiling for v3.3
ANDROID: ARM: Add generic fiq serial debugger
ANDROID: ARM: Add fiq_glue
ANDROID: fix false disconnect due to a signal sent to the reading process
ANDROID: usb: gadget: cleanup: fix unused variable and function warnings
ANDROID: usb: gadget: build audio_source function only if SND is enabled
ANDROID: usb: gadget: configfs: handle gadget reset request for android
ANDROID: usb: gadget: create F_midi device
ANDROID: usb: gadget: Add device attribute to determine gadget state
ANDROID: usb: phy: fix dual role sysfs build if kernel modules are supported
ANDROID: usb: phy: Dual role sysfs class definition
ANDROID: usb: gadget: fix NULL ptr derefer while symlinking PTP func
ANDROID: usb:gadget:Add "state" attribute to android_device
ANDROID: usb: gadget: Do not disconnect unregistered dev
ANDROID: usb: gadget: Relocate f_accessory
ANDROID: usb: gadget: Accessory:Migrate to USB_FUNCTION API
ANDROID: usb: gadget: Move gadget functions code
ANDROID: usb:gadget:audio_source: Move to USB_FUNCTION API
ANDROID: usb: gadget: Add function devices to the parent
ANDROID: usb: gadget: f_audio_source:replace deprecated API
ANDROID: usb: gadget: check for accessory device before disconnecting HIDs
ANDROID: usb: gadget: Add Uevent to notify userspace
ANDROID: usb: gadget: configfs: Add usb_function ptr to fi struct
ANDROID: usb: gadget: mtp/ptp: Migrate functions to the USB_FUNCTION interface
Linux 4.9.6
libceph: stop allocating a new cipher on every crypto request
libceph: uninline ceph_crypto_key_destroy()
tools/virtio/ringtest: fix run-on-all.sh for offline cpus
selftest/powerpc: Wrong PMC initialized in pmc56_overflow test
soc: ti: wkup_m3_ipc: Fix error return code in wkup_m3_ipc_probe()
spi: pxa2xx: add missed break
dmaengine: pl330: Fix runtime PM support for terminated transfers
dmaengine: rcar-dmac: unmap slave resource when channel is freed
s5p-mfc: Fix clock management in s5p_mfc_release() function
s5p-cec: mark PM functions as __maybe_unused again
st-hva: fix some error handling in hva_hw_probe()
ite-cir: initialize use_demodulator before using it
gs1662: drop kfree for memory allocated with devm_kzalloc
platform: pxa_camera: add VIDEO_V4L2 dependency
blackfin: check devm_pinctrl_get() for errors
rpmsg: virtio_rpmsg_bus: fix channel creation
mtd: spi-nor: Fix some error codes in cqspi_setup_flash()
mtd: spi-nor: Off by one in cqspi_setup_flash()
PM / devfreq: Fix the bug of devfreq_add_device when governor is NULL
PM / devfreq: exynos-bus: Fix the wrong return value
scsi: mpt3sas: fix hang on ata passthrough commands
scsi: ses: Fix SAS device detection in enclosure
swiotlb: Add swiotlb=noforce debug option
swiotlb: Convert swiotlb_force from int to enum
arm64: Fix swiotlb fallback allocation
arm64: mm: avoid name clash in __page_to_voff()
xprtrdma: Squelch "max send, max recv" messages at connect time
xprtrdma: Make FRWR send queue entry accounting more accurate
libceph: make sure ceph_aes_crypt() IV is aligned
ceph: fix endianness bug in frag_tree_split_cmp
ceph: fix endianness of getattr mask in ceph_d_revalidate
ceph: fix ceph_get_caps() interruption
ceph: fix scheduler warning due to nested blocking
ARM: 8613/1: Fix the uaccess crash on PB11MPCore
ARM: ux500: fix prcmu_is_cpu_in_wfi() calculation
ARM: dts: omap3: Fix Card Detect and Write Protect on Logic PD SOM-LV
ARM: dts: imx6qdl-nitrogen6_max: fix sgtl5000 pinctrl init
ARM: dts: omap2: Add an empty chosen node to top level DTSI
ARM: dts: omap3: Add an empty chosen node to top level DTSI
ARM: dts: am4372: Add an empty chosen node to top level DTSI
ARM: dts: omap5: Add an empty chosen node to top level DTSI
ARM: dts: omap4: Add an empty chosen node to top level DTSI
ARM: dts: am33xx: Add an empty chosen node to top level DTSI
ARM: dts: dm814x: Add an empty chosen node to top level DTSI
ARM: dts: dm816x: Add an empty chosen node to top level DTSI
ARM: dts: dra7: Add an empty chosen node to top level DTSI
libceph: remove now unused ceph_*{en,de}crypt*() functions
libceph: switch ceph_x_decrypt() to ceph_crypt()
libceph: switch ceph_x_encrypt() to ceph_crypt()
libceph: tweak calcu_signature() a little
libceph: rename and align ceph_x_authorizer::reply_buf
libceph: introduce ceph_crypt() for in-place en/decryption
libceph: introduce ceph_x_encrypt_offset()
libceph: old_key in process_one_ticket() is redundant
libceph: ceph_x_encrypt_buflen() takes in_len
Input: ALPS - fix TrackStick support for SS5 hardware
arm64/ptrace: Reject attempts to set incomplete hardware breakpoint fields
arm64/ptrace: Avoid uninitialised struct padding in fpr_set()
arm64/ptrace: Preserve previous registers for short regset write - 3
arm64/ptrace: Preserve previous registers for short regset write - 2
arm64/ptrace: Preserve previous registers for short regset write
arm64: avoid returning from bad_mode
ARM: dts: da850-evm: fix read access to SPI flash
ARM: dts: OMAP5 / DRA7: indicate that SATA port 0 is available.
ceph: fix bad endianness handling in parse_reply_info_extra
ibmvscsis: Fix max transfer length
ibmvscsis: Fix sleeping in interrupt context
ARM: 8634/1: hw_breakpoint: blacklist Scorpion CPUs
svcrdma: avoid duplicate dma unmapping during error recovery
clocksource/exynos_mct: Clear interrupt when cpu is shut down
ubifs: Fix journal replay wrt. xattr nodes
mac80211: implement multicast forwarding on fast-RX path
qla2xxx: Fix crash due to null pointer access
x86/ioapic: Restore IO-APIC irq_chip retrigger callback
powerpc: Ignore reserved field in DCSR and PVR reads and writes
powerpc/ptrace: Preserve previous TM fprs/vsrs on short regset write
powerpc/ptrace: Preserve previous fprs/vsrs on short regset write
powerpc/perf: Fix PM_BRU_CMPL event code for power9
powerpc/icp-opal: Fix missing KVM case and harden replay
KVM: arm/arm64: vgic: Fix deadlock on error handling
KVM: s390: do not expose random data via facility bitmap
mtd: nand: xway: fix build because of module functions
mtd: nand: xway: disable module support
mtd: nand: lpc32xx: fix invalid error handling of a requested irq
ieee802154: atusb: do not use the stack for buffers to make them DMA able
mmc: mxs-mmc: Fix additional cycles after transmission stop
mmc: sdhci-acpi: Only powered up enabled acpi child devices
HID: corsair: fix control-transfer error handling
HID: corsair: fix DMA buffers on stack
PCI: Enumerate switches below PCI-to-PCIe bridges
PCI: designware: Check for iATU unroll only on platforms that use ATU
fuse: fix time_to_jiffies nsec sanity check
fuse: clear FR_PENDING flag when moving requests out of pending queue
ARC: module: Fix !CONFIG_ARC_DW2_UNWIND builds
libnvdimm, namespace: fix pmem namespace leak, delete when size set to zero
svcrpc: don't leak contexts on PROC_DESTROY
sunrpc: don't call sleeping functions from the notifier block callbacks
rcu: Narrow early boot window of illegal synchronous grace periods
rcu: Remove cond_resched() from Tiny synchronize_sched()
x86/PCI: Ignore _CRS on Supermicro X8DTH-i/6/iF/6F
tmpfs: clear S_ISGID when setting posix ACLs
ARM: dts: omap3: Add DTS for Logic PD SOM-LV 37xx Dev Kit
ARM: dts: imx31: fix AVIC base address
ARM: dts: imx31: move CCM device node to AIPS2 bus devices
ARM: dts: imx31: fix clock control module interrupts description
ARM: dts: imx6q-cm-fx6: fix fec pinctrl
ARM: dts: r8a7794: remove Z clock
ARM: dts: r8a7794: Use SYSC "always-on" PM Domain for sound
ARM: dts: bcm283x: fix typo in mailbox address
perf jit: Enable jitdump support without dwarf
perf scripting: Avoid leaking the scripting_context variable
perf callchain: Fixup help/config for no-unwinding
perf diff: Do not overwrite valid build id
perf trace: Check if MAP_32BIT is defined (again)
perf mem: Fix --all-user/--all-kernel options
perf trace: Use the syscall raw_syscalls:sys_enter timestamp
IB/IPoIB: Remove can't use GFP_NOIO warning
IB/mlx4: Check if GRH is available before using it
IB/mlx4: When no DMFS for IPoIB, don't allow NET_IF QPs
IB/mlx4: Fix port query for 56Gb Ethernet links
IB/mlx4: Handle well-known-gid in mad_demux processing
IB/mlx4: Fix out-of-range array index in destroy qp flow
IB/mlx4: Set traffic class in AH
IB/mlx5: Wait for all async command completions to complete
IB/mlx5: Assign SRQ type earlier
IB/mlx5: Fix reported max SGE calculation
IB/mlx5: Avoid system crash when enabling many VFs
IB/rxe: avoid putting a large struct rxe_qp on stack
IB/rxe: Increase max number of completions to 32k
IB/core: Release allocated memory in cache setup failure
Linux 4.9.5
ANDROID: usb: gadget: f_audio_source: Fixed USB Audio Class Interface Descriptor
ANDROID: usb: gadget: f_audio_source: change max ISO packet size
ANDROID: usb: gadget: f_accessory: Enabled Zero Length Packet (ZLP) for acc_write
ANDROID: drivers: usb: gadget: 64-bit related type fixes
ANDROID: usb: gadget: f_accessory: move userspace interface to uapi
ANDROID: usb: gadget: f_mtp: move userspace interface to uapi
ANDROID: USB: remove duplicate out endpoint creation in MTP mode
ANDROID: usb: gadget: Fix android gadget driver build
ANDROID: usb: gadget: Fixes and hacks to make android usb gadget compile on 3.8
ANDROID: usb: otg: otg-wakelock: Fix build for 3.7
ANDROID: usb: gadget: accessory: Fix section mismatch (again)
ANDROID: USB: gadget: f_audio_source: New gadget driver for audio output
ANDROID: USB: gadget: f_accessory: Add support for HID input devices
ANDROID: USB: gadget: Add ACCESSORY_SET_AUDIO_MODE control request and ioctl
ANDROID: usb: gadget: accessory: Fix section mismatch
ANDROID: usb: otg: otg-wakelock: Fix build for 3.4
ANDROID: usb: gadget: adb: Only enable the gadget when adbd is ready
ANDROID: usb: gadget: adb: do not set error flag when dequeuing req
ANDROID: usb: gadget: adb: allow freezing in adb_read
ANDROID: usb: gadget: accessory: Add Android Accessory function
ANDROID: usb: gadget: adb: Add ADB function
ANDROID: usb: gadget: mtp: Add MTP/PTP function
ANDROID: usb: otg: otg-wakelock: fix build for 3.3
ANDROID: usb: otg: Temporarily grab wakelock on charger and disconnect events
ANDROID: USB: OTG: Take wakelock when VBUS present
ANDROID: wlan: Add get_wake_irq functionality
ANDROID: Add flags parameter to get_country_code template
ANDROID: net: wireless: Add get_country_code functionality to platform
ANDROID: network: wireless: Add get_mac_addr functionality to platform
ANDROID: wlan: Create generic wlan platform data header
ANDROID: net: wireless: Decrease scan entry expiration to avoid stall results
ANDROID: bridge: Have tx_bytes count headers like rx_bytes.
ANDROID: rfkill: Introduce CONFIG_RFKILL_PM and use instead of CONFIG_PM to power down
ANDROID: net: ipv6: fix virtual tunneling build
ANDROID: tcp: fix tcp_default_init_rwnd() for 4.1
ANDROID: net: support marking accepting TCP sockets
ANDROID: tcp: add a sysctl to config the tcp_default_init_rwnd
ANDROID: xt_qtaguid: fix a race condition in if_tag_stat_update
ANDROID: netfilter: xt_qtaguid/socket: build fixes for 4.4
ANDROID: netfilter: xt_qtaguid: xt_socket: build fixes
ANDROID: net: xt_qtaguid/xt_socket: fix refcount underflow and crash
ANDROID: xt_qtaguid: use sock_gen_put() instead of xt_socket_put_sk()
ANDROID: xt_qtaguid: Use sk_callback_lock read locks before reading sk->sk_socket
ANDROID: xt_qtaguid: fix broken uid/gid range check
ANDROID: netfilter: Build fixups - kuid/kguid changes & xt_socket_get/put_sk
ANDROID: net: ipv6: autoconf routes into per-device tables
ANDROID: nf: IDLETIMER: Fix broken uid field in the msg
ANDROID: nf: IDLETIMER: Adds the uid field in the msg
ANDROID: netfilter: fix seq_printf type mismatch warning
ANDROID: nf: Remove compilation error caused by e8430cbed3ef15fdb1ac26cfd020e010aa5f1c35
ANDROID: nf: IDLETIMER: time-stamp and suspend/resume handling.
ANDROID: xt_qtaguid: Fix boot panic
ANDROID: net: kuid/kguid build fixes
ANDROID: netfilter: ipv6: fix crash caused by ipv6_find_hdr()
ANDROID: netfilter: xt_qtaguid: 64-bit warning fixes
ANDROID: netfilter: xt_qtaguid: fix memory leak in seq_file handlers
ANDROID: netfilter: xt_qtaguid: fix bad tcp_time_wait sock handling
ANDROID: netfilter: xt_qtaguid: 3.10 fixes
ANDROID: netfilter: xt_quota2: 3.10 fixes.
ANDROID: netfilter: qtaguid: rate limit some of the printks
ANDROID: netfilter: xt_qtaguid: Allow tracking loopback
ANDROID: netfilter: xt_qtaguid: extend iface stat to report protocols
ANDROID: netfilter: xt_qtaguid: remove AID_* dependency for access control
ANDROID: netfilter: qtaguid: Don't BUG_ON if create_if_tag_stat fails
ANDROID: netfilter: xt_qtaguid: fix error exit that would keep a spinlock.
ANDROID: netfilter: xt_qtaguid: report only uid tags to non-privileged processes
ANDROID: netfilter: xt_qtaguid: start tracking iface rx/tx at low level
ANDROID: netfilter: xt_IDLETIMER: Add new netlink msg type
ANDROID: netfilter: xt_qtaguid: fix ipv6 protocol lookup
ANDROID: netfilter: qtaguid: initialize a local var to keep compiler happy.
ANDROID: netfilter: fixup the quota2, and enable.
ANDROID: netfilter: adding the original quota2 from xtables-addons
ANDROID: netfilter: add xt_qtaguid matching module
ANDROID: net: PPPoPNS and PPPoLAC build fixes for 4.4
ANDROID: Hack: net: PPPoPNS and PPPoLAC build fixes for 4.1
ANDROID: net: pppopns: pppolac: fix sendmsg function calls
ANDROID: net: PPPoPNS: Remove length argument from data_ready
ANDROID: net: move PPPoLAC and PPPoPNS headers to uapi
ANDROID: Include if_pppolac.h and if_pppopns.h into header-y target
ANDROID: net: PPPoPNS and PPPoLAC update to use PPP_MRU instead of PPP_MRU
ANDROID: net: Reorder incoming packets in PPPoLAC and PPPoPNS.
ANDROID: net: PPPoPNS and PPPoLAC fixes.
ANDROID: net: add PPP on PPTP Network Server (PPPoPNS) driver.
ANDROID: net: add PPP on L2TP Access Concentrator (PPPoLAC) driver.
ANDROID: sysfs_net_ipv4: Add sysfs-based knobs for controlling TCP window size
ANDROID: net: Only NET_ADMIN is allowed to fully control TUN interfaces.
ANDROID: net: Replace AID_NET_RAW checks with capable(CAP_NET_RAW).
ANDROID: security: Add AID_NET_RAW and AID_NET_ADMIN capability check in cap_capable().
ANDROID: Paranoid network.
ANDROID: Add android_aid.h
ANDROID: fs: block_dump: Don't display inode changes if block_dump < 2
ANDROID: mmc: core: Remove stray CONFIG_EXPERIMENTAL dependencies
ANDROID: mmc: Add "ignore mmc pm notify" functionality
ANDROID: mmc: sdio: Fix sdio_reset_comm for sync
ANDROID: mmc: sdio: fix sdio_reset_comm() voltage selection
ANDROID: mmc: sdio: Fix enable_hs and enable_wide in sdio_reset_comm()
ANDROID: mmc: sdio: Add high speed support to sdio_reset_comm()
ANDROID: mmc: sdio: Claim host in sdio_reset_comm()
ANDROID: mmc: Add new API call 'sdio_reset_comm' for resetting communication with an SDIO device
ANDROID: mmc: Add sdio_readb_ext() function
ANDROID: mmc: Add concept of an 'embedded' SDIO device.
ANDROID: mmc: sd: Add retries in re-detection
ANDROID: mmc: sd: When resuming, try a little harder to init the card
ANDROID: mmc: sd: Add new CONFIG_MMC_PARANOID_SD_INIT for enabling retries during SD detection
ANDROID: mtd: nand: Allow NAND chip ids to be included standalone.
ANDROID: gpio_input: convert from wakelocks to wakeup sources
ANDROID: input: Made keyreset more robust
ANDROID: input: Changed keyreset to act as a wrapper for keycombo.
ANDROID: input: add keycombo, a general key combo driver.
ANDROID: input: misc: keychord: move header to uapi
ANDROID: input: misc: keychord: log when keychord triggered
ANDROID: input: keychord: Add keychord driver
ANDROID: input: Add keyreset driver.
ANDROID: input: misc: gpio_event: remove early suspend
ANDROID: Input: Generic GPIO Input device.
ANDROID: lowmemorykiller: use module_param_cb instead of __module_param_call
ANDROID: lowmemorykiller: trace kill events.
ANDROID: staging: lowmemorykiller: Add config option to support oom_adj values
pinctrl: sh-pfc: Do not unconditionally support PIN_CONFIG_BIAS_DISABLE
arm64: hugetlb: fix the wrong return value for huge_ptep_set_access_flags
arm64: hugetlb: remove the wrong pmd check in find_num_contig()
arm64: hugetlb: fix the wrong address for several functions
powerpc/powernv: Don't warn on PE init if unfreeze is unsupported
powerpc/ibmebus: Fix device reference leaks in sysfs interface
powerpc/ibmebus: Fix further device reference leaks
powerpc/mm: Correct process and partition table max size
bus: vexpress-config: fix device reference leak
blk-mq: Always schedule hctx->next_cpu
power: supply: bq27xxx_battery: Fix register map for BQ27510 and BQ27520
bq24190_charger: Fix PM runtime use for bq24190_battery_set_property
iw_cxgb4: Fix error return code in c4iw_rdev_open()
powercap/intel_rapl: fix and tidy up error handling
ACPI / APEI: Fix NMI notification handling
block: cfq_cpd_alloc() should use @gfp
block: Change extern inline to static inline
ACPI / CPPC: set an error code on probe error path
regulators: helpers: Fix handling of bypass_val_on in get_bypass_regmap
cpufreq: powernv: Disable preemption while checking CPU throttling state
powerpc/64: Simplify adaptation to new ISA v3.00 HPTE format
remoteproc: st: Fix error return code in st_rproc_probe()
remoteproc: qcom_wcnss: Fix circular module dependency
drm: Initialise drm_mm.head_node.allocated
drm/i915: Move the min_pixclk[] handling to the end of readout
drm/panel: simple: Check against num_timings when setting preferred for timing
drm: avoid uninitialized timestamp use in wait_vblank
drm/i915/gen9: Fix PCODE polling during SAGV disabling
i2c: mux: pca954x: fix i2c mux selection caching
NFSv4.1: nfs4_fl_prepare_ds must be careful about reporting success.
NFS: Fix a performance regression in readdir
pNFS: Fix race in pnfs_wait_on_layoutreturn
NFS: fix typo in parameter description
pinctrl: meson: fix gpio request disabling other modes
btrfs: fix error handling when run_delayed_extent_op fails
btrfs: fix locking when we put back a delayed ref that's too new
nvme: apply DELAY_BEFORE_CHK_RDY quirk at probe time too
x86/cpu: Fix bootup crashes by sanitizing the argument of the 'clearcpuid=' command-line option
i2c: piix4: Avoid race conditions with IMC
net/mlx5: Only cancel recovery work when cleaning up device
USB: serial: ch341: fix modem-control and B0 handling
drm/amdgpu: drop verde dpm quirks
drm/amdgpu: update si kicker smc firmware
drm/radeon: drop verde dpm quirks
drm/radeon: update smc firmware selection for SI
drm: Clean up planes in atomic commit helper failure path
drm/i915/gen9: Fix PCODE polling timeout in stable backport
net/af_iucv: don't use paged skbs for TX on HiperSockets
sysctl: Drop reference added by grab_header in proc_sys_readdir
Clearing FIFOs in RS485 emulation mode causes subsequent transmits to break
extcon: return error code on failure
sysrq: attach sysrq handler correctly for 32-bit kernel
orinoco: Use shash instead of ahash for MIC calculations
ibmvscsis: Fix srp_transfer_data fail return code
tty/serial: atmel_serial: BUG: stop DMA from transmitting in stop_tx
tty/serial: atmel: RS485 half duplex w/DMA: enable RX after TX is done
virtio_blk: avoid DMA to stack for the sense buffer
dmaengine: omap-dma: Fix dynamic lch_map allocation
drivers: char: mem: Fix thinkos in kmem address checks
mnt: Protect the mountpoint hashtable with mount_lock
pid: fix lockdep deadlock warning due to ucount_lock
vme: Fix wrong pointer utilization in ca91cx42_slave_get
Revert "tty: serial: 8250: add CON_CONSDEV to flags"
ASoC: hdmi-codec: use unsigned type to structure members with bit-field
btrfs: fix crash when tracepoint arguments are freed by wq callbacks
xhci: fix deadlock at host remove by running watchdog correctly
fix a fencepost error in pipe_advance()
i2c: fix kernel memory disclosure in dev interface
i2c: print correct device invalid address
Input: elants_i2c - avoid divide by 0 errors on bad touchscreen data
USB: serial: ch341: fix open and resume after B0
USB: serial: ch341: fix control-message error handling
USB: serial: ch341: fix open error handling
USB: serial: ch341: fix resume after reset
USB: serial: ch341: fix initial modem-control state
USB: serial: kl5kusb105: fix line-state error handling
usb: musb: fix runtime PM in debugfs
wusbcore: Fix one more crypto-on-the-stack bug
x86/CPU/AMD: Fix Bulldozer topology
x86/bugs: Separate AMD E400 erratum and C1E bug
x86/cpu/AMD: Clean up cpu_llc_id assignment per topology feature
bridge: netfilter: Fix dropping packets that moving through bridge interface
xfs: Timely free truncated dirty pages
gpio: Move freeing of GPIO hogs before numbing of the device
nl80211: fix sched scan netlink socket owner destruction
x86/efi: Don't allocate memmap through memblock after mm_init()
efi/x86: Prune invalid memory map entries and fix boot regression
efi/libstub/arm*: Pass latest memory map to the kernel
KVM: x86: Introduce segmented_write_std
KVM: x86: emulate FXSAVE and FXRSTOR
KVM: x86: add asm_safe wrapper
KVM: x86: add Align16 instruction flag
KVM: x86: fix NULL deref in vcpu_scan_ioapic
KVM: x86: flush pending lapic jump label updates on module unload
jump_labels: API for flushing deferred jump label updates
KVM: eventfd: fix NULL deref irqbypass consumer
KVM: x86: fix emulation of "MOV SS, null selector"
mm/hugetlb.c: fix reservation race when freeing surplus pages
mm/slab.c: fix SLAB freelist randomization duplicate entries
mm: support anonymous stable page
mm, memcg: fix the active list aging for lowmem requests when memcg is enabled
ocfs2: fix crash caused by stale lvb with fsdlm plugin
mm: fix devm_memremap_pages crash, use mem_hotplug_{begin, done}
mm: pmd dirty emulation in page fault handler
dax: fix deadlock with DAX 4k holes
zram: support BDI_CAP_STABLE_WRITES
zram: revalidate disk under init_lock
selftests: do not require bash for the generated test
selftests: do not require bash to run netsocktests testcase
drm/savage: dereferencing an error pointer
drm/vc4: Fix a couple error codes in vc4_cl_lookup_bos()
drm/tegra: dpaux: Fix error handling
regulator: axp20x: Fix axp809 ldo_io registration error on cold boot
regulator: tps65086: Fix 25mV ranges for BUCK regulators
pinctrl: sh-pfc: Add helper to handle bias lookup table
pinctrl: sh-pfc: r8a7795: Use lookup function for bias data
pinctrl: imx: fix imx_pinctrl_desc initialization
Input: i8042 - add Pegatron touchpad to noloop table
Input: xpad - use correct product id for x360w controllers
Linux 4.9.4
rtlwifi: rtl_usb: Fix missing entry in USB driver's private data
rtlwifi: Fix enter/exit power_save
drm/i915/gen9: Fix PCODE polling during CDCLK change notification
ALSA: usb-audio: Add a quirk for Plantronics BT600
spi: mvebu: fix baudrate calculation for armada variant
ARM: omap2+: am437x: rollback to use omap3_gptimer_timer_init()
ARM: 8631/1: clkdev: Detect errors in clk_hw_register_clkdev() for mass registration
ARM: OMAP4+: Fix bad fallthrough for cpuidle
ARM: OMAP5: Fix build for PM code
ARM: OMAP5: Fix mpuss_early_init
bus: arm-ccn: Prevent hotplug callback leak
svcrdma: Clear xpt_bc_xps in xprt_setup_rdma_bc() error exit arm
ARM: qcom_defconfig: Fix MDM9515 LCC and GCC config
ARM: zynq: Reserve correct amount of non-DMA RAM
ARM: pxa: fix pxa25x interrupt init
ARM64: dts: bcm2835: Fix bcm2837 compatible string
ARM64: dts: bcm2837-rpi-3-b: remove incorrect pwr LED
arm64: dts: mt8173: Fix auxadc node
tools/virtio: fix READ_ONCE()
powerpc: Fix build warning on 32-bit PPC
ALSA: firewire-tascam: Fix to handle error from initialization of stream data
HID: hid-cypress: validate length of report
net: vrf: do not allow table id 0
net: ipv4: Fix multipath selection with vrf
net/mlx5e: Remove WARN_ONCE from adaptive moderation code
gro: Disable frag0 optimization on IPv6 ext headers
gro: use min_t() in skb_gro_reset_offset()
gro: Enter slow-path if there is no tailroom
net: add the AF_QIPCRTR entries to family name tables
net: dsa: Ensure validity of dst->ds[0]
r8152: fix rx issue for runtime suspend
r8152: split rtl8152_suspend function
net: dsa: bcm_sf2: Utilize nested MDIO read/write
net: dsa: bcm_sf2: Do not clobber b53_switch_ops
bpf: change back to orig prog on too many passes
net: vrf: Add missing Rx counters
ipv4: Do not allow MAIN to be alias for new LOCAL w/ custom rules
igmp: Make igmp group member RFC 3376 compliant
flow_dissector: Update pptp handling to avoid null pointer deref.
drop_monitor: consider inserted data in genlmsg_end
drop_monitor: add missing call to genlmsg_end
net: ipv4: dst for local input routes should use l3mdev if relevant
net: fix incorrect original ingress device index in PKTINFO
rtnl: stats - add missing netlink message size checks
net/mlx5e: Disable netdev after close
net/mlx5e: Don't sync netdev state when not registered
net/mlx5: Prevent setting multicast macs for VFs
net/mlx5: Mask destination mac value in ethtool steering rules
net/mlx5: Avoid shadowing numa_node
net/mlx5: Cancel recovery work in remove flow
net/mlx5: Check FW limitations on log_max_qp before setting it
net/sched: cls_flower: Fix missing addr_type in classify
net: stmmac: Fix race between stmmac_drv_probe and stmmac_open
net, sched: fix soft lockup in tc_classify
ipv6: handle -EFAULT from skb_copy_bits
inet: fix IP(V6)_RECVORIGDSTADDR for udp sockets
sctp: sctp_transport_lookup_process should rcu_read_unlock when transport is null
net: vrf: Drop conntrack data after pass through VRF device on Tx
net: vrf: Fix NAT within a VRF
Linux 4.9.3
usb: gadget: composite: always set ep->mult to a sensible value
Revert "usb: gadget: composite: always set ep->mult to a sensible value"
Revert "rtlwifi: Fix enter/exit power_save"
tick/broadcast: Prevent NULL pointer dereference
clocksource/dummy_timer: Move hotplug callback after the real timers
xfs: fix max_retries _show and _store functions
xfs: fix crash and data corruption due to removal of busy COW extents
xfs: use the actual AG length when reserving blocks
xfs: fix double-cleanup when CUI recovery fails
xfs: use GPF_NOFS when allocating btree cursors
xfs: ignore leaf attr ichdr.count in verifier during log replay
xfs: don't cap maximum dedupe request length
xfs: don't allow di_size with high bit set
xfs: error out if trying to add attrs and anextents > 0
xfs: don't crash if reading a directory results in an unexpected hole
xfs: complain if we don't get nextents bmap records
xfs: check for bogus values in btree block headers
xfs: forbid AG btrees with level == 0
xfs: handle cow fork in xfs_bmap_trace_exlist
xfs: pass state not whichfork to trace_xfs_extlist
xfs: Move AGI buffer type setting to xfs_read_agi
xfs: pass post-eof speculative prealloc blocks to bmapi
xfs: use new extent lookup helpers xfs_file_iomap_begin_delay
xfs: clean up cow fork reservation and tag inodes correctly
xfs: use new extent lookup helpers in __xfs_reflink_reserve_cow
xfs: track preallocation separately in xfs_bmapi_reserve_delalloc()
xfs: remove prev argument to xfs_bmapi_reserve_delalloc
xfs: always succeed when deduping zero bytes
xfs: factor rmap btree size into the indlen calculations
xfs: new inode extent list lookup helpers
xfs: fix unbalanced inode reclaim flush locking
xfs: check minimum block size for CRC filesystems
xfs: provide helper for counting extents from if_bytes
xfs: don't BUG() on mixed direct and mapped I/O
xfs: don't skip cow forks w/ delalloc blocks in cowblocks scan
xfs: check return value of _trans_reserve_quota_nblks
xfs: don't call xfs_sb_quota_from_disk twice
tpm_tis: Check return values from get_burstcount.
drm/i915/gen9: fix the WM memory bandwidth WA for Y tiling cases
drm/i915/gen9: unconditionally apply the memory bandwidth WA
drm/i915: disable PSR by default on HSW/BDW
drm/radeon: Always store CRTC relative radeon_crtc->cursor_x/y values
s390/pci: fix dma address calculation in map_sg
s390/topology: always use s390 specific sched_domain_topology_level
powerpc/pci/rpadlpar: Fix device reference leaks
PCI: Enable access to non-standard VPD for Chelsio devices (cxgb3)
PCI: Support INTx masking on ConnectX-4 with firmware x.14.1100+
PCI: Convert Mellanox broken INTx quirks to be for listed devices only
PCI: Convert broken INTx masking quirks from HEADER to FINAL
PCI: Add Mellanox device IDs
PCI: rockchip: Correct the use of FTS mask
PCI: rockchip: Fix negotiated lanes calculation
staging: media: davinci_vpfe: unlock on error in vpfe_reqbufs()
f2fs: hide a maybe-uninitialized warning
f2fs: remove percpu_count due to performance regression
md: fix refcount problem on mddev when stopping array.
md: MD_RECOVERY_NEEDED is set for mddev->recovery
crypto: arm64/aes-ce - fix for big endian
crypto: arm64/aes-xts-ce: fix for big endian
crypto: arm64/sha1-ce - fix for big endian
crypto: arm64/aes-neon - fix for big endian
crypto: arm64/aes-ccm-ce: fix for big endian
crypto: arm/aes-ce - fix for big endian
crypto: arm64/ghash-ce - fix for big endian
crypto: arm64/sha2-ce - fix for big endian
s390/crypto: unlock on error in prng_tdes_read()
mm, compaction: fix NR_ISOLATED_* stats for pfn based migration
mm: khugepaged: fix radix tree node leak in shmem collapse error path
mm: khugepaged: close use-after-free race during shmem collapsing
docs-rst: fix LaTeX \DURole renewcommand with Sphinx 1.3+
mm/hugetlb.c: use the right pte val for compare in hugetlb_cow
rpmsg: qcom_smd: Correct return value for O_NONBLOCK
mmc: mmc_test: Uninitialized return value
genirq/affinity: Fix node generation from cpumask
PM / wakeirq: Fix dedicated wakeirq for drivers not using autosuspend
irqchip/bcm7038-l1: Implement irq_cpu_offline() callback
PCI/MSI: Check for NULL affinity mask in pci_irq_get_affinity()
ima: fix memory leak in ima_release_policy
relay: check array offset before using it
sbp-target: Fix second argument of percpu_ida_alloc()
target/iscsi: Fix double free in lio_target_tiqn_addtpg()
scsi: mvsas: fix command_active typo
scsi: g_NCR5380: Fix release_region in error handling
ASoC: samsung: i2s: Fixup last IRQ unsafe spin lock call
ASoC: Intel: Skylake: Fix a shift wrapping bug
ASoC: cht_bsw_rt5645: Fix leftover kmalloc
ASoC: lpass-platform: initialize dma channel number
iommu/vt-d: Flush old iommu caches for kdump when the device gets context mapped
iommu/vt-d: Fix pasid table size encoding
iommu/amd: Fix the left value check of cmd buffer
iommu/amd: Missing error code in amd_iommu_init_device()
clk: renesas: mstp: Support 8-bit registers for r7s72100
clk: imx31: fix rewritten input argument of mx31_clocks_init()
clk: sunxi-ng: sun8i-h3: Set CLK_SET_RATE_PARENT for audio module clocks
clk: sunxi-ng: sun8i-a23: Set CLK_SET_RATE_PARENT for audio module clocks
clk: ti: dra7: fix "failed to lookup clock node gmac_gmii_ref_clk_div" boot message
clk: clk-wm831x: fix a logic error
clk: qcom: ipq806x: Fix board clk rates
Input: synaptics-rmi4 - unlock on error
hwmon: (lm90) fix temp1_max_alarm attribute
hwmon: (g762) Fix overflows and crash seen when writing limit attributes
hwmon: (nct7802) Fix overflows seen when writing into limit attributes
hwmon: (ds620) Fix overflows seen when writing temperature limits
hwmon: (amc6821) sign extension temperature
hwmon: (scpi) Fix module autoload
platform/x86: fujitsu-laptop: use brightness_set_blocking for LED-setting callbacks
x86/cpu: Probe CPUID leaf 6 even when cpuid_level == 6
x86/prctl/uapi: Remove #ifdef for CHECKPOINT_RESTORE
debugfs: improve DEFINE_DEBUGFS_ATTRIBUTE for !CONFIG_DEBUG_FS
clk: renesas: cpg-mssr: Fix inverted debug check
efi/efivar_ssdt_load: Don't return success on allocation failure
cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected
ath10k: use the right length of "background"
mfd: tps65217: Fix page fault on unloading modules
ath10k: fix failure to send NULL func frame for 10.4
nl80211: Use different attrs for BSSID and random MAC addr in scan req
mac80211: fix tid_agg_rx NULL dereference
drm/i915: tune down the fast link training vs boot fail
drm/i915/dp: add lane_count check in intel_dp_check_link_status
usb: dwc3: gadget: always unmap EP0 requests
usb: dwc3: ep0: explicitly call dwc3_ep0_prepare_one_trb()
usb: dwc3: ep0: add dwc3_ep0_prepare_one_trb()
iio: accel: st_accel: fix LIS3LV02 reading and scaling
staging: iio: ad7606: fix improper setting of oversampling pins
mei: move write cb to completion on credentials failures
mei: bus: fix mei_cldev_enable KDoc
mei: fix parameter rename KDoc
USB: serial: io_ti: bind to interface after fw download
dibusb: fix possible memory leak in dibusb_rc_query()
ARM: dts: sun7i: bananapi-m1-plus: Enable USB PHY for USB host support
arm64: dts: hip06: Correct hardware pin number of usb node
USB: phy: am335x-control: fix device and of_node leaks
ARM: dts: r8a7794: Correct hsusb parent clock
usb: gadget: fix request length error for isoc transfer
usb: gadget: Fix second argument of percpu_ida_alloc()
USB: serial: kl5kusb105: abort on open exception path
ALSA: usb-audio: Fix bogus error return in snd_usb_create_stream()
usb: musb: blackfin: add bfin_fifo_offset in bfin_ops
usb: gadget: udc: core: fix return code of usb_gadget_probe_driver()
usb: hub: Move hub_port_disable() to fix warning if PM is disabled
usb: musb: Fix trying to free already-free IRQ 4
usb: dwc3: gadget: Fix full speed mode
usb: dwc3: pci: Fix dr_mode misspelling
usb: dwc3: pci: add Intel Gemini Lake PCI ID
xhci: Fix race related to abort operation
xhci: Use delayed_work instead of timer for command timeout
usb: xhci-mem: use passed in GFP flags instead of GFP_KERNEL
USB: serial: mos7720: fix parallel probe
USB: serial: mos7720: fix parport use-after-free on probe errors
USB: serial: mos7720: fix use-after-free on probe errors
USB: serial: mos7720: fix NULL-deref at open
USB: serial: mos7840: fix NULL-deref at open
USB: serial: kobil_sct: fix NULL-deref in write
USB: serial: cyberjack: fix NULL-deref at open
USB: serial: oti6858: fix NULL-deref at open
USB: serial: io_edgeport: fix NULL-deref at open
USB: serial: ti_usb_3410_5052: fix NULL-deref at open
USB: serial: garmin_gps: fix memory leak on failed URB submit
USB: serial: iuu_phoenix: fix NULL-deref at open
USB: serial: io_ti: fix I/O after disconnect
USB: serial: io_ti: fix another NULL-deref at open
USB: serial: io_ti: fix NULL-deref at open
USB: serial: spcp8x5: fix NULL-deref at open
USB: serial: keyspan_pda: verify endpoints at probe
USB: serial: pl2303: fix NULL-deref at open
USB: serial: quatech2: fix sleep-while-atomic in close
USB: serial: omninet: fix NULL-derefs at open and disconnect
usb: return error code when platform_get_irq fails
usb: xhci: hold lock over xhci_abort_cmd_ring()
xhci: Handle command completion and timeout race
usb: host: xhci: Fix possible wild pointer when handling abort command
usb: xhci: fix return value of xhci_setup_device()
xhci: free xhci virtual devices with leaf nodes first
usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake
usb: xhci: fix possible wild pointer
usb: dwc3: core: avoid Overflow events
usb: gadget: composite: Test get_alt() presence instead of set_alt()
USB: dummy-hcd: fix bug in stop_activity (handle ep0)
USB: fix problems with duplicate endpoint addresses
USB: gadgetfs: fix checks of wTotalLength in config descriptors
USB: gadgetfs: fix use-after-free bug
USB: gadgetfs: fix unbounded memory allocation bug
usb: gadgetfs: restrict upper bound on device configuration size
usb: storage: unusual_uas: Add JMicron JMS56x to unusual device
usb: musb: dsps: implement clear_ep_rxintr() callback
usb: musb: core: add clear_ep_rxintr() to musb_platform_ops
KVM: MIPS: Flush KVM entry code from icache globally
KVM: MIPS: Don't clobber CP0_Status.UX
KVM: x86: reset MMU on KVM_SET_VCPU_EVENTS
drm/i915: Initialize overlay->last_flip properly
drm/i915: Force VDD off on the new power seqeuencer before starting to use it
drm/i915: Fix oops in overlay due to frontbuffer tracking
drm/i915: Fix oopses in the overlay code due to i915_gem_active stuff
gcc-plugins: update gcc-common.h for gcc-7
asm-prototypes: Clear any CPP defines before declaring the functions
mac80211: initialize fast-xmit 'info' later
pinctrl/amd: Set the level based on ACPI tables
ARM: davinci: da850: don't add emac clock to lookup table twice
HID: sensor-hub: Move the memset to sensor_hub_get_feature()
parisc: Mark cr16 clocksource unstable on SMP systems
parisc: Add line-break when printing segfault info
fscrypt: fix renaming and linking special files
ALSA: usb-audio: Fix irq/process data synchronization
ALSA: hda - Apply asus-mode8 fixup to ASUS X71SL
ALSA: hda - Fix up GPIO for ASUS ROG Ranger
staging: octeon: Call SET_NETDEV_DEV()
iio: bmi160: Fix time needed to sleep after command execution
iio: max44000: correct value in illuminance_integration_time_available
iio: common: st_sensors: fix channel data parsing
Linux 4.9.2
drm/i915: Fix setting of boost freq tunable
drm/i915: skip the first 4k of stolen memory on everything >= gen8
drm/i915: Initialize dev_priv->atomic_cdclk_freq at init time
drm/i915: Fix cdclk vs. dev_cdclk mess when not recomputing things
drm/i915/dsi: Do not clear DPOUNIT_CLOCK_GATE_DISABLE from vlv_init_display_clock_gating
drm/i915/dsi: Fix chv_exec_gpio disabling the GPIOs it is setting
net: mvpp2: fix dma unmapping of TX buffers for fragments
sg_write()/bsg_write() is not fit to be called under KERNEL_DS
kconfig/nconf: Fix hang when editing symbol with a long prompt
target/user: Fix use-after-free of tcmu_cmds if they are expired
libnvdimm, pfn: fix align attribute
of, numa: Return NUMA_NO_NODE from disable of_node_to_nid() if nid not possible.
powerpc/boot: Request no dynamic linker for boot wrapper
powerpc/ps3: Fix system hang with GCC 5 builds
powerpc/64e: Convert cmpi to cmpwi in head_64.S
SUNRPC: fix refcounting problems with auth_gss messages.
pNFS: Fix a deadlock between read resends and layoutreturn
pNFS: Clear NFS_LAYOUT_RETURN_REQUESTED when invalidating the layout stateid
pNFS: Don't clear the layout stateid if a layout return is outstanding
pNFS: On error, do not send LAYOUTGET until the LAYOUTRETURN has completed
nfs_write_end(): fix handling of short copies
libceph: verify authorize reply on connect
PCI: Check for PME in targeted sleep state
i40iw: Use correct src address in memcpy to rdma stats counters
bad_inode: add missing i_op initializers
Input: drv260x - fix input device's parent assignment
v4l: tvp5150: Add missing break in set control handler
media: solo6x10: fix lockup by avoiding delayed register write
s5p-mfc: fix failure path of s5p_mfc_alloc_memdev()
mn88473: fix chip id check on probe
mn88472: fix chip id check on probe
IB/cma: Fix a race condition in iboe_addr_get_sgid()
IB/rxe: Fix a memory leak in rxe_qp_cleanup()
IB/multicast: Check ib_find_pkey() return value
IPoIB: Avoid reading an uninitialized member variable
IB/mad: Fix an array index check
fgraph: Handle a case where a tracer ignores set_graph_notrace
x86/smpboot: Make logical package management more robust
platform/x86: asus-nb-wmi.c: Add X45U quirk
ftrace/x86_32: Set ftrace_stub to weak to prevent gcc from using short jumps to it
vsock/virtio: fix src/dst cid format
fsnotify: Fix possible use-after-free in inode iteration on umount
kvm: nVMX: Allow L1 to intercept software exceptions (#BP and #OF)
KVM: PPC: Book3S HV: Don't lose hardware R/C bit updates in H_PROTECT
KVM: PPC: Book3S HV: Save/restore XER in checkpointed register state
scsi: aacraid: remove wildcard for series 9 controllers
md/raid5: limit request size according to implementation limits
sc16is7xx: Drop bogus use of IRQF_ONESHOT
latent_entropy: fix ARM build error on earlier gcc
arm64: KVM: pmu: Reset PMSELR_EL0.SEL to a sane value before entering the guest
s390/kexec: use node 0 when re-adding crash kernel memory
s390/vmlogrdr: fix IUCV buffer allocation
firmware: fix usermode helper fallback loading
ARC: mm: arc700: Don't assume 2 colours for aliasing VIPT dcache
scsi: avoid a permanent stop of the scsi device's request queue
scsi: zfcp: fix rport unblock race with LUN recovery
scsi: zfcp: do not trace pure benign residual HBA responses at default level
scsi: zfcp: fix use-after-"free" in FC ingress path after TMF
iscsi-target: Return error if unable to add network portal
scsi: megaraid_sas: Do not set MPI2_TYPE_CUDA for JBOD FP path for FW which does not support JBOD sequence map
scsi: megaraid_sas: For SRIOV enabled firmware, ensure VF driver waits for 30secs before reset
stm class: Fix device leak in open error path
vt: fix Scroll Lock LED trigger name
block: protect iterate_bdevs() against concurrent close
mei: me: add lewisburg device ids
mei: request async autosuspend at the end of enumeration
drivers/gpu/drm/ast: Fix infinite loop if read fails
drm/amdgpu: fix init save/restore list in gfx_v8.0
drm/amdgpu: fix enable_cp_power_gating in gfx_v8.0.
drm/amd/powerplay: bypass fan table setup if no fan connected
drm/gma500: Add compat ioctl
drm/radeon/si: load the proper firmware on 0x87 oland boards
drm/radeon: add additional pci revision to dpm workaround
drm/radeon: Hide the HW cursor while it's out of bounds
drm/radeon: Also call cursor_move_locked when the cursor size changes
drm/nouveau/fifo/gf100-: protect channel preempt with subdev mutex
drm/nouveau/i2c/gk110b,gm10x: use the correct implementation
drm/nouveau/ttm: wait for bo fence to signal before unmapping vmas
drm/nouveau/ltc: protect clearing of comptags with mutex
drm/nouveau/bios: require checksum to match for fast acpi shadow method
drm/nouveau/kms: lvds panel strap moved again on maxwell
drm/nouveau/gr: fallback to legacy paths during firmware lookup
drm/amd/amdgpu: enable GUI idle INT after enabling CGCG
drm/amdgpu: Also call cursor_move_locked when the cursor size changes
drm/amdgpu: Store CRTC relative amdgpu_crtc->cursor_x/y values
drm/amdgpu: add additional pci revision to dpm workaround
drm/amdgpu/si: load the proper firmware on 0x87 oland boards
ACPI / video: Add force_native quirk for HP Pavilion dv6
ACPI / video: Add force_native quirk for Dell XPS 17 L702X
staging: comedi: ni_mio_common: fix E series ni_ai_insn_read() data
staging: comedi: ni_mio_common: fix M Series ni_ai_insn_read() data mask
staging: lustre: ldlm: pl_recalc time handling is wrong
staging/lustre/osc: Revert erroneous list_for_each_entry_safe use
hv: acquire vmbus_connection.channel_mutex in vmbus_free_channels()
docs: sphinx-extensions: make rstFlatTable work with docutils 0.13
thermal: hwmon: Properly report critical temperature in sysfs
clk: bcm2835: Avoid overwriting the div info when disabling a pll_div clk
arm64: tegra: Add VDD_GPU regulator to Jetson TX1
gpio: chardev: Return error for seek operations
gpio: stmpe: fix interrupt handling bug
timekeeping_Force_unsigned_clocksource_to_nanoseconds_conversion
mmc: sd: Meet alignment requirements for raw_ssr DMA
regulator: stw481x-vmmc: fix ages old enable error
mmc: sdhci: Fix recovery from tuning timeout
Revert "mmc: sdhci: Reset cmd and data circuits after tuning failure"
ath9k: do not return early to fix rcu unlocking
ath9k: Really fix LED polarity for some Mini PCI AR9220 MB92 cards.
ath9k: fix ath9k_hw_gpio_get() to return 0 or 1 on success
cfg80211/mac80211: fix BSS leaks when abandoning assoc attempts
rtl8xxxu: Work around issue with 8192eu and 8723bu devices not reconnecting
perf/x86/intel/cstate: Prevent hotplug callback leak
perf annotate: Don't throw error for zero length symbols
perf/x86: Fix exclusion of BTS and LBR for Goldmont
rtlwifi: Fix enter/exit power_save
ath10k: fix soft lockup during firmware crash/hw-restart
ssb: Fix error routine when fallback SPROM fails
Linux 4.9.1
x86/kbuild: enable modversions for symbols exported from asm
builddeb: fix cross-building to arm64 producing host-arch debs
xfs: set AGI buffer type in xlog_recover_clear_agi_bucket
xfs: fix up xfs_swap_extent_forks inline extent handling
arm/xen: Use alloc_percpu rather than __alloc_percpu
xen/gntdev: Use VM_MIXEDMAP instead of VM_IO to avoid NUMA balancing
tpm xen: Remove bogus tpm_chip_unregister
kernel/debug/debug_core.c: more properly delay for secondary CPUs
watchdog: qcom: fix kernel panic due to external abort on non-linefetch
watchdog: mei_wdt: request stop on reboot to prevent false positive event
kernel/watchdog: use nmi registers snapshot in hardlockup handler
CIFS: Fix a possible memory corruption in push locks
CIFS: Decrease verbosity of ioctl call
CIFS: Fix a possible double locking of mutex during reconnect
CIFS: Fix missing nls unload in smb2_reconnect()
CIFS: Fix a possible memory corruption during reconnect
cifs: Fix smbencrypt() to stop pointing a scatterlist at the stack
ASoC: intel: Fix crash at suspend/resume without card registration
dm space map metadata: fix 'struct sm_metadata' leak on failed create
dm raid: fix discard support regression
dm rq: fix a race condition in rq_completed()
dm crypt: mark key as invalid until properly loaded
dm flakey: return -EINVAL on interval bounds error in flakey_ctr()
dm table: an 'all_blk_mq' table must be loaded for a blk-mq DM device
dm table: fix 'all_blk_mq' inconsistency when an empty table is loaded
blk-mq: Do not invoke .queue_rq() for a stopped queue
PM / OPP: Don't use OPP structure outside of rcu protected section
PM / OPP: Pass opp_table to dev_pm_opp_put_regulator()
usb: gadget: composite: always set ep->mult to a sensible value
mm, page_alloc: keep pcp count and list contents in sync if struct page is corrupted
mm/vmscan.c: set correct defer count for shrinker
nvmet: Fix possible infinite loop triggered on hot namespace removal
loop: return proper error from loop_queue_rq()
f2fs: fix to determine start_cp_addr by sbi->cur_cp_pack
f2fs: fix overflow due to condition check order
f2fs: set ->owner for debugfs status file's file_operations
Revert "f2fs: use percpu_counter for # of dirty pages in inode"
ext4: do not perform data journaling when data is encrypted
ext4: return -ENOMEM instead of success
ext4: reject inodes with negative size
ext4: add sanity checking to count_overhead()
ext4: fix in-superblock mount options processing
ext4: use more strict checks for inodes_per_block on mount
ext4: fix stack memory corruption with 64k block size
ext4: fix mballoc breakage with 64k block size
ext4: don't lock buffer in ext4_commit_super if holding spinlock
crypto: caam - fix AEAD givenc descriptors
ptrace: Don't allow accessing an undumpable mm
ptrace: Capture the ptracer's creds not PT_PTRACE_CAP
vfs,mm: fix return value of read() at s_maxbytes
mm: Add a user_ns owner to mm_struct and fix ptrace permission checks
block_dev: don't test bdev->bd_contains when it is not stable
splice: reinstate SIGPIPE/EPIPE handling
fs: exec: apply CLOEXEC before changing dumpable task flags
exec: Ensure mm->user_ns contains the execed files
clk: ti: omap36xx: Work around sprz319 advisory 2.1
ALSA: hda: when comparing pin configurations, ignore assoc in addition to seq
ALSA: hda - Gate the mic jack on HP Z1 Gen3 AiO
ALSA: hda - fix headset-mic problem on a Dell laptop
ALSA: hda - ignore the assoc and seq when comparing pin configurations
ALSA: hda/ca0132 - Add quirk for Alienware 15 R2 2016
ALSA: hiface: Fix M2Tech hiFace driver sampling rate change
ALSA: usb-audio: Add QuickCam Communicate Deluxe/S7500 to volume_control_quirks
usbip: vudc: fix: Clear already_seen flag also for ep0
USB: UHCI: report non-PME wakeup signalling for Intel hardware
usb: gadget: composite: correctly initialize ep->maxpacket
usb: gadget: f_uac2: fix error handling at afunc_bind
usb: core: usbport: Use proper LED API to fix potential crash
usb: hub: Fix auto-remount of safely removed or ejected USB-3 devices
usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs
USB: cdc-acm: add device id for GW Instek AFG-125
USB: serial: kl5kusb105: fix open error path
USB: serial: option: add dlink dwm-158
USB: serial: option: add support for Telit LE922A PIDs 0x1040, 0x1041
Btrfs: fix qgroup rescan worker initialization
Btrfs: fix emptiness check for dirtied extent buffers at check_leaf()
btrfs: store and load values of stripes_min/stripes_max in balance status item
Btrfs: fix relocation incorrectly dropping data references
Btrfs: fix tree search logic when replaying directory entry deletes
Btrfs: fix deadlock caused by fsync when logging directory entries
Btrfs: fix BUG_ON in btrfs_mark_buffer_dirty
btrfs: limit async_work allocation and worker func duration
hotplug: Make register and unregister notifier API symmetric
ANDROID: Shrink ashmem directly through shmem_fallocate
ANDROID: ashmem: Add shmem_set_file to mm/shmem.c
ANDROID: Add android config documentation to boot framework.
Conflicts:
Documentation/android.txt
Documentation/cpu-freq/governors.txt
Documentation/networking/ip-sysctl.txt
arch/arm64/boot/Makefile
arch/arm64/kernel/process.c
arch/arm64/kernel/topology.c
arch/arm64/mm/dma-mapping.c
drivers/cpufreq/cpufreq_interactive.c
drivers/input/misc/gpio_matrix.c
drivers/md/Kconfig
drivers/md/dm-android-verity.c
drivers/md/dm-android-verity.h
drivers/md/dm-linear.c
drivers/md/dm-verity-fec.h
drivers/mmc/core/host.c
drivers/platform/goldfish/goldfish_pipe.c
drivers/power/supply/power_supply_sysfs.c
drivers/scsi/ufs/ufshcd.c
drivers/scsi/ufs/ufshcd.h
drivers/staging/android/fiq_debugger/fiq_debugger.c
drivers/staging/android/lowmemorykiller.c
drivers/usb/dwc3/core.h
drivers/usb/gadget/Kconfig
drivers/usb/gadget/configfs.c
drivers/usb/gadget/function/Makefile
drivers/usb/gadget/function/f_accessory.c
drivers/usb/gadget/function/f_audio_source.c
drivers/usb/gadget/function/f_fs.c
drivers/usb/gadget/function/f_mtp.c
drivers/usb/phy/Kconfig
drivers/usb/phy/otg-wakelock.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/f2fs/data.c
fs/proc/task_mmu.c
fs/sdcardfs/derived_perm.c
fs/sdcardfs/file.c
fs/sdcardfs/inode.c
fs/sdcardfs/lookup.c
fs/sdcardfs/main.c
fs/sdcardfs/packagelist.c
fs/sdcardfs/sdcardfs.h
fs/sdcardfs/super.c
include/linux/mmc/core.h
include/linux/power_supply.h
include/linux/sched.h
include/linux/usb/f_mtp.h
include/net/fib_rules.h
include/net/route.h
include/trace/events/cpufreq_interactive.h
include/trace/events/power.h
include/trace/events/sched.h
include/uapi/linux/magic.h
include/uapi/linux/prctl.h
init/Kconfig
kernel/cgroup.c
kernel/configs/android-base.config
kernel/power/process.c
kernel/sched/Makefile
kernel/sched/core.c
kernel/sched/cputime.c
kernel/sched/fair.c
kernel/sched/rt.c
kernel/sched/sched.h
kernel/sched/stop_task.c
kernel/sched/tune.c
lib/Kconfig.debug
net/core/fib_rules.c
net/ipv4/inet_connection_sock.c
net/ipv4/ping.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/syncookies.c
net/ipv4/udp.c
net/ipv6/af_inet6.c
net/ipv6/ah6.c
net/ipv6/datagram.c
net/ipv6/esp6.c
net/ipv6/icmp.c
net/ipv6/inet6_connection_sock.c
net/ipv6/ip6_vti.c
net/ipv6/ipcomp6.c
net/ipv6/ping.c
net/ipv6/raw.c
net/ipv6/route.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
Change-Id: I82455dc7b564fc5d3ad2b784a0eb8f96c6b05d4c
Signed-off-by: Channagoud Kadabi <ckadabi@codeaurora.org>
7865 lines
189 KiB
C
7865 lines
189 KiB
C
/*
|
|
* ring buffer based function tracer
|
|
*
|
|
* Copyright (C) 2007-2012 Steven Rostedt <srostedt@redhat.com>
|
|
* Copyright (C) 2008 Ingo Molnar <mingo@redhat.com>
|
|
*
|
|
* Originally taken from the RT patch by:
|
|
* Arnaldo Carvalho de Melo <acme@redhat.com>
|
|
*
|
|
* Based on code from the latency_tracer, that is:
|
|
* Copyright (C) 2004-2006 Ingo Molnar
|
|
* Copyright (C) 2004 Nadia Yvette Chambers
|
|
*/
|
|
#include <linux/ring_buffer.h>
|
|
#include <generated/utsrelease.h>
|
|
#include <linux/stacktrace.h>
|
|
#include <linux/writeback.h>
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/irqflags.h>
|
|
#include <linux/debugfs.h>
|
|
#include <linux/tracefs.h>
|
|
#include <linux/pagemap.h>
|
|
#include <linux/hardirq.h>
|
|
#include <linux/linkage.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/ftrace.h>
|
|
#include <linux/module.h>
|
|
#include <linux/percpu.h>
|
|
#include <linux/splice.h>
|
|
#include <linux/kdebug.h>
|
|
#include <linux/string.h>
|
|
#include <linux/mount.h>
|
|
#include <linux/rwsem.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/ctype.h>
|
|
#include <linux/init.h>
|
|
#include <linux/poll.h>
|
|
#include <linux/nmi.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/sched/rt.h>
|
|
#include <linux/coresight-stm.h>
|
|
|
|
#include "trace.h"
|
|
#include "trace_output.h"
|
|
|
|
/*
|
|
* On boot up, the ring buffer is set to the minimum size, so that
|
|
* we do not waste memory on systems that are not using tracing.
|
|
*/
|
|
bool ring_buffer_expanded;
|
|
|
|
/*
|
|
* We need to change this state when a selftest is running.
|
|
* A selftest will lurk into the ring-buffer to count the
|
|
* entries inserted during the selftest although some concurrent
|
|
* insertions into the ring-buffer such as trace_printk could occurred
|
|
* at the same time, giving false positive or negative results.
|
|
*/
|
|
static bool __read_mostly tracing_selftest_running;
|
|
|
|
/*
|
|
* If a tracer is running, we do not want to run SELFTEST.
|
|
*/
|
|
bool __read_mostly tracing_selftest_disabled;
|
|
|
|
/* Pipe tracepoints to printk */
|
|
struct trace_iterator *tracepoint_print_iter;
|
|
int tracepoint_printk;
|
|
|
|
/* For tracers that don't implement custom flags */
|
|
static struct tracer_opt dummy_tracer_opt[] = {
|
|
{ }
|
|
};
|
|
|
|
static int
|
|
dummy_set_flag(struct trace_array *tr, u32 old_flags, u32 bit, int set)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* To prevent the comm cache from being overwritten when no
|
|
* tracing is active, only save the comm when a trace event
|
|
* occurred.
|
|
*/
|
|
static DEFINE_PER_CPU(bool, trace_cmdline_save);
|
|
|
|
/*
|
|
* Kill all tracing for good (never come back).
|
|
* It is initialized to 1 but will turn to zero if the initialization
|
|
* of the tracer is successful. But that is the only place that sets
|
|
* this back to zero.
|
|
*/
|
|
static int tracing_disabled = 1;
|
|
|
|
cpumask_var_t __read_mostly tracing_buffer_mask;
|
|
|
|
/*
|
|
* ftrace_dump_on_oops - variable to dump ftrace buffer on oops
|
|
*
|
|
* If there is an oops (or kernel panic) and the ftrace_dump_on_oops
|
|
* is set, then ftrace_dump is called. This will output the contents
|
|
* of the ftrace buffers to the console. This is very useful for
|
|
* capturing traces that lead to crashes and outputing it to a
|
|
* serial console.
|
|
*
|
|
* It is default off, but you can enable it with either specifying
|
|
* "ftrace_dump_on_oops" in the kernel command line, or setting
|
|
* /proc/sys/kernel/ftrace_dump_on_oops
|
|
* Set 1 if you want to dump buffers of all CPUs
|
|
* Set 2 if you want to dump the buffer of the CPU that triggered oops
|
|
*/
|
|
|
|
enum ftrace_dump_mode ftrace_dump_on_oops;
|
|
|
|
/* When set, tracing will stop when a WARN*() is hit */
|
|
int __disable_trace_on_warning;
|
|
|
|
#ifdef CONFIG_TRACE_ENUM_MAP_FILE
|
|
/* Map of enums to their values, for "enum_map" file */
|
|
struct trace_enum_map_head {
|
|
struct module *mod;
|
|
unsigned long length;
|
|
};
|
|
|
|
union trace_enum_map_item;
|
|
|
|
struct trace_enum_map_tail {
|
|
/*
|
|
* "end" is first and points to NULL as it must be different
|
|
* than "mod" or "enum_string"
|
|
*/
|
|
union trace_enum_map_item *next;
|
|
const char *end; /* points to NULL */
|
|
};
|
|
|
|
static DEFINE_MUTEX(trace_enum_mutex);
|
|
|
|
/*
|
|
* The trace_enum_maps are saved in an array with two extra elements,
|
|
* one at the beginning, and one at the end. The beginning item contains
|
|
* the count of the saved maps (head.length), and the module they
|
|
* belong to if not built in (head.mod). The ending item contains a
|
|
* pointer to the next array of saved enum_map items.
|
|
*/
|
|
union trace_enum_map_item {
|
|
struct trace_enum_map map;
|
|
struct trace_enum_map_head head;
|
|
struct trace_enum_map_tail tail;
|
|
};
|
|
|
|
static union trace_enum_map_item *trace_enum_maps;
|
|
#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
|
|
|
|
static int tracing_set_tracer(struct trace_array *tr, const char *buf);
|
|
|
|
#define MAX_TRACER_SIZE 100
|
|
static char bootup_tracer_buf[MAX_TRACER_SIZE] __initdata;
|
|
static char *default_bootup_tracer;
|
|
|
|
static bool allocate_snapshot;
|
|
|
|
static int __init set_cmdline_ftrace(char *str)
|
|
{
|
|
strlcpy(bootup_tracer_buf, str, MAX_TRACER_SIZE);
|
|
default_bootup_tracer = bootup_tracer_buf;
|
|
/* We are using ftrace early, expand it */
|
|
ring_buffer_expanded = true;
|
|
return 1;
|
|
}
|
|
__setup("ftrace=", set_cmdline_ftrace);
|
|
|
|
static int __init set_ftrace_dump_on_oops(char *str)
|
|
{
|
|
if (*str++ != '=' || !*str) {
|
|
ftrace_dump_on_oops = DUMP_ALL;
|
|
return 1;
|
|
}
|
|
|
|
if (!strcmp("orig_cpu", str)) {
|
|
ftrace_dump_on_oops = DUMP_ORIG;
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
__setup("ftrace_dump_on_oops", set_ftrace_dump_on_oops);
|
|
|
|
static int __init stop_trace_on_warning(char *str)
|
|
{
|
|
if ((strcmp(str, "=0") != 0 && strcmp(str, "=off") != 0))
|
|
__disable_trace_on_warning = 1;
|
|
return 1;
|
|
}
|
|
__setup("traceoff_on_warning", stop_trace_on_warning);
|
|
|
|
static int __init boot_alloc_snapshot(char *str)
|
|
{
|
|
allocate_snapshot = true;
|
|
/* We also need the main ring buffer expanded */
|
|
ring_buffer_expanded = true;
|
|
return 1;
|
|
}
|
|
__setup("alloc_snapshot", boot_alloc_snapshot);
|
|
|
|
|
|
static char trace_boot_options_buf[MAX_TRACER_SIZE] __initdata;
|
|
|
|
static int __init set_trace_boot_options(char *str)
|
|
{
|
|
strlcpy(trace_boot_options_buf, str, MAX_TRACER_SIZE);
|
|
return 0;
|
|
}
|
|
__setup("trace_options=", set_trace_boot_options);
|
|
|
|
static char trace_boot_clock_buf[MAX_TRACER_SIZE] __initdata;
|
|
static char *trace_boot_clock __initdata;
|
|
|
|
static int __init set_trace_boot_clock(char *str)
|
|
{
|
|
strlcpy(trace_boot_clock_buf, str, MAX_TRACER_SIZE);
|
|
trace_boot_clock = trace_boot_clock_buf;
|
|
return 0;
|
|
}
|
|
__setup("trace_clock=", set_trace_boot_clock);
|
|
|
|
static int __init set_tracepoint_printk(char *str)
|
|
{
|
|
if ((strcmp(str, "=0") != 0 && strcmp(str, "=off") != 0))
|
|
tracepoint_printk = 1;
|
|
return 1;
|
|
}
|
|
__setup("tp_printk", set_tracepoint_printk);
|
|
|
|
unsigned long long ns2usecs(cycle_t nsec)
|
|
{
|
|
nsec += 500;
|
|
do_div(nsec, 1000);
|
|
return nsec;
|
|
}
|
|
|
|
/* trace_flags holds trace_options default values */
|
|
#define TRACE_DEFAULT_FLAGS \
|
|
(FUNCTION_DEFAULT_FLAGS | \
|
|
TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | \
|
|
TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | \
|
|
TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE | \
|
|
TRACE_ITER_IRQ_INFO | TRACE_ITER_MARKERS)
|
|
|
|
/* trace_options that are only supported by global_trace */
|
|
#define TOP_LEVEL_TRACE_FLAGS (TRACE_ITER_PRINTK | \
|
|
TRACE_ITER_PRINTK_MSGONLY | TRACE_ITER_RECORD_CMD)
|
|
|
|
/* trace_flags that are default zero for instances */
|
|
#define ZEROED_TRACE_FLAGS \
|
|
TRACE_ITER_EVENT_FORK
|
|
|
|
/*
|
|
* The global_trace is the descriptor that holds the tracing
|
|
* buffers for the live tracing. For each CPU, it contains
|
|
* a link list of pages that will store trace entries. The
|
|
* page descriptor of the pages in the memory is used to hold
|
|
* the link list by linking the lru item in the page descriptor
|
|
* to each of the pages in the buffer per CPU.
|
|
*
|
|
* For each active CPU there is a data field that holds the
|
|
* pages for the buffer for that CPU. Each CPU has the same number
|
|
* of pages allocated for its buffer.
|
|
*/
|
|
static struct trace_array global_trace = {
|
|
.trace_flags = TRACE_DEFAULT_FLAGS,
|
|
};
|
|
|
|
LIST_HEAD(ftrace_trace_arrays);
|
|
|
|
int trace_array_get(struct trace_array *this_tr)
|
|
{
|
|
struct trace_array *tr;
|
|
int ret = -ENODEV;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
list_for_each_entry(tr, &ftrace_trace_arrays, list) {
|
|
if (tr == this_tr) {
|
|
tr->ref++;
|
|
ret = 0;
|
|
break;
|
|
}
|
|
}
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void __trace_array_put(struct trace_array *this_tr)
|
|
{
|
|
WARN_ON(!this_tr->ref);
|
|
this_tr->ref--;
|
|
}
|
|
|
|
void trace_array_put(struct trace_array *this_tr)
|
|
{
|
|
mutex_lock(&trace_types_lock);
|
|
__trace_array_put(this_tr);
|
|
mutex_unlock(&trace_types_lock);
|
|
}
|
|
|
|
int call_filter_check_discard(struct trace_event_call *call, void *rec,
|
|
struct ring_buffer *buffer,
|
|
struct ring_buffer_event *event)
|
|
{
|
|
if (unlikely(call->flags & TRACE_EVENT_FL_FILTERED) &&
|
|
!filter_match_preds(call->filter, rec)) {
|
|
__trace_event_discard_commit(buffer, event);
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
void trace_free_pid_list(struct trace_pid_list *pid_list)
|
|
{
|
|
vfree(pid_list->pids);
|
|
kfree(pid_list);
|
|
}
|
|
|
|
/**
|
|
* trace_find_filtered_pid - check if a pid exists in a filtered_pid list
|
|
* @filtered_pids: The list of pids to check
|
|
* @search_pid: The PID to find in @filtered_pids
|
|
*
|
|
* Returns true if @search_pid is fonud in @filtered_pids, and false otherwis.
|
|
*/
|
|
bool
|
|
trace_find_filtered_pid(struct trace_pid_list *filtered_pids, pid_t search_pid)
|
|
{
|
|
/*
|
|
* If pid_max changed after filtered_pids was created, we
|
|
* by default ignore all pids greater than the previous pid_max.
|
|
*/
|
|
if (search_pid >= filtered_pids->pid_max)
|
|
return false;
|
|
|
|
return test_bit(search_pid, filtered_pids->pids);
|
|
}
|
|
|
|
/**
|
|
* trace_ignore_this_task - should a task be ignored for tracing
|
|
* @filtered_pids: The list of pids to check
|
|
* @task: The task that should be ignored if not filtered
|
|
*
|
|
* Checks if @task should be traced or not from @filtered_pids.
|
|
* Returns true if @task should *NOT* be traced.
|
|
* Returns false if @task should be traced.
|
|
*/
|
|
bool
|
|
trace_ignore_this_task(struct trace_pid_list *filtered_pids, struct task_struct *task)
|
|
{
|
|
/*
|
|
* Return false, because if filtered_pids does not exist,
|
|
* all pids are good to trace.
|
|
*/
|
|
if (!filtered_pids)
|
|
return false;
|
|
|
|
return !trace_find_filtered_pid(filtered_pids, task->pid);
|
|
}
|
|
|
|
/**
|
|
* trace_pid_filter_add_remove - Add or remove a task from a pid_list
|
|
* @pid_list: The list to modify
|
|
* @self: The current task for fork or NULL for exit
|
|
* @task: The task to add or remove
|
|
*
|
|
* If adding a task, if @self is defined, the task is only added if @self
|
|
* is also included in @pid_list. This happens on fork and tasks should
|
|
* only be added when the parent is listed. If @self is NULL, then the
|
|
* @task pid will be removed from the list, which would happen on exit
|
|
* of a task.
|
|
*/
|
|
void trace_filter_add_remove_task(struct trace_pid_list *pid_list,
|
|
struct task_struct *self,
|
|
struct task_struct *task)
|
|
{
|
|
if (!pid_list)
|
|
return;
|
|
|
|
/* For forks, we only add if the forking task is listed */
|
|
if (self) {
|
|
if (!trace_find_filtered_pid(pid_list, self->pid))
|
|
return;
|
|
}
|
|
|
|
/* Sorry, but we don't support pid_max changing after setting */
|
|
if (task->pid >= pid_list->pid_max)
|
|
return;
|
|
|
|
/* "self" is set for forks, and NULL for exits */
|
|
if (self)
|
|
set_bit(task->pid, pid_list->pids);
|
|
else
|
|
clear_bit(task->pid, pid_list->pids);
|
|
}
|
|
|
|
/**
|
|
* trace_pid_next - Used for seq_file to get to the next pid of a pid_list
|
|
* @pid_list: The pid list to show
|
|
* @v: The last pid that was shown (+1 the actual pid to let zero be displayed)
|
|
* @pos: The position of the file
|
|
*
|
|
* This is used by the seq_file "next" operation to iterate the pids
|
|
* listed in a trace_pid_list structure.
|
|
*
|
|
* Returns the pid+1 as we want to display pid of zero, but NULL would
|
|
* stop the iteration.
|
|
*/
|
|
void *trace_pid_next(struct trace_pid_list *pid_list, void *v, loff_t *pos)
|
|
{
|
|
unsigned long pid = (unsigned long)v;
|
|
|
|
(*pos)++;
|
|
|
|
/* pid already is +1 of the actual prevous bit */
|
|
pid = find_next_bit(pid_list->pids, pid_list->pid_max, pid);
|
|
|
|
/* Return pid + 1 to allow zero to be represented */
|
|
if (pid < pid_list->pid_max)
|
|
return (void *)(pid + 1);
|
|
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* trace_pid_start - Used for seq_file to start reading pid lists
|
|
* @pid_list: The pid list to show
|
|
* @pos: The position of the file
|
|
*
|
|
* This is used by seq_file "start" operation to start the iteration
|
|
* of listing pids.
|
|
*
|
|
* Returns the pid+1 as we want to display pid of zero, but NULL would
|
|
* stop the iteration.
|
|
*/
|
|
void *trace_pid_start(struct trace_pid_list *pid_list, loff_t *pos)
|
|
{
|
|
unsigned long pid;
|
|
loff_t l = 0;
|
|
|
|
pid = find_first_bit(pid_list->pids, pid_list->pid_max);
|
|
if (pid >= pid_list->pid_max)
|
|
return NULL;
|
|
|
|
/* Return pid + 1 so that zero can be the exit value */
|
|
for (pid++; pid && l < *pos;
|
|
pid = (unsigned long)trace_pid_next(pid_list, (void *)pid, &l))
|
|
;
|
|
return (void *)pid;
|
|
}
|
|
|
|
/**
|
|
* trace_pid_show - show the current pid in seq_file processing
|
|
* @m: The seq_file structure to write into
|
|
* @v: A void pointer of the pid (+1) value to display
|
|
*
|
|
* Can be directly used by seq_file operations to display the current
|
|
* pid value.
|
|
*/
|
|
int trace_pid_show(struct seq_file *m, void *v)
|
|
{
|
|
unsigned long pid = (unsigned long)v - 1;
|
|
|
|
seq_printf(m, "%lu\n", pid);
|
|
return 0;
|
|
}
|
|
|
|
/* 128 should be much more than enough */
|
|
#define PID_BUF_SIZE 127
|
|
|
|
int trace_pid_write(struct trace_pid_list *filtered_pids,
|
|
struct trace_pid_list **new_pid_list,
|
|
const char __user *ubuf, size_t cnt)
|
|
{
|
|
struct trace_pid_list *pid_list;
|
|
struct trace_parser parser;
|
|
unsigned long val;
|
|
int nr_pids = 0;
|
|
ssize_t read = 0;
|
|
ssize_t ret = 0;
|
|
loff_t pos;
|
|
pid_t pid;
|
|
|
|
if (trace_parser_get_init(&parser, PID_BUF_SIZE + 1))
|
|
return -ENOMEM;
|
|
|
|
/*
|
|
* Always recreate a new array. The write is an all or nothing
|
|
* operation. Always create a new array when adding new pids by
|
|
* the user. If the operation fails, then the current list is
|
|
* not modified.
|
|
*/
|
|
pid_list = kmalloc(sizeof(*pid_list), GFP_KERNEL);
|
|
if (!pid_list)
|
|
return -ENOMEM;
|
|
|
|
pid_list->pid_max = READ_ONCE(pid_max);
|
|
|
|
/* Only truncating will shrink pid_max */
|
|
if (filtered_pids && filtered_pids->pid_max > pid_list->pid_max)
|
|
pid_list->pid_max = filtered_pids->pid_max;
|
|
|
|
pid_list->pids = vzalloc((pid_list->pid_max + 7) >> 3);
|
|
if (!pid_list->pids) {
|
|
kfree(pid_list);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
if (filtered_pids) {
|
|
/* copy the current bits to the new max */
|
|
for_each_set_bit(pid, filtered_pids->pids,
|
|
filtered_pids->pid_max) {
|
|
set_bit(pid, pid_list->pids);
|
|
nr_pids++;
|
|
}
|
|
}
|
|
|
|
while (cnt > 0) {
|
|
|
|
pos = 0;
|
|
|
|
ret = trace_get_user(&parser, ubuf, cnt, &pos);
|
|
if (ret < 0 || !trace_parser_loaded(&parser))
|
|
break;
|
|
|
|
read += ret;
|
|
ubuf += ret;
|
|
cnt -= ret;
|
|
|
|
parser.buffer[parser.idx] = 0;
|
|
|
|
ret = -EINVAL;
|
|
if (kstrtoul(parser.buffer, 0, &val))
|
|
break;
|
|
if (val >= pid_list->pid_max)
|
|
break;
|
|
|
|
pid = (pid_t)val;
|
|
|
|
set_bit(pid, pid_list->pids);
|
|
nr_pids++;
|
|
|
|
trace_parser_clear(&parser);
|
|
ret = 0;
|
|
}
|
|
trace_parser_put(&parser);
|
|
|
|
if (ret < 0) {
|
|
trace_free_pid_list(pid_list);
|
|
return ret;
|
|
}
|
|
|
|
if (!nr_pids) {
|
|
/* Cleared the list of pids */
|
|
trace_free_pid_list(pid_list);
|
|
read = ret;
|
|
pid_list = NULL;
|
|
}
|
|
|
|
*new_pid_list = pid_list;
|
|
|
|
return read;
|
|
}
|
|
|
|
static cycle_t buffer_ftrace_now(struct trace_buffer *buf, int cpu)
|
|
{
|
|
u64 ts;
|
|
|
|
/* Early boot up does not have a buffer yet */
|
|
if (!buf->buffer)
|
|
return trace_clock_local();
|
|
|
|
ts = ring_buffer_time_stamp(buf->buffer, cpu);
|
|
ring_buffer_normalize_time_stamp(buf->buffer, cpu, &ts);
|
|
|
|
return ts;
|
|
}
|
|
|
|
cycle_t ftrace_now(int cpu)
|
|
{
|
|
return buffer_ftrace_now(&global_trace.trace_buffer, cpu);
|
|
}
|
|
|
|
/**
|
|
* tracing_is_enabled - Show if global_trace has been disabled
|
|
*
|
|
* Shows if the global trace has been enabled or not. It uses the
|
|
* mirror flag "buffer_disabled" to be used in fast paths such as for
|
|
* the irqsoff tracer. But it may be inaccurate due to races. If you
|
|
* need to know the accurate state, use tracing_is_on() which is a little
|
|
* slower, but accurate.
|
|
*/
|
|
int tracing_is_enabled(void)
|
|
{
|
|
/*
|
|
* For quick access (irqsoff uses this in fast path), just
|
|
* return the mirror variable of the state of the ring buffer.
|
|
* It's a little racy, but we don't really care.
|
|
*/
|
|
smp_rmb();
|
|
return !global_trace.buffer_disabled;
|
|
}
|
|
|
|
/*
|
|
* trace_buf_size is the size in bytes that is allocated
|
|
* for a buffer. Note, the number of bytes is always rounded
|
|
* to page size.
|
|
*
|
|
* This number is purposely set to a low number of 16384.
|
|
* If the dump on oops happens, it will be much appreciated
|
|
* to not have to wait for all that output. Anyway this can be
|
|
* boot time and run time configurable.
|
|
*/
|
|
#define TRACE_BUF_SIZE_DEFAULT 1441792UL /* 16384 * 88 (sizeof(entry)) */
|
|
|
|
static unsigned long trace_buf_size = TRACE_BUF_SIZE_DEFAULT;
|
|
|
|
/* trace_types holds a link list of available tracers. */
|
|
static struct tracer *trace_types __read_mostly;
|
|
|
|
/*
|
|
* trace_types_lock is used to protect the trace_types list.
|
|
*/
|
|
DEFINE_MUTEX(trace_types_lock);
|
|
|
|
/*
|
|
* serialize the access of the ring buffer
|
|
*
|
|
* ring buffer serializes readers, but it is low level protection.
|
|
* The validity of the events (which returns by ring_buffer_peek() ..etc)
|
|
* are not protected by ring buffer.
|
|
*
|
|
* The content of events may become garbage if we allow other process consumes
|
|
* these events concurrently:
|
|
* A) the page of the consumed events may become a normal page
|
|
* (not reader page) in ring buffer, and this page will be rewrited
|
|
* by events producer.
|
|
* B) The page of the consumed events may become a page for splice_read,
|
|
* and this page will be returned to system.
|
|
*
|
|
* These primitives allow multi process access to different cpu ring buffer
|
|
* concurrently.
|
|
*
|
|
* These primitives don't distinguish read-only and read-consume access.
|
|
* Multi read-only access are also serialized.
|
|
*/
|
|
|
|
#ifdef CONFIG_SMP
|
|
static DECLARE_RWSEM(all_cpu_access_lock);
|
|
static DEFINE_PER_CPU(struct mutex, cpu_access_lock);
|
|
|
|
static inline void trace_access_lock(int cpu)
|
|
{
|
|
if (cpu == RING_BUFFER_ALL_CPUS) {
|
|
/* gain it for accessing the whole ring buffer. */
|
|
down_write(&all_cpu_access_lock);
|
|
} else {
|
|
/* gain it for accessing a cpu ring buffer. */
|
|
|
|
/* Firstly block other trace_access_lock(RING_BUFFER_ALL_CPUS). */
|
|
down_read(&all_cpu_access_lock);
|
|
|
|
/* Secondly block other access to this @cpu ring buffer. */
|
|
mutex_lock(&per_cpu(cpu_access_lock, cpu));
|
|
}
|
|
}
|
|
|
|
static inline void trace_access_unlock(int cpu)
|
|
{
|
|
if (cpu == RING_BUFFER_ALL_CPUS) {
|
|
up_write(&all_cpu_access_lock);
|
|
} else {
|
|
mutex_unlock(&per_cpu(cpu_access_lock, cpu));
|
|
up_read(&all_cpu_access_lock);
|
|
}
|
|
}
|
|
|
|
static inline void trace_access_lock_init(void)
|
|
{
|
|
int cpu;
|
|
|
|
for_each_possible_cpu(cpu)
|
|
mutex_init(&per_cpu(cpu_access_lock, cpu));
|
|
}
|
|
|
|
#else
|
|
|
|
static DEFINE_MUTEX(access_lock);
|
|
|
|
static inline void trace_access_lock(int cpu)
|
|
{
|
|
(void)cpu;
|
|
mutex_lock(&access_lock);
|
|
}
|
|
|
|
static inline void trace_access_unlock(int cpu)
|
|
{
|
|
(void)cpu;
|
|
mutex_unlock(&access_lock);
|
|
}
|
|
|
|
static inline void trace_access_lock_init(void)
|
|
{
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_STACKTRACE
|
|
static void __ftrace_trace_stack(struct ring_buffer *buffer,
|
|
unsigned long flags,
|
|
int skip, int pc, struct pt_regs *regs);
|
|
static inline void ftrace_trace_stack(struct trace_array *tr,
|
|
struct ring_buffer *buffer,
|
|
unsigned long flags,
|
|
int skip, int pc, struct pt_regs *regs);
|
|
|
|
#else
|
|
static inline void __ftrace_trace_stack(struct ring_buffer *buffer,
|
|
unsigned long flags,
|
|
int skip, int pc, struct pt_regs *regs)
|
|
{
|
|
}
|
|
static inline void ftrace_trace_stack(struct trace_array *tr,
|
|
struct ring_buffer *buffer,
|
|
unsigned long flags,
|
|
int skip, int pc, struct pt_regs *regs)
|
|
{
|
|
}
|
|
|
|
#endif
|
|
|
|
static void tracer_tracing_on(struct trace_array *tr)
|
|
{
|
|
if (tr->trace_buffer.buffer)
|
|
ring_buffer_record_on(tr->trace_buffer.buffer);
|
|
/*
|
|
* This flag is looked at when buffers haven't been allocated
|
|
* yet, or by some tracers (like irqsoff), that just want to
|
|
* know if the ring buffer has been disabled, but it can handle
|
|
* races of where it gets disabled but we still do a record.
|
|
* As the check is in the fast path of the tracers, it is more
|
|
* important to be fast than accurate.
|
|
*/
|
|
tr->buffer_disabled = 0;
|
|
/* Make the flag seen by readers */
|
|
smp_wmb();
|
|
}
|
|
|
|
/**
|
|
* tracing_on - enable tracing buffers
|
|
*
|
|
* This function enables tracing buffers that may have been
|
|
* disabled with tracing_off.
|
|
*/
|
|
void tracing_on(void)
|
|
{
|
|
tracer_tracing_on(&global_trace);
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_on);
|
|
|
|
/**
|
|
* __trace_puts - write a constant string into the trace buffer.
|
|
* @ip: The address of the caller
|
|
* @str: The constant string to write
|
|
* @size: The size of the string.
|
|
*/
|
|
int __trace_puts(unsigned long ip, const char *str, int size)
|
|
{
|
|
struct ring_buffer_event *event;
|
|
struct ring_buffer *buffer;
|
|
struct print_entry *entry;
|
|
unsigned long irq_flags;
|
|
int alloc;
|
|
int pc;
|
|
|
|
if (!(global_trace.trace_flags & TRACE_ITER_PRINTK))
|
|
return 0;
|
|
|
|
pc = preempt_count();
|
|
|
|
if (unlikely(tracing_selftest_running || tracing_disabled))
|
|
return 0;
|
|
|
|
alloc = sizeof(*entry) + size + 2; /* possible \n added */
|
|
|
|
local_save_flags(irq_flags);
|
|
buffer = global_trace.trace_buffer.buffer;
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_PRINT, alloc,
|
|
irq_flags, pc);
|
|
if (!event)
|
|
return 0;
|
|
|
|
entry = ring_buffer_event_data(event);
|
|
entry->ip = ip;
|
|
|
|
memcpy(&entry->buf, str, size);
|
|
|
|
/* Add a newline if necessary */
|
|
if (entry->buf[size - 1] != '\n') {
|
|
entry->buf[size] = '\n';
|
|
entry->buf[size + 1] = '\0';
|
|
} else
|
|
entry->buf[size] = '\0';
|
|
|
|
__buffer_unlock_commit(buffer, event);
|
|
ftrace_trace_stack(&global_trace, buffer, irq_flags, 4, pc, NULL);
|
|
|
|
return size;
|
|
}
|
|
EXPORT_SYMBOL_GPL(__trace_puts);
|
|
|
|
/**
|
|
* __trace_bputs - write the pointer to a constant string into trace buffer
|
|
* @ip: The address of the caller
|
|
* @str: The constant string to write to the buffer to
|
|
*/
|
|
int __trace_bputs(unsigned long ip, const char *str)
|
|
{
|
|
struct ring_buffer_event *event;
|
|
struct ring_buffer *buffer;
|
|
struct bputs_entry *entry;
|
|
unsigned long irq_flags;
|
|
int size = sizeof(struct bputs_entry);
|
|
int pc;
|
|
|
|
if (!(global_trace.trace_flags & TRACE_ITER_PRINTK))
|
|
return 0;
|
|
|
|
pc = preempt_count();
|
|
|
|
if (unlikely(tracing_selftest_running || tracing_disabled))
|
|
return 0;
|
|
|
|
local_save_flags(irq_flags);
|
|
buffer = global_trace.trace_buffer.buffer;
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size,
|
|
irq_flags, pc);
|
|
if (!event)
|
|
return 0;
|
|
|
|
entry = ring_buffer_event_data(event);
|
|
entry->ip = ip;
|
|
entry->str = str;
|
|
|
|
__buffer_unlock_commit(buffer, event);
|
|
ftrace_trace_stack(&global_trace, buffer, irq_flags, 4, pc, NULL);
|
|
|
|
return 1;
|
|
}
|
|
EXPORT_SYMBOL_GPL(__trace_bputs);
|
|
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
/**
|
|
* trace_snapshot - take a snapshot of the current buffer.
|
|
*
|
|
* This causes a swap between the snapshot buffer and the current live
|
|
* tracing buffer. You can use this to take snapshots of the live
|
|
* trace when some condition is triggered, but continue to trace.
|
|
*
|
|
* Note, make sure to allocate the snapshot with either
|
|
* a tracing_snapshot_alloc(), or by doing it manually
|
|
* with: echo 1 > /sys/kernel/debug/tracing/snapshot
|
|
*
|
|
* If the snapshot buffer is not allocated, it will stop tracing.
|
|
* Basically making a permanent snapshot.
|
|
*/
|
|
void tracing_snapshot(void)
|
|
{
|
|
struct trace_array *tr = &global_trace;
|
|
struct tracer *tracer = tr->current_trace;
|
|
unsigned long flags;
|
|
|
|
if (in_nmi()) {
|
|
internal_trace_puts("*** SNAPSHOT CALLED FROM NMI CONTEXT ***\n");
|
|
internal_trace_puts("*** snapshot is being ignored ***\n");
|
|
return;
|
|
}
|
|
|
|
if (!tr->allocated_snapshot) {
|
|
internal_trace_puts("*** SNAPSHOT NOT ALLOCATED ***\n");
|
|
internal_trace_puts("*** stopping trace here! ***\n");
|
|
tracing_off();
|
|
return;
|
|
}
|
|
|
|
/* Note, snapshot can not be used when the tracer uses it */
|
|
if (tracer->use_max_tr) {
|
|
internal_trace_puts("*** LATENCY TRACER ACTIVE ***\n");
|
|
internal_trace_puts("*** Can not use snapshot (sorry) ***\n");
|
|
return;
|
|
}
|
|
|
|
local_irq_save(flags);
|
|
update_max_tr(tr, current, smp_processor_id());
|
|
local_irq_restore(flags);
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_snapshot);
|
|
|
|
static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf,
|
|
struct trace_buffer *size_buf, int cpu_id);
|
|
static void set_buffer_entries(struct trace_buffer *buf, unsigned long val);
|
|
|
|
static int alloc_snapshot(struct trace_array *tr)
|
|
{
|
|
int ret;
|
|
|
|
if (!tr->allocated_snapshot) {
|
|
|
|
/* allocate spare buffer */
|
|
ret = resize_buffer_duplicate_size(&tr->max_buffer,
|
|
&tr->trace_buffer, RING_BUFFER_ALL_CPUS);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
tr->allocated_snapshot = true;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void free_snapshot(struct trace_array *tr)
|
|
{
|
|
/*
|
|
* We don't free the ring buffer. instead, resize it because
|
|
* The max_tr ring buffer has some state (e.g. ring->clock) and
|
|
* we want preserve it.
|
|
*/
|
|
ring_buffer_resize(tr->max_buffer.buffer, 1, RING_BUFFER_ALL_CPUS);
|
|
set_buffer_entries(&tr->max_buffer, 1);
|
|
tracing_reset_online_cpus(&tr->max_buffer);
|
|
tr->allocated_snapshot = false;
|
|
}
|
|
|
|
/**
|
|
* tracing_alloc_snapshot - allocate snapshot buffer.
|
|
*
|
|
* This only allocates the snapshot buffer if it isn't already
|
|
* allocated - it doesn't also take a snapshot.
|
|
*
|
|
* This is meant to be used in cases where the snapshot buffer needs
|
|
* to be set up for events that can't sleep but need to be able to
|
|
* trigger a snapshot.
|
|
*/
|
|
int tracing_alloc_snapshot(void)
|
|
{
|
|
struct trace_array *tr = &global_trace;
|
|
int ret;
|
|
|
|
ret = alloc_snapshot(tr);
|
|
WARN_ON(ret < 0);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_alloc_snapshot);
|
|
|
|
/**
|
|
* trace_snapshot_alloc - allocate and take a snapshot of the current buffer.
|
|
*
|
|
* This is similar to trace_snapshot(), but it will allocate the
|
|
* snapshot buffer if it isn't already allocated. Use this only
|
|
* where it is safe to sleep, as the allocation may sleep.
|
|
*
|
|
* This causes a swap between the snapshot buffer and the current live
|
|
* tracing buffer. You can use this to take snapshots of the live
|
|
* trace when some condition is triggered, but continue to trace.
|
|
*/
|
|
void tracing_snapshot_alloc(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = tracing_alloc_snapshot();
|
|
if (ret < 0)
|
|
return;
|
|
|
|
tracing_snapshot();
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_snapshot_alloc);
|
|
#else
|
|
void tracing_snapshot(void)
|
|
{
|
|
WARN_ONCE(1, "Snapshot feature not enabled, but internal snapshot used");
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_snapshot);
|
|
int tracing_alloc_snapshot(void)
|
|
{
|
|
WARN_ONCE(1, "Snapshot feature not enabled, but snapshot allocation used");
|
|
return -ENODEV;
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_alloc_snapshot);
|
|
void tracing_snapshot_alloc(void)
|
|
{
|
|
/* Give warning */
|
|
tracing_snapshot();
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_snapshot_alloc);
|
|
#endif /* CONFIG_TRACER_SNAPSHOT */
|
|
|
|
static void tracer_tracing_off(struct trace_array *tr)
|
|
{
|
|
if (tr->trace_buffer.buffer)
|
|
ring_buffer_record_off(tr->trace_buffer.buffer);
|
|
/*
|
|
* This flag is looked at when buffers haven't been allocated
|
|
* yet, or by some tracers (like irqsoff), that just want to
|
|
* know if the ring buffer has been disabled, but it can handle
|
|
* races of where it gets disabled but we still do a record.
|
|
* As the check is in the fast path of the tracers, it is more
|
|
* important to be fast than accurate.
|
|
*/
|
|
tr->buffer_disabled = 1;
|
|
/* Make the flag seen by readers */
|
|
smp_wmb();
|
|
}
|
|
|
|
/**
|
|
* tracing_off - turn off tracing buffers
|
|
*
|
|
* This function stops the tracing buffers from recording data.
|
|
* It does not disable any overhead the tracers themselves may
|
|
* be causing. This function simply causes all recording to
|
|
* the ring buffers to fail.
|
|
*/
|
|
void tracing_off(void)
|
|
{
|
|
tracer_tracing_off(&global_trace);
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_off);
|
|
|
|
void disable_trace_on_warning(void)
|
|
{
|
|
if (__disable_trace_on_warning)
|
|
tracing_off();
|
|
}
|
|
|
|
/**
|
|
* tracer_tracing_is_on - show real state of ring buffer enabled
|
|
* @tr : the trace array to know if ring buffer is enabled
|
|
*
|
|
* Shows real state of the ring buffer if it is enabled or not.
|
|
*/
|
|
int tracer_tracing_is_on(struct trace_array *tr)
|
|
{
|
|
if (tr->trace_buffer.buffer)
|
|
return ring_buffer_record_is_on(tr->trace_buffer.buffer);
|
|
return !tr->buffer_disabled;
|
|
}
|
|
|
|
/**
|
|
* tracing_is_on - show state of ring buffers enabled
|
|
*/
|
|
int tracing_is_on(void)
|
|
{
|
|
return tracer_tracing_is_on(&global_trace);
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_is_on);
|
|
|
|
static int __init set_buf_size(char *str)
|
|
{
|
|
unsigned long buf_size;
|
|
|
|
if (!str)
|
|
return 0;
|
|
buf_size = memparse(str, &str);
|
|
/* nr_entries can not be zero */
|
|
if (buf_size == 0)
|
|
return 0;
|
|
trace_buf_size = buf_size;
|
|
return 1;
|
|
}
|
|
__setup("trace_buf_size=", set_buf_size);
|
|
|
|
static int __init set_tracing_thresh(char *str)
|
|
{
|
|
unsigned long threshold;
|
|
int ret;
|
|
|
|
if (!str)
|
|
return 0;
|
|
ret = kstrtoul(str, 0, &threshold);
|
|
if (ret < 0)
|
|
return 0;
|
|
tracing_thresh = threshold * 1000;
|
|
return 1;
|
|
}
|
|
__setup("tracing_thresh=", set_tracing_thresh);
|
|
|
|
unsigned long nsecs_to_usecs(unsigned long nsecs)
|
|
{
|
|
return nsecs / 1000;
|
|
}
|
|
|
|
/*
|
|
* TRACE_FLAGS is defined as a tuple matching bit masks with strings.
|
|
* It uses C(a, b) where 'a' is the enum name and 'b' is the string that
|
|
* matches it. By defining "C(a, b) b", TRACE_FLAGS becomes a list
|
|
* of strings in the order that the enums were defined.
|
|
*/
|
|
#undef C
|
|
#define C(a, b) b
|
|
|
|
/* These must match the bit postions in trace_iterator_flags */
|
|
static const char *trace_options[] = {
|
|
TRACE_FLAGS
|
|
NULL
|
|
};
|
|
|
|
static struct {
|
|
u64 (*func)(void);
|
|
const char *name;
|
|
int in_ns; /* is this clock in nanoseconds? */
|
|
} trace_clocks[] = {
|
|
{ trace_clock_local, "local", 1 },
|
|
{ trace_clock_global, "global", 1 },
|
|
{ trace_clock_counter, "counter", 0 },
|
|
{ trace_clock_jiffies, "uptime", 0 },
|
|
{ trace_clock, "perf", 1 },
|
|
{ ktime_get_mono_fast_ns, "mono", 1 },
|
|
{ ktime_get_raw_fast_ns, "mono_raw", 1 },
|
|
{ ktime_get_boot_fast_ns, "boot", 1 },
|
|
ARCH_TRACE_CLOCKS
|
|
};
|
|
|
|
/*
|
|
* trace_parser_get_init - gets the buffer for trace parser
|
|
*/
|
|
int trace_parser_get_init(struct trace_parser *parser, int size)
|
|
{
|
|
memset(parser, 0, sizeof(*parser));
|
|
|
|
parser->buffer = kmalloc(size, GFP_KERNEL);
|
|
if (!parser->buffer)
|
|
return 1;
|
|
|
|
parser->size = size;
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* trace_parser_put - frees the buffer for trace parser
|
|
*/
|
|
void trace_parser_put(struct trace_parser *parser)
|
|
{
|
|
kfree(parser->buffer);
|
|
}
|
|
|
|
/*
|
|
* trace_get_user - reads the user input string separated by space
|
|
* (matched by isspace(ch))
|
|
*
|
|
* For each string found the 'struct trace_parser' is updated,
|
|
* and the function returns.
|
|
*
|
|
* Returns number of bytes read.
|
|
*
|
|
* See kernel/trace/trace.h for 'struct trace_parser' details.
|
|
*/
|
|
int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
char ch;
|
|
size_t read = 0;
|
|
ssize_t ret;
|
|
|
|
if (!*ppos)
|
|
trace_parser_clear(parser);
|
|
|
|
ret = get_user(ch, ubuf++);
|
|
if (ret)
|
|
goto out;
|
|
|
|
read++;
|
|
cnt--;
|
|
|
|
/*
|
|
* The parser is not finished with the last write,
|
|
* continue reading the user input without skipping spaces.
|
|
*/
|
|
if (!parser->cont) {
|
|
/* skip white space */
|
|
while (cnt && isspace(ch)) {
|
|
ret = get_user(ch, ubuf++);
|
|
if (ret)
|
|
goto out;
|
|
read++;
|
|
cnt--;
|
|
}
|
|
|
|
/* only spaces were written */
|
|
if (isspace(ch)) {
|
|
*ppos += read;
|
|
ret = read;
|
|
goto out;
|
|
}
|
|
|
|
parser->idx = 0;
|
|
}
|
|
|
|
/* read the non-space input */
|
|
while (cnt && !isspace(ch)) {
|
|
if (parser->idx < parser->size - 1)
|
|
parser->buffer[parser->idx++] = ch;
|
|
else {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
ret = get_user(ch, ubuf++);
|
|
if (ret)
|
|
goto out;
|
|
read++;
|
|
cnt--;
|
|
}
|
|
|
|
/* We either got finished input or we have to wait for another call. */
|
|
if (isspace(ch)) {
|
|
parser->buffer[parser->idx] = 0;
|
|
parser->cont = false;
|
|
} else if (parser->idx < parser->size - 1) {
|
|
parser->cont = true;
|
|
parser->buffer[parser->idx++] = ch;
|
|
} else {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
*ppos += read;
|
|
ret = read;
|
|
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
/* TODO add a seq_buf_to_buffer() */
|
|
static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
|
|
{
|
|
int len;
|
|
|
|
if (trace_seq_used(s) <= s->seq.readpos)
|
|
return -EBUSY;
|
|
|
|
len = trace_seq_used(s) - s->seq.readpos;
|
|
if (cnt > len)
|
|
cnt = len;
|
|
memcpy(buf, s->buffer + s->seq.readpos, cnt);
|
|
|
|
s->seq.readpos += cnt;
|
|
return cnt;
|
|
}
|
|
|
|
unsigned long __read_mostly tracing_thresh;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
/*
|
|
* Copy the new maximum trace into the separate maximum-trace
|
|
* structure. (this way the maximum trace is permanently saved,
|
|
* for later retrieval via /sys/kernel/debug/tracing/latency_trace)
|
|
*/
|
|
static void
|
|
__update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
|
|
{
|
|
struct trace_buffer *trace_buf = &tr->trace_buffer;
|
|
struct trace_buffer *max_buf = &tr->max_buffer;
|
|
struct trace_array_cpu *data = per_cpu_ptr(trace_buf->data, cpu);
|
|
struct trace_array_cpu *max_data = per_cpu_ptr(max_buf->data, cpu);
|
|
|
|
max_buf->cpu = cpu;
|
|
max_buf->time_start = data->preempt_timestamp;
|
|
|
|
max_data->saved_latency = tr->max_latency;
|
|
max_data->critical_start = data->critical_start;
|
|
max_data->critical_end = data->critical_end;
|
|
|
|
memcpy(max_data->comm, tsk->comm, TASK_COMM_LEN);
|
|
max_data->pid = tsk->pid;
|
|
/*
|
|
* If tsk == current, then use current_uid(), as that does not use
|
|
* RCU. The irq tracer can be called out of RCU scope.
|
|
*/
|
|
if (tsk == current)
|
|
max_data->uid = current_uid();
|
|
else
|
|
max_data->uid = task_uid(tsk);
|
|
|
|
max_data->nice = tsk->static_prio - 20 - MAX_RT_PRIO;
|
|
max_data->policy = tsk->policy;
|
|
max_data->rt_priority = tsk->rt_priority;
|
|
|
|
/* record this tasks comm */
|
|
tracing_record_cmdline(tsk);
|
|
}
|
|
|
|
/**
|
|
* update_max_tr - snapshot all trace buffers from global_trace to max_tr
|
|
* @tr: tracer
|
|
* @tsk: the task with the latency
|
|
* @cpu: The cpu that initiated the trace.
|
|
*
|
|
* Flip the buffers between the @tr and the max_tr and record information
|
|
* about which task was the cause of this latency.
|
|
*/
|
|
void
|
|
update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
|
|
{
|
|
struct ring_buffer *buf;
|
|
|
|
if (tr->stop_count)
|
|
return;
|
|
|
|
WARN_ON_ONCE(!irqs_disabled());
|
|
|
|
if (!tr->allocated_snapshot) {
|
|
/* Only the nop tracer should hit this when disabling */
|
|
WARN_ON_ONCE(tr->current_trace != &nop_trace);
|
|
return;
|
|
}
|
|
|
|
arch_spin_lock(&tr->max_lock);
|
|
|
|
buf = tr->trace_buffer.buffer;
|
|
tr->trace_buffer.buffer = tr->max_buffer.buffer;
|
|
tr->max_buffer.buffer = buf;
|
|
|
|
__update_max_tr(tr, tsk, cpu);
|
|
arch_spin_unlock(&tr->max_lock);
|
|
}
|
|
|
|
/**
|
|
* update_max_tr_single - only copy one trace over, and reset the rest
|
|
* @tr - tracer
|
|
* @tsk - task with the latency
|
|
* @cpu - the cpu of the buffer to copy.
|
|
*
|
|
* Flip the trace of a single CPU buffer between the @tr and the max_tr.
|
|
*/
|
|
void
|
|
update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
|
|
{
|
|
int ret;
|
|
|
|
if (tr->stop_count)
|
|
return;
|
|
|
|
WARN_ON_ONCE(!irqs_disabled());
|
|
if (!tr->allocated_snapshot) {
|
|
/* Only the nop tracer should hit this when disabling */
|
|
WARN_ON_ONCE(tr->current_trace != &nop_trace);
|
|
return;
|
|
}
|
|
|
|
arch_spin_lock(&tr->max_lock);
|
|
|
|
ret = ring_buffer_swap_cpu(tr->max_buffer.buffer, tr->trace_buffer.buffer, cpu);
|
|
|
|
if (ret == -EBUSY) {
|
|
/*
|
|
* We failed to swap the buffer due to a commit taking
|
|
* place on this CPU. We fail to record, but we reset
|
|
* the max trace buffer (no one writes directly to it)
|
|
* and flag that it failed.
|
|
*/
|
|
trace_array_printk_buf(tr->max_buffer.buffer, _THIS_IP_,
|
|
"Failed to swap buffers due to commit in progress\n");
|
|
}
|
|
|
|
WARN_ON_ONCE(ret && ret != -EAGAIN && ret != -EBUSY);
|
|
|
|
__update_max_tr(tr, tsk, cpu);
|
|
arch_spin_unlock(&tr->max_lock);
|
|
}
|
|
#endif /* CONFIG_TRACER_MAX_TRACE */
|
|
|
|
static int wait_on_pipe(struct trace_iterator *iter, bool full)
|
|
{
|
|
/* Iterators are static, they should be filled or empty */
|
|
if (trace_buffer_iter(iter, iter->cpu_file))
|
|
return 0;
|
|
|
|
return ring_buffer_wait(iter->trace_buffer->buffer, iter->cpu_file,
|
|
full);
|
|
}
|
|
|
|
#ifdef CONFIG_FTRACE_STARTUP_TEST
|
|
static int run_tracer_selftest(struct tracer *type)
|
|
{
|
|
struct trace_array *tr = &global_trace;
|
|
struct tracer *saved_tracer = tr->current_trace;
|
|
int ret;
|
|
|
|
if (!type->selftest || tracing_selftest_disabled)
|
|
return 0;
|
|
|
|
/*
|
|
* Run a selftest on this tracer.
|
|
* Here we reset the trace buffer, and set the current
|
|
* tracer to be this tracer. The tracer can then run some
|
|
* internal tracing to verify that everything is in order.
|
|
* If we fail, we do not register this tracer.
|
|
*/
|
|
tracing_reset_online_cpus(&tr->trace_buffer);
|
|
|
|
tr->current_trace = type;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (type->use_max_tr) {
|
|
/* If we expanded the buffers, make sure the max is expanded too */
|
|
if (ring_buffer_expanded)
|
|
ring_buffer_resize(tr->max_buffer.buffer, trace_buf_size,
|
|
RING_BUFFER_ALL_CPUS);
|
|
tr->allocated_snapshot = true;
|
|
}
|
|
#endif
|
|
|
|
/* the test is responsible for initializing and enabling */
|
|
pr_info("Testing tracer %s: ", type->name);
|
|
ret = type->selftest(type, tr);
|
|
/* the test is responsible for resetting too */
|
|
tr->current_trace = saved_tracer;
|
|
if (ret) {
|
|
printk(KERN_CONT "FAILED!\n");
|
|
/* Add the warning after printing 'FAILED' */
|
|
WARN_ON(1);
|
|
return -1;
|
|
}
|
|
/* Only reset on passing, to avoid touching corrupted buffers */
|
|
tracing_reset_online_cpus(&tr->trace_buffer);
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (type->use_max_tr) {
|
|
tr->allocated_snapshot = false;
|
|
|
|
/* Shrink the max buffer again */
|
|
if (ring_buffer_expanded)
|
|
ring_buffer_resize(tr->max_buffer.buffer, 1,
|
|
RING_BUFFER_ALL_CPUS);
|
|
}
|
|
#endif
|
|
|
|
printk(KERN_CONT "PASSED\n");
|
|
return 0;
|
|
}
|
|
#else
|
|
static inline int run_tracer_selftest(struct tracer *type)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif /* CONFIG_FTRACE_STARTUP_TEST */
|
|
|
|
static void add_tracer_options(struct trace_array *tr, struct tracer *t);
|
|
|
|
static void __init apply_trace_boot_options(void);
|
|
|
|
/**
|
|
* register_tracer - register a tracer with the ftrace system.
|
|
* @type - the plugin for the tracer
|
|
*
|
|
* Register a new plugin tracer.
|
|
*/
|
|
int __init register_tracer(struct tracer *type)
|
|
{
|
|
struct tracer *t;
|
|
int ret = 0;
|
|
|
|
if (!type->name) {
|
|
pr_info("Tracer must have a name\n");
|
|
return -1;
|
|
}
|
|
|
|
if (strlen(type->name) >= MAX_TRACER_SIZE) {
|
|
pr_info("Tracer has a name longer than %d\n", MAX_TRACER_SIZE);
|
|
return -1;
|
|
}
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
tracing_selftest_running = true;
|
|
|
|
for (t = trace_types; t; t = t->next) {
|
|
if (strcmp(type->name, t->name) == 0) {
|
|
/* already found */
|
|
pr_info("Tracer %s already registered\n",
|
|
type->name);
|
|
ret = -1;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
if (!type->set_flag)
|
|
type->set_flag = &dummy_set_flag;
|
|
if (!type->flags) {
|
|
/*allocate a dummy tracer_flags*/
|
|
type->flags = kmalloc(sizeof(*type->flags), GFP_KERNEL);
|
|
if (!type->flags) {
|
|
ret = -ENOMEM;
|
|
goto out;
|
|
}
|
|
type->flags->val = 0;
|
|
type->flags->opts = dummy_tracer_opt;
|
|
} else
|
|
if (!type->flags->opts)
|
|
type->flags->opts = dummy_tracer_opt;
|
|
|
|
/* store the tracer for __set_tracer_option */
|
|
type->flags->trace = type;
|
|
|
|
ret = run_tracer_selftest(type);
|
|
if (ret < 0)
|
|
goto out;
|
|
|
|
type->next = trace_types;
|
|
trace_types = type;
|
|
add_tracer_options(&global_trace, type);
|
|
|
|
out:
|
|
tracing_selftest_running = false;
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
if (ret || !default_bootup_tracer)
|
|
goto out_unlock;
|
|
|
|
if (strncmp(default_bootup_tracer, type->name, MAX_TRACER_SIZE))
|
|
goto out_unlock;
|
|
|
|
printk(KERN_INFO "Starting tracer '%s'\n", type->name);
|
|
/* Do we want this tracer to start on bootup? */
|
|
tracing_set_tracer(&global_trace, type->name);
|
|
default_bootup_tracer = NULL;
|
|
|
|
apply_trace_boot_options();
|
|
|
|
/* disable other selftests, since this will break it. */
|
|
tracing_selftest_disabled = true;
|
|
#ifdef CONFIG_FTRACE_STARTUP_TEST
|
|
printk(KERN_INFO "Disabling FTRACE selftests due to running tracer '%s'\n",
|
|
type->name);
|
|
#endif
|
|
|
|
out_unlock:
|
|
return ret;
|
|
}
|
|
|
|
void tracing_reset(struct trace_buffer *buf, int cpu)
|
|
{
|
|
struct ring_buffer *buffer = buf->buffer;
|
|
|
|
if (!buffer)
|
|
return;
|
|
|
|
ring_buffer_record_disable(buffer);
|
|
|
|
/* Make sure all commits have finished */
|
|
synchronize_sched();
|
|
ring_buffer_reset_cpu(buffer, cpu);
|
|
|
|
ring_buffer_record_enable(buffer);
|
|
}
|
|
|
|
void tracing_reset_online_cpus(struct trace_buffer *buf)
|
|
{
|
|
struct ring_buffer *buffer = buf->buffer;
|
|
int cpu;
|
|
|
|
if (!buffer)
|
|
return;
|
|
|
|
ring_buffer_record_disable(buffer);
|
|
|
|
/* Make sure all commits have finished */
|
|
synchronize_sched();
|
|
|
|
buf->time_start = buffer_ftrace_now(buf, buf->cpu);
|
|
|
|
for_each_online_cpu(cpu)
|
|
ring_buffer_reset_cpu(buffer, cpu);
|
|
|
|
ring_buffer_record_enable(buffer);
|
|
}
|
|
|
|
/* Must have trace_types_lock held */
|
|
void tracing_reset_all_online_cpus(void)
|
|
{
|
|
struct trace_array *tr;
|
|
|
|
list_for_each_entry(tr, &ftrace_trace_arrays, list) {
|
|
tracing_reset_online_cpus(&tr->trace_buffer);
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
tracing_reset_online_cpus(&tr->max_buffer);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
#define SAVED_CMDLINES_DEFAULT 128
|
|
#define NO_CMDLINE_MAP UINT_MAX
|
|
static unsigned saved_tgids[SAVED_CMDLINES_DEFAULT];
|
|
static arch_spinlock_t trace_cmdline_lock = __ARCH_SPIN_LOCK_UNLOCKED;
|
|
struct saved_cmdlines_buffer {
|
|
unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1];
|
|
unsigned *map_cmdline_to_pid;
|
|
unsigned cmdline_num;
|
|
int cmdline_idx;
|
|
char *saved_cmdlines;
|
|
};
|
|
static struct saved_cmdlines_buffer *savedcmd;
|
|
|
|
/* temporary disable recording */
|
|
static atomic_t trace_record_cmdline_disabled __read_mostly;
|
|
|
|
static inline char *get_saved_cmdlines(int idx)
|
|
{
|
|
return &savedcmd->saved_cmdlines[idx * TASK_COMM_LEN];
|
|
}
|
|
|
|
static inline void set_cmdline(int idx, const char *cmdline)
|
|
{
|
|
memcpy(get_saved_cmdlines(idx), cmdline, TASK_COMM_LEN);
|
|
}
|
|
|
|
static int allocate_cmdlines_buffer(unsigned int val,
|
|
struct saved_cmdlines_buffer *s)
|
|
{
|
|
s->map_cmdline_to_pid = kmalloc(val * sizeof(*s->map_cmdline_to_pid),
|
|
GFP_KERNEL);
|
|
if (!s->map_cmdline_to_pid)
|
|
return -ENOMEM;
|
|
|
|
s->saved_cmdlines = kmalloc(val * TASK_COMM_LEN, GFP_KERNEL);
|
|
if (!s->saved_cmdlines) {
|
|
kfree(s->map_cmdline_to_pid);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
s->cmdline_idx = 0;
|
|
s->cmdline_num = val;
|
|
memset(&s->map_pid_to_cmdline, NO_CMDLINE_MAP,
|
|
sizeof(s->map_pid_to_cmdline));
|
|
memset(s->map_cmdline_to_pid, NO_CMDLINE_MAP,
|
|
val * sizeof(*s->map_cmdline_to_pid));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int trace_create_savedcmd(void)
|
|
{
|
|
int ret;
|
|
|
|
savedcmd = kmalloc(sizeof(*savedcmd), GFP_KERNEL);
|
|
if (!savedcmd)
|
|
return -ENOMEM;
|
|
|
|
ret = allocate_cmdlines_buffer(SAVED_CMDLINES_DEFAULT, savedcmd);
|
|
if (ret < 0) {
|
|
kfree(savedcmd);
|
|
savedcmd = NULL;
|
|
return -ENOMEM;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int is_tracing_stopped(void)
|
|
{
|
|
return global_trace.stop_count;
|
|
}
|
|
|
|
/**
|
|
* tracing_start - quick start of the tracer
|
|
*
|
|
* If tracing is enabled but was stopped by tracing_stop,
|
|
* this will start the tracer back up.
|
|
*/
|
|
void tracing_start(void)
|
|
{
|
|
struct ring_buffer *buffer;
|
|
unsigned long flags;
|
|
|
|
if (tracing_disabled)
|
|
return;
|
|
|
|
raw_spin_lock_irqsave(&global_trace.start_lock, flags);
|
|
if (--global_trace.stop_count) {
|
|
if (global_trace.stop_count < 0) {
|
|
/* Someone screwed up their debugging */
|
|
WARN_ON_ONCE(1);
|
|
global_trace.stop_count = 0;
|
|
}
|
|
goto out;
|
|
}
|
|
|
|
/* Prevent the buffers from switching */
|
|
arch_spin_lock(&global_trace.max_lock);
|
|
|
|
buffer = global_trace.trace_buffer.buffer;
|
|
if (buffer)
|
|
ring_buffer_record_enable(buffer);
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
buffer = global_trace.max_buffer.buffer;
|
|
if (buffer)
|
|
ring_buffer_record_enable(buffer);
|
|
#endif
|
|
|
|
arch_spin_unlock(&global_trace.max_lock);
|
|
|
|
out:
|
|
raw_spin_unlock_irqrestore(&global_trace.start_lock, flags);
|
|
}
|
|
|
|
static void tracing_start_tr(struct trace_array *tr)
|
|
{
|
|
struct ring_buffer *buffer;
|
|
unsigned long flags;
|
|
|
|
if (tracing_disabled)
|
|
return;
|
|
|
|
/* If global, we need to also start the max tracer */
|
|
if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
|
|
return tracing_start();
|
|
|
|
raw_spin_lock_irqsave(&tr->start_lock, flags);
|
|
|
|
if (--tr->stop_count) {
|
|
if (tr->stop_count < 0) {
|
|
/* Someone screwed up their debugging */
|
|
WARN_ON_ONCE(1);
|
|
tr->stop_count = 0;
|
|
}
|
|
goto out;
|
|
}
|
|
|
|
buffer = tr->trace_buffer.buffer;
|
|
if (buffer)
|
|
ring_buffer_record_enable(buffer);
|
|
|
|
out:
|
|
raw_spin_unlock_irqrestore(&tr->start_lock, flags);
|
|
}
|
|
|
|
/**
|
|
* tracing_stop - quick stop of the tracer
|
|
*
|
|
* Light weight way to stop tracing. Use in conjunction with
|
|
* tracing_start.
|
|
*/
|
|
void tracing_stop(void)
|
|
{
|
|
struct ring_buffer *buffer;
|
|
unsigned long flags;
|
|
|
|
raw_spin_lock_irqsave(&global_trace.start_lock, flags);
|
|
if (global_trace.stop_count++)
|
|
goto out;
|
|
|
|
/* Prevent the buffers from switching */
|
|
arch_spin_lock(&global_trace.max_lock);
|
|
|
|
buffer = global_trace.trace_buffer.buffer;
|
|
if (buffer)
|
|
ring_buffer_record_disable(buffer);
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
buffer = global_trace.max_buffer.buffer;
|
|
if (buffer)
|
|
ring_buffer_record_disable(buffer);
|
|
#endif
|
|
|
|
arch_spin_unlock(&global_trace.max_lock);
|
|
|
|
out:
|
|
raw_spin_unlock_irqrestore(&global_trace.start_lock, flags);
|
|
}
|
|
|
|
static void tracing_stop_tr(struct trace_array *tr)
|
|
{
|
|
struct ring_buffer *buffer;
|
|
unsigned long flags;
|
|
|
|
/* If global, we need to also stop the max tracer */
|
|
if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
|
|
return tracing_stop();
|
|
|
|
raw_spin_lock_irqsave(&tr->start_lock, flags);
|
|
if (tr->stop_count++)
|
|
goto out;
|
|
|
|
buffer = tr->trace_buffer.buffer;
|
|
if (buffer)
|
|
ring_buffer_record_disable(buffer);
|
|
|
|
out:
|
|
raw_spin_unlock_irqrestore(&tr->start_lock, flags);
|
|
}
|
|
|
|
void trace_stop_cmdline_recording(void);
|
|
|
|
static int trace_save_cmdline(struct task_struct *tsk)
|
|
{
|
|
unsigned pid, idx;
|
|
|
|
if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT))
|
|
return 0;
|
|
|
|
/*
|
|
* It's not the end of the world if we don't get
|
|
* the lock, but we also don't want to spin
|
|
* nor do we want to disable interrupts,
|
|
* so if we miss here, then better luck next time.
|
|
*/
|
|
if (!arch_spin_trylock(&trace_cmdline_lock))
|
|
return 0;
|
|
|
|
idx = savedcmd->map_pid_to_cmdline[tsk->pid];
|
|
if (idx == NO_CMDLINE_MAP) {
|
|
idx = (savedcmd->cmdline_idx + 1) % savedcmd->cmdline_num;
|
|
|
|
/*
|
|
* Check whether the cmdline buffer at idx has a pid
|
|
* mapped. We are going to overwrite that entry so we
|
|
* need to clear the map_pid_to_cmdline. Otherwise we
|
|
* would read the new comm for the old pid.
|
|
*/
|
|
pid = savedcmd->map_cmdline_to_pid[idx];
|
|
if (pid != NO_CMDLINE_MAP)
|
|
savedcmd->map_pid_to_cmdline[pid] = NO_CMDLINE_MAP;
|
|
|
|
savedcmd->map_cmdline_to_pid[idx] = tsk->pid;
|
|
savedcmd->map_pid_to_cmdline[tsk->pid] = idx;
|
|
|
|
savedcmd->cmdline_idx = idx;
|
|
}
|
|
|
|
set_cmdline(idx, tsk->comm);
|
|
saved_tgids[idx] = tsk->tgid;
|
|
arch_spin_unlock(&trace_cmdline_lock);
|
|
|
|
return 1;
|
|
}
|
|
|
|
static void __trace_find_cmdline(int pid, char comm[])
|
|
{
|
|
unsigned map;
|
|
|
|
if (!pid) {
|
|
strcpy(comm, "<idle>");
|
|
return;
|
|
}
|
|
|
|
if (WARN_ON_ONCE(pid < 0)) {
|
|
strcpy(comm, "<XXX>");
|
|
return;
|
|
}
|
|
|
|
if (pid > PID_MAX_DEFAULT) {
|
|
strcpy(comm, "<...>");
|
|
return;
|
|
}
|
|
|
|
map = savedcmd->map_pid_to_cmdline[pid];
|
|
if (map != NO_CMDLINE_MAP)
|
|
strcpy(comm, get_saved_cmdlines(map));
|
|
else
|
|
strcpy(comm, "<...>");
|
|
}
|
|
|
|
void trace_find_cmdline(int pid, char comm[])
|
|
{
|
|
preempt_disable();
|
|
arch_spin_lock(&trace_cmdline_lock);
|
|
|
|
__trace_find_cmdline(pid, comm);
|
|
|
|
arch_spin_unlock(&trace_cmdline_lock);
|
|
preempt_enable();
|
|
}
|
|
|
|
int trace_find_tgid(int pid)
|
|
{
|
|
unsigned map;
|
|
int tgid;
|
|
|
|
preempt_disable();
|
|
arch_spin_lock(&trace_cmdline_lock);
|
|
map = savedcmd->map_pid_to_cmdline[pid];
|
|
if (map != NO_CMDLINE_MAP)
|
|
tgid = saved_tgids[map];
|
|
else
|
|
tgid = -1;
|
|
|
|
arch_spin_unlock(&trace_cmdline_lock);
|
|
preempt_enable();
|
|
|
|
return tgid;
|
|
}
|
|
|
|
void tracing_record_cmdline(struct task_struct *tsk)
|
|
{
|
|
if (atomic_read(&trace_record_cmdline_disabled) || !tracing_is_on())
|
|
return;
|
|
|
|
if (!__this_cpu_read(trace_cmdline_save))
|
|
return;
|
|
|
|
if (trace_save_cmdline(tsk))
|
|
__this_cpu_write(trace_cmdline_save, false);
|
|
}
|
|
|
|
void
|
|
tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags,
|
|
int pc)
|
|
{
|
|
struct task_struct *tsk = current;
|
|
|
|
entry->preempt_count = pc & 0xff;
|
|
entry->pid = (tsk) ? tsk->pid : 0;
|
|
entry->flags =
|
|
#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
|
|
(irqs_disabled_flags(flags) ? TRACE_FLAG_IRQS_OFF : 0) |
|
|
#else
|
|
TRACE_FLAG_IRQS_NOSUPPORT |
|
|
#endif
|
|
((pc & NMI_MASK ) ? TRACE_FLAG_NMI : 0) |
|
|
((pc & HARDIRQ_MASK) ? TRACE_FLAG_HARDIRQ : 0) |
|
|
((pc & SOFTIRQ_MASK) ? TRACE_FLAG_SOFTIRQ : 0) |
|
|
(tif_need_resched() ? TRACE_FLAG_NEED_RESCHED : 0) |
|
|
(test_preempt_need_resched() ? TRACE_FLAG_PREEMPT_RESCHED : 0);
|
|
}
|
|
EXPORT_SYMBOL_GPL(tracing_generic_entry_update);
|
|
|
|
static __always_inline void
|
|
trace_event_setup(struct ring_buffer_event *event,
|
|
int type, unsigned long flags, int pc)
|
|
{
|
|
struct trace_entry *ent = ring_buffer_event_data(event);
|
|
|
|
tracing_generic_entry_update(ent, flags, pc);
|
|
ent->type = type;
|
|
}
|
|
|
|
struct ring_buffer_event *
|
|
trace_buffer_lock_reserve(struct ring_buffer *buffer,
|
|
int type,
|
|
unsigned long len,
|
|
unsigned long flags, int pc)
|
|
{
|
|
struct ring_buffer_event *event;
|
|
|
|
event = ring_buffer_lock_reserve(buffer, len);
|
|
if (event != NULL)
|
|
trace_event_setup(event, type, flags, pc);
|
|
|
|
return event;
|
|
}
|
|
|
|
DEFINE_PER_CPU(struct ring_buffer_event *, trace_buffered_event);
|
|
DEFINE_PER_CPU(int, trace_buffered_event_cnt);
|
|
static int trace_buffered_event_ref;
|
|
|
|
/**
|
|
* trace_buffered_event_enable - enable buffering events
|
|
*
|
|
* When events are being filtered, it is quicker to use a temporary
|
|
* buffer to write the event data into if there's a likely chance
|
|
* that it will not be committed. The discard of the ring buffer
|
|
* is not as fast as committing, and is much slower than copying
|
|
* a commit.
|
|
*
|
|
* When an event is to be filtered, allocate per cpu buffers to
|
|
* write the event data into, and if the event is filtered and discarded
|
|
* it is simply dropped, otherwise, the entire data is to be committed
|
|
* in one shot.
|
|
*/
|
|
void trace_buffered_event_enable(void)
|
|
{
|
|
struct ring_buffer_event *event;
|
|
struct page *page;
|
|
int cpu;
|
|
|
|
WARN_ON_ONCE(!mutex_is_locked(&event_mutex));
|
|
|
|
if (trace_buffered_event_ref++)
|
|
return;
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
page = alloc_pages_node(cpu_to_node(cpu),
|
|
GFP_KERNEL | __GFP_NORETRY, 0);
|
|
if (!page)
|
|
goto failed;
|
|
|
|
event = page_address(page);
|
|
memset(event, 0, sizeof(*event));
|
|
|
|
per_cpu(trace_buffered_event, cpu) = event;
|
|
|
|
preempt_disable();
|
|
if (cpu == smp_processor_id() &&
|
|
this_cpu_read(trace_buffered_event) !=
|
|
per_cpu(trace_buffered_event, cpu))
|
|
WARN_ON_ONCE(1);
|
|
preempt_enable();
|
|
}
|
|
|
|
return;
|
|
failed:
|
|
trace_buffered_event_disable();
|
|
}
|
|
|
|
static void enable_trace_buffered_event(void *data)
|
|
{
|
|
/* Probably not needed, but do it anyway */
|
|
smp_rmb();
|
|
this_cpu_dec(trace_buffered_event_cnt);
|
|
}
|
|
|
|
static void disable_trace_buffered_event(void *data)
|
|
{
|
|
this_cpu_inc(trace_buffered_event_cnt);
|
|
}
|
|
|
|
/**
|
|
* trace_buffered_event_disable - disable buffering events
|
|
*
|
|
* When a filter is removed, it is faster to not use the buffered
|
|
* events, and to commit directly into the ring buffer. Free up
|
|
* the temp buffers when there are no more users. This requires
|
|
* special synchronization with current events.
|
|
*/
|
|
void trace_buffered_event_disable(void)
|
|
{
|
|
int cpu;
|
|
|
|
WARN_ON_ONCE(!mutex_is_locked(&event_mutex));
|
|
|
|
if (WARN_ON_ONCE(!trace_buffered_event_ref))
|
|
return;
|
|
|
|
if (--trace_buffered_event_ref)
|
|
return;
|
|
|
|
preempt_disable();
|
|
/* For each CPU, set the buffer as used. */
|
|
smp_call_function_many(tracing_buffer_mask,
|
|
disable_trace_buffered_event, NULL, 1);
|
|
preempt_enable();
|
|
|
|
/* Wait for all current users to finish */
|
|
synchronize_sched();
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
free_page((unsigned long)per_cpu(trace_buffered_event, cpu));
|
|
per_cpu(trace_buffered_event, cpu) = NULL;
|
|
}
|
|
/*
|
|
* Make sure trace_buffered_event is NULL before clearing
|
|
* trace_buffered_event_cnt.
|
|
*/
|
|
smp_wmb();
|
|
|
|
preempt_disable();
|
|
/* Do the work on each cpu */
|
|
smp_call_function_many(tracing_buffer_mask,
|
|
enable_trace_buffered_event, NULL, 1);
|
|
preempt_enable();
|
|
}
|
|
|
|
void
|
|
__buffer_unlock_commit(struct ring_buffer *buffer, struct ring_buffer_event *event)
|
|
{
|
|
__this_cpu_write(trace_cmdline_save, true);
|
|
|
|
/* If this is the temp buffer, we need to commit fully */
|
|
if (this_cpu_read(trace_buffered_event) == event) {
|
|
/* Length is in event->array[0] */
|
|
ring_buffer_write(buffer, event->array[0], &event->array[1]);
|
|
/* Release the temp buffer */
|
|
this_cpu_dec(trace_buffered_event_cnt);
|
|
} else
|
|
ring_buffer_unlock_commit(buffer, event);
|
|
}
|
|
|
|
static struct ring_buffer *temp_buffer;
|
|
|
|
struct ring_buffer_event *
|
|
trace_event_buffer_lock_reserve(struct ring_buffer **current_rb,
|
|
struct trace_event_file *trace_file,
|
|
int type, unsigned long len,
|
|
unsigned long flags, int pc)
|
|
{
|
|
struct ring_buffer_event *entry;
|
|
int val;
|
|
|
|
*current_rb = trace_file->tr->trace_buffer.buffer;
|
|
|
|
if ((trace_file->flags &
|
|
(EVENT_FILE_FL_SOFT_DISABLED | EVENT_FILE_FL_FILTERED)) &&
|
|
(entry = this_cpu_read(trace_buffered_event))) {
|
|
/* Try to use the per cpu buffer first */
|
|
val = this_cpu_inc_return(trace_buffered_event_cnt);
|
|
if (val == 1) {
|
|
trace_event_setup(entry, type, flags, pc);
|
|
entry->array[0] = len;
|
|
return entry;
|
|
}
|
|
this_cpu_dec(trace_buffered_event_cnt);
|
|
}
|
|
|
|
entry = trace_buffer_lock_reserve(*current_rb,
|
|
type, len, flags, pc);
|
|
/*
|
|
* If tracing is off, but we have triggers enabled
|
|
* we still need to look at the event data. Use the temp_buffer
|
|
* to store the trace event for the tigger to use. It's recusive
|
|
* safe and will not be recorded anywhere.
|
|
*/
|
|
if (!entry && trace_file->flags & EVENT_FILE_FL_TRIGGER_COND) {
|
|
*current_rb = temp_buffer;
|
|
entry = trace_buffer_lock_reserve(*current_rb,
|
|
type, len, flags, pc);
|
|
}
|
|
return entry;
|
|
}
|
|
EXPORT_SYMBOL_GPL(trace_event_buffer_lock_reserve);
|
|
|
|
void trace_buffer_unlock_commit_regs(struct trace_array *tr,
|
|
struct ring_buffer *buffer,
|
|
struct ring_buffer_event *event,
|
|
unsigned long flags, int pc,
|
|
struct pt_regs *regs)
|
|
{
|
|
__buffer_unlock_commit(buffer, event);
|
|
|
|
/*
|
|
* If regs is not set, then skip the following callers:
|
|
* trace_buffer_unlock_commit_regs
|
|
* event_trigger_unlock_commit
|
|
* trace_event_buffer_commit
|
|
* trace_event_raw_event_sched_switch
|
|
* Note, we can still get here via blktrace, wakeup tracer
|
|
* and mmiotrace, but that's ok if they lose a function or
|
|
* two. They are that meaningful.
|
|
*/
|
|
ftrace_trace_stack(tr, buffer, flags, regs ? 0 : 4, pc, regs);
|
|
ftrace_trace_userstack(buffer, flags, pc);
|
|
}
|
|
|
|
void
|
|
trace_function(struct trace_array *tr,
|
|
unsigned long ip, unsigned long parent_ip, unsigned long flags,
|
|
int pc)
|
|
{
|
|
struct trace_event_call *call = &event_function;
|
|
struct ring_buffer *buffer = tr->trace_buffer.buffer;
|
|
struct ring_buffer_event *event;
|
|
struct ftrace_entry *entry;
|
|
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_FN, sizeof(*entry),
|
|
flags, pc);
|
|
if (!event)
|
|
return;
|
|
entry = ring_buffer_event_data(event);
|
|
entry->ip = ip;
|
|
entry->parent_ip = parent_ip;
|
|
|
|
if (!call_filter_check_discard(call, entry, buffer, event))
|
|
__buffer_unlock_commit(buffer, event);
|
|
}
|
|
|
|
#ifdef CONFIG_STACKTRACE
|
|
|
|
#define FTRACE_STACK_MAX_ENTRIES (PAGE_SIZE / sizeof(unsigned long))
|
|
struct ftrace_stack {
|
|
unsigned long calls[FTRACE_STACK_MAX_ENTRIES];
|
|
};
|
|
|
|
static DEFINE_PER_CPU(struct ftrace_stack, ftrace_stack);
|
|
static DEFINE_PER_CPU(int, ftrace_stack_reserve);
|
|
|
|
static void __ftrace_trace_stack(struct ring_buffer *buffer,
|
|
unsigned long flags,
|
|
int skip, int pc, struct pt_regs *regs)
|
|
{
|
|
struct trace_event_call *call = &event_kernel_stack;
|
|
struct ring_buffer_event *event;
|
|
struct stack_entry *entry;
|
|
struct stack_trace trace;
|
|
int use_stack;
|
|
int size = FTRACE_STACK_ENTRIES;
|
|
|
|
trace.nr_entries = 0;
|
|
trace.skip = skip;
|
|
|
|
/*
|
|
* Add two, for this function and the call to save_stack_trace()
|
|
* If regs is set, then these functions will not be in the way.
|
|
*/
|
|
if (!regs)
|
|
trace.skip += 2;
|
|
|
|
/*
|
|
* Since events can happen in NMIs there's no safe way to
|
|
* use the per cpu ftrace_stacks. We reserve it and if an interrupt
|
|
* or NMI comes in, it will just have to use the default
|
|
* FTRACE_STACK_SIZE.
|
|
*/
|
|
preempt_disable_notrace();
|
|
|
|
use_stack = __this_cpu_inc_return(ftrace_stack_reserve);
|
|
/*
|
|
* We don't need any atomic variables, just a barrier.
|
|
* If an interrupt comes in, we don't care, because it would
|
|
* have exited and put the counter back to what we want.
|
|
* We just need a barrier to keep gcc from moving things
|
|
* around.
|
|
*/
|
|
barrier();
|
|
if (use_stack == 1) {
|
|
trace.entries = this_cpu_ptr(ftrace_stack.calls);
|
|
trace.max_entries = FTRACE_STACK_MAX_ENTRIES;
|
|
|
|
if (regs)
|
|
save_stack_trace_regs(regs, &trace);
|
|
else
|
|
save_stack_trace(&trace);
|
|
|
|
if (trace.nr_entries > size)
|
|
size = trace.nr_entries;
|
|
} else
|
|
/* From now on, use_stack is a boolean */
|
|
use_stack = 0;
|
|
|
|
size *= sizeof(unsigned long);
|
|
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_STACK,
|
|
sizeof(*entry) + size, flags, pc);
|
|
if (!event)
|
|
goto out;
|
|
entry = ring_buffer_event_data(event);
|
|
|
|
memset(&entry->caller, 0, size);
|
|
|
|
if (use_stack)
|
|
memcpy(&entry->caller, trace.entries,
|
|
trace.nr_entries * sizeof(unsigned long));
|
|
else {
|
|
trace.max_entries = FTRACE_STACK_ENTRIES;
|
|
trace.entries = entry->caller;
|
|
if (regs)
|
|
save_stack_trace_regs(regs, &trace);
|
|
else
|
|
save_stack_trace(&trace);
|
|
}
|
|
|
|
entry->size = trace.nr_entries;
|
|
|
|
if (!call_filter_check_discard(call, entry, buffer, event))
|
|
__buffer_unlock_commit(buffer, event);
|
|
|
|
out:
|
|
/* Again, don't let gcc optimize things here */
|
|
barrier();
|
|
__this_cpu_dec(ftrace_stack_reserve);
|
|
preempt_enable_notrace();
|
|
|
|
}
|
|
|
|
static inline void ftrace_trace_stack(struct trace_array *tr,
|
|
struct ring_buffer *buffer,
|
|
unsigned long flags,
|
|
int skip, int pc, struct pt_regs *regs)
|
|
{
|
|
if (!(tr->trace_flags & TRACE_ITER_STACKTRACE))
|
|
return;
|
|
|
|
__ftrace_trace_stack(buffer, flags, skip, pc, regs);
|
|
}
|
|
|
|
void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
|
|
int pc)
|
|
{
|
|
__ftrace_trace_stack(tr->trace_buffer.buffer, flags, skip, pc, NULL);
|
|
}
|
|
|
|
/**
|
|
* trace_dump_stack - record a stack back trace in the trace buffer
|
|
* @skip: Number of functions to skip (helper handlers)
|
|
*/
|
|
void trace_dump_stack(int skip)
|
|
{
|
|
unsigned long flags;
|
|
|
|
if (tracing_disabled || tracing_selftest_running)
|
|
return;
|
|
|
|
local_save_flags(flags);
|
|
|
|
/*
|
|
* Skip 3 more, seems to get us at the caller of
|
|
* this function.
|
|
*/
|
|
skip += 3;
|
|
__ftrace_trace_stack(global_trace.trace_buffer.buffer,
|
|
flags, skip, preempt_count(), NULL);
|
|
}
|
|
|
|
static DEFINE_PER_CPU(int, user_stack_count);
|
|
|
|
void
|
|
ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)
|
|
{
|
|
struct trace_event_call *call = &event_user_stack;
|
|
struct ring_buffer_event *event;
|
|
struct userstack_entry *entry;
|
|
struct stack_trace trace;
|
|
|
|
if (!(global_trace.trace_flags & TRACE_ITER_USERSTACKTRACE))
|
|
return;
|
|
|
|
/*
|
|
* NMIs can not handle page faults, even with fix ups.
|
|
* The save user stack can (and often does) fault.
|
|
*/
|
|
if (unlikely(in_nmi()))
|
|
return;
|
|
|
|
/*
|
|
* prevent recursion, since the user stack tracing may
|
|
* trigger other kernel events.
|
|
*/
|
|
preempt_disable();
|
|
if (__this_cpu_read(user_stack_count))
|
|
goto out;
|
|
|
|
__this_cpu_inc(user_stack_count);
|
|
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_USER_STACK,
|
|
sizeof(*entry), flags, pc);
|
|
if (!event)
|
|
goto out_drop_count;
|
|
entry = ring_buffer_event_data(event);
|
|
|
|
entry->tgid = current->tgid;
|
|
memset(&entry->caller, 0, sizeof(entry->caller));
|
|
|
|
trace.nr_entries = 0;
|
|
trace.max_entries = FTRACE_STACK_ENTRIES;
|
|
trace.skip = 0;
|
|
trace.entries = entry->caller;
|
|
|
|
save_stack_trace_user(&trace);
|
|
if (!call_filter_check_discard(call, entry, buffer, event))
|
|
__buffer_unlock_commit(buffer, event);
|
|
|
|
out_drop_count:
|
|
__this_cpu_dec(user_stack_count);
|
|
out:
|
|
preempt_enable();
|
|
}
|
|
|
|
#ifdef UNUSED
|
|
static void __trace_userstack(struct trace_array *tr, unsigned long flags)
|
|
{
|
|
ftrace_trace_userstack(tr, flags, preempt_count());
|
|
}
|
|
#endif /* UNUSED */
|
|
|
|
#endif /* CONFIG_STACKTRACE */
|
|
|
|
/* created for use with alloc_percpu */
|
|
struct trace_buffer_struct {
|
|
int nesting;
|
|
char buffer[4][TRACE_BUF_SIZE];
|
|
};
|
|
|
|
static struct trace_buffer_struct *trace_percpu_buffer;
|
|
|
|
/*
|
|
* Thise allows for lockless recording. If we're nested too deeply, then
|
|
* this returns NULL.
|
|
*/
|
|
static char *get_trace_buf(void)
|
|
{
|
|
struct trace_buffer_struct *buffer = this_cpu_ptr(trace_percpu_buffer);
|
|
|
|
if (!buffer || buffer->nesting >= 4)
|
|
return NULL;
|
|
|
|
return &buffer->buffer[buffer->nesting++][0];
|
|
}
|
|
|
|
static void put_trace_buf(void)
|
|
{
|
|
this_cpu_dec(trace_percpu_buffer->nesting);
|
|
}
|
|
|
|
static int alloc_percpu_trace_buffer(void)
|
|
{
|
|
struct trace_buffer_struct *buffers;
|
|
|
|
buffers = alloc_percpu(struct trace_buffer_struct);
|
|
if (WARN(!buffers, "Could not allocate percpu trace_printk buffer"))
|
|
return -ENOMEM;
|
|
|
|
trace_percpu_buffer = buffers;
|
|
return 0;
|
|
}
|
|
|
|
static int buffers_allocated;
|
|
|
|
void trace_printk_init_buffers(void)
|
|
{
|
|
if (buffers_allocated)
|
|
return;
|
|
|
|
if (alloc_percpu_trace_buffer())
|
|
return;
|
|
|
|
/* trace_printk() is for debug use only. Don't use it in production. */
|
|
|
|
pr_warn("\n");
|
|
pr_warn("**********************************************************\n");
|
|
pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n");
|
|
pr_warn("** **\n");
|
|
pr_warn("** trace_printk() being used. Allocating extra memory. **\n");
|
|
pr_warn("** **\n");
|
|
pr_warn("** This means that this is a DEBUG kernel and it is **\n");
|
|
pr_warn("** unsafe for production use. **\n");
|
|
pr_warn("** **\n");
|
|
pr_warn("** If you see this message and you are not debugging **\n");
|
|
pr_warn("** the kernel, report this immediately to your vendor! **\n");
|
|
pr_warn("** **\n");
|
|
pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n");
|
|
pr_warn("**********************************************************\n");
|
|
|
|
/* Expand the buffers to set size */
|
|
tracing_update_buffers();
|
|
|
|
buffers_allocated = 1;
|
|
|
|
/*
|
|
* trace_printk_init_buffers() can be called by modules.
|
|
* If that happens, then we need to start cmdline recording
|
|
* directly here. If the global_trace.buffer is already
|
|
* allocated here, then this was called by module code.
|
|
*/
|
|
if (global_trace.trace_buffer.buffer)
|
|
tracing_start_cmdline_record();
|
|
}
|
|
|
|
void trace_printk_start_comm(void)
|
|
{
|
|
/* Start tracing comms if trace printk is set */
|
|
if (!buffers_allocated)
|
|
return;
|
|
tracing_start_cmdline_record();
|
|
}
|
|
|
|
static void trace_printk_start_stop_comm(int enabled)
|
|
{
|
|
if (!buffers_allocated)
|
|
return;
|
|
|
|
if (enabled)
|
|
tracing_start_cmdline_record();
|
|
else
|
|
tracing_stop_cmdline_record();
|
|
}
|
|
|
|
/**
|
|
* trace_vbprintk - write binary msg to tracing buffer
|
|
*
|
|
*/
|
|
int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
|
|
{
|
|
struct trace_event_call *call = &event_bprint;
|
|
struct ring_buffer_event *event;
|
|
struct ring_buffer *buffer;
|
|
struct trace_array *tr = &global_trace;
|
|
struct bprint_entry *entry;
|
|
unsigned long flags;
|
|
char *tbuffer;
|
|
int len = 0, size, pc;
|
|
|
|
if (unlikely(tracing_selftest_running || tracing_disabled))
|
|
return 0;
|
|
|
|
/* Don't pollute graph traces with trace_vprintk internals */
|
|
pause_graph_tracing();
|
|
|
|
pc = preempt_count();
|
|
preempt_disable_notrace();
|
|
|
|
tbuffer = get_trace_buf();
|
|
if (!tbuffer) {
|
|
len = 0;
|
|
goto out_nobuffer;
|
|
}
|
|
|
|
len = vbin_printf((u32 *)tbuffer, TRACE_BUF_SIZE/sizeof(int), fmt, args);
|
|
|
|
if (len > TRACE_BUF_SIZE/sizeof(int) || len < 0)
|
|
goto out;
|
|
|
|
local_save_flags(flags);
|
|
size = sizeof(*entry) + sizeof(u32) * len;
|
|
buffer = tr->trace_buffer.buffer;
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_BPRINT, size,
|
|
flags, pc);
|
|
if (!event)
|
|
goto out;
|
|
entry = ring_buffer_event_data(event);
|
|
entry->ip = ip;
|
|
entry->fmt = fmt;
|
|
|
|
memcpy(entry->buf, tbuffer, sizeof(u32) * len);
|
|
if (!call_filter_check_discard(call, entry, buffer, event)) {
|
|
__buffer_unlock_commit(buffer, event);
|
|
ftrace_trace_stack(tr, buffer, flags, 6, pc, NULL);
|
|
}
|
|
|
|
out:
|
|
put_trace_buf();
|
|
|
|
out_nobuffer:
|
|
preempt_enable_notrace();
|
|
unpause_graph_tracing();
|
|
|
|
return len;
|
|
}
|
|
EXPORT_SYMBOL_GPL(trace_vbprintk);
|
|
|
|
static int
|
|
__trace_array_vprintk(struct ring_buffer *buffer,
|
|
unsigned long ip, const char *fmt, va_list args)
|
|
{
|
|
struct trace_event_call *call = &event_print;
|
|
struct ring_buffer_event *event;
|
|
int len = 0, size, pc;
|
|
struct print_entry *entry;
|
|
unsigned long flags;
|
|
char *tbuffer;
|
|
|
|
if (tracing_disabled || tracing_selftest_running)
|
|
return 0;
|
|
|
|
/* Don't pollute graph traces with trace_vprintk internals */
|
|
pause_graph_tracing();
|
|
|
|
pc = preempt_count();
|
|
preempt_disable_notrace();
|
|
|
|
|
|
tbuffer = get_trace_buf();
|
|
if (!tbuffer) {
|
|
len = 0;
|
|
goto out_nobuffer;
|
|
}
|
|
|
|
len = vscnprintf(tbuffer, TRACE_BUF_SIZE, fmt, args);
|
|
|
|
local_save_flags(flags);
|
|
size = sizeof(*entry) + len + 1;
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_PRINT, size,
|
|
flags, pc);
|
|
if (!event)
|
|
goto out;
|
|
entry = ring_buffer_event_data(event);
|
|
entry->ip = ip;
|
|
|
|
memcpy(&entry->buf, tbuffer, len + 1);
|
|
if (!call_filter_check_discard(call, entry, buffer, event)) {
|
|
stm_log(OST_ENTITY_TRACE_PRINTK, entry->buf, len + 1);
|
|
__buffer_unlock_commit(buffer, event);
|
|
ftrace_trace_stack(&global_trace, buffer, flags, 6, pc, NULL);
|
|
}
|
|
|
|
out:
|
|
put_trace_buf();
|
|
|
|
out_nobuffer:
|
|
preempt_enable_notrace();
|
|
unpause_graph_tracing();
|
|
|
|
return len;
|
|
}
|
|
|
|
int trace_array_vprintk(struct trace_array *tr,
|
|
unsigned long ip, const char *fmt, va_list args)
|
|
{
|
|
return __trace_array_vprintk(tr->trace_buffer.buffer, ip, fmt, args);
|
|
}
|
|
|
|
int trace_array_printk(struct trace_array *tr,
|
|
unsigned long ip, const char *fmt, ...)
|
|
{
|
|
int ret;
|
|
va_list ap;
|
|
|
|
if (!(global_trace.trace_flags & TRACE_ITER_PRINTK))
|
|
return 0;
|
|
|
|
va_start(ap, fmt);
|
|
ret = trace_array_vprintk(tr, ip, fmt, ap);
|
|
va_end(ap);
|
|
return ret;
|
|
}
|
|
|
|
int trace_array_printk_buf(struct ring_buffer *buffer,
|
|
unsigned long ip, const char *fmt, ...)
|
|
{
|
|
int ret;
|
|
va_list ap;
|
|
|
|
if (!(global_trace.trace_flags & TRACE_ITER_PRINTK))
|
|
return 0;
|
|
|
|
va_start(ap, fmt);
|
|
ret = __trace_array_vprintk(buffer, ip, fmt, ap);
|
|
va_end(ap);
|
|
return ret;
|
|
}
|
|
|
|
int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
|
|
{
|
|
return trace_array_vprintk(&global_trace, ip, fmt, args);
|
|
}
|
|
EXPORT_SYMBOL_GPL(trace_vprintk);
|
|
|
|
static void trace_iterator_increment(struct trace_iterator *iter)
|
|
{
|
|
struct ring_buffer_iter *buf_iter = trace_buffer_iter(iter, iter->cpu);
|
|
|
|
iter->idx++;
|
|
if (buf_iter)
|
|
ring_buffer_read(buf_iter, NULL);
|
|
}
|
|
|
|
static struct trace_entry *
|
|
peek_next_entry(struct trace_iterator *iter, int cpu, u64 *ts,
|
|
unsigned long *lost_events)
|
|
{
|
|
struct ring_buffer_event *event;
|
|
struct ring_buffer_iter *buf_iter = trace_buffer_iter(iter, cpu);
|
|
|
|
if (buf_iter)
|
|
event = ring_buffer_iter_peek(buf_iter, ts);
|
|
else
|
|
event = ring_buffer_peek(iter->trace_buffer->buffer, cpu, ts,
|
|
lost_events);
|
|
|
|
if (event) {
|
|
iter->ent_size = ring_buffer_event_length(event);
|
|
return ring_buffer_event_data(event);
|
|
}
|
|
iter->ent_size = 0;
|
|
return NULL;
|
|
}
|
|
|
|
static struct trace_entry *
|
|
__find_next_entry(struct trace_iterator *iter, int *ent_cpu,
|
|
unsigned long *missing_events, u64 *ent_ts)
|
|
{
|
|
struct ring_buffer *buffer = iter->trace_buffer->buffer;
|
|
struct trace_entry *ent, *next = NULL;
|
|
unsigned long lost_events = 0, next_lost = 0;
|
|
int cpu_file = iter->cpu_file;
|
|
u64 next_ts = 0, ts;
|
|
int next_cpu = -1;
|
|
int next_size = 0;
|
|
int cpu;
|
|
|
|
/*
|
|
* If we are in a per_cpu trace file, don't bother by iterating over
|
|
* all cpu and peek directly.
|
|
*/
|
|
if (cpu_file > RING_BUFFER_ALL_CPUS) {
|
|
if (ring_buffer_empty_cpu(buffer, cpu_file))
|
|
return NULL;
|
|
ent = peek_next_entry(iter, cpu_file, ent_ts, missing_events);
|
|
if (ent_cpu)
|
|
*ent_cpu = cpu_file;
|
|
|
|
return ent;
|
|
}
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
|
|
if (ring_buffer_empty_cpu(buffer, cpu))
|
|
continue;
|
|
|
|
ent = peek_next_entry(iter, cpu, &ts, &lost_events);
|
|
|
|
/*
|
|
* Pick the entry with the smallest timestamp:
|
|
*/
|
|
if (ent && (!next || ts < next_ts)) {
|
|
next = ent;
|
|
next_cpu = cpu;
|
|
next_ts = ts;
|
|
next_lost = lost_events;
|
|
next_size = iter->ent_size;
|
|
}
|
|
}
|
|
|
|
iter->ent_size = next_size;
|
|
|
|
if (ent_cpu)
|
|
*ent_cpu = next_cpu;
|
|
|
|
if (ent_ts)
|
|
*ent_ts = next_ts;
|
|
|
|
if (missing_events)
|
|
*missing_events = next_lost;
|
|
|
|
return next;
|
|
}
|
|
|
|
/* Find the next real entry, without updating the iterator itself */
|
|
struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
|
|
int *ent_cpu, u64 *ent_ts)
|
|
{
|
|
return __find_next_entry(iter, ent_cpu, NULL, ent_ts);
|
|
}
|
|
|
|
/* Find the next real entry, and increment the iterator to the next entry */
|
|
void *trace_find_next_entry_inc(struct trace_iterator *iter)
|
|
{
|
|
iter->ent = __find_next_entry(iter, &iter->cpu,
|
|
&iter->lost_events, &iter->ts);
|
|
|
|
if (iter->ent)
|
|
trace_iterator_increment(iter);
|
|
|
|
return iter->ent ? iter : NULL;
|
|
}
|
|
|
|
static void trace_consume(struct trace_iterator *iter)
|
|
{
|
|
ring_buffer_consume(iter->trace_buffer->buffer, iter->cpu, &iter->ts,
|
|
&iter->lost_events);
|
|
}
|
|
|
|
static void *s_next(struct seq_file *m, void *v, loff_t *pos)
|
|
{
|
|
struct trace_iterator *iter = m->private;
|
|
int i = (int)*pos;
|
|
void *ent;
|
|
|
|
WARN_ON_ONCE(iter->leftover);
|
|
|
|
(*pos)++;
|
|
|
|
/* can't go backwards */
|
|
if (iter->idx > i)
|
|
return NULL;
|
|
|
|
if (iter->idx < 0)
|
|
ent = trace_find_next_entry_inc(iter);
|
|
else
|
|
ent = iter;
|
|
|
|
while (ent && iter->idx < i)
|
|
ent = trace_find_next_entry_inc(iter);
|
|
|
|
iter->pos = *pos;
|
|
|
|
return ent;
|
|
}
|
|
|
|
void tracing_iter_reset(struct trace_iterator *iter, int cpu)
|
|
{
|
|
struct ring_buffer_event *event;
|
|
struct ring_buffer_iter *buf_iter;
|
|
unsigned long entries = 0;
|
|
u64 ts;
|
|
|
|
per_cpu_ptr(iter->trace_buffer->data, cpu)->skipped_entries = 0;
|
|
|
|
buf_iter = trace_buffer_iter(iter, cpu);
|
|
if (!buf_iter)
|
|
return;
|
|
|
|
ring_buffer_iter_reset(buf_iter);
|
|
|
|
/*
|
|
* We could have the case with the max latency tracers
|
|
* that a reset never took place on a cpu. This is evident
|
|
* by the timestamp being before the start of the buffer.
|
|
*/
|
|
while ((event = ring_buffer_iter_peek(buf_iter, &ts))) {
|
|
if (ts >= iter->trace_buffer->time_start)
|
|
break;
|
|
entries++;
|
|
ring_buffer_read(buf_iter, NULL);
|
|
}
|
|
|
|
per_cpu_ptr(iter->trace_buffer->data, cpu)->skipped_entries = entries;
|
|
}
|
|
|
|
/*
|
|
* The current tracer is copied to avoid a global locking
|
|
* all around.
|
|
*/
|
|
static void *s_start(struct seq_file *m, loff_t *pos)
|
|
{
|
|
struct trace_iterator *iter = m->private;
|
|
struct trace_array *tr = iter->tr;
|
|
int cpu_file = iter->cpu_file;
|
|
void *p = NULL;
|
|
loff_t l = 0;
|
|
int cpu;
|
|
|
|
/*
|
|
* copy the tracer to avoid using a global lock all around.
|
|
* iter->trace is a copy of current_trace, the pointer to the
|
|
* name may be used instead of a strcmp(), as iter->trace->name
|
|
* will point to the same string as current_trace->name.
|
|
*/
|
|
mutex_lock(&trace_types_lock);
|
|
if (unlikely(tr->current_trace && iter->trace->name != tr->current_trace->name))
|
|
*iter->trace = *tr->current_trace;
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (iter->snapshot && iter->trace->use_max_tr)
|
|
return ERR_PTR(-EBUSY);
|
|
#endif
|
|
|
|
if (!iter->snapshot)
|
|
atomic_inc(&trace_record_cmdline_disabled);
|
|
|
|
if (*pos != iter->pos) {
|
|
iter->ent = NULL;
|
|
iter->cpu = 0;
|
|
iter->idx = -1;
|
|
|
|
if (cpu_file == RING_BUFFER_ALL_CPUS) {
|
|
for_each_tracing_cpu(cpu)
|
|
tracing_iter_reset(iter, cpu);
|
|
} else
|
|
tracing_iter_reset(iter, cpu_file);
|
|
|
|
iter->leftover = 0;
|
|
for (p = iter; p && l < *pos; p = s_next(m, p, &l))
|
|
;
|
|
|
|
} else {
|
|
/*
|
|
* If we overflowed the seq_file before, then we want
|
|
* to just reuse the trace_seq buffer again.
|
|
*/
|
|
if (iter->leftover)
|
|
p = iter;
|
|
else {
|
|
l = *pos - 1;
|
|
p = s_next(m, p, &l);
|
|
}
|
|
}
|
|
|
|
trace_event_read_lock();
|
|
trace_access_lock(cpu_file);
|
|
return p;
|
|
}
|
|
|
|
static void s_stop(struct seq_file *m, void *p)
|
|
{
|
|
struct trace_iterator *iter = m->private;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (iter->snapshot && iter->trace->use_max_tr)
|
|
return;
|
|
#endif
|
|
|
|
if (!iter->snapshot)
|
|
atomic_dec(&trace_record_cmdline_disabled);
|
|
|
|
trace_access_unlock(iter->cpu_file);
|
|
trace_event_read_unlock();
|
|
}
|
|
|
|
static void
|
|
get_total_entries(struct trace_buffer *buf,
|
|
unsigned long *total, unsigned long *entries)
|
|
{
|
|
unsigned long count;
|
|
int cpu;
|
|
|
|
*total = 0;
|
|
*entries = 0;
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
count = ring_buffer_entries_cpu(buf->buffer, cpu);
|
|
/*
|
|
* If this buffer has skipped entries, then we hold all
|
|
* entries for the trace and we need to ignore the
|
|
* ones before the time stamp.
|
|
*/
|
|
if (per_cpu_ptr(buf->data, cpu)->skipped_entries) {
|
|
count -= per_cpu_ptr(buf->data, cpu)->skipped_entries;
|
|
/* total is the same as the entries */
|
|
*total += count;
|
|
} else
|
|
*total += count +
|
|
ring_buffer_overrun_cpu(buf->buffer, cpu);
|
|
*entries += count;
|
|
}
|
|
}
|
|
|
|
static void print_lat_help_header(struct seq_file *m)
|
|
{
|
|
seq_puts(m, "# _------=> CPU# \n"
|
|
"# / _-----=> irqs-off \n"
|
|
"# | / _----=> need-resched \n"
|
|
"# || / _---=> hardirq/softirq \n"
|
|
"# ||| / _--=> preempt-depth \n"
|
|
"# |||| / delay \n"
|
|
"# cmd pid ||||| time | caller \n"
|
|
"# \\ / ||||| \\ | / \n");
|
|
}
|
|
|
|
static void print_event_info(struct trace_buffer *buf, struct seq_file *m)
|
|
{
|
|
unsigned long total;
|
|
unsigned long entries;
|
|
|
|
get_total_entries(buf, &total, &entries);
|
|
seq_printf(m, "# entries-in-buffer/entries-written: %lu/%lu #P:%d\n",
|
|
entries, total, num_online_cpus());
|
|
seq_puts(m, "#\n");
|
|
}
|
|
|
|
static void print_func_help_header(struct trace_buffer *buf, struct seq_file *m)
|
|
{
|
|
print_event_info(buf, m);
|
|
seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n"
|
|
"# | | | | |\n");
|
|
}
|
|
|
|
static void print_func_help_header_tgid(struct trace_buffer *buf, struct seq_file *m)
|
|
{
|
|
print_event_info(buf, m);
|
|
seq_puts(m, "# TASK-PID TGID CPU# TIMESTAMP FUNCTION\n");
|
|
seq_puts(m, "# | | | | | |\n");
|
|
}
|
|
|
|
static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m)
|
|
{
|
|
print_event_info(buf, m);
|
|
seq_puts(m, "# _-----=> irqs-off\n"
|
|
"# / _----=> need-resched\n"
|
|
"# | / _---=> hardirq/softirq\n"
|
|
"# || / _--=> preempt-depth\n"
|
|
"# ||| / delay\n"
|
|
"# TASK-PID CPU# |||| TIMESTAMP FUNCTION\n"
|
|
"# | | | |||| | |\n");
|
|
}
|
|
|
|
static void print_func_help_header_irq_tgid(struct trace_buffer *buf, struct seq_file *m)
|
|
{
|
|
print_event_info(buf, m);
|
|
seq_puts(m, "# _-----=> irqs-off\n");
|
|
seq_puts(m, "# / _----=> need-resched\n");
|
|
seq_puts(m, "# | / _---=> hardirq/softirq\n");
|
|
seq_puts(m, "# || / _--=> preempt-depth\n");
|
|
seq_puts(m, "# ||| / delay\n");
|
|
seq_puts(m, "# TASK-PID TGID CPU# |||| TIMESTAMP FUNCTION\n");
|
|
seq_puts(m, "# | | | | |||| | |\n");
|
|
}
|
|
|
|
void
|
|
print_trace_header(struct seq_file *m, struct trace_iterator *iter)
|
|
{
|
|
unsigned long sym_flags = (global_trace.trace_flags & TRACE_ITER_SYM_MASK);
|
|
struct trace_buffer *buf = iter->trace_buffer;
|
|
struct trace_array_cpu *data = per_cpu_ptr(buf->data, buf->cpu);
|
|
struct tracer *type = iter->trace;
|
|
unsigned long entries;
|
|
unsigned long total;
|
|
const char *name = "preemption";
|
|
|
|
name = type->name;
|
|
|
|
get_total_entries(buf, &total, &entries);
|
|
|
|
seq_printf(m, "# %s latency trace v1.1.5 on %s\n",
|
|
name, UTS_RELEASE);
|
|
seq_puts(m, "# -----------------------------------"
|
|
"---------------------------------\n");
|
|
seq_printf(m, "# latency: %lu us, #%lu/%lu, CPU#%d |"
|
|
" (M:%s VP:%d, KP:%d, SP:%d HP:%d",
|
|
nsecs_to_usecs(data->saved_latency),
|
|
entries,
|
|
total,
|
|
buf->cpu,
|
|
#if defined(CONFIG_PREEMPT_NONE)
|
|
"server",
|
|
#elif defined(CONFIG_PREEMPT_VOLUNTARY)
|
|
"desktop",
|
|
#elif defined(CONFIG_PREEMPT)
|
|
"preempt",
|
|
#else
|
|
"unknown",
|
|
#endif
|
|
/* These are reserved for later use */
|
|
0, 0, 0, 0);
|
|
#ifdef CONFIG_SMP
|
|
seq_printf(m, " #P:%d)\n", num_online_cpus());
|
|
#else
|
|
seq_puts(m, ")\n");
|
|
#endif
|
|
seq_puts(m, "# -----------------\n");
|
|
seq_printf(m, "# | task: %.16s-%d "
|
|
"(uid:%d nice:%ld policy:%ld rt_prio:%ld)\n",
|
|
data->comm, data->pid,
|
|
from_kuid_munged(seq_user_ns(m), data->uid), data->nice,
|
|
data->policy, data->rt_priority);
|
|
seq_puts(m, "# -----------------\n");
|
|
|
|
if (data->critical_start) {
|
|
seq_puts(m, "# => started at: ");
|
|
seq_print_ip_sym(&iter->seq, data->critical_start, sym_flags);
|
|
trace_print_seq(m, &iter->seq);
|
|
seq_puts(m, "\n# => ended at: ");
|
|
seq_print_ip_sym(&iter->seq, data->critical_end, sym_flags);
|
|
trace_print_seq(m, &iter->seq);
|
|
seq_puts(m, "\n#\n");
|
|
}
|
|
|
|
seq_puts(m, "#\n");
|
|
}
|
|
|
|
static void test_cpu_buff_start(struct trace_iterator *iter)
|
|
{
|
|
struct trace_seq *s = &iter->seq;
|
|
struct trace_array *tr = iter->tr;
|
|
|
|
if (!(tr->trace_flags & TRACE_ITER_ANNOTATE))
|
|
return;
|
|
|
|
if (!(iter->iter_flags & TRACE_FILE_ANNOTATE))
|
|
return;
|
|
|
|
if (iter->started && cpumask_test_cpu(iter->cpu, iter->started))
|
|
return;
|
|
|
|
if (per_cpu_ptr(iter->trace_buffer->data, iter->cpu)->skipped_entries)
|
|
return;
|
|
|
|
if (iter->started)
|
|
cpumask_set_cpu(iter->cpu, iter->started);
|
|
|
|
/* Don't print started cpu buffer for the first entry of the trace */
|
|
if (iter->idx > 1)
|
|
trace_seq_printf(s, "##### CPU %u buffer started ####\n",
|
|
iter->cpu);
|
|
}
|
|
|
|
static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
|
|
{
|
|
struct trace_array *tr = iter->tr;
|
|
struct trace_seq *s = &iter->seq;
|
|
unsigned long sym_flags = (tr->trace_flags & TRACE_ITER_SYM_MASK);
|
|
struct trace_entry *entry;
|
|
struct trace_event *event;
|
|
|
|
entry = iter->ent;
|
|
|
|
test_cpu_buff_start(iter);
|
|
|
|
event = ftrace_find_event(entry->type);
|
|
|
|
if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) {
|
|
if (iter->iter_flags & TRACE_FILE_LAT_FMT)
|
|
trace_print_lat_context(iter);
|
|
else
|
|
trace_print_context(iter);
|
|
}
|
|
|
|
if (trace_seq_has_overflowed(s))
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
if (event)
|
|
return event->funcs->trace(iter, sym_flags, event);
|
|
|
|
trace_seq_printf(s, "Unknown type %d\n", entry->type);
|
|
|
|
return trace_handle_return(s);
|
|
}
|
|
|
|
static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
|
|
{
|
|
struct trace_array *tr = iter->tr;
|
|
struct trace_seq *s = &iter->seq;
|
|
struct trace_entry *entry;
|
|
struct trace_event *event;
|
|
|
|
entry = iter->ent;
|
|
|
|
if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO)
|
|
trace_seq_printf(s, "%d %d %llu ",
|
|
entry->pid, iter->cpu, iter->ts);
|
|
|
|
if (trace_seq_has_overflowed(s))
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
|
|
event = ftrace_find_event(entry->type);
|
|
if (event)
|
|
return event->funcs->raw(iter, 0, event);
|
|
|
|
trace_seq_printf(s, "%d ?\n", entry->type);
|
|
|
|
return trace_handle_return(s);
|
|
}
|
|
|
|
static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
|
|
{
|
|
struct trace_array *tr = iter->tr;
|
|
struct trace_seq *s = &iter->seq;
|
|
unsigned char newline = '\n';
|
|
struct trace_entry *entry;
|
|
struct trace_event *event;
|
|
|
|
entry = iter->ent;
|
|
|
|
if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) {
|
|
SEQ_PUT_HEX_FIELD(s, entry->pid);
|
|
SEQ_PUT_HEX_FIELD(s, iter->cpu);
|
|
SEQ_PUT_HEX_FIELD(s, iter->ts);
|
|
if (trace_seq_has_overflowed(s))
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
}
|
|
|
|
event = ftrace_find_event(entry->type);
|
|
if (event) {
|
|
enum print_line_t ret = event->funcs->hex(iter, 0, event);
|
|
if (ret != TRACE_TYPE_HANDLED)
|
|
return ret;
|
|
}
|
|
|
|
SEQ_PUT_FIELD(s, newline);
|
|
|
|
return trace_handle_return(s);
|
|
}
|
|
|
|
static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
|
|
{
|
|
struct trace_array *tr = iter->tr;
|
|
struct trace_seq *s = &iter->seq;
|
|
struct trace_entry *entry;
|
|
struct trace_event *event;
|
|
|
|
entry = iter->ent;
|
|
|
|
if (tr->trace_flags & TRACE_ITER_CONTEXT_INFO) {
|
|
SEQ_PUT_FIELD(s, entry->pid);
|
|
SEQ_PUT_FIELD(s, iter->cpu);
|
|
SEQ_PUT_FIELD(s, iter->ts);
|
|
if (trace_seq_has_overflowed(s))
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
}
|
|
|
|
event = ftrace_find_event(entry->type);
|
|
return event ? event->funcs->binary(iter, 0, event) :
|
|
TRACE_TYPE_HANDLED;
|
|
}
|
|
|
|
int trace_empty(struct trace_iterator *iter)
|
|
{
|
|
struct ring_buffer_iter *buf_iter;
|
|
int cpu;
|
|
|
|
/* If we are looking at one CPU buffer, only check that one */
|
|
if (iter->cpu_file != RING_BUFFER_ALL_CPUS) {
|
|
cpu = iter->cpu_file;
|
|
buf_iter = trace_buffer_iter(iter, cpu);
|
|
if (buf_iter) {
|
|
if (!ring_buffer_iter_empty(buf_iter))
|
|
return 0;
|
|
} else {
|
|
if (!ring_buffer_empty_cpu(iter->trace_buffer->buffer, cpu))
|
|
return 0;
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
buf_iter = trace_buffer_iter(iter, cpu);
|
|
if (buf_iter) {
|
|
if (!ring_buffer_iter_empty(buf_iter))
|
|
return 0;
|
|
} else {
|
|
if (!ring_buffer_empty_cpu(iter->trace_buffer->buffer, cpu))
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
/* Called with trace_event_read_lock() held. */
|
|
enum print_line_t print_trace_line(struct trace_iterator *iter)
|
|
{
|
|
struct trace_array *tr = iter->tr;
|
|
unsigned long trace_flags = tr->trace_flags;
|
|
enum print_line_t ret;
|
|
|
|
if (iter->lost_events) {
|
|
trace_seq_printf(&iter->seq, "CPU:%d [LOST %lu EVENTS]\n",
|
|
iter->cpu, iter->lost_events);
|
|
if (trace_seq_has_overflowed(&iter->seq))
|
|
return TRACE_TYPE_PARTIAL_LINE;
|
|
}
|
|
|
|
if (iter->trace && iter->trace->print_line) {
|
|
ret = iter->trace->print_line(iter);
|
|
if (ret != TRACE_TYPE_UNHANDLED)
|
|
return ret;
|
|
}
|
|
|
|
if (iter->ent->type == TRACE_BPUTS &&
|
|
trace_flags & TRACE_ITER_PRINTK &&
|
|
trace_flags & TRACE_ITER_PRINTK_MSGONLY)
|
|
return trace_print_bputs_msg_only(iter);
|
|
|
|
if (iter->ent->type == TRACE_BPRINT &&
|
|
trace_flags & TRACE_ITER_PRINTK &&
|
|
trace_flags & TRACE_ITER_PRINTK_MSGONLY)
|
|
return trace_print_bprintk_msg_only(iter);
|
|
|
|
if (iter->ent->type == TRACE_PRINT &&
|
|
trace_flags & TRACE_ITER_PRINTK &&
|
|
trace_flags & TRACE_ITER_PRINTK_MSGONLY)
|
|
return trace_print_printk_msg_only(iter);
|
|
|
|
if (trace_flags & TRACE_ITER_BIN)
|
|
return print_bin_fmt(iter);
|
|
|
|
if (trace_flags & TRACE_ITER_HEX)
|
|
return print_hex_fmt(iter);
|
|
|
|
if (trace_flags & TRACE_ITER_RAW)
|
|
return print_raw_fmt(iter);
|
|
|
|
return print_trace_fmt(iter);
|
|
}
|
|
|
|
void trace_latency_header(struct seq_file *m)
|
|
{
|
|
struct trace_iterator *iter = m->private;
|
|
struct trace_array *tr = iter->tr;
|
|
|
|
/* print nothing if the buffers are empty */
|
|
if (trace_empty(iter))
|
|
return;
|
|
|
|
if (iter->iter_flags & TRACE_FILE_LAT_FMT)
|
|
print_trace_header(m, iter);
|
|
|
|
if (!(tr->trace_flags & TRACE_ITER_VERBOSE))
|
|
print_lat_help_header(m);
|
|
}
|
|
|
|
void trace_default_header(struct seq_file *m)
|
|
{
|
|
struct trace_iterator *iter = m->private;
|
|
struct trace_array *tr = iter->tr;
|
|
unsigned long trace_flags = tr->trace_flags;
|
|
|
|
if (!(trace_flags & TRACE_ITER_CONTEXT_INFO))
|
|
return;
|
|
|
|
if (iter->iter_flags & TRACE_FILE_LAT_FMT) {
|
|
/* print nothing if the buffers are empty */
|
|
if (trace_empty(iter))
|
|
return;
|
|
print_trace_header(m, iter);
|
|
if (!(trace_flags & TRACE_ITER_VERBOSE))
|
|
print_lat_help_header(m);
|
|
} else {
|
|
if (!(trace_flags & TRACE_ITER_VERBOSE)) {
|
|
if (trace_flags & TRACE_ITER_IRQ_INFO)
|
|
if (trace_flags & TRACE_ITER_TGID)
|
|
print_func_help_header_irq_tgid(iter->trace_buffer, m);
|
|
else
|
|
print_func_help_header_irq(iter->trace_buffer, m);
|
|
else
|
|
if (trace_flags & TRACE_ITER_TGID)
|
|
print_func_help_header_tgid(iter->trace_buffer, m);
|
|
else
|
|
print_func_help_header(iter->trace_buffer, m);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void test_ftrace_alive(struct seq_file *m)
|
|
{
|
|
if (!ftrace_is_dead())
|
|
return;
|
|
seq_puts(m, "# WARNING: FUNCTION TRACING IS CORRUPTED\n"
|
|
"# MAY BE MISSING FUNCTION EVENTS\n");
|
|
}
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
static void show_snapshot_main_help(struct seq_file *m)
|
|
{
|
|
seq_puts(m, "# echo 0 > snapshot : Clears and frees snapshot buffer\n"
|
|
"# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n"
|
|
"# Takes a snapshot of the main buffer.\n"
|
|
"# echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)\n"
|
|
"# (Doesn't have to be '2' works with any number that\n"
|
|
"# is not a '0' or '1')\n");
|
|
}
|
|
|
|
static void show_snapshot_percpu_help(struct seq_file *m)
|
|
{
|
|
seq_puts(m, "# echo 0 > snapshot : Invalid for per_cpu snapshot file.\n");
|
|
#ifdef CONFIG_RING_BUFFER_ALLOW_SWAP
|
|
seq_puts(m, "# echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.\n"
|
|
"# Takes a snapshot of the main buffer for this cpu.\n");
|
|
#else
|
|
seq_puts(m, "# echo 1 > snapshot : Not supported with this kernel.\n"
|
|
"# Must use main snapshot file to allocate.\n");
|
|
#endif
|
|
seq_puts(m, "# echo 2 > snapshot : Clears this cpu's snapshot buffer (but does not allocate)\n"
|
|
"# (Doesn't have to be '2' works with any number that\n"
|
|
"# is not a '0' or '1')\n");
|
|
}
|
|
|
|
static void print_snapshot_help(struct seq_file *m, struct trace_iterator *iter)
|
|
{
|
|
if (iter->tr->allocated_snapshot)
|
|
seq_puts(m, "#\n# * Snapshot is allocated *\n#\n");
|
|
else
|
|
seq_puts(m, "#\n# * Snapshot is freed *\n#\n");
|
|
|
|
seq_puts(m, "# Snapshot commands:\n");
|
|
if (iter->cpu_file == RING_BUFFER_ALL_CPUS)
|
|
show_snapshot_main_help(m);
|
|
else
|
|
show_snapshot_percpu_help(m);
|
|
}
|
|
#else
|
|
/* Should never be called */
|
|
static inline void print_snapshot_help(struct seq_file *m, struct trace_iterator *iter) { }
|
|
#endif
|
|
|
|
static int s_show(struct seq_file *m, void *v)
|
|
{
|
|
struct trace_iterator *iter = v;
|
|
int ret;
|
|
|
|
if (iter->ent == NULL) {
|
|
if (iter->tr) {
|
|
seq_printf(m, "# tracer: %s\n", iter->trace->name);
|
|
seq_puts(m, "#\n");
|
|
test_ftrace_alive(m);
|
|
}
|
|
if (iter->snapshot && trace_empty(iter))
|
|
print_snapshot_help(m, iter);
|
|
else if (iter->trace && iter->trace->print_header)
|
|
iter->trace->print_header(m);
|
|
else
|
|
trace_default_header(m);
|
|
|
|
} else if (iter->leftover) {
|
|
/*
|
|
* If we filled the seq_file buffer earlier, we
|
|
* want to just show it now.
|
|
*/
|
|
ret = trace_print_seq(m, &iter->seq);
|
|
|
|
/* ret should this time be zero, but you never know */
|
|
iter->leftover = ret;
|
|
|
|
} else {
|
|
print_trace_line(iter);
|
|
ret = trace_print_seq(m, &iter->seq);
|
|
/*
|
|
* If we overflow the seq_file buffer, then it will
|
|
* ask us for this data again at start up.
|
|
* Use that instead.
|
|
* ret is 0 if seq_file write succeeded.
|
|
* -1 otherwise.
|
|
*/
|
|
iter->leftover = ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Should be used after trace_array_get(), trace_types_lock
|
|
* ensures that i_cdev was already initialized.
|
|
*/
|
|
static inline int tracing_get_cpu(struct inode *inode)
|
|
{
|
|
if (inode->i_cdev) /* See trace_create_cpu_file() */
|
|
return (long)inode->i_cdev - 1;
|
|
return RING_BUFFER_ALL_CPUS;
|
|
}
|
|
|
|
static const struct seq_operations tracer_seq_ops = {
|
|
.start = s_start,
|
|
.next = s_next,
|
|
.stop = s_stop,
|
|
.show = s_show,
|
|
};
|
|
|
|
static struct trace_iterator *
|
|
__tracing_open(struct inode *inode, struct file *file, bool snapshot)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
struct trace_iterator *iter;
|
|
int cpu;
|
|
|
|
if (tracing_disabled)
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
iter = __seq_open_private(file, &tracer_seq_ops, sizeof(*iter));
|
|
if (!iter)
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
iter->buffer_iter = kcalloc(nr_cpu_ids, sizeof(*iter->buffer_iter),
|
|
GFP_KERNEL);
|
|
if (!iter->buffer_iter)
|
|
goto release;
|
|
|
|
/*
|
|
* We make a copy of the current tracer to avoid concurrent
|
|
* changes on it while we are reading.
|
|
*/
|
|
mutex_lock(&trace_types_lock);
|
|
iter->trace = kzalloc(sizeof(*iter->trace), GFP_KERNEL);
|
|
if (!iter->trace)
|
|
goto fail;
|
|
|
|
*iter->trace = *tr->current_trace;
|
|
|
|
if (!zalloc_cpumask_var(&iter->started, GFP_KERNEL))
|
|
goto fail;
|
|
|
|
iter->tr = tr;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
/* Currently only the top directory has a snapshot */
|
|
if (tr->current_trace->print_max || snapshot)
|
|
iter->trace_buffer = &tr->max_buffer;
|
|
else
|
|
#endif
|
|
iter->trace_buffer = &tr->trace_buffer;
|
|
iter->snapshot = snapshot;
|
|
iter->pos = -1;
|
|
iter->cpu_file = tracing_get_cpu(inode);
|
|
mutex_init(&iter->mutex);
|
|
|
|
/* Notify the tracer early; before we stop tracing. */
|
|
if (iter->trace && iter->trace->open)
|
|
iter->trace->open(iter);
|
|
|
|
/* Annotate start of buffers if we had overruns */
|
|
if (ring_buffer_overruns(iter->trace_buffer->buffer))
|
|
iter->iter_flags |= TRACE_FILE_ANNOTATE;
|
|
|
|
/* Output in nanoseconds only if we are using a clock in nanoseconds. */
|
|
if (trace_clocks[tr->clock_id].in_ns)
|
|
iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
|
|
|
|
/* stop the trace while dumping if we are not opening "snapshot" */
|
|
if (!iter->snapshot)
|
|
tracing_stop_tr(tr);
|
|
|
|
if (iter->cpu_file == RING_BUFFER_ALL_CPUS) {
|
|
for_each_tracing_cpu(cpu) {
|
|
iter->buffer_iter[cpu] =
|
|
ring_buffer_read_prepare(iter->trace_buffer->buffer, cpu);
|
|
}
|
|
ring_buffer_read_prepare_sync();
|
|
for_each_tracing_cpu(cpu) {
|
|
ring_buffer_read_start(iter->buffer_iter[cpu]);
|
|
tracing_iter_reset(iter, cpu);
|
|
}
|
|
} else {
|
|
cpu = iter->cpu_file;
|
|
iter->buffer_iter[cpu] =
|
|
ring_buffer_read_prepare(iter->trace_buffer->buffer, cpu);
|
|
ring_buffer_read_prepare_sync();
|
|
ring_buffer_read_start(iter->buffer_iter[cpu]);
|
|
tracing_iter_reset(iter, cpu);
|
|
}
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return iter;
|
|
|
|
fail:
|
|
mutex_unlock(&trace_types_lock);
|
|
kfree(iter->trace);
|
|
kfree(iter->buffer_iter);
|
|
release:
|
|
seq_release_private(inode, file);
|
|
return ERR_PTR(-ENOMEM);
|
|
}
|
|
|
|
int tracing_open_generic(struct inode *inode, struct file *filp)
|
|
{
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
filp->private_data = inode->i_private;
|
|
return 0;
|
|
}
|
|
|
|
bool tracing_is_disabled(void)
|
|
{
|
|
return (tracing_disabled) ? true: false;
|
|
}
|
|
|
|
/*
|
|
* Open and update trace_array ref count.
|
|
* Must have the current trace_array passed to it.
|
|
*/
|
|
static int tracing_open_generic_tr(struct inode *inode, struct file *filp)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
if (trace_array_get(tr) < 0)
|
|
return -ENODEV;
|
|
|
|
filp->private_data = inode->i_private;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int tracing_release(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
struct seq_file *m = file->private_data;
|
|
struct trace_iterator *iter;
|
|
int cpu;
|
|
|
|
if (!(file->f_mode & FMODE_READ)) {
|
|
trace_array_put(tr);
|
|
return 0;
|
|
}
|
|
|
|
/* Writes do not use seq_file */
|
|
iter = m->private;
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
if (iter->buffer_iter[cpu])
|
|
ring_buffer_read_finish(iter->buffer_iter[cpu]);
|
|
}
|
|
|
|
if (iter->trace && iter->trace->close)
|
|
iter->trace->close(iter);
|
|
|
|
if (!iter->snapshot)
|
|
/* reenable tracing if it was previously enabled */
|
|
tracing_start_tr(tr);
|
|
|
|
__trace_array_put(tr);
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
mutex_destroy(&iter->mutex);
|
|
free_cpumask_var(iter->started);
|
|
kfree(iter->trace);
|
|
kfree(iter->buffer_iter);
|
|
seq_release_private(inode, file);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int tracing_release_generic_tr(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
|
|
trace_array_put(tr);
|
|
return 0;
|
|
}
|
|
|
|
static int tracing_single_release_tr(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
|
|
trace_array_put(tr);
|
|
|
|
return single_release(inode, file);
|
|
}
|
|
|
|
static int tracing_open(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
struct trace_iterator *iter;
|
|
int ret = 0;
|
|
|
|
if (trace_array_get(tr) < 0)
|
|
return -ENODEV;
|
|
|
|
/* If this file was open for write, then erase contents */
|
|
if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) {
|
|
int cpu = tracing_get_cpu(inode);
|
|
|
|
if (cpu == RING_BUFFER_ALL_CPUS)
|
|
tracing_reset_online_cpus(&tr->trace_buffer);
|
|
else
|
|
tracing_reset(&tr->trace_buffer, cpu);
|
|
}
|
|
|
|
if (file->f_mode & FMODE_READ) {
|
|
iter = __tracing_open(inode, file, false);
|
|
if (IS_ERR(iter))
|
|
ret = PTR_ERR(iter);
|
|
else if (tr->trace_flags & TRACE_ITER_LATENCY_FMT)
|
|
iter->iter_flags |= TRACE_FILE_LAT_FMT;
|
|
}
|
|
|
|
if (ret < 0)
|
|
trace_array_put(tr);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Some tracers are not suitable for instance buffers.
|
|
* A tracer is always available for the global array (toplevel)
|
|
* or if it explicitly states that it is.
|
|
*/
|
|
static bool
|
|
trace_ok_for_array(struct tracer *t, struct trace_array *tr)
|
|
{
|
|
return (tr->flags & TRACE_ARRAY_FL_GLOBAL) || t->allow_instances;
|
|
}
|
|
|
|
/* Find the next tracer that this trace array may use */
|
|
static struct tracer *
|
|
get_tracer_for_array(struct trace_array *tr, struct tracer *t)
|
|
{
|
|
while (t && !trace_ok_for_array(t, tr))
|
|
t = t->next;
|
|
|
|
return t;
|
|
}
|
|
|
|
static void *
|
|
t_next(struct seq_file *m, void *v, loff_t *pos)
|
|
{
|
|
struct trace_array *tr = m->private;
|
|
struct tracer *t = v;
|
|
|
|
(*pos)++;
|
|
|
|
if (t)
|
|
t = get_tracer_for_array(tr, t->next);
|
|
|
|
return t;
|
|
}
|
|
|
|
static void *t_start(struct seq_file *m, loff_t *pos)
|
|
{
|
|
struct trace_array *tr = m->private;
|
|
struct tracer *t;
|
|
loff_t l = 0;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
t = get_tracer_for_array(tr, trace_types);
|
|
for (; t && l < *pos; t = t_next(m, t, &l))
|
|
;
|
|
|
|
return t;
|
|
}
|
|
|
|
static void t_stop(struct seq_file *m, void *p)
|
|
{
|
|
mutex_unlock(&trace_types_lock);
|
|
}
|
|
|
|
static int t_show(struct seq_file *m, void *v)
|
|
{
|
|
struct tracer *t = v;
|
|
|
|
if (!t)
|
|
return 0;
|
|
|
|
seq_puts(m, t->name);
|
|
if (t->next)
|
|
seq_putc(m, ' ');
|
|
else
|
|
seq_putc(m, '\n');
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct seq_operations show_traces_seq_ops = {
|
|
.start = t_start,
|
|
.next = t_next,
|
|
.stop = t_stop,
|
|
.show = t_show,
|
|
};
|
|
|
|
static int show_traces_open(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
struct seq_file *m;
|
|
int ret;
|
|
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
ret = seq_open(file, &show_traces_seq_ops);
|
|
if (ret)
|
|
return ret;
|
|
|
|
m = file->private_data;
|
|
m->private = tr;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_write_stub(struct file *filp, const char __user *ubuf,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
return count;
|
|
}
|
|
|
|
loff_t tracing_lseek(struct file *file, loff_t offset, int whence)
|
|
{
|
|
int ret;
|
|
|
|
if (file->f_mode & FMODE_READ)
|
|
ret = seq_lseek(file, offset, whence);
|
|
else
|
|
file->f_pos = ret = 0;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static const struct file_operations tracing_fops = {
|
|
.open = tracing_open,
|
|
.read = seq_read,
|
|
.write = tracing_write_stub,
|
|
.llseek = tracing_lseek,
|
|
.release = tracing_release,
|
|
};
|
|
|
|
static const struct file_operations show_traces_fops = {
|
|
.open = show_traces_open,
|
|
.read = seq_read,
|
|
.release = seq_release,
|
|
.llseek = seq_lseek,
|
|
};
|
|
|
|
/*
|
|
* The tracer itself will not take this lock, but still we want
|
|
* to provide a consistent cpumask to user-space:
|
|
*/
|
|
static DEFINE_MUTEX(tracing_cpumask_update_lock);
|
|
|
|
/*
|
|
* Temporary storage for the character representation of the
|
|
* CPU bitmask (and one more byte for the newline):
|
|
*/
|
|
static char mask_str[NR_CPUS + 1];
|
|
|
|
static ssize_t
|
|
tracing_cpumask_read(struct file *filp, char __user *ubuf,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = file_inode(filp)->i_private;
|
|
int len;
|
|
|
|
mutex_lock(&tracing_cpumask_update_lock);
|
|
|
|
len = snprintf(mask_str, count, "%*pb\n",
|
|
cpumask_pr_args(tr->tracing_cpumask));
|
|
if (len >= count) {
|
|
count = -EINVAL;
|
|
goto out_err;
|
|
}
|
|
count = simple_read_from_buffer(ubuf, count, ppos, mask_str, NR_CPUS+1);
|
|
|
|
out_err:
|
|
mutex_unlock(&tracing_cpumask_update_lock);
|
|
|
|
return count;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_cpumask_write(struct file *filp, const char __user *ubuf,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = file_inode(filp)->i_private;
|
|
cpumask_var_t tracing_cpumask_new;
|
|
int err, cpu;
|
|
|
|
if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
|
|
return -ENOMEM;
|
|
|
|
err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
|
|
if (err)
|
|
goto err_unlock;
|
|
|
|
mutex_lock(&tracing_cpumask_update_lock);
|
|
|
|
local_irq_disable();
|
|
arch_spin_lock(&tr->max_lock);
|
|
for_each_tracing_cpu(cpu) {
|
|
/*
|
|
* Increase/decrease the disabled counter if we are
|
|
* about to flip a bit in the cpumask:
|
|
*/
|
|
if (cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
|
|
!cpumask_test_cpu(cpu, tracing_cpumask_new)) {
|
|
atomic_inc(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled);
|
|
ring_buffer_record_disable_cpu(tr->trace_buffer.buffer, cpu);
|
|
}
|
|
if (!cpumask_test_cpu(cpu, tr->tracing_cpumask) &&
|
|
cpumask_test_cpu(cpu, tracing_cpumask_new)) {
|
|
atomic_dec(&per_cpu_ptr(tr->trace_buffer.data, cpu)->disabled);
|
|
ring_buffer_record_enable_cpu(tr->trace_buffer.buffer, cpu);
|
|
}
|
|
}
|
|
arch_spin_unlock(&tr->max_lock);
|
|
local_irq_enable();
|
|
|
|
cpumask_copy(tr->tracing_cpumask, tracing_cpumask_new);
|
|
|
|
mutex_unlock(&tracing_cpumask_update_lock);
|
|
free_cpumask_var(tracing_cpumask_new);
|
|
|
|
return count;
|
|
|
|
err_unlock:
|
|
free_cpumask_var(tracing_cpumask_new);
|
|
|
|
return err;
|
|
}
|
|
|
|
static const struct file_operations tracing_cpumask_fops = {
|
|
.open = tracing_open_generic_tr,
|
|
.read = tracing_cpumask_read,
|
|
.write = tracing_cpumask_write,
|
|
.release = tracing_release_generic_tr,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
|
|
static int tracing_trace_options_show(struct seq_file *m, void *v)
|
|
{
|
|
struct tracer_opt *trace_opts;
|
|
struct trace_array *tr = m->private;
|
|
u32 tracer_flags;
|
|
int i;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
tracer_flags = tr->current_trace->flags->val;
|
|
trace_opts = tr->current_trace->flags->opts;
|
|
|
|
for (i = 0; trace_options[i]; i++) {
|
|
if (tr->trace_flags & (1 << i))
|
|
seq_printf(m, "%s\n", trace_options[i]);
|
|
else
|
|
seq_printf(m, "no%s\n", trace_options[i]);
|
|
}
|
|
|
|
for (i = 0; trace_opts[i].name; i++) {
|
|
if (tracer_flags & trace_opts[i].bit)
|
|
seq_printf(m, "%s\n", trace_opts[i].name);
|
|
else
|
|
seq_printf(m, "no%s\n", trace_opts[i].name);
|
|
}
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int __set_tracer_option(struct trace_array *tr,
|
|
struct tracer_flags *tracer_flags,
|
|
struct tracer_opt *opts, int neg)
|
|
{
|
|
struct tracer *trace = tracer_flags->trace;
|
|
int ret;
|
|
|
|
ret = trace->set_flag(tr, tracer_flags->val, opts->bit, !neg);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (neg)
|
|
tracer_flags->val &= ~opts->bit;
|
|
else
|
|
tracer_flags->val |= opts->bit;
|
|
return 0;
|
|
}
|
|
|
|
/* Try to assign a tracer specific option */
|
|
static int set_tracer_option(struct trace_array *tr, char *cmp, int neg)
|
|
{
|
|
struct tracer *trace = tr->current_trace;
|
|
struct tracer_flags *tracer_flags = trace->flags;
|
|
struct tracer_opt *opts = NULL;
|
|
int i;
|
|
|
|
for (i = 0; tracer_flags->opts[i].name; i++) {
|
|
opts = &tracer_flags->opts[i];
|
|
|
|
if (strcmp(cmp, opts->name) == 0)
|
|
return __set_tracer_option(tr, trace->flags, opts, neg);
|
|
}
|
|
|
|
return -EINVAL;
|
|
}
|
|
|
|
/* Some tracers require overwrite to stay enabled */
|
|
int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
|
|
{
|
|
if (tracer->enabled && (mask & TRACE_ITER_OVERWRITE) && !set)
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
|
|
{
|
|
/* do nothing if flag is already set */
|
|
if (!!(tr->trace_flags & mask) == !!enabled)
|
|
return 0;
|
|
|
|
/* Give the tracer a chance to approve the change */
|
|
if (tr->current_trace->flag_changed)
|
|
if (tr->current_trace->flag_changed(tr, mask, !!enabled))
|
|
return -EINVAL;
|
|
|
|
if (enabled)
|
|
tr->trace_flags |= mask;
|
|
else
|
|
tr->trace_flags &= ~mask;
|
|
|
|
if (mask == TRACE_ITER_RECORD_CMD)
|
|
trace_event_enable_cmd_record(enabled);
|
|
|
|
if (mask == TRACE_ITER_EVENT_FORK)
|
|
trace_event_follow_fork(tr, enabled);
|
|
|
|
if (mask == TRACE_ITER_OVERWRITE) {
|
|
ring_buffer_change_overwrite(tr->trace_buffer.buffer, enabled);
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
ring_buffer_change_overwrite(tr->max_buffer.buffer, enabled);
|
|
#endif
|
|
}
|
|
|
|
if (mask == TRACE_ITER_PRINTK) {
|
|
trace_printk_start_stop_comm(enabled);
|
|
trace_printk_control(enabled);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int trace_set_options(struct trace_array *tr, char *option)
|
|
{
|
|
char *cmp;
|
|
int neg = 0;
|
|
int ret = -ENODEV;
|
|
int i;
|
|
size_t orig_len = strlen(option);
|
|
|
|
cmp = strstrip(option);
|
|
|
|
if (strncmp(cmp, "no", 2) == 0) {
|
|
neg = 1;
|
|
cmp += 2;
|
|
}
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
for (i = 0; trace_options[i]; i++) {
|
|
if (strcmp(cmp, trace_options[i]) == 0) {
|
|
ret = set_tracer_flag(tr, 1 << i, !neg);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* If no option could be set, test the specific tracer options */
|
|
if (!trace_options[i])
|
|
ret = set_tracer_option(tr, cmp, neg);
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
/*
|
|
* If the first trailing whitespace is replaced with '\0' by strstrip,
|
|
* turn it back into a space.
|
|
*/
|
|
if (orig_len > strlen(option))
|
|
option[strlen(option)] = ' ';
|
|
|
|
return ret;
|
|
}
|
|
|
|
static void __init apply_trace_boot_options(void)
|
|
{
|
|
char *buf = trace_boot_options_buf;
|
|
char *option;
|
|
|
|
while (true) {
|
|
option = strsep(&buf, ",");
|
|
|
|
if (!option)
|
|
break;
|
|
|
|
if (*option)
|
|
trace_set_options(&global_trace, option);
|
|
|
|
/* Put back the comma to allow this to be called again */
|
|
if (buf)
|
|
*(buf - 1) = ',';
|
|
}
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_trace_options_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct seq_file *m = filp->private_data;
|
|
struct trace_array *tr = m->private;
|
|
char buf[64];
|
|
int ret;
|
|
|
|
if (cnt >= sizeof(buf))
|
|
return -EINVAL;
|
|
|
|
if (copy_from_user(buf, ubuf, cnt))
|
|
return -EFAULT;
|
|
|
|
buf[cnt] = 0;
|
|
|
|
ret = trace_set_options(tr, buf);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
*ppos += cnt;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static int tracing_trace_options_open(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
int ret;
|
|
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
if (trace_array_get(tr) < 0)
|
|
return -ENODEV;
|
|
|
|
ret = single_open(file, tracing_trace_options_show, inode->i_private);
|
|
if (ret < 0)
|
|
trace_array_put(tr);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static const struct file_operations tracing_iter_fops = {
|
|
.open = tracing_trace_options_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = tracing_single_release_tr,
|
|
.write = tracing_trace_options_write,
|
|
};
|
|
|
|
static const char readme_msg[] =
|
|
"tracing mini-HOWTO:\n\n"
|
|
"# echo 0 > tracing_on : quick way to disable tracing\n"
|
|
"# echo 1 > tracing_on : quick way to re-enable tracing\n\n"
|
|
" Important files:\n"
|
|
" trace\t\t\t- The static contents of the buffer\n"
|
|
"\t\t\t To clear the buffer write into this file: echo > trace\n"
|
|
" trace_pipe\t\t- A consuming read to see the contents of the buffer\n"
|
|
" current_tracer\t- function and latency tracers\n"
|
|
" available_tracers\t- list of configured tracers for current_tracer\n"
|
|
" buffer_size_kb\t- view and modify size of per cpu buffer\n"
|
|
" buffer_total_size_kb - view total size of all cpu buffers\n\n"
|
|
" trace_clock\t\t-change the clock used to order events\n"
|
|
" local: Per cpu clock but may not be synced across CPUs\n"
|
|
" global: Synced across CPUs but slows tracing down.\n"
|
|
" counter: Not a clock, but just an increment\n"
|
|
" uptime: Jiffy counter from time of boot\n"
|
|
" perf: Same clock that perf events use\n"
|
|
#ifdef CONFIG_X86_64
|
|
" x86-tsc: TSC cycle counter\n"
|
|
#endif
|
|
"\n trace_marker\t\t- Writes into this file writes into the kernel buffer\n"
|
|
" tracing_cpumask\t- Limit which CPUs to trace\n"
|
|
" instances\t\t- Make sub-buffers with: mkdir instances/foo\n"
|
|
"\t\t\t Remove sub-buffer with rmdir\n"
|
|
" trace_options\t\t- Set format or modify how tracing happens\n"
|
|
"\t\t\t Disable an option by adding a suffix 'no' to the\n"
|
|
"\t\t\t option name\n"
|
|
" saved_cmdlines_size\t- echo command number in here to store comm-pid list\n"
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
|
"\n available_filter_functions - list of functions that can be filtered on\n"
|
|
" set_ftrace_filter\t- echo function name in here to only trace these\n"
|
|
"\t\t\t functions\n"
|
|
"\t accepts: func_full_name, *func_end, func_begin*, *func_middle*\n"
|
|
"\t modules: Can select a group via module\n"
|
|
"\t Format: :mod:<module-name>\n"
|
|
"\t example: echo :mod:ext3 > set_ftrace_filter\n"
|
|
"\t triggers: a command to perform when function is hit\n"
|
|
"\t Format: <function>:<trigger>[:count]\n"
|
|
"\t trigger: traceon, traceoff\n"
|
|
"\t\t enable_event:<system>:<event>\n"
|
|
"\t\t disable_event:<system>:<event>\n"
|
|
#ifdef CONFIG_STACKTRACE
|
|
"\t\t stacktrace\n"
|
|
#endif
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
"\t\t snapshot\n"
|
|
#endif
|
|
"\t\t dump\n"
|
|
"\t\t cpudump\n"
|
|
"\t example: echo do_fault:traceoff > set_ftrace_filter\n"
|
|
"\t echo do_trap:traceoff:3 > set_ftrace_filter\n"
|
|
"\t The first one will disable tracing every time do_fault is hit\n"
|
|
"\t The second will disable tracing at most 3 times when do_trap is hit\n"
|
|
"\t The first time do trap is hit and it disables tracing, the\n"
|
|
"\t counter will decrement to 2. If tracing is already disabled,\n"
|
|
"\t the counter will not decrement. It only decrements when the\n"
|
|
"\t trigger did work\n"
|
|
"\t To remove trigger without count:\n"
|
|
"\t echo '!<function>:<trigger> > set_ftrace_filter\n"
|
|
"\t To remove trigger with a count:\n"
|
|
"\t echo '!<function>:<trigger>:0 > set_ftrace_filter\n"
|
|
" set_ftrace_notrace\t- echo function name in here to never trace.\n"
|
|
"\t accepts: func_full_name, *func_end, func_begin*, *func_middle*\n"
|
|
"\t modules: Can select a group via module command :mod:\n"
|
|
"\t Does not accept triggers\n"
|
|
#endif /* CONFIG_DYNAMIC_FTRACE */
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
|
" set_ftrace_pid\t- Write pid(s) to only function trace those pids\n"
|
|
"\t\t (function)\n"
|
|
#endif
|
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
" set_graph_function\t- Trace the nested calls of a function (function_graph)\n"
|
|
" set_graph_notrace\t- Do not trace the nested calls of a function (function_graph)\n"
|
|
" max_graph_depth\t- Trace a limited depth of nested calls (0 is unlimited)\n"
|
|
#endif
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
"\n snapshot\t\t- Like 'trace' but shows the content of the static\n"
|
|
"\t\t\t snapshot buffer. Read the contents for more\n"
|
|
"\t\t\t information\n"
|
|
#endif
|
|
#ifdef CONFIG_STACK_TRACER
|
|
" stack_trace\t\t- Shows the max stack trace when active\n"
|
|
" stack_max_size\t- Shows current max stack size that was traced\n"
|
|
"\t\t\t Write into this file to reset the max size (trigger a\n"
|
|
"\t\t\t new trace)\n"
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
|
" stack_trace_filter\t- Like set_ftrace_filter but limits what stack_trace\n"
|
|
"\t\t\t traces\n"
|
|
#endif
|
|
#endif /* CONFIG_STACK_TRACER */
|
|
#ifdef CONFIG_KPROBE_EVENT
|
|
" kprobe_events\t\t- Add/remove/show the kernel dynamic events\n"
|
|
"\t\t\t Write into this file to define/undefine new trace events.\n"
|
|
#endif
|
|
#ifdef CONFIG_UPROBE_EVENT
|
|
" uprobe_events\t\t- Add/remove/show the userspace dynamic events\n"
|
|
"\t\t\t Write into this file to define/undefine new trace events.\n"
|
|
#endif
|
|
#if defined(CONFIG_KPROBE_EVENT) || defined(CONFIG_UPROBE_EVENT)
|
|
"\t accepts: event-definitions (one definition per line)\n"
|
|
"\t Format: p|r[:[<group>/]<event>] <place> [<args>]\n"
|
|
"\t -:[<group>/]<event>\n"
|
|
#ifdef CONFIG_KPROBE_EVENT
|
|
"\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n"
|
|
#endif
|
|
#ifdef CONFIG_UPROBE_EVENT
|
|
"\t place: <path>:<offset>\n"
|
|
#endif
|
|
"\t args: <name>=fetcharg[:type]\n"
|
|
"\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n"
|
|
"\t $stack<index>, $stack, $retval, $comm\n"
|
|
"\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string,\n"
|
|
"\t b<bit-width>@<bit-offset>/<container-size>\n"
|
|
#endif
|
|
" events/\t\t- Directory containing all trace event subsystems:\n"
|
|
" enable\t\t- Write 0/1 to enable/disable tracing of all events\n"
|
|
" events/<system>/\t- Directory containing all trace events for <system>:\n"
|
|
" enable\t\t- Write 0/1 to enable/disable tracing of all <system>\n"
|
|
"\t\t\t events\n"
|
|
" filter\t\t- If set, only events passing filter are traced\n"
|
|
" events/<system>/<event>/\t- Directory containing control files for\n"
|
|
"\t\t\t <event>:\n"
|
|
" enable\t\t- Write 0/1 to enable/disable tracing of <event>\n"
|
|
" filter\t\t- If set, only events passing filter are traced\n"
|
|
" trigger\t\t- If set, a command to perform when event is hit\n"
|
|
"\t Format: <trigger>[:count][if <filter>]\n"
|
|
"\t trigger: traceon, traceoff\n"
|
|
"\t enable_event:<system>:<event>\n"
|
|
"\t disable_event:<system>:<event>\n"
|
|
#ifdef CONFIG_HIST_TRIGGERS
|
|
"\t enable_hist:<system>:<event>\n"
|
|
"\t disable_hist:<system>:<event>\n"
|
|
#endif
|
|
#ifdef CONFIG_STACKTRACE
|
|
"\t\t stacktrace\n"
|
|
#endif
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
"\t\t snapshot\n"
|
|
#endif
|
|
#ifdef CONFIG_HIST_TRIGGERS
|
|
"\t\t hist (see below)\n"
|
|
#endif
|
|
"\t example: echo traceoff > events/block/block_unplug/trigger\n"
|
|
"\t echo traceoff:3 > events/block/block_unplug/trigger\n"
|
|
"\t echo 'enable_event:kmem:kmalloc:3 if nr_rq > 1' > \\\n"
|
|
"\t events/block/block_unplug/trigger\n"
|
|
"\t The first disables tracing every time block_unplug is hit.\n"
|
|
"\t The second disables tracing the first 3 times block_unplug is hit.\n"
|
|
"\t The third enables the kmalloc event the first 3 times block_unplug\n"
|
|
"\t is hit and has value of greater than 1 for the 'nr_rq' event field.\n"
|
|
"\t Like function triggers, the counter is only decremented if it\n"
|
|
"\t enabled or disabled tracing.\n"
|
|
"\t To remove a trigger without a count:\n"
|
|
"\t echo '!<trigger> > <system>/<event>/trigger\n"
|
|
"\t To remove a trigger with a count:\n"
|
|
"\t echo '!<trigger>:0 > <system>/<event>/trigger\n"
|
|
"\t Filters can be ignored when removing a trigger.\n"
|
|
#ifdef CONFIG_HIST_TRIGGERS
|
|
" hist trigger\t- If set, event hits are aggregated into a hash table\n"
|
|
"\t Format: hist:keys=<field1[,field2,...]>\n"
|
|
"\t [:values=<field1[,field2,...]>]\n"
|
|
"\t [:sort=<field1[,field2,...]>]\n"
|
|
"\t [:size=#entries]\n"
|
|
"\t [:pause][:continue][:clear]\n"
|
|
"\t [:name=histname1]\n"
|
|
"\t [if <filter>]\n\n"
|
|
"\t When a matching event is hit, an entry is added to a hash\n"
|
|
"\t table using the key(s) and value(s) named, and the value of a\n"
|
|
"\t sum called 'hitcount' is incremented. Keys and values\n"
|
|
"\t correspond to fields in the event's format description. Keys\n"
|
|
"\t can be any field, or the special string 'stacktrace'.\n"
|
|
"\t Compound keys consisting of up to two fields can be specified\n"
|
|
"\t by the 'keys' keyword. Values must correspond to numeric\n"
|
|
"\t fields. Sort keys consisting of up to two fields can be\n"
|
|
"\t specified using the 'sort' keyword. The sort direction can\n"
|
|
"\t be modified by appending '.descending' or '.ascending' to a\n"
|
|
"\t sort field. The 'size' parameter can be used to specify more\n"
|
|
"\t or fewer than the default 2048 entries for the hashtable size.\n"
|
|
"\t If a hist trigger is given a name using the 'name' parameter,\n"
|
|
"\t its histogram data will be shared with other triggers of the\n"
|
|
"\t same name, and trigger hits will update this common data.\n\n"
|
|
"\t Reading the 'hist' file for the event will dump the hash\n"
|
|
"\t table in its entirety to stdout. If there are multiple hist\n"
|
|
"\t triggers attached to an event, there will be a table for each\n"
|
|
"\t trigger in the output. The table displayed for a named\n"
|
|
"\t trigger will be the same as any other instance having the\n"
|
|
"\t same name. The default format used to display a given field\n"
|
|
"\t can be modified by appending any of the following modifiers\n"
|
|
"\t to the field name, as applicable:\n\n"
|
|
"\t .hex display a number as a hex value\n"
|
|
"\t .sym display an address as a symbol\n"
|
|
"\t .sym-offset display an address as a symbol and offset\n"
|
|
"\t .execname display a common_pid as a program name\n"
|
|
"\t .syscall display a syscall id as a syscall name\n\n"
|
|
"\t .log2 display log2 value rather than raw number\n\n"
|
|
"\t The 'pause' parameter can be used to pause an existing hist\n"
|
|
"\t trigger or to start a hist trigger but not log any events\n"
|
|
"\t until told to do so. 'continue' can be used to start or\n"
|
|
"\t restart a paused hist trigger.\n\n"
|
|
"\t The 'clear' parameter will clear the contents of a running\n"
|
|
"\t hist trigger and leave its current paused/active state\n"
|
|
"\t unchanged.\n\n"
|
|
"\t The enable_hist and disable_hist triggers can be used to\n"
|
|
"\t have one event conditionally start and stop another event's\n"
|
|
"\t already-attached hist trigger. The syntax is analagous to\n"
|
|
"\t the enable_event and disable_event triggers.\n"
|
|
#endif
|
|
;
|
|
|
|
static ssize_t
|
|
tracing_readme_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
return simple_read_from_buffer(ubuf, cnt, ppos,
|
|
readme_msg, strlen(readme_msg));
|
|
}
|
|
|
|
static const struct file_operations tracing_readme_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = tracing_readme_read,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
|
|
static void *saved_cmdlines_next(struct seq_file *m, void *v, loff_t *pos)
|
|
{
|
|
unsigned int *ptr = v;
|
|
|
|
if (*pos || m->count)
|
|
ptr++;
|
|
|
|
(*pos)++;
|
|
|
|
for (; ptr < &savedcmd->map_cmdline_to_pid[savedcmd->cmdline_num];
|
|
ptr++) {
|
|
if (*ptr == -1 || *ptr == NO_CMDLINE_MAP)
|
|
continue;
|
|
|
|
return ptr;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static void *saved_cmdlines_start(struct seq_file *m, loff_t *pos)
|
|
{
|
|
void *v;
|
|
loff_t l = 0;
|
|
|
|
preempt_disable();
|
|
arch_spin_lock(&trace_cmdline_lock);
|
|
|
|
v = &savedcmd->map_cmdline_to_pid[0];
|
|
while (l <= *pos) {
|
|
v = saved_cmdlines_next(m, v, &l);
|
|
if (!v)
|
|
return NULL;
|
|
}
|
|
|
|
return v;
|
|
}
|
|
|
|
static void saved_cmdlines_stop(struct seq_file *m, void *v)
|
|
{
|
|
arch_spin_unlock(&trace_cmdline_lock);
|
|
preempt_enable();
|
|
}
|
|
|
|
static int saved_cmdlines_show(struct seq_file *m, void *v)
|
|
{
|
|
char buf[TASK_COMM_LEN];
|
|
unsigned int *pid = v;
|
|
|
|
__trace_find_cmdline(*pid, buf);
|
|
seq_printf(m, "%d %s\n", *pid, buf);
|
|
return 0;
|
|
}
|
|
|
|
static const struct seq_operations tracing_saved_cmdlines_seq_ops = {
|
|
.start = saved_cmdlines_start,
|
|
.next = saved_cmdlines_next,
|
|
.stop = saved_cmdlines_stop,
|
|
.show = saved_cmdlines_show,
|
|
};
|
|
|
|
static int tracing_saved_cmdlines_open(struct inode *inode, struct file *filp)
|
|
{
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
return seq_open(filp, &tracing_saved_cmdlines_seq_ops);
|
|
}
|
|
|
|
static const struct file_operations tracing_saved_cmdlines_fops = {
|
|
.open = tracing_saved_cmdlines_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = seq_release,
|
|
};
|
|
|
|
static ssize_t
|
|
tracing_saved_cmdlines_size_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
char buf[64];
|
|
int r;
|
|
|
|
arch_spin_lock(&trace_cmdline_lock);
|
|
r = scnprintf(buf, sizeof(buf), "%u\n", savedcmd->cmdline_num);
|
|
arch_spin_unlock(&trace_cmdline_lock);
|
|
|
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
|
|
}
|
|
|
|
static void free_saved_cmdlines_buffer(struct saved_cmdlines_buffer *s)
|
|
{
|
|
kfree(s->saved_cmdlines);
|
|
kfree(s->map_cmdline_to_pid);
|
|
kfree(s);
|
|
}
|
|
|
|
static int tracing_resize_saved_cmdlines(unsigned int val)
|
|
{
|
|
struct saved_cmdlines_buffer *s, *savedcmd_temp;
|
|
|
|
s = kmalloc(sizeof(*s), GFP_KERNEL);
|
|
if (!s)
|
|
return -ENOMEM;
|
|
|
|
if (allocate_cmdlines_buffer(val, s) < 0) {
|
|
kfree(s);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
arch_spin_lock(&trace_cmdline_lock);
|
|
savedcmd_temp = savedcmd;
|
|
savedcmd = s;
|
|
arch_spin_unlock(&trace_cmdline_lock);
|
|
free_saved_cmdlines_buffer(savedcmd_temp);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_saved_cmdlines_size_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
unsigned long val;
|
|
int ret;
|
|
|
|
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* must have at least 1 entry or less than PID_MAX_DEFAULT */
|
|
if (!val || val > PID_MAX_DEFAULT)
|
|
return -EINVAL;
|
|
|
|
ret = tracing_resize_saved_cmdlines((unsigned int)val);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
*ppos += cnt;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static const struct file_operations tracing_saved_cmdlines_size_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = tracing_saved_cmdlines_size_read,
|
|
.write = tracing_saved_cmdlines_size_write,
|
|
};
|
|
|
|
#ifdef CONFIG_TRACE_ENUM_MAP_FILE
|
|
static union trace_enum_map_item *
|
|
update_enum_map(union trace_enum_map_item *ptr)
|
|
{
|
|
if (!ptr->map.enum_string) {
|
|
if (ptr->tail.next) {
|
|
ptr = ptr->tail.next;
|
|
/* Set ptr to the next real item (skip head) */
|
|
ptr++;
|
|
} else
|
|
return NULL;
|
|
}
|
|
return ptr;
|
|
}
|
|
|
|
static void *enum_map_next(struct seq_file *m, void *v, loff_t *pos)
|
|
{
|
|
union trace_enum_map_item *ptr = v;
|
|
|
|
/*
|
|
* Paranoid! If ptr points to end, we don't want to increment past it.
|
|
* This really should never happen.
|
|
*/
|
|
ptr = update_enum_map(ptr);
|
|
if (WARN_ON_ONCE(!ptr))
|
|
return NULL;
|
|
|
|
ptr++;
|
|
|
|
(*pos)++;
|
|
|
|
ptr = update_enum_map(ptr);
|
|
|
|
return ptr;
|
|
}
|
|
|
|
static void *enum_map_start(struct seq_file *m, loff_t *pos)
|
|
{
|
|
union trace_enum_map_item *v;
|
|
loff_t l = 0;
|
|
|
|
mutex_lock(&trace_enum_mutex);
|
|
|
|
v = trace_enum_maps;
|
|
if (v)
|
|
v++;
|
|
|
|
while (v && l < *pos) {
|
|
v = enum_map_next(m, v, &l);
|
|
}
|
|
|
|
return v;
|
|
}
|
|
|
|
static void enum_map_stop(struct seq_file *m, void *v)
|
|
{
|
|
mutex_unlock(&trace_enum_mutex);
|
|
}
|
|
|
|
static int enum_map_show(struct seq_file *m, void *v)
|
|
{
|
|
union trace_enum_map_item *ptr = v;
|
|
|
|
seq_printf(m, "%s %ld (%s)\n",
|
|
ptr->map.enum_string, ptr->map.enum_value,
|
|
ptr->map.system);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct seq_operations tracing_enum_map_seq_ops = {
|
|
.start = enum_map_start,
|
|
.next = enum_map_next,
|
|
.stop = enum_map_stop,
|
|
.show = enum_map_show,
|
|
};
|
|
|
|
static int tracing_enum_map_open(struct inode *inode, struct file *filp)
|
|
{
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
return seq_open(filp, &tracing_enum_map_seq_ops);
|
|
}
|
|
|
|
static const struct file_operations tracing_enum_map_fops = {
|
|
.open = tracing_enum_map_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = seq_release,
|
|
};
|
|
|
|
static inline union trace_enum_map_item *
|
|
trace_enum_jmp_to_tail(union trace_enum_map_item *ptr)
|
|
{
|
|
/* Return tail of array given the head */
|
|
return ptr + ptr->head.length + 1;
|
|
}
|
|
|
|
static void
|
|
trace_insert_enum_map_file(struct module *mod, struct trace_enum_map **start,
|
|
int len)
|
|
{
|
|
struct trace_enum_map **stop;
|
|
struct trace_enum_map **map;
|
|
union trace_enum_map_item *map_array;
|
|
union trace_enum_map_item *ptr;
|
|
|
|
stop = start + len;
|
|
|
|
/*
|
|
* The trace_enum_maps contains the map plus a head and tail item,
|
|
* where the head holds the module and length of array, and the
|
|
* tail holds a pointer to the next list.
|
|
*/
|
|
map_array = kmalloc(sizeof(*map_array) * (len + 2), GFP_KERNEL);
|
|
if (!map_array) {
|
|
pr_warn("Unable to allocate trace enum mapping\n");
|
|
return;
|
|
}
|
|
|
|
mutex_lock(&trace_enum_mutex);
|
|
|
|
if (!trace_enum_maps)
|
|
trace_enum_maps = map_array;
|
|
else {
|
|
ptr = trace_enum_maps;
|
|
for (;;) {
|
|
ptr = trace_enum_jmp_to_tail(ptr);
|
|
if (!ptr->tail.next)
|
|
break;
|
|
ptr = ptr->tail.next;
|
|
|
|
}
|
|
ptr->tail.next = map_array;
|
|
}
|
|
map_array->head.mod = mod;
|
|
map_array->head.length = len;
|
|
map_array++;
|
|
|
|
for (map = start; (unsigned long)map < (unsigned long)stop; map++) {
|
|
map_array->map = **map;
|
|
map_array++;
|
|
}
|
|
memset(map_array, 0, sizeof(*map_array));
|
|
|
|
mutex_unlock(&trace_enum_mutex);
|
|
}
|
|
|
|
static void trace_create_enum_file(struct dentry *d_tracer)
|
|
{
|
|
trace_create_file("enum_map", 0444, d_tracer,
|
|
NULL, &tracing_enum_map_fops);
|
|
}
|
|
|
|
#else /* CONFIG_TRACE_ENUM_MAP_FILE */
|
|
static inline void trace_create_enum_file(struct dentry *d_tracer) { }
|
|
static inline void trace_insert_enum_map_file(struct module *mod,
|
|
struct trace_enum_map **start, int len) { }
|
|
#endif /* !CONFIG_TRACE_ENUM_MAP_FILE */
|
|
|
|
static void trace_insert_enum_map(struct module *mod,
|
|
struct trace_enum_map **start, int len)
|
|
{
|
|
struct trace_enum_map **map;
|
|
|
|
if (len <= 0)
|
|
return;
|
|
|
|
map = start;
|
|
|
|
trace_event_enum_update(map, len);
|
|
|
|
trace_insert_enum_map_file(mod, start, len);
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_saved_tgids_read(struct file *file, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
char *file_buf;
|
|
char *buf;
|
|
int len = 0;
|
|
int pid;
|
|
int i;
|
|
|
|
file_buf = kmalloc(SAVED_CMDLINES_DEFAULT*(16+1+16), GFP_KERNEL);
|
|
if (!file_buf)
|
|
return -ENOMEM;
|
|
|
|
buf = file_buf;
|
|
|
|
for (i = 0; i < SAVED_CMDLINES_DEFAULT; i++) {
|
|
int tgid;
|
|
int r;
|
|
|
|
pid = savedcmd->map_cmdline_to_pid[i];
|
|
if (pid == -1 || pid == NO_CMDLINE_MAP)
|
|
continue;
|
|
|
|
tgid = trace_find_tgid(pid);
|
|
r = sprintf(buf, "%d %d\n", pid, tgid);
|
|
buf += r;
|
|
len += r;
|
|
}
|
|
|
|
len = simple_read_from_buffer(ubuf, cnt, ppos,
|
|
file_buf, len);
|
|
|
|
kfree(file_buf);
|
|
|
|
return len;
|
|
}
|
|
|
|
static const struct file_operations tracing_saved_tgids_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = tracing_saved_tgids_read,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
|
|
static ssize_t
|
|
tracing_set_trace_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = filp->private_data;
|
|
char buf[MAX_TRACER_SIZE+2];
|
|
int r;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
r = sprintf(buf, "%s\n", tr->current_trace->name);
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
|
|
}
|
|
|
|
int tracer_init(struct tracer *t, struct trace_array *tr)
|
|
{
|
|
tracing_reset_online_cpus(&tr->trace_buffer);
|
|
return t->init(tr);
|
|
}
|
|
|
|
static void set_buffer_entries(struct trace_buffer *buf, unsigned long val)
|
|
{
|
|
int cpu;
|
|
|
|
for_each_tracing_cpu(cpu)
|
|
per_cpu_ptr(buf->data, cpu)->entries = val;
|
|
}
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
/* resize @tr's buffer to the size of @size_tr's entries */
|
|
static int resize_buffer_duplicate_size(struct trace_buffer *trace_buf,
|
|
struct trace_buffer *size_buf, int cpu_id)
|
|
{
|
|
int cpu, ret = 0;
|
|
|
|
if (cpu_id == RING_BUFFER_ALL_CPUS) {
|
|
for_each_tracing_cpu(cpu) {
|
|
ret = ring_buffer_resize(trace_buf->buffer,
|
|
per_cpu_ptr(size_buf->data, cpu)->entries, cpu);
|
|
if (ret < 0)
|
|
break;
|
|
per_cpu_ptr(trace_buf->data, cpu)->entries =
|
|
per_cpu_ptr(size_buf->data, cpu)->entries;
|
|
}
|
|
} else {
|
|
ret = ring_buffer_resize(trace_buf->buffer,
|
|
per_cpu_ptr(size_buf->data, cpu_id)->entries, cpu_id);
|
|
if (ret == 0)
|
|
per_cpu_ptr(trace_buf->data, cpu_id)->entries =
|
|
per_cpu_ptr(size_buf->data, cpu_id)->entries;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
#endif /* CONFIG_TRACER_MAX_TRACE */
|
|
|
|
static int __tracing_resize_ring_buffer(struct trace_array *tr,
|
|
unsigned long size, int cpu)
|
|
{
|
|
int ret;
|
|
|
|
/*
|
|
* If kernel or user changes the size of the ring buffer
|
|
* we use the size that was given, and we can forget about
|
|
* expanding it later.
|
|
*/
|
|
ring_buffer_expanded = true;
|
|
|
|
/* May be called before buffers are initialized */
|
|
if (!tr->trace_buffer.buffer)
|
|
return 0;
|
|
|
|
ret = ring_buffer_resize(tr->trace_buffer.buffer, size, cpu);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (!(tr->flags & TRACE_ARRAY_FL_GLOBAL) ||
|
|
!tr->current_trace->use_max_tr)
|
|
goto out;
|
|
|
|
ret = ring_buffer_resize(tr->max_buffer.buffer, size, cpu);
|
|
if (ret < 0) {
|
|
int r = resize_buffer_duplicate_size(&tr->trace_buffer,
|
|
&tr->trace_buffer, cpu);
|
|
if (r < 0) {
|
|
/*
|
|
* AARGH! We are left with different
|
|
* size max buffer!!!!
|
|
* The max buffer is our "snapshot" buffer.
|
|
* When a tracer needs a snapshot (one of the
|
|
* latency tracers), it swaps the max buffer
|
|
* with the saved snap shot. We succeeded to
|
|
* update the size of the main buffer, but failed to
|
|
* update the size of the max buffer. But when we tried
|
|
* to reset the main buffer to the original size, we
|
|
* failed there too. This is very unlikely to
|
|
* happen, but if it does, warn and kill all
|
|
* tracing.
|
|
*/
|
|
WARN_ON(1);
|
|
tracing_disabled = 1;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
if (cpu == RING_BUFFER_ALL_CPUS)
|
|
set_buffer_entries(&tr->max_buffer, size);
|
|
else
|
|
per_cpu_ptr(tr->max_buffer.data, cpu)->entries = size;
|
|
|
|
out:
|
|
#endif /* CONFIG_TRACER_MAX_TRACE */
|
|
|
|
if (cpu == RING_BUFFER_ALL_CPUS)
|
|
set_buffer_entries(&tr->trace_buffer, size);
|
|
else
|
|
per_cpu_ptr(tr->trace_buffer.data, cpu)->entries = size;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t tracing_resize_ring_buffer(struct trace_array *tr,
|
|
unsigned long size, int cpu_id)
|
|
{
|
|
int ret = size;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
if (cpu_id != RING_BUFFER_ALL_CPUS) {
|
|
/* make sure, this cpu is enabled in the mask */
|
|
if (!cpumask_test_cpu(cpu_id, tracing_buffer_mask)) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
ret = __tracing_resize_ring_buffer(tr, size, cpu_id);
|
|
if (ret < 0)
|
|
ret = -ENOMEM;
|
|
|
|
out:
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
/**
|
|
* tracing_update_buffers - used by tracing facility to expand ring buffers
|
|
*
|
|
* To save on memory when the tracing is never used on a system with it
|
|
* configured in. The ring buffers are set to a minimum size. But once
|
|
* a user starts to use the tracing facility, then they need to grow
|
|
* to their default size.
|
|
*
|
|
* This function is to be called when a tracer is about to be used.
|
|
*/
|
|
int tracing_update_buffers(void)
|
|
{
|
|
int ret = 0;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
if (!ring_buffer_expanded)
|
|
ret = __tracing_resize_ring_buffer(&global_trace, trace_buf_size,
|
|
RING_BUFFER_ALL_CPUS);
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
struct trace_option_dentry;
|
|
|
|
static void
|
|
create_trace_option_files(struct trace_array *tr, struct tracer *tracer);
|
|
|
|
/*
|
|
* Used to clear out the tracer before deletion of an instance.
|
|
* Must have trace_types_lock held.
|
|
*/
|
|
static void tracing_set_nop(struct trace_array *tr)
|
|
{
|
|
if (tr->current_trace == &nop_trace)
|
|
return;
|
|
|
|
tr->current_trace->enabled--;
|
|
|
|
if (tr->current_trace->reset)
|
|
tr->current_trace->reset(tr);
|
|
|
|
tr->current_trace = &nop_trace;
|
|
}
|
|
|
|
static void add_tracer_options(struct trace_array *tr, struct tracer *t)
|
|
{
|
|
/* Only enable if the directory has been created already. */
|
|
if (!tr->dir)
|
|
return;
|
|
|
|
create_trace_option_files(tr, t);
|
|
}
|
|
|
|
static int tracing_set_tracer(struct trace_array *tr, const char *buf)
|
|
{
|
|
struct tracer *t;
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
bool had_max_tr;
|
|
#endif
|
|
int ret = 0;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
if (!ring_buffer_expanded) {
|
|
ret = __tracing_resize_ring_buffer(tr, trace_buf_size,
|
|
RING_BUFFER_ALL_CPUS);
|
|
if (ret < 0)
|
|
goto out;
|
|
ret = 0;
|
|
}
|
|
|
|
for (t = trace_types; t; t = t->next) {
|
|
if (strcmp(t->name, buf) == 0)
|
|
break;
|
|
}
|
|
if (!t) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
if (t == tr->current_trace)
|
|
goto out;
|
|
|
|
/* Some tracers are only allowed for the top level buffer */
|
|
if (!trace_ok_for_array(t, tr)) {
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
/* If trace pipe files are being read, we can't change the tracer */
|
|
if (tr->current_trace->ref) {
|
|
ret = -EBUSY;
|
|
goto out;
|
|
}
|
|
|
|
trace_branch_disable();
|
|
|
|
tr->current_trace->enabled--;
|
|
|
|
if (tr->current_trace->reset)
|
|
tr->current_trace->reset(tr);
|
|
|
|
/* Current trace needs to be nop_trace before synchronize_sched */
|
|
tr->current_trace = &nop_trace;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
had_max_tr = tr->allocated_snapshot;
|
|
|
|
if (had_max_tr && !t->use_max_tr) {
|
|
/*
|
|
* We need to make sure that the update_max_tr sees that
|
|
* current_trace changed to nop_trace to keep it from
|
|
* swapping the buffers after we resize it.
|
|
* The update_max_tr is called from interrupts disabled
|
|
* so a synchronized_sched() is sufficient.
|
|
*/
|
|
synchronize_sched();
|
|
free_snapshot(tr);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (t->use_max_tr && !had_max_tr) {
|
|
ret = alloc_snapshot(tr);
|
|
if (ret < 0)
|
|
goto out;
|
|
}
|
|
#endif
|
|
|
|
if (t->init) {
|
|
ret = tracer_init(t, tr);
|
|
if (ret)
|
|
goto out;
|
|
}
|
|
|
|
tr->current_trace = t;
|
|
tr->current_trace->enabled++;
|
|
trace_branch_enable(tr);
|
|
out:
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_set_trace_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = filp->private_data;
|
|
char buf[MAX_TRACER_SIZE+1];
|
|
int i;
|
|
size_t ret;
|
|
int err;
|
|
|
|
ret = cnt;
|
|
|
|
if (cnt > MAX_TRACER_SIZE)
|
|
cnt = MAX_TRACER_SIZE;
|
|
|
|
if (copy_from_user(buf, ubuf, cnt))
|
|
return -EFAULT;
|
|
|
|
buf[cnt] = 0;
|
|
|
|
/* strip ending whitespace. */
|
|
for (i = cnt - 1; i > 0 && isspace(buf[i]); i--)
|
|
buf[i] = 0;
|
|
|
|
err = tracing_set_tracer(tr, buf);
|
|
if (err)
|
|
return err;
|
|
|
|
*ppos += ret;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_nsecs_read(unsigned long *ptr, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
char buf[64];
|
|
int r;
|
|
|
|
r = snprintf(buf, sizeof(buf), "%ld\n",
|
|
*ptr == (unsigned long)-1 ? -1 : nsecs_to_usecs(*ptr));
|
|
if (r > sizeof(buf))
|
|
r = sizeof(buf);
|
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_nsecs_write(unsigned long *ptr, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
unsigned long val;
|
|
int ret;
|
|
|
|
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
*ptr = val * 1000;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_thresh_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
return tracing_nsecs_read(&tracing_thresh, ubuf, cnt, ppos);
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_thresh_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = filp->private_data;
|
|
int ret;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
ret = tracing_nsecs_write(&tracing_thresh, ubuf, cnt, ppos);
|
|
if (ret < 0)
|
|
goto out;
|
|
|
|
if (tr->current_trace->update_thresh) {
|
|
ret = tr->current_trace->update_thresh(tr);
|
|
if (ret < 0)
|
|
goto out;
|
|
}
|
|
|
|
ret = cnt;
|
|
out:
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
#if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)
|
|
|
|
static ssize_t
|
|
tracing_max_lat_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
return tracing_nsecs_read(filp->private_data, ubuf, cnt, ppos);
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_max_lat_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
return tracing_nsecs_write(filp->private_data, ubuf, cnt, ppos);
|
|
}
|
|
|
|
#endif
|
|
|
|
static int tracing_open_pipe(struct inode *inode, struct file *filp)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
struct trace_iterator *iter;
|
|
int ret = 0;
|
|
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
if (trace_array_get(tr) < 0)
|
|
return -ENODEV;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
/* create a buffer to store the information to pass to userspace */
|
|
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
|
|
if (!iter) {
|
|
ret = -ENOMEM;
|
|
__trace_array_put(tr);
|
|
goto out;
|
|
}
|
|
|
|
trace_seq_init(&iter->seq);
|
|
iter->trace = tr->current_trace;
|
|
|
|
if (!alloc_cpumask_var(&iter->started, GFP_KERNEL)) {
|
|
ret = -ENOMEM;
|
|
goto fail;
|
|
}
|
|
|
|
/* trace pipe does not show start of buffer */
|
|
cpumask_setall(iter->started);
|
|
|
|
if (tr->trace_flags & TRACE_ITER_LATENCY_FMT)
|
|
iter->iter_flags |= TRACE_FILE_LAT_FMT;
|
|
|
|
/* Output in nanoseconds only if we are using a clock in nanoseconds. */
|
|
if (trace_clocks[tr->clock_id].in_ns)
|
|
iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
|
|
|
|
iter->tr = tr;
|
|
iter->trace_buffer = &tr->trace_buffer;
|
|
iter->cpu_file = tracing_get_cpu(inode);
|
|
mutex_init(&iter->mutex);
|
|
filp->private_data = iter;
|
|
|
|
if (iter->trace->pipe_open)
|
|
iter->trace->pipe_open(iter);
|
|
|
|
nonseekable_open(inode, filp);
|
|
|
|
tr->current_trace->ref++;
|
|
out:
|
|
mutex_unlock(&trace_types_lock);
|
|
return ret;
|
|
|
|
fail:
|
|
kfree(iter->trace);
|
|
kfree(iter);
|
|
__trace_array_put(tr);
|
|
mutex_unlock(&trace_types_lock);
|
|
return ret;
|
|
}
|
|
|
|
static int tracing_release_pipe(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_iterator *iter = file->private_data;
|
|
struct trace_array *tr = inode->i_private;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
tr->current_trace->ref--;
|
|
|
|
if (iter->trace->pipe_close)
|
|
iter->trace->pipe_close(iter);
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
free_cpumask_var(iter->started);
|
|
mutex_destroy(&iter->mutex);
|
|
kfree(iter);
|
|
|
|
trace_array_put(tr);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static unsigned int
|
|
trace_poll(struct trace_iterator *iter, struct file *filp, poll_table *poll_table)
|
|
{
|
|
struct trace_array *tr = iter->tr;
|
|
|
|
/* Iterators are static, they should be filled or empty */
|
|
if (trace_buffer_iter(iter, iter->cpu_file))
|
|
return POLLIN | POLLRDNORM;
|
|
|
|
if (tr->trace_flags & TRACE_ITER_BLOCK)
|
|
/*
|
|
* Always select as readable when in blocking mode
|
|
*/
|
|
return POLLIN | POLLRDNORM;
|
|
else
|
|
return ring_buffer_poll_wait(iter->trace_buffer->buffer, iter->cpu_file,
|
|
filp, poll_table);
|
|
}
|
|
|
|
static unsigned int
|
|
tracing_poll_pipe(struct file *filp, poll_table *poll_table)
|
|
{
|
|
struct trace_iterator *iter = filp->private_data;
|
|
|
|
return trace_poll(iter, filp, poll_table);
|
|
}
|
|
|
|
/* Must be called with iter->mutex held. */
|
|
static int tracing_wait_pipe(struct file *filp)
|
|
{
|
|
struct trace_iterator *iter = filp->private_data;
|
|
int ret;
|
|
|
|
while (trace_empty(iter)) {
|
|
|
|
if ((filp->f_flags & O_NONBLOCK)) {
|
|
return -EAGAIN;
|
|
}
|
|
|
|
/*
|
|
* We block until we read something and tracing is disabled.
|
|
* We still block if tracing is disabled, but we have never
|
|
* read anything. This allows a user to cat this file, and
|
|
* then enable tracing. But after we have read something,
|
|
* we give an EOF when tracing is again disabled.
|
|
*
|
|
* iter->pos will be 0 if we haven't read anything.
|
|
*/
|
|
if (!tracing_is_on() && iter->pos)
|
|
break;
|
|
|
|
mutex_unlock(&iter->mutex);
|
|
|
|
ret = wait_on_pipe(iter, false);
|
|
|
|
mutex_lock(&iter->mutex);
|
|
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* Consumer reader.
|
|
*/
|
|
static ssize_t
|
|
tracing_read_pipe(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct trace_iterator *iter = filp->private_data;
|
|
ssize_t sret;
|
|
|
|
/*
|
|
* Avoid more than one consumer on a single file descriptor
|
|
* This is just a matter of traces coherency, the ring buffer itself
|
|
* is protected.
|
|
*/
|
|
mutex_lock(&iter->mutex);
|
|
|
|
/* return any leftover data */
|
|
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
|
|
if (sret != -EBUSY)
|
|
goto out;
|
|
|
|
trace_seq_init(&iter->seq);
|
|
|
|
if (iter->trace->read) {
|
|
sret = iter->trace->read(iter, filp, ubuf, cnt, ppos);
|
|
if (sret)
|
|
goto out;
|
|
}
|
|
|
|
waitagain:
|
|
sret = tracing_wait_pipe(filp);
|
|
if (sret <= 0)
|
|
goto out;
|
|
|
|
/* stop when tracing is finished */
|
|
if (trace_empty(iter)) {
|
|
sret = 0;
|
|
goto out;
|
|
}
|
|
|
|
if (cnt >= PAGE_SIZE)
|
|
cnt = PAGE_SIZE - 1;
|
|
|
|
/* reset all but tr, trace, and overruns */
|
|
memset(&iter->seq, 0,
|
|
sizeof(struct trace_iterator) -
|
|
offsetof(struct trace_iterator, seq));
|
|
cpumask_clear(iter->started);
|
|
iter->pos = -1;
|
|
|
|
trace_event_read_lock();
|
|
trace_access_lock(iter->cpu_file);
|
|
while (trace_find_next_entry_inc(iter) != NULL) {
|
|
enum print_line_t ret;
|
|
int save_len = iter->seq.seq.len;
|
|
|
|
ret = print_trace_line(iter);
|
|
if (ret == TRACE_TYPE_PARTIAL_LINE) {
|
|
/* don't print partial lines */
|
|
iter->seq.seq.len = save_len;
|
|
break;
|
|
}
|
|
if (ret != TRACE_TYPE_NO_CONSUME)
|
|
trace_consume(iter);
|
|
|
|
if (trace_seq_used(&iter->seq) >= cnt)
|
|
break;
|
|
|
|
/*
|
|
* Setting the full flag means we reached the trace_seq buffer
|
|
* size and we should leave by partial output condition above.
|
|
* One of the trace_seq_* functions is not used properly.
|
|
*/
|
|
WARN_ONCE(iter->seq.full, "full flag set for trace type %d",
|
|
iter->ent->type);
|
|
}
|
|
trace_access_unlock(iter->cpu_file);
|
|
trace_event_read_unlock();
|
|
|
|
/* Now copy what we have to the user */
|
|
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
|
|
if (iter->seq.seq.readpos >= trace_seq_used(&iter->seq))
|
|
trace_seq_init(&iter->seq);
|
|
|
|
/*
|
|
* If there was nothing to send to user, in spite of consuming trace
|
|
* entries, go back to wait for more entries.
|
|
*/
|
|
if (sret == -EBUSY)
|
|
goto waitagain;
|
|
|
|
out:
|
|
mutex_unlock(&iter->mutex);
|
|
|
|
return sret;
|
|
}
|
|
|
|
static void tracing_spd_release_pipe(struct splice_pipe_desc *spd,
|
|
unsigned int idx)
|
|
{
|
|
__free_page(spd->pages[idx]);
|
|
}
|
|
|
|
static const struct pipe_buf_operations tracing_pipe_buf_ops = {
|
|
.can_merge = 0,
|
|
.confirm = generic_pipe_buf_confirm,
|
|
.release = generic_pipe_buf_release,
|
|
.steal = generic_pipe_buf_steal,
|
|
.get = generic_pipe_buf_get,
|
|
};
|
|
|
|
static size_t
|
|
tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter)
|
|
{
|
|
size_t count;
|
|
int save_len;
|
|
int ret;
|
|
|
|
/* Seq buffer is page-sized, exactly what we need. */
|
|
for (;;) {
|
|
save_len = iter->seq.seq.len;
|
|
ret = print_trace_line(iter);
|
|
|
|
if (trace_seq_has_overflowed(&iter->seq)) {
|
|
iter->seq.seq.len = save_len;
|
|
break;
|
|
}
|
|
|
|
/*
|
|
* This should not be hit, because it should only
|
|
* be set if the iter->seq overflowed. But check it
|
|
* anyway to be safe.
|
|
*/
|
|
if (ret == TRACE_TYPE_PARTIAL_LINE) {
|
|
iter->seq.seq.len = save_len;
|
|
break;
|
|
}
|
|
|
|
count = trace_seq_used(&iter->seq) - save_len;
|
|
if (rem < count) {
|
|
rem = 0;
|
|
iter->seq.seq.len = save_len;
|
|
break;
|
|
}
|
|
|
|
if (ret != TRACE_TYPE_NO_CONSUME)
|
|
trace_consume(iter);
|
|
rem -= count;
|
|
if (!trace_find_next_entry_inc(iter)) {
|
|
rem = 0;
|
|
iter->ent = NULL;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return rem;
|
|
}
|
|
|
|
static ssize_t tracing_splice_read_pipe(struct file *filp,
|
|
loff_t *ppos,
|
|
struct pipe_inode_info *pipe,
|
|
size_t len,
|
|
unsigned int flags)
|
|
{
|
|
struct page *pages_def[PIPE_DEF_BUFFERS];
|
|
struct partial_page partial_def[PIPE_DEF_BUFFERS];
|
|
struct trace_iterator *iter = filp->private_data;
|
|
struct splice_pipe_desc spd = {
|
|
.pages = pages_def,
|
|
.partial = partial_def,
|
|
.nr_pages = 0, /* This gets updated below. */
|
|
.nr_pages_max = PIPE_DEF_BUFFERS,
|
|
.flags = flags,
|
|
.ops = &tracing_pipe_buf_ops,
|
|
.spd_release = tracing_spd_release_pipe,
|
|
};
|
|
ssize_t ret;
|
|
size_t rem;
|
|
unsigned int i;
|
|
|
|
if (splice_grow_spd(pipe, &spd))
|
|
return -ENOMEM;
|
|
|
|
mutex_lock(&iter->mutex);
|
|
|
|
if (iter->trace->splice_read) {
|
|
ret = iter->trace->splice_read(iter, filp,
|
|
ppos, pipe, len, flags);
|
|
if (ret)
|
|
goto out_err;
|
|
}
|
|
|
|
ret = tracing_wait_pipe(filp);
|
|
if (ret <= 0)
|
|
goto out_err;
|
|
|
|
if (!iter->ent && !trace_find_next_entry_inc(iter)) {
|
|
ret = -EFAULT;
|
|
goto out_err;
|
|
}
|
|
|
|
trace_event_read_lock();
|
|
trace_access_lock(iter->cpu_file);
|
|
|
|
/* Fill as many pages as possible. */
|
|
for (i = 0, rem = len; i < spd.nr_pages_max && rem; i++) {
|
|
spd.pages[i] = alloc_page(GFP_KERNEL);
|
|
if (!spd.pages[i])
|
|
break;
|
|
|
|
rem = tracing_fill_pipe_page(rem, iter);
|
|
|
|
/* Copy the data into the page, so we can start over. */
|
|
ret = trace_seq_to_buffer(&iter->seq,
|
|
page_address(spd.pages[i]),
|
|
trace_seq_used(&iter->seq));
|
|
if (ret < 0) {
|
|
__free_page(spd.pages[i]);
|
|
break;
|
|
}
|
|
spd.partial[i].offset = 0;
|
|
spd.partial[i].len = trace_seq_used(&iter->seq);
|
|
|
|
trace_seq_init(&iter->seq);
|
|
}
|
|
|
|
trace_access_unlock(iter->cpu_file);
|
|
trace_event_read_unlock();
|
|
mutex_unlock(&iter->mutex);
|
|
|
|
spd.nr_pages = i;
|
|
|
|
if (i)
|
|
ret = splice_to_pipe(pipe, &spd);
|
|
else
|
|
ret = 0;
|
|
out:
|
|
splice_shrink_spd(&spd);
|
|
return ret;
|
|
|
|
out_err:
|
|
mutex_unlock(&iter->mutex);
|
|
goto out;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_entries_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct inode *inode = file_inode(filp);
|
|
struct trace_array *tr = inode->i_private;
|
|
int cpu = tracing_get_cpu(inode);
|
|
char buf[64];
|
|
int r = 0;
|
|
ssize_t ret;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
if (cpu == RING_BUFFER_ALL_CPUS) {
|
|
int cpu, buf_size_same;
|
|
unsigned long size;
|
|
|
|
size = 0;
|
|
buf_size_same = 1;
|
|
/* check if all cpu sizes are same */
|
|
for_each_tracing_cpu(cpu) {
|
|
/* fill in the size from first enabled cpu */
|
|
if (size == 0)
|
|
size = per_cpu_ptr(tr->trace_buffer.data, cpu)->entries;
|
|
if (size != per_cpu_ptr(tr->trace_buffer.data, cpu)->entries) {
|
|
buf_size_same = 0;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (buf_size_same) {
|
|
if (!ring_buffer_expanded)
|
|
r = sprintf(buf, "%lu (expanded: %lu)\n",
|
|
size >> 10,
|
|
trace_buf_size >> 10);
|
|
else
|
|
r = sprintf(buf, "%lu\n", size >> 10);
|
|
} else
|
|
r = sprintf(buf, "X\n");
|
|
} else
|
|
r = sprintf(buf, "%lu\n", per_cpu_ptr(tr->trace_buffer.data, cpu)->entries >> 10);
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
ret = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_entries_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct inode *inode = file_inode(filp);
|
|
struct trace_array *tr = inode->i_private;
|
|
unsigned long val;
|
|
int ret;
|
|
|
|
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* must have at least 1 entry */
|
|
if (!val)
|
|
return -EINVAL;
|
|
|
|
/* value is in KB */
|
|
val <<= 10;
|
|
ret = tracing_resize_ring_buffer(tr, val, tracing_get_cpu(inode));
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
*ppos += cnt;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_total_entries_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = filp->private_data;
|
|
char buf[64];
|
|
int r, cpu;
|
|
unsigned long size = 0, expanded_size = 0;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
for_each_tracing_cpu(cpu) {
|
|
size += per_cpu_ptr(tr->trace_buffer.data, cpu)->entries >> 10;
|
|
if (!ring_buffer_expanded)
|
|
expanded_size += trace_buf_size >> 10;
|
|
}
|
|
if (ring_buffer_expanded)
|
|
r = sprintf(buf, "%lu\n", size);
|
|
else
|
|
r = sprintf(buf, "%lu (expanded: %lu)\n", size, expanded_size);
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_free_buffer_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
/*
|
|
* There is no need to read what the user has written, this function
|
|
* is just to make sure that there is no error when "echo" is used
|
|
*/
|
|
|
|
*ppos += cnt;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static int
|
|
tracing_free_buffer_release(struct inode *inode, struct file *filp)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
|
|
/* disable tracing ? */
|
|
if (tr->trace_flags & TRACE_ITER_STOP_ON_FREE)
|
|
tracer_tracing_off(tr);
|
|
/* resize the ring buffer to 0 */
|
|
tracing_resize_ring_buffer(tr, 0, RING_BUFFER_ALL_CPUS);
|
|
|
|
trace_array_put(tr);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_mark_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *fpos)
|
|
{
|
|
unsigned long addr = (unsigned long)ubuf;
|
|
struct trace_array *tr = filp->private_data;
|
|
struct ring_buffer_event *event;
|
|
struct ring_buffer *buffer;
|
|
struct print_entry *entry;
|
|
unsigned long irq_flags;
|
|
struct page *pages[2];
|
|
void *map_page[2];
|
|
int nr_pages = 1;
|
|
ssize_t written;
|
|
int offset;
|
|
int size;
|
|
int len;
|
|
int ret;
|
|
int i;
|
|
|
|
if (tracing_disabled)
|
|
return -EINVAL;
|
|
|
|
if (!(tr->trace_flags & TRACE_ITER_MARKERS))
|
|
return -EINVAL;
|
|
|
|
if (cnt > TRACE_BUF_SIZE)
|
|
cnt = TRACE_BUF_SIZE;
|
|
|
|
/*
|
|
* Userspace is injecting traces into the kernel trace buffer.
|
|
* We want to be as non intrusive as possible.
|
|
* To do so, we do not want to allocate any special buffers
|
|
* or take any locks, but instead write the userspace data
|
|
* straight into the ring buffer.
|
|
*
|
|
* First we need to pin the userspace buffer into memory,
|
|
* which, most likely it is, because it just referenced it.
|
|
* But there's no guarantee that it is. By using get_user_pages_fast()
|
|
* and kmap_atomic/kunmap_atomic() we can get access to the
|
|
* pages directly. We then write the data directly into the
|
|
* ring buffer.
|
|
*/
|
|
BUILD_BUG_ON(TRACE_BUF_SIZE >= PAGE_SIZE);
|
|
|
|
/* check if we cross pages */
|
|
if ((addr & PAGE_MASK) != ((addr + cnt) & PAGE_MASK))
|
|
nr_pages = 2;
|
|
|
|
offset = addr & (PAGE_SIZE - 1);
|
|
addr &= PAGE_MASK;
|
|
|
|
ret = get_user_pages_fast(addr, nr_pages, 0, pages);
|
|
if (ret < nr_pages) {
|
|
while (--ret >= 0)
|
|
put_page(pages[ret]);
|
|
written = -EFAULT;
|
|
goto out;
|
|
}
|
|
|
|
for (i = 0; i < nr_pages; i++)
|
|
map_page[i] = kmap_atomic(pages[i]);
|
|
|
|
local_save_flags(irq_flags);
|
|
size = sizeof(*entry) + cnt + 2; /* possible \n added */
|
|
buffer = tr->trace_buffer.buffer;
|
|
event = trace_buffer_lock_reserve(buffer, TRACE_PRINT, size,
|
|
irq_flags, preempt_count());
|
|
if (!event) {
|
|
/* Ring buffer disabled, return as if not open for write */
|
|
written = -EBADF;
|
|
goto out_unlock;
|
|
}
|
|
|
|
entry = ring_buffer_event_data(event);
|
|
entry->ip = _THIS_IP_;
|
|
|
|
if (nr_pages == 2) {
|
|
len = PAGE_SIZE - offset;
|
|
memcpy(&entry->buf, map_page[0] + offset, len);
|
|
memcpy(&entry->buf[len], map_page[1], cnt - len);
|
|
} else
|
|
memcpy(&entry->buf, map_page[0] + offset, cnt);
|
|
|
|
if (entry->buf[cnt - 1] != '\n') {
|
|
entry->buf[cnt] = '\n';
|
|
entry->buf[cnt + 1] = '\0';
|
|
stm_log(OST_ENTITY_TRACE_MARKER, entry->buf, cnt + 2);
|
|
} else {
|
|
entry->buf[cnt] = '\0';
|
|
stm_log(OST_ENTITY_TRACE_MARKER, entry->buf, cnt + 1);
|
|
}
|
|
|
|
__buffer_unlock_commit(buffer, event);
|
|
|
|
written = cnt;
|
|
|
|
*fpos += written;
|
|
|
|
out_unlock:
|
|
for (i = nr_pages - 1; i >= 0; i--) {
|
|
kunmap_atomic(map_page[i]);
|
|
put_page(pages[i]);
|
|
}
|
|
out:
|
|
return written;
|
|
}
|
|
|
|
static int tracing_clock_show(struct seq_file *m, void *v)
|
|
{
|
|
struct trace_array *tr = m->private;
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(trace_clocks); i++)
|
|
seq_printf(m,
|
|
"%s%s%s%s", i ? " " : "",
|
|
i == tr->clock_id ? "[" : "", trace_clocks[i].name,
|
|
i == tr->clock_id ? "]" : "");
|
|
seq_putc(m, '\n');
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int tracing_set_clock(struct trace_array *tr, const char *clockstr)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(trace_clocks); i++) {
|
|
if (strcmp(trace_clocks[i].name, clockstr) == 0)
|
|
break;
|
|
}
|
|
if (i == ARRAY_SIZE(trace_clocks))
|
|
return -EINVAL;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
tr->clock_id = i;
|
|
|
|
ring_buffer_set_clock(tr->trace_buffer.buffer, trace_clocks[i].func);
|
|
|
|
/*
|
|
* New clock may not be consistent with the previous clock.
|
|
* Reset the buffer so that it doesn't have incomparable timestamps.
|
|
*/
|
|
tracing_reset_online_cpus(&tr->trace_buffer);
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (tr->flags & TRACE_ARRAY_FL_GLOBAL && tr->max_buffer.buffer)
|
|
ring_buffer_set_clock(tr->max_buffer.buffer, trace_clocks[i].func);
|
|
tracing_reset_online_cpus(&tr->max_buffer);
|
|
#endif
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t tracing_clock_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *fpos)
|
|
{
|
|
struct seq_file *m = filp->private_data;
|
|
struct trace_array *tr = m->private;
|
|
char buf[64];
|
|
const char *clockstr;
|
|
int ret;
|
|
|
|
if (cnt >= sizeof(buf))
|
|
return -EINVAL;
|
|
|
|
if (copy_from_user(buf, ubuf, cnt))
|
|
return -EFAULT;
|
|
|
|
buf[cnt] = 0;
|
|
|
|
clockstr = strstrip(buf);
|
|
|
|
ret = tracing_set_clock(tr, clockstr);
|
|
if (ret)
|
|
return ret;
|
|
|
|
*fpos += cnt;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static int tracing_clock_open(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
int ret;
|
|
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
if (trace_array_get(tr))
|
|
return -ENODEV;
|
|
|
|
ret = single_open(file, tracing_clock_show, inode->i_private);
|
|
if (ret < 0)
|
|
trace_array_put(tr);
|
|
|
|
return ret;
|
|
}
|
|
|
|
struct ftrace_buffer_info {
|
|
struct trace_iterator iter;
|
|
void *spare;
|
|
unsigned int read;
|
|
};
|
|
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
static int tracing_snapshot_open(struct inode *inode, struct file *file)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
struct trace_iterator *iter;
|
|
struct seq_file *m;
|
|
int ret = 0;
|
|
|
|
if (trace_array_get(tr) < 0)
|
|
return -ENODEV;
|
|
|
|
if (file->f_mode & FMODE_READ) {
|
|
iter = __tracing_open(inode, file, true);
|
|
if (IS_ERR(iter))
|
|
ret = PTR_ERR(iter);
|
|
} else {
|
|
/* Writes still need the seq_file to hold the private data */
|
|
ret = -ENOMEM;
|
|
m = kzalloc(sizeof(*m), GFP_KERNEL);
|
|
if (!m)
|
|
goto out;
|
|
iter = kzalloc(sizeof(*iter), GFP_KERNEL);
|
|
if (!iter) {
|
|
kfree(m);
|
|
goto out;
|
|
}
|
|
ret = 0;
|
|
|
|
iter->tr = tr;
|
|
iter->trace_buffer = &tr->max_buffer;
|
|
iter->cpu_file = tracing_get_cpu(inode);
|
|
m->private = iter;
|
|
file->private_data = m;
|
|
}
|
|
out:
|
|
if (ret < 0)
|
|
trace_array_put(tr);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt,
|
|
loff_t *ppos)
|
|
{
|
|
struct seq_file *m = filp->private_data;
|
|
struct trace_iterator *iter = m->private;
|
|
struct trace_array *tr = iter->tr;
|
|
unsigned long val;
|
|
int ret;
|
|
|
|
ret = tracing_update_buffers();
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
if (tr->current_trace->use_max_tr) {
|
|
ret = -EBUSY;
|
|
goto out;
|
|
}
|
|
|
|
switch (val) {
|
|
case 0:
|
|
if (iter->cpu_file != RING_BUFFER_ALL_CPUS) {
|
|
ret = -EINVAL;
|
|
break;
|
|
}
|
|
if (tr->allocated_snapshot)
|
|
free_snapshot(tr);
|
|
break;
|
|
case 1:
|
|
/* Only allow per-cpu swap if the ring buffer supports it */
|
|
#ifndef CONFIG_RING_BUFFER_ALLOW_SWAP
|
|
if (iter->cpu_file != RING_BUFFER_ALL_CPUS) {
|
|
ret = -EINVAL;
|
|
break;
|
|
}
|
|
#endif
|
|
if (!tr->allocated_snapshot) {
|
|
ret = alloc_snapshot(tr);
|
|
if (ret < 0)
|
|
break;
|
|
}
|
|
local_irq_disable();
|
|
/* Now, we're going to swap */
|
|
if (iter->cpu_file == RING_BUFFER_ALL_CPUS)
|
|
update_max_tr(tr, current, smp_processor_id());
|
|
else
|
|
update_max_tr_single(tr, current, iter->cpu_file);
|
|
local_irq_enable();
|
|
break;
|
|
default:
|
|
if (tr->allocated_snapshot) {
|
|
if (iter->cpu_file == RING_BUFFER_ALL_CPUS)
|
|
tracing_reset_online_cpus(&tr->max_buffer);
|
|
else
|
|
tracing_reset(&tr->max_buffer, iter->cpu_file);
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (ret >= 0) {
|
|
*ppos += cnt;
|
|
ret = cnt;
|
|
}
|
|
out:
|
|
mutex_unlock(&trace_types_lock);
|
|
return ret;
|
|
}
|
|
|
|
static int tracing_snapshot_release(struct inode *inode, struct file *file)
|
|
{
|
|
struct seq_file *m = file->private_data;
|
|
int ret;
|
|
|
|
ret = tracing_release(inode, file);
|
|
|
|
if (file->f_mode & FMODE_READ)
|
|
return ret;
|
|
|
|
/* If write only, the seq_file is just a stub */
|
|
if (m)
|
|
kfree(m->private);
|
|
kfree(m);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int tracing_buffers_open(struct inode *inode, struct file *filp);
|
|
static ssize_t tracing_buffers_read(struct file *filp, char __user *ubuf,
|
|
size_t count, loff_t *ppos);
|
|
static int tracing_buffers_release(struct inode *inode, struct file *file);
|
|
static ssize_t tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
|
struct pipe_inode_info *pipe, size_t len, unsigned int flags);
|
|
|
|
static int snapshot_raw_open(struct inode *inode, struct file *filp)
|
|
{
|
|
struct ftrace_buffer_info *info;
|
|
int ret;
|
|
|
|
ret = tracing_buffers_open(inode, filp);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
info = filp->private_data;
|
|
|
|
if (info->iter.trace->use_max_tr) {
|
|
tracing_buffers_release(inode, filp);
|
|
return -EBUSY;
|
|
}
|
|
|
|
info->iter.snapshot = true;
|
|
info->iter.trace_buffer = &info->iter.tr->max_buffer;
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* CONFIG_TRACER_SNAPSHOT */
|
|
|
|
|
|
static const struct file_operations tracing_thresh_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = tracing_thresh_read,
|
|
.write = tracing_thresh_write,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
|
|
#if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)
|
|
static const struct file_operations tracing_max_lat_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = tracing_max_lat_read,
|
|
.write = tracing_max_lat_write,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
#endif
|
|
|
|
static const struct file_operations set_tracer_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = tracing_set_trace_read,
|
|
.write = tracing_set_trace_write,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
|
|
static const struct file_operations tracing_pipe_fops = {
|
|
.open = tracing_open_pipe,
|
|
.poll = tracing_poll_pipe,
|
|
.read = tracing_read_pipe,
|
|
.splice_read = tracing_splice_read_pipe,
|
|
.release = tracing_release_pipe,
|
|
.llseek = no_llseek,
|
|
};
|
|
|
|
static const struct file_operations tracing_entries_fops = {
|
|
.open = tracing_open_generic_tr,
|
|
.read = tracing_entries_read,
|
|
.write = tracing_entries_write,
|
|
.llseek = generic_file_llseek,
|
|
.release = tracing_release_generic_tr,
|
|
};
|
|
|
|
static const struct file_operations tracing_total_entries_fops = {
|
|
.open = tracing_open_generic_tr,
|
|
.read = tracing_total_entries_read,
|
|
.llseek = generic_file_llseek,
|
|
.release = tracing_release_generic_tr,
|
|
};
|
|
|
|
static const struct file_operations tracing_free_buffer_fops = {
|
|
.open = tracing_open_generic_tr,
|
|
.write = tracing_free_buffer_write,
|
|
.release = tracing_free_buffer_release,
|
|
};
|
|
|
|
static const struct file_operations tracing_mark_fops = {
|
|
.open = tracing_open_generic_tr,
|
|
.write = tracing_mark_write,
|
|
.llseek = generic_file_llseek,
|
|
.release = tracing_release_generic_tr,
|
|
};
|
|
|
|
static const struct file_operations trace_clock_fops = {
|
|
.open = tracing_clock_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = tracing_single_release_tr,
|
|
.write = tracing_clock_write,
|
|
};
|
|
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
static const struct file_operations snapshot_fops = {
|
|
.open = tracing_snapshot_open,
|
|
.read = seq_read,
|
|
.write = tracing_snapshot_write,
|
|
.llseek = tracing_lseek,
|
|
.release = tracing_snapshot_release,
|
|
};
|
|
|
|
static const struct file_operations snapshot_raw_fops = {
|
|
.open = snapshot_raw_open,
|
|
.read = tracing_buffers_read,
|
|
.release = tracing_buffers_release,
|
|
.splice_read = tracing_buffers_splice_read,
|
|
.llseek = no_llseek,
|
|
};
|
|
|
|
#endif /* CONFIG_TRACER_SNAPSHOT */
|
|
|
|
static int tracing_buffers_open(struct inode *inode, struct file *filp)
|
|
{
|
|
struct trace_array *tr = inode->i_private;
|
|
struct ftrace_buffer_info *info;
|
|
int ret;
|
|
|
|
if (tracing_disabled)
|
|
return -ENODEV;
|
|
|
|
if (trace_array_get(tr) < 0)
|
|
return -ENODEV;
|
|
|
|
info = kzalloc(sizeof(*info), GFP_KERNEL);
|
|
if (!info) {
|
|
trace_array_put(tr);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
info->iter.tr = tr;
|
|
info->iter.cpu_file = tracing_get_cpu(inode);
|
|
info->iter.trace = tr->current_trace;
|
|
info->iter.trace_buffer = &tr->trace_buffer;
|
|
info->spare = NULL;
|
|
/* Force reading ring buffer for first read */
|
|
info->read = (unsigned int)-1;
|
|
|
|
filp->private_data = info;
|
|
|
|
tr->current_trace->ref++;
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
ret = nonseekable_open(inode, filp);
|
|
if (ret < 0)
|
|
trace_array_put(tr);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static unsigned int
|
|
tracing_buffers_poll(struct file *filp, poll_table *poll_table)
|
|
{
|
|
struct ftrace_buffer_info *info = filp->private_data;
|
|
struct trace_iterator *iter = &info->iter;
|
|
|
|
return trace_poll(iter, filp, poll_table);
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_buffers_read(struct file *filp, char __user *ubuf,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
struct ftrace_buffer_info *info = filp->private_data;
|
|
struct trace_iterator *iter = &info->iter;
|
|
ssize_t ret;
|
|
ssize_t size;
|
|
|
|
if (!count)
|
|
return 0;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (iter->snapshot && iter->tr->current_trace->use_max_tr)
|
|
return -EBUSY;
|
|
#endif
|
|
|
|
if (!info->spare)
|
|
info->spare = ring_buffer_alloc_read_page(iter->trace_buffer->buffer,
|
|
iter->cpu_file);
|
|
if (!info->spare)
|
|
return -ENOMEM;
|
|
|
|
/* Do we have previous read data to read? */
|
|
if (info->read < PAGE_SIZE)
|
|
goto read;
|
|
|
|
again:
|
|
trace_access_lock(iter->cpu_file);
|
|
ret = ring_buffer_read_page(iter->trace_buffer->buffer,
|
|
&info->spare,
|
|
count,
|
|
iter->cpu_file, 0);
|
|
trace_access_unlock(iter->cpu_file);
|
|
|
|
if (ret < 0) {
|
|
if (trace_empty(iter)) {
|
|
if ((filp->f_flags & O_NONBLOCK))
|
|
return -EAGAIN;
|
|
|
|
ret = wait_on_pipe(iter, false);
|
|
if (ret)
|
|
return ret;
|
|
|
|
goto again;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
info->read = 0;
|
|
read:
|
|
size = PAGE_SIZE - info->read;
|
|
if (size > count)
|
|
size = count;
|
|
|
|
ret = copy_to_user(ubuf, info->spare + info->read, size);
|
|
if (ret == size)
|
|
return -EFAULT;
|
|
|
|
size -= ret;
|
|
|
|
*ppos += size;
|
|
info->read += size;
|
|
|
|
return size;
|
|
}
|
|
|
|
static int tracing_buffers_release(struct inode *inode, struct file *file)
|
|
{
|
|
struct ftrace_buffer_info *info = file->private_data;
|
|
struct trace_iterator *iter = &info->iter;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
iter->tr->current_trace->ref--;
|
|
|
|
__trace_array_put(iter->tr);
|
|
|
|
if (info->spare)
|
|
ring_buffer_free_read_page(iter->trace_buffer->buffer, info->spare);
|
|
kfree(info);
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
struct buffer_ref {
|
|
struct ring_buffer *buffer;
|
|
void *page;
|
|
int ref;
|
|
};
|
|
|
|
static void buffer_pipe_buf_release(struct pipe_inode_info *pipe,
|
|
struct pipe_buffer *buf)
|
|
{
|
|
struct buffer_ref *ref = (struct buffer_ref *)buf->private;
|
|
|
|
if (--ref->ref)
|
|
return;
|
|
|
|
ring_buffer_free_read_page(ref->buffer, ref->page);
|
|
kfree(ref);
|
|
buf->private = 0;
|
|
}
|
|
|
|
static void buffer_pipe_buf_get(struct pipe_inode_info *pipe,
|
|
struct pipe_buffer *buf)
|
|
{
|
|
struct buffer_ref *ref = (struct buffer_ref *)buf->private;
|
|
|
|
ref->ref++;
|
|
}
|
|
|
|
/* Pipe buffer operations for a buffer. */
|
|
static const struct pipe_buf_operations buffer_pipe_buf_ops = {
|
|
.can_merge = 0,
|
|
.confirm = generic_pipe_buf_confirm,
|
|
.release = buffer_pipe_buf_release,
|
|
.steal = generic_pipe_buf_steal,
|
|
.get = buffer_pipe_buf_get,
|
|
};
|
|
|
|
/*
|
|
* Callback from splice_to_pipe(), if we need to release some pages
|
|
* at the end of the spd in case we error'ed out in filling the pipe.
|
|
*/
|
|
static void buffer_spd_release(struct splice_pipe_desc *spd, unsigned int i)
|
|
{
|
|
struct buffer_ref *ref =
|
|
(struct buffer_ref *)spd->partial[i].private;
|
|
|
|
if (--ref->ref)
|
|
return;
|
|
|
|
ring_buffer_free_read_page(ref->buffer, ref->page);
|
|
kfree(ref);
|
|
spd->partial[i].private = 0;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_buffers_splice_read(struct file *file, loff_t *ppos,
|
|
struct pipe_inode_info *pipe, size_t len,
|
|
unsigned int flags)
|
|
{
|
|
struct ftrace_buffer_info *info = file->private_data;
|
|
struct trace_iterator *iter = &info->iter;
|
|
struct partial_page partial_def[PIPE_DEF_BUFFERS];
|
|
struct page *pages_def[PIPE_DEF_BUFFERS];
|
|
struct splice_pipe_desc spd = {
|
|
.pages = pages_def,
|
|
.partial = partial_def,
|
|
.nr_pages_max = PIPE_DEF_BUFFERS,
|
|
.flags = flags,
|
|
.ops = &buffer_pipe_buf_ops,
|
|
.spd_release = buffer_spd_release,
|
|
};
|
|
struct buffer_ref *ref;
|
|
int entries, size, i;
|
|
ssize_t ret = 0;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
if (iter->snapshot && iter->tr->current_trace->use_max_tr)
|
|
return -EBUSY;
|
|
#endif
|
|
|
|
if (*ppos & (PAGE_SIZE - 1))
|
|
return -EINVAL;
|
|
|
|
if (len & (PAGE_SIZE - 1)) {
|
|
if (len < PAGE_SIZE)
|
|
return -EINVAL;
|
|
len &= PAGE_MASK;
|
|
}
|
|
|
|
if (splice_grow_spd(pipe, &spd))
|
|
return -ENOMEM;
|
|
|
|
again:
|
|
trace_access_lock(iter->cpu_file);
|
|
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
|
|
|
|
for (i = 0; i < spd.nr_pages_max && len && entries; i++, len -= PAGE_SIZE) {
|
|
struct page *page;
|
|
int r;
|
|
|
|
ref = kzalloc(sizeof(*ref), GFP_KERNEL);
|
|
if (!ref) {
|
|
ret = -ENOMEM;
|
|
break;
|
|
}
|
|
|
|
ref->ref = 1;
|
|
ref->buffer = iter->trace_buffer->buffer;
|
|
ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
|
|
if (!ref->page) {
|
|
ret = -ENOMEM;
|
|
kfree(ref);
|
|
break;
|
|
}
|
|
|
|
r = ring_buffer_read_page(ref->buffer, &ref->page,
|
|
len, iter->cpu_file, 1);
|
|
if (r < 0) {
|
|
ring_buffer_free_read_page(ref->buffer, ref->page);
|
|
kfree(ref);
|
|
break;
|
|
}
|
|
|
|
/*
|
|
* zero out any left over data, this is going to
|
|
* user land.
|
|
*/
|
|
size = ring_buffer_page_len(ref->page);
|
|
if (size < PAGE_SIZE)
|
|
memset(ref->page + size, 0, PAGE_SIZE - size);
|
|
|
|
page = virt_to_page(ref->page);
|
|
|
|
spd.pages[i] = page;
|
|
spd.partial[i].len = PAGE_SIZE;
|
|
spd.partial[i].offset = 0;
|
|
spd.partial[i].private = (unsigned long)ref;
|
|
spd.nr_pages++;
|
|
*ppos += PAGE_SIZE;
|
|
|
|
entries = ring_buffer_entries_cpu(iter->trace_buffer->buffer, iter->cpu_file);
|
|
}
|
|
|
|
trace_access_unlock(iter->cpu_file);
|
|
spd.nr_pages = i;
|
|
|
|
/* did we read anything? */
|
|
if (!spd.nr_pages) {
|
|
if (ret)
|
|
goto out;
|
|
|
|
ret = -EAGAIN;
|
|
if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
|
|
goto out;
|
|
|
|
ret = wait_on_pipe(iter, true);
|
|
if (ret)
|
|
goto out;
|
|
|
|
goto again;
|
|
}
|
|
|
|
ret = splice_to_pipe(pipe, &spd);
|
|
out:
|
|
splice_shrink_spd(&spd);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static const struct file_operations tracing_buffers_fops = {
|
|
.open = tracing_buffers_open,
|
|
.read = tracing_buffers_read,
|
|
.poll = tracing_buffers_poll,
|
|
.release = tracing_buffers_release,
|
|
.splice_read = tracing_buffers_splice_read,
|
|
.llseek = no_llseek,
|
|
};
|
|
|
|
static ssize_t
|
|
tracing_stats_read(struct file *filp, char __user *ubuf,
|
|
size_t count, loff_t *ppos)
|
|
{
|
|
struct inode *inode = file_inode(filp);
|
|
struct trace_array *tr = inode->i_private;
|
|
struct trace_buffer *trace_buf = &tr->trace_buffer;
|
|
int cpu = tracing_get_cpu(inode);
|
|
struct trace_seq *s;
|
|
unsigned long cnt;
|
|
unsigned long long t;
|
|
unsigned long usec_rem;
|
|
|
|
s = kmalloc(sizeof(*s), GFP_KERNEL);
|
|
if (!s)
|
|
return -ENOMEM;
|
|
|
|
trace_seq_init(s);
|
|
|
|
cnt = ring_buffer_entries_cpu(trace_buf->buffer, cpu);
|
|
trace_seq_printf(s, "entries: %ld\n", cnt);
|
|
|
|
cnt = ring_buffer_overrun_cpu(trace_buf->buffer, cpu);
|
|
trace_seq_printf(s, "overrun: %ld\n", cnt);
|
|
|
|
cnt = ring_buffer_commit_overrun_cpu(trace_buf->buffer, cpu);
|
|
trace_seq_printf(s, "commit overrun: %ld\n", cnt);
|
|
|
|
cnt = ring_buffer_bytes_cpu(trace_buf->buffer, cpu);
|
|
trace_seq_printf(s, "bytes: %ld\n", cnt);
|
|
|
|
if (trace_clocks[tr->clock_id].in_ns) {
|
|
/* local or global for trace_clock */
|
|
t = ns2usecs(ring_buffer_oldest_event_ts(trace_buf->buffer, cpu));
|
|
usec_rem = do_div(t, USEC_PER_SEC);
|
|
trace_seq_printf(s, "oldest event ts: %5llu.%06lu\n",
|
|
t, usec_rem);
|
|
|
|
t = ns2usecs(ring_buffer_time_stamp(trace_buf->buffer, cpu));
|
|
usec_rem = do_div(t, USEC_PER_SEC);
|
|
trace_seq_printf(s, "now ts: %5llu.%06lu\n", t, usec_rem);
|
|
} else {
|
|
/* counter or tsc mode for trace_clock */
|
|
trace_seq_printf(s, "oldest event ts: %llu\n",
|
|
ring_buffer_oldest_event_ts(trace_buf->buffer, cpu));
|
|
|
|
trace_seq_printf(s, "now ts: %llu\n",
|
|
ring_buffer_time_stamp(trace_buf->buffer, cpu));
|
|
}
|
|
|
|
cnt = ring_buffer_dropped_events_cpu(trace_buf->buffer, cpu);
|
|
trace_seq_printf(s, "dropped events: %ld\n", cnt);
|
|
|
|
cnt = ring_buffer_read_events_cpu(trace_buf->buffer, cpu);
|
|
trace_seq_printf(s, "read events: %ld\n", cnt);
|
|
|
|
count = simple_read_from_buffer(ubuf, count, ppos,
|
|
s->buffer, trace_seq_used(s));
|
|
|
|
kfree(s);
|
|
|
|
return count;
|
|
}
|
|
|
|
static const struct file_operations tracing_stats_fops = {
|
|
.open = tracing_open_generic_tr,
|
|
.read = tracing_stats_read,
|
|
.llseek = generic_file_llseek,
|
|
.release = tracing_release_generic_tr,
|
|
};
|
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
|
|
|
int __weak ftrace_arch_read_dyn_info(char *buf, int size)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t
|
|
tracing_read_dyn_info(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
static char ftrace_dyn_info_buffer[1024];
|
|
static DEFINE_MUTEX(dyn_info_mutex);
|
|
unsigned long *p = filp->private_data;
|
|
char *buf = ftrace_dyn_info_buffer;
|
|
int size = ARRAY_SIZE(ftrace_dyn_info_buffer);
|
|
int r;
|
|
|
|
mutex_lock(&dyn_info_mutex);
|
|
r = sprintf(buf, "%ld ", *p);
|
|
|
|
r += ftrace_arch_read_dyn_info(buf+r, (size-1)-r);
|
|
buf[r++] = '\n';
|
|
|
|
r = simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
|
|
|
|
mutex_unlock(&dyn_info_mutex);
|
|
|
|
return r;
|
|
}
|
|
|
|
static const struct file_operations tracing_dyn_info_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = tracing_read_dyn_info,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
#endif /* CONFIG_DYNAMIC_FTRACE */
|
|
|
|
#if defined(CONFIG_TRACER_SNAPSHOT) && defined(CONFIG_DYNAMIC_FTRACE)
|
|
static void
|
|
ftrace_snapshot(unsigned long ip, unsigned long parent_ip, void **data)
|
|
{
|
|
tracing_snapshot();
|
|
}
|
|
|
|
static void
|
|
ftrace_count_snapshot(unsigned long ip, unsigned long parent_ip, void **data)
|
|
{
|
|
unsigned long *count = (long *)data;
|
|
|
|
if (!*count)
|
|
return;
|
|
|
|
if (*count != -1)
|
|
(*count)--;
|
|
|
|
tracing_snapshot();
|
|
}
|
|
|
|
static int
|
|
ftrace_snapshot_print(struct seq_file *m, unsigned long ip,
|
|
struct ftrace_probe_ops *ops, void *data)
|
|
{
|
|
long count = (long)data;
|
|
|
|
seq_printf(m, "%ps:", (void *)ip);
|
|
|
|
seq_puts(m, "snapshot");
|
|
|
|
if (count == -1)
|
|
seq_puts(m, ":unlimited\n");
|
|
else
|
|
seq_printf(m, ":count=%ld\n", count);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct ftrace_probe_ops snapshot_probe_ops = {
|
|
.func = ftrace_snapshot,
|
|
.print = ftrace_snapshot_print,
|
|
};
|
|
|
|
static struct ftrace_probe_ops snapshot_count_probe_ops = {
|
|
.func = ftrace_count_snapshot,
|
|
.print = ftrace_snapshot_print,
|
|
};
|
|
|
|
static int
|
|
ftrace_trace_snapshot_callback(struct ftrace_hash *hash,
|
|
char *glob, char *cmd, char *param, int enable)
|
|
{
|
|
struct ftrace_probe_ops *ops;
|
|
void *count = (void *)-1;
|
|
char *number;
|
|
int ret;
|
|
|
|
/* hash funcs only work with set_ftrace_filter */
|
|
if (!enable)
|
|
return -EINVAL;
|
|
|
|
ops = param ? &snapshot_count_probe_ops : &snapshot_probe_ops;
|
|
|
|
if (glob[0] == '!') {
|
|
unregister_ftrace_function_probe_func(glob+1, ops);
|
|
return 0;
|
|
}
|
|
|
|
if (!param)
|
|
goto out_reg;
|
|
|
|
number = strsep(¶m, ":");
|
|
|
|
if (!strlen(number))
|
|
goto out_reg;
|
|
|
|
/*
|
|
* We use the callback data field (which is a pointer)
|
|
* as our counter.
|
|
*/
|
|
ret = kstrtoul(number, 0, (unsigned long *)&count);
|
|
if (ret)
|
|
return ret;
|
|
|
|
out_reg:
|
|
ret = register_ftrace_function_probe(glob, ops, count);
|
|
|
|
if (ret >= 0)
|
|
alloc_snapshot(&global_trace);
|
|
|
|
return ret < 0 ? ret : 0;
|
|
}
|
|
|
|
static struct ftrace_func_command ftrace_snapshot_cmd = {
|
|
.name = "snapshot",
|
|
.func = ftrace_trace_snapshot_callback,
|
|
};
|
|
|
|
static __init int register_snapshot_cmd(void)
|
|
{
|
|
return register_ftrace_command(&ftrace_snapshot_cmd);
|
|
}
|
|
#else
|
|
static inline __init int register_snapshot_cmd(void) { return 0; }
|
|
#endif /* defined(CONFIG_TRACER_SNAPSHOT) && defined(CONFIG_DYNAMIC_FTRACE) */
|
|
|
|
static struct dentry *tracing_get_dentry(struct trace_array *tr)
|
|
{
|
|
if (WARN_ON(!tr->dir))
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
/* Top directory uses NULL as the parent */
|
|
if (tr->flags & TRACE_ARRAY_FL_GLOBAL)
|
|
return NULL;
|
|
|
|
/* All sub buffers have a descriptor */
|
|
return tr->dir;
|
|
}
|
|
|
|
static struct dentry *tracing_dentry_percpu(struct trace_array *tr, int cpu)
|
|
{
|
|
struct dentry *d_tracer;
|
|
|
|
if (tr->percpu_dir)
|
|
return tr->percpu_dir;
|
|
|
|
d_tracer = tracing_get_dentry(tr);
|
|
if (IS_ERR(d_tracer))
|
|
return NULL;
|
|
|
|
tr->percpu_dir = tracefs_create_dir("per_cpu", d_tracer);
|
|
|
|
WARN_ONCE(!tr->percpu_dir,
|
|
"Could not create tracefs directory 'per_cpu/%d'\n", cpu);
|
|
|
|
return tr->percpu_dir;
|
|
}
|
|
|
|
static struct dentry *
|
|
trace_create_cpu_file(const char *name, umode_t mode, struct dentry *parent,
|
|
void *data, long cpu, const struct file_operations *fops)
|
|
{
|
|
struct dentry *ret = trace_create_file(name, mode, parent, data, fops);
|
|
|
|
if (ret) /* See tracing_get_cpu() */
|
|
d_inode(ret)->i_cdev = (void *)(cpu + 1);
|
|
return ret;
|
|
}
|
|
|
|
static void
|
|
tracing_init_tracefs_percpu(struct trace_array *tr, long cpu)
|
|
{
|
|
struct dentry *d_percpu = tracing_dentry_percpu(tr, cpu);
|
|
struct dentry *d_cpu;
|
|
char cpu_dir[30]; /* 30 characters should be more than enough */
|
|
|
|
if (!d_percpu)
|
|
return;
|
|
|
|
snprintf(cpu_dir, 30, "cpu%ld", cpu);
|
|
d_cpu = tracefs_create_dir(cpu_dir, d_percpu);
|
|
if (!d_cpu) {
|
|
pr_warn("Could not create tracefs '%s' entry\n", cpu_dir);
|
|
return;
|
|
}
|
|
|
|
/* per cpu trace_pipe */
|
|
trace_create_cpu_file("trace_pipe", 0444, d_cpu,
|
|
tr, cpu, &tracing_pipe_fops);
|
|
|
|
/* per cpu trace */
|
|
trace_create_cpu_file("trace", 0644, d_cpu,
|
|
tr, cpu, &tracing_fops);
|
|
|
|
trace_create_cpu_file("trace_pipe_raw", 0444, d_cpu,
|
|
tr, cpu, &tracing_buffers_fops);
|
|
|
|
trace_create_cpu_file("stats", 0444, d_cpu,
|
|
tr, cpu, &tracing_stats_fops);
|
|
|
|
trace_create_cpu_file("buffer_size_kb", 0444, d_cpu,
|
|
tr, cpu, &tracing_entries_fops);
|
|
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
trace_create_cpu_file("snapshot", 0644, d_cpu,
|
|
tr, cpu, &snapshot_fops);
|
|
|
|
trace_create_cpu_file("snapshot_raw", 0444, d_cpu,
|
|
tr, cpu, &snapshot_raw_fops);
|
|
#endif
|
|
}
|
|
|
|
#ifdef CONFIG_FTRACE_SELFTEST
|
|
/* Let selftest have access to static functions in this file */
|
|
#include "trace_selftest.c"
|
|
#endif
|
|
|
|
static ssize_t
|
|
trace_options_read(struct file *filp, char __user *ubuf, size_t cnt,
|
|
loff_t *ppos)
|
|
{
|
|
struct trace_option_dentry *topt = filp->private_data;
|
|
char *buf;
|
|
|
|
if (topt->flags->val & topt->opt->bit)
|
|
buf = "1\n";
|
|
else
|
|
buf = "0\n";
|
|
|
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
|
|
}
|
|
|
|
static ssize_t
|
|
trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt,
|
|
loff_t *ppos)
|
|
{
|
|
struct trace_option_dentry *topt = filp->private_data;
|
|
unsigned long val;
|
|
int ret;
|
|
|
|
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (val != 0 && val != 1)
|
|
return -EINVAL;
|
|
|
|
if (!!(topt->flags->val & topt->opt->bit) != val) {
|
|
mutex_lock(&trace_types_lock);
|
|
ret = __set_tracer_option(topt->tr, topt->flags,
|
|
topt->opt, !val);
|
|
mutex_unlock(&trace_types_lock);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
*ppos += cnt;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
|
|
static const struct file_operations trace_options_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = trace_options_read,
|
|
.write = trace_options_write,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
|
|
/*
|
|
* In order to pass in both the trace_array descriptor as well as the index
|
|
* to the flag that the trace option file represents, the trace_array
|
|
* has a character array of trace_flags_index[], which holds the index
|
|
* of the bit for the flag it represents. index[0] == 0, index[1] == 1, etc.
|
|
* The address of this character array is passed to the flag option file
|
|
* read/write callbacks.
|
|
*
|
|
* In order to extract both the index and the trace_array descriptor,
|
|
* get_tr_index() uses the following algorithm.
|
|
*
|
|
* idx = *ptr;
|
|
*
|
|
* As the pointer itself contains the address of the index (remember
|
|
* index[1] == 1).
|
|
*
|
|
* Then to get the trace_array descriptor, by subtracting that index
|
|
* from the ptr, we get to the start of the index itself.
|
|
*
|
|
* ptr - idx == &index[0]
|
|
*
|
|
* Then a simple container_of() from that pointer gets us to the
|
|
* trace_array descriptor.
|
|
*/
|
|
static void get_tr_index(void *data, struct trace_array **ptr,
|
|
unsigned int *pindex)
|
|
{
|
|
*pindex = *(unsigned char *)data;
|
|
|
|
*ptr = container_of(data - *pindex, struct trace_array,
|
|
trace_flags_index);
|
|
}
|
|
|
|
static ssize_t
|
|
trace_options_core_read(struct file *filp, char __user *ubuf, size_t cnt,
|
|
loff_t *ppos)
|
|
{
|
|
void *tr_index = filp->private_data;
|
|
struct trace_array *tr;
|
|
unsigned int index;
|
|
char *buf;
|
|
|
|
get_tr_index(tr_index, &tr, &index);
|
|
|
|
if (tr->trace_flags & (1 << index))
|
|
buf = "1\n";
|
|
else
|
|
buf = "0\n";
|
|
|
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, 2);
|
|
}
|
|
|
|
static ssize_t
|
|
trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
|
|
loff_t *ppos)
|
|
{
|
|
void *tr_index = filp->private_data;
|
|
struct trace_array *tr;
|
|
unsigned int index;
|
|
unsigned long val;
|
|
int ret;
|
|
|
|
get_tr_index(tr_index, &tr, &index);
|
|
|
|
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (val != 0 && val != 1)
|
|
return -EINVAL;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
ret = set_tracer_flag(tr, 1 << index, val);
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
*ppos += cnt;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static const struct file_operations trace_options_core_fops = {
|
|
.open = tracing_open_generic,
|
|
.read = trace_options_core_read,
|
|
.write = trace_options_core_write,
|
|
.llseek = generic_file_llseek,
|
|
};
|
|
|
|
struct dentry *trace_create_file(const char *name,
|
|
umode_t mode,
|
|
struct dentry *parent,
|
|
void *data,
|
|
const struct file_operations *fops)
|
|
{
|
|
struct dentry *ret;
|
|
|
|
ret = tracefs_create_file(name, mode, parent, data, fops);
|
|
if (!ret)
|
|
pr_warn("Could not create tracefs '%s' entry\n", name);
|
|
|
|
return ret;
|
|
}
|
|
|
|
|
|
static struct dentry *trace_options_init_dentry(struct trace_array *tr)
|
|
{
|
|
struct dentry *d_tracer;
|
|
|
|
if (tr->options)
|
|
return tr->options;
|
|
|
|
d_tracer = tracing_get_dentry(tr);
|
|
if (IS_ERR(d_tracer))
|
|
return NULL;
|
|
|
|
tr->options = tracefs_create_dir("options", d_tracer);
|
|
if (!tr->options) {
|
|
pr_warn("Could not create tracefs directory 'options'\n");
|
|
return NULL;
|
|
}
|
|
|
|
return tr->options;
|
|
}
|
|
|
|
static void
|
|
create_trace_option_file(struct trace_array *tr,
|
|
struct trace_option_dentry *topt,
|
|
struct tracer_flags *flags,
|
|
struct tracer_opt *opt)
|
|
{
|
|
struct dentry *t_options;
|
|
|
|
t_options = trace_options_init_dentry(tr);
|
|
if (!t_options)
|
|
return;
|
|
|
|
topt->flags = flags;
|
|
topt->opt = opt;
|
|
topt->tr = tr;
|
|
|
|
topt->entry = trace_create_file(opt->name, 0644, t_options, topt,
|
|
&trace_options_fops);
|
|
|
|
}
|
|
|
|
static void
|
|
create_trace_option_files(struct trace_array *tr, struct tracer *tracer)
|
|
{
|
|
struct trace_option_dentry *topts;
|
|
struct trace_options *tr_topts;
|
|
struct tracer_flags *flags;
|
|
struct tracer_opt *opts;
|
|
int cnt;
|
|
int i;
|
|
|
|
if (!tracer)
|
|
return;
|
|
|
|
flags = tracer->flags;
|
|
|
|
if (!flags || !flags->opts)
|
|
return;
|
|
|
|
/*
|
|
* If this is an instance, only create flags for tracers
|
|
* the instance may have.
|
|
*/
|
|
if (!trace_ok_for_array(tracer, tr))
|
|
return;
|
|
|
|
for (i = 0; i < tr->nr_topts; i++) {
|
|
/* Make sure there's no duplicate flags. */
|
|
if (WARN_ON_ONCE(tr->topts[i].tracer->flags == tracer->flags))
|
|
return;
|
|
}
|
|
|
|
opts = flags->opts;
|
|
|
|
for (cnt = 0; opts[cnt].name; cnt++)
|
|
;
|
|
|
|
topts = kcalloc(cnt + 1, sizeof(*topts), GFP_KERNEL);
|
|
if (!topts)
|
|
return;
|
|
|
|
tr_topts = krealloc(tr->topts, sizeof(*tr->topts) * (tr->nr_topts + 1),
|
|
GFP_KERNEL);
|
|
if (!tr_topts) {
|
|
kfree(topts);
|
|
return;
|
|
}
|
|
|
|
tr->topts = tr_topts;
|
|
tr->topts[tr->nr_topts].tracer = tracer;
|
|
tr->topts[tr->nr_topts].topts = topts;
|
|
tr->nr_topts++;
|
|
|
|
for (cnt = 0; opts[cnt].name; cnt++) {
|
|
create_trace_option_file(tr, &topts[cnt], flags,
|
|
&opts[cnt]);
|
|
WARN_ONCE(topts[cnt].entry == NULL,
|
|
"Failed to create trace option: %s",
|
|
opts[cnt].name);
|
|
}
|
|
}
|
|
|
|
static struct dentry *
|
|
create_trace_option_core_file(struct trace_array *tr,
|
|
const char *option, long index)
|
|
{
|
|
struct dentry *t_options;
|
|
|
|
t_options = trace_options_init_dentry(tr);
|
|
if (!t_options)
|
|
return NULL;
|
|
|
|
return trace_create_file(option, 0644, t_options,
|
|
(void *)&tr->trace_flags_index[index],
|
|
&trace_options_core_fops);
|
|
}
|
|
|
|
static void create_trace_options_dir(struct trace_array *tr)
|
|
{
|
|
struct dentry *t_options;
|
|
bool top_level = tr == &global_trace;
|
|
int i;
|
|
|
|
t_options = trace_options_init_dentry(tr);
|
|
if (!t_options)
|
|
return;
|
|
|
|
for (i = 0; trace_options[i]; i++) {
|
|
if (top_level ||
|
|
!((1 << i) & TOP_LEVEL_TRACE_FLAGS))
|
|
create_trace_option_core_file(tr, trace_options[i], i);
|
|
}
|
|
}
|
|
|
|
static ssize_t
|
|
rb_simple_read(struct file *filp, char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = filp->private_data;
|
|
char buf[64];
|
|
int r;
|
|
|
|
r = tracer_tracing_is_on(tr);
|
|
r = sprintf(buf, "%d\n", r);
|
|
|
|
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
|
|
}
|
|
|
|
static ssize_t
|
|
rb_simple_write(struct file *filp, const char __user *ubuf,
|
|
size_t cnt, loff_t *ppos)
|
|
{
|
|
struct trace_array *tr = filp->private_data;
|
|
struct ring_buffer *buffer = tr->trace_buffer.buffer;
|
|
unsigned long val;
|
|
int ret;
|
|
|
|
ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (buffer) {
|
|
mutex_lock(&trace_types_lock);
|
|
if (val) {
|
|
tracer_tracing_on(tr);
|
|
if (tr->current_trace->start)
|
|
tr->current_trace->start(tr);
|
|
} else {
|
|
tracer_tracing_off(tr);
|
|
if (tr->current_trace->stop)
|
|
tr->current_trace->stop(tr);
|
|
}
|
|
mutex_unlock(&trace_types_lock);
|
|
}
|
|
|
|
(*ppos)++;
|
|
|
|
return cnt;
|
|
}
|
|
|
|
static const struct file_operations rb_simple_fops = {
|
|
.open = tracing_open_generic_tr,
|
|
.read = rb_simple_read,
|
|
.write = rb_simple_write,
|
|
.release = tracing_release_generic_tr,
|
|
.llseek = default_llseek,
|
|
};
|
|
|
|
struct dentry *trace_instance_dir;
|
|
|
|
static void
|
|
init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer);
|
|
|
|
static int
|
|
allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size)
|
|
{
|
|
enum ring_buffer_flags rb_flags;
|
|
|
|
rb_flags = tr->trace_flags & TRACE_ITER_OVERWRITE ? RB_FL_OVERWRITE : 0;
|
|
|
|
buf->tr = tr;
|
|
|
|
buf->buffer = ring_buffer_alloc(size, rb_flags);
|
|
if (!buf->buffer)
|
|
return -ENOMEM;
|
|
|
|
buf->data = alloc_percpu(struct trace_array_cpu);
|
|
if (!buf->data) {
|
|
ring_buffer_free(buf->buffer);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
/* Allocate the first page for all buffers */
|
|
set_buffer_entries(&tr->trace_buffer,
|
|
ring_buffer_size(tr->trace_buffer.buffer, 0));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int allocate_trace_buffers(struct trace_array *tr, int size)
|
|
{
|
|
int ret;
|
|
|
|
ret = allocate_trace_buffer(tr, &tr->trace_buffer, size);
|
|
if (ret)
|
|
return ret;
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
ret = allocate_trace_buffer(tr, &tr->max_buffer,
|
|
allocate_snapshot ? size : 1);
|
|
if (WARN_ON(ret)) {
|
|
ring_buffer_free(tr->trace_buffer.buffer);
|
|
free_percpu(tr->trace_buffer.data);
|
|
return -ENOMEM;
|
|
}
|
|
tr->allocated_snapshot = allocate_snapshot;
|
|
|
|
/*
|
|
* Only the top level trace array gets its snapshot allocated
|
|
* from the kernel command line.
|
|
*/
|
|
allocate_snapshot = false;
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
static void free_trace_buffer(struct trace_buffer *buf)
|
|
{
|
|
if (buf->buffer) {
|
|
ring_buffer_free(buf->buffer);
|
|
buf->buffer = NULL;
|
|
free_percpu(buf->data);
|
|
buf->data = NULL;
|
|
}
|
|
}
|
|
|
|
static void free_trace_buffers(struct trace_array *tr)
|
|
{
|
|
if (!tr)
|
|
return;
|
|
|
|
free_trace_buffer(&tr->trace_buffer);
|
|
|
|
#ifdef CONFIG_TRACER_MAX_TRACE
|
|
free_trace_buffer(&tr->max_buffer);
|
|
#endif
|
|
}
|
|
|
|
static void init_trace_flags_index(struct trace_array *tr)
|
|
{
|
|
int i;
|
|
|
|
/* Used by the trace options files */
|
|
for (i = 0; i < TRACE_FLAGS_MAX_SIZE; i++)
|
|
tr->trace_flags_index[i] = i;
|
|
}
|
|
|
|
static void __update_tracer_options(struct trace_array *tr)
|
|
{
|
|
struct tracer *t;
|
|
|
|
for (t = trace_types; t; t = t->next)
|
|
add_tracer_options(tr, t);
|
|
}
|
|
|
|
static void update_tracer_options(struct trace_array *tr)
|
|
{
|
|
mutex_lock(&trace_types_lock);
|
|
__update_tracer_options(tr);
|
|
mutex_unlock(&trace_types_lock);
|
|
}
|
|
|
|
static int instance_mkdir(const char *name)
|
|
{
|
|
struct trace_array *tr;
|
|
int ret;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
ret = -EEXIST;
|
|
list_for_each_entry(tr, &ftrace_trace_arrays, list) {
|
|
if (tr->name && strcmp(tr->name, name) == 0)
|
|
goto out_unlock;
|
|
}
|
|
|
|
ret = -ENOMEM;
|
|
tr = kzalloc(sizeof(*tr), GFP_KERNEL);
|
|
if (!tr)
|
|
goto out_unlock;
|
|
|
|
tr->name = kstrdup(name, GFP_KERNEL);
|
|
if (!tr->name)
|
|
goto out_free_tr;
|
|
|
|
if (!alloc_cpumask_var(&tr->tracing_cpumask, GFP_KERNEL))
|
|
goto out_free_tr;
|
|
|
|
tr->trace_flags = global_trace.trace_flags & ~ZEROED_TRACE_FLAGS;
|
|
|
|
cpumask_copy(tr->tracing_cpumask, cpu_all_mask);
|
|
|
|
raw_spin_lock_init(&tr->start_lock);
|
|
|
|
tr->max_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
|
|
|
|
tr->current_trace = &nop_trace;
|
|
|
|
INIT_LIST_HEAD(&tr->systems);
|
|
INIT_LIST_HEAD(&tr->events);
|
|
|
|
if (allocate_trace_buffers(tr, trace_buf_size) < 0)
|
|
goto out_free_tr;
|
|
|
|
tr->dir = tracefs_create_dir(name, trace_instance_dir);
|
|
if (!tr->dir)
|
|
goto out_free_tr;
|
|
|
|
ret = event_trace_add_tracer(tr->dir, tr);
|
|
if (ret) {
|
|
tracefs_remove_recursive(tr->dir);
|
|
goto out_free_tr;
|
|
}
|
|
|
|
init_tracer_tracefs(tr, tr->dir);
|
|
init_trace_flags_index(tr);
|
|
__update_tracer_options(tr);
|
|
|
|
list_add(&tr->list, &ftrace_trace_arrays);
|
|
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return 0;
|
|
|
|
out_free_tr:
|
|
free_trace_buffers(tr);
|
|
free_cpumask_var(tr->tracing_cpumask);
|
|
kfree(tr->name);
|
|
kfree(tr);
|
|
|
|
out_unlock:
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
static int instance_rmdir(const char *name)
|
|
{
|
|
struct trace_array *tr;
|
|
int found = 0;
|
|
int ret;
|
|
int i;
|
|
|
|
mutex_lock(&trace_types_lock);
|
|
|
|
ret = -ENODEV;
|
|
list_for_each_entry(tr, &ftrace_trace_arrays, list) {
|
|
if (tr->name && strcmp(tr->name, name) == 0) {
|
|
found = 1;
|
|
break;
|
|
}
|
|
}
|
|
if (!found)
|
|
goto out_unlock;
|
|
|
|
ret = -EBUSY;
|
|
if (tr->ref || (tr->current_trace && tr->current_trace->ref))
|
|
goto out_unlock;
|
|
|
|
list_del(&tr->list);
|
|
|
|
/* Disable all the flags that were enabled coming in */
|
|
for (i = 0; i < TRACE_FLAGS_MAX_SIZE; i++) {
|
|
if ((1 << i) & ZEROED_TRACE_FLAGS)
|
|
set_tracer_flag(tr, 1 << i, 0);
|
|
}
|
|
|
|
tracing_set_nop(tr);
|
|
event_trace_del_tracer(tr);
|
|
ftrace_destroy_function_files(tr);
|
|
tracefs_remove_recursive(tr->dir);
|
|
free_trace_buffers(tr);
|
|
|
|
for (i = 0; i < tr->nr_topts; i++) {
|
|
kfree(tr->topts[i].topts);
|
|
}
|
|
kfree(tr->topts);
|
|
|
|
kfree(tr->name);
|
|
kfree(tr);
|
|
|
|
ret = 0;
|
|
|
|
out_unlock:
|
|
mutex_unlock(&trace_types_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static __init void create_trace_instances(struct dentry *d_tracer)
|
|
{
|
|
trace_instance_dir = tracefs_create_instance_dir("instances", d_tracer,
|
|
instance_mkdir,
|
|
instance_rmdir);
|
|
if (WARN_ON(!trace_instance_dir))
|
|
return;
|
|
}
|
|
|
|
static void
|
|
init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
|
|
{
|
|
int cpu;
|
|
|
|
trace_create_file("available_tracers", 0444, d_tracer,
|
|
tr, &show_traces_fops);
|
|
|
|
trace_create_file("current_tracer", 0644, d_tracer,
|
|
tr, &set_tracer_fops);
|
|
|
|
trace_create_file("tracing_cpumask", 0644, d_tracer,
|
|
tr, &tracing_cpumask_fops);
|
|
|
|
trace_create_file("trace_options", 0644, d_tracer,
|
|
tr, &tracing_iter_fops);
|
|
|
|
trace_create_file("trace", 0644, d_tracer,
|
|
tr, &tracing_fops);
|
|
|
|
trace_create_file("trace_pipe", 0444, d_tracer,
|
|
tr, &tracing_pipe_fops);
|
|
|
|
trace_create_file("buffer_size_kb", 0644, d_tracer,
|
|
tr, &tracing_entries_fops);
|
|
|
|
trace_create_file("buffer_total_size_kb", 0444, d_tracer,
|
|
tr, &tracing_total_entries_fops);
|
|
|
|
trace_create_file("free_buffer", 0200, d_tracer,
|
|
tr, &tracing_free_buffer_fops);
|
|
|
|
trace_create_file("trace_marker", 0220, d_tracer,
|
|
tr, &tracing_mark_fops);
|
|
|
|
trace_create_file("saved_tgids", 0444, d_tracer,
|
|
tr, &tracing_saved_tgids_fops);
|
|
|
|
trace_create_file("trace_clock", 0644, d_tracer, tr,
|
|
&trace_clock_fops);
|
|
|
|
trace_create_file("tracing_on", 0644, d_tracer,
|
|
tr, &rb_simple_fops);
|
|
|
|
create_trace_options_dir(tr);
|
|
|
|
#if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)
|
|
trace_create_file("tracing_max_latency", 0644, d_tracer,
|
|
&tr->max_latency, &tracing_max_lat_fops);
|
|
#endif
|
|
|
|
if (ftrace_create_function_files(tr, d_tracer))
|
|
WARN(1, "Could not allocate function filter files");
|
|
|
|
#ifdef CONFIG_TRACER_SNAPSHOT
|
|
trace_create_file("snapshot", 0644, d_tracer,
|
|
tr, &snapshot_fops);
|
|
#endif
|
|
|
|
for_each_tracing_cpu(cpu)
|
|
tracing_init_tracefs_percpu(tr, cpu);
|
|
|
|
ftrace_init_tracefs(tr, d_tracer);
|
|
}
|
|
|
|
static struct vfsmount *trace_automount(void *ingore)
|
|
{
|
|
struct vfsmount *mnt;
|
|
struct file_system_type *type;
|
|
|
|
/*
|
|
* To maintain backward compatibility for tools that mount
|
|
* debugfs to get to the tracing facility, tracefs is automatically
|
|
* mounted to the debugfs/tracing directory.
|
|
*/
|
|
type = get_fs_type("tracefs");
|
|
if (!type)
|
|
return NULL;
|
|
mnt = vfs_kern_mount(type, 0, "tracefs", NULL);
|
|
put_filesystem(type);
|
|
if (IS_ERR(mnt))
|
|
return NULL;
|
|
mntget(mnt);
|
|
|
|
return mnt;
|
|
}
|
|
|
|
/**
|
|
* tracing_init_dentry - initialize top level trace array
|
|
*
|
|
* This is called when creating files or directories in the tracing
|
|
* directory. It is called via fs_initcall() by any of the boot up code
|
|
* and expects to return the dentry of the top level tracing directory.
|
|
*/
|
|
struct dentry *tracing_init_dentry(void)
|
|
{
|
|
struct trace_array *tr = &global_trace;
|
|
|
|
/* The top level trace array uses NULL as parent */
|
|
if (tr->dir)
|
|
return NULL;
|
|
|
|
if (WARN_ON(!tracefs_initialized()) ||
|
|
(IS_ENABLED(CONFIG_DEBUG_FS) &&
|
|
WARN_ON(!debugfs_initialized())))
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
/*
|
|
* As there may still be users that expect the tracing
|
|
* files to exist in debugfs/tracing, we must automount
|
|
* the tracefs file system there, so older tools still
|
|
* work with the newer kerenl.
|
|
*/
|
|
tr->dir = debugfs_create_automount("tracing", NULL,
|
|
trace_automount, NULL);
|
|
if (!tr->dir) {
|
|
pr_warn_once("Could not create debugfs directory 'tracing'\n");
|
|
return ERR_PTR(-ENOMEM);
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
extern struct trace_enum_map *__start_ftrace_enum_maps[];
|
|
extern struct trace_enum_map *__stop_ftrace_enum_maps[];
|
|
|
|
static void __init trace_enum_init(void)
|
|
{
|
|
int len;
|
|
|
|
len = __stop_ftrace_enum_maps - __start_ftrace_enum_maps;
|
|
trace_insert_enum_map(NULL, __start_ftrace_enum_maps, len);
|
|
}
|
|
|
|
#ifdef CONFIG_MODULES
|
|
static void trace_module_add_enums(struct module *mod)
|
|
{
|
|
if (!mod->num_trace_enums)
|
|
return;
|
|
|
|
/*
|
|
* Modules with bad taint do not have events created, do
|
|
* not bother with enums either.
|
|
*/
|
|
if (trace_module_has_bad_taint(mod))
|
|
return;
|
|
|
|
trace_insert_enum_map(mod, mod->trace_enums, mod->num_trace_enums);
|
|
}
|
|
|
|
#ifdef CONFIG_TRACE_ENUM_MAP_FILE
|
|
static void trace_module_remove_enums(struct module *mod)
|
|
{
|
|
union trace_enum_map_item *map;
|
|
union trace_enum_map_item **last = &trace_enum_maps;
|
|
|
|
if (!mod->num_trace_enums)
|
|
return;
|
|
|
|
mutex_lock(&trace_enum_mutex);
|
|
|
|
map = trace_enum_maps;
|
|
|
|
while (map) {
|
|
if (map->head.mod == mod)
|
|
break;
|
|
map = trace_enum_jmp_to_tail(map);
|
|
last = &map->tail.next;
|
|
map = map->tail.next;
|
|
}
|
|
if (!map)
|
|
goto out;
|
|
|
|
*last = trace_enum_jmp_to_tail(map)->tail.next;
|
|
kfree(map);
|
|
out:
|
|
mutex_unlock(&trace_enum_mutex);
|
|
}
|
|
#else
|
|
static inline void trace_module_remove_enums(struct module *mod) { }
|
|
#endif /* CONFIG_TRACE_ENUM_MAP_FILE */
|
|
|
|
static int trace_module_notify(struct notifier_block *self,
|
|
unsigned long val, void *data)
|
|
{
|
|
struct module *mod = data;
|
|
|
|
switch (val) {
|
|
case MODULE_STATE_COMING:
|
|
trace_module_add_enums(mod);
|
|
break;
|
|
case MODULE_STATE_GOING:
|
|
trace_module_remove_enums(mod);
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct notifier_block trace_module_nb = {
|
|
.notifier_call = trace_module_notify,
|
|
.priority = 0,
|
|
};
|
|
#endif /* CONFIG_MODULES */
|
|
|
|
static __init int tracer_init_tracefs(void)
|
|
{
|
|
struct dentry *d_tracer;
|
|
|
|
trace_access_lock_init();
|
|
|
|
d_tracer = tracing_init_dentry();
|
|
if (IS_ERR(d_tracer))
|
|
return 0;
|
|
|
|
init_tracer_tracefs(&global_trace, d_tracer);
|
|
ftrace_init_tracefs_toplevel(&global_trace, d_tracer);
|
|
|
|
trace_create_file("tracing_thresh", 0644, d_tracer,
|
|
&global_trace, &tracing_thresh_fops);
|
|
|
|
trace_create_file("README", 0444, d_tracer,
|
|
NULL, &tracing_readme_fops);
|
|
|
|
trace_create_file("saved_cmdlines", 0444, d_tracer,
|
|
NULL, &tracing_saved_cmdlines_fops);
|
|
|
|
trace_create_file("saved_cmdlines_size", 0644, d_tracer,
|
|
NULL, &tracing_saved_cmdlines_size_fops);
|
|
|
|
trace_enum_init();
|
|
|
|
trace_create_enum_file(d_tracer);
|
|
|
|
#ifdef CONFIG_MODULES
|
|
register_module_notifier(&trace_module_nb);
|
|
#endif
|
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
|
trace_create_file("dyn_ftrace_total_info", 0444, d_tracer,
|
|
&ftrace_update_tot_cnt, &tracing_dyn_info_fops);
|
|
#endif
|
|
|
|
create_trace_instances(d_tracer);
|
|
|
|
update_tracer_options(&global_trace);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int trace_panic_handler(struct notifier_block *this,
|
|
unsigned long event, void *unused)
|
|
{
|
|
if (ftrace_dump_on_oops)
|
|
ftrace_dump(ftrace_dump_on_oops);
|
|
return NOTIFY_OK;
|
|
}
|
|
|
|
static struct notifier_block trace_panic_notifier = {
|
|
.notifier_call = trace_panic_handler,
|
|
.next = NULL,
|
|
.priority = 150 /* priority: INT_MAX >= x >= 0 */
|
|
};
|
|
|
|
static int trace_die_handler(struct notifier_block *self,
|
|
unsigned long val,
|
|
void *data)
|
|
{
|
|
switch (val) {
|
|
case DIE_OOPS:
|
|
if (ftrace_dump_on_oops)
|
|
ftrace_dump(ftrace_dump_on_oops);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return NOTIFY_OK;
|
|
}
|
|
|
|
static struct notifier_block trace_die_notifier = {
|
|
.notifier_call = trace_die_handler,
|
|
.priority = 200
|
|
};
|
|
|
|
/*
|
|
* printk is set to max of 1024, we really don't need it that big.
|
|
* Nothing should be printing 1000 characters anyway.
|
|
*/
|
|
#define TRACE_MAX_PRINT 1000
|
|
|
|
/*
|
|
* Define here KERN_TRACE so that we have one place to modify
|
|
* it if we decide to change what log level the ftrace dump
|
|
* should be at.
|
|
*/
|
|
#define KERN_TRACE KERN_EMERG
|
|
|
|
void
|
|
trace_printk_seq(struct trace_seq *s)
|
|
{
|
|
/* Probably should print a warning here. */
|
|
if (s->seq.len >= TRACE_MAX_PRINT)
|
|
s->seq.len = TRACE_MAX_PRINT;
|
|
|
|
/*
|
|
* More paranoid code. Although the buffer size is set to
|
|
* PAGE_SIZE, and TRACE_MAX_PRINT is 1000, this is just
|
|
* an extra layer of protection.
|
|
*/
|
|
if (WARN_ON_ONCE(s->seq.len >= s->seq.size))
|
|
s->seq.len = s->seq.size - 1;
|
|
|
|
/* should be zero ended, but we are paranoid. */
|
|
s->buffer[s->seq.len] = 0;
|
|
|
|
printk(KERN_TRACE "%s", s->buffer);
|
|
|
|
trace_seq_init(s);
|
|
}
|
|
|
|
void trace_init_global_iter(struct trace_iterator *iter)
|
|
{
|
|
iter->tr = &global_trace;
|
|
iter->trace = iter->tr->current_trace;
|
|
iter->cpu_file = RING_BUFFER_ALL_CPUS;
|
|
iter->trace_buffer = &global_trace.trace_buffer;
|
|
|
|
if (iter->trace && iter->trace->open)
|
|
iter->trace->open(iter);
|
|
|
|
/* Annotate start of buffers if we had overruns */
|
|
if (ring_buffer_overruns(iter->trace_buffer->buffer))
|
|
iter->iter_flags |= TRACE_FILE_ANNOTATE;
|
|
|
|
/* Output in nanoseconds only if we are using a clock in nanoseconds. */
|
|
if (trace_clocks[iter->tr->clock_id].in_ns)
|
|
iter->iter_flags |= TRACE_FILE_TIME_IN_NS;
|
|
}
|
|
|
|
void ftrace_dump(enum ftrace_dump_mode oops_dump_mode)
|
|
{
|
|
/* use static because iter can be a bit big for the stack */
|
|
static struct trace_iterator iter;
|
|
static atomic_t dump_running;
|
|
struct trace_array *tr = &global_trace;
|
|
unsigned int old_userobj;
|
|
unsigned long flags;
|
|
int cnt = 0, cpu;
|
|
|
|
/* Only allow one dump user at a time. */
|
|
if (atomic_inc_return(&dump_running) != 1) {
|
|
atomic_dec(&dump_running);
|
|
return;
|
|
}
|
|
|
|
/*
|
|
* Always turn off tracing when we dump.
|
|
* We don't need to show trace output of what happens
|
|
* between multiple crashes.
|
|
*
|
|
* If the user does a sysrq-z, then they can re-enable
|
|
* tracing with echo 1 > tracing_on.
|
|
*/
|
|
tracing_off();
|
|
|
|
local_irq_save(flags);
|
|
|
|
/* Simulate the iterator */
|
|
trace_init_global_iter(&iter);
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
atomic_inc(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
|
|
}
|
|
|
|
old_userobj = tr->trace_flags & TRACE_ITER_SYM_USEROBJ;
|
|
|
|
/* don't look at user memory in panic mode */
|
|
tr->trace_flags &= ~TRACE_ITER_SYM_USEROBJ;
|
|
|
|
switch (oops_dump_mode) {
|
|
case DUMP_ALL:
|
|
iter.cpu_file = RING_BUFFER_ALL_CPUS;
|
|
break;
|
|
case DUMP_ORIG:
|
|
iter.cpu_file = raw_smp_processor_id();
|
|
break;
|
|
case DUMP_NONE:
|
|
goto out_enable;
|
|
default:
|
|
printk(KERN_TRACE "Bad dumping mode, switching to all CPUs dump\n");
|
|
iter.cpu_file = RING_BUFFER_ALL_CPUS;
|
|
}
|
|
|
|
printk(KERN_TRACE "Dumping ftrace buffer:\n");
|
|
|
|
/* Did function tracer already get disabled? */
|
|
if (ftrace_is_dead()) {
|
|
printk("# WARNING: FUNCTION TRACING IS CORRUPTED\n");
|
|
printk("# MAY BE MISSING FUNCTION EVENTS\n");
|
|
}
|
|
|
|
/*
|
|
* We need to stop all tracing on all CPUS to read the
|
|
* the next buffer. This is a bit expensive, but is
|
|
* not done often. We fill all what we can read,
|
|
* and then release the locks again.
|
|
*/
|
|
|
|
while (!trace_empty(&iter)) {
|
|
|
|
if (!cnt)
|
|
printk(KERN_TRACE "---------------------------------\n");
|
|
|
|
cnt++;
|
|
|
|
/* reset all but tr, trace, and overruns */
|
|
memset(&iter.seq, 0,
|
|
sizeof(struct trace_iterator) -
|
|
offsetof(struct trace_iterator, seq));
|
|
iter.iter_flags |= TRACE_FILE_LAT_FMT;
|
|
iter.pos = -1;
|
|
|
|
if (trace_find_next_entry_inc(&iter) != NULL) {
|
|
int ret;
|
|
|
|
ret = print_trace_line(&iter);
|
|
if (ret != TRACE_TYPE_NO_CONSUME)
|
|
trace_consume(&iter);
|
|
}
|
|
touch_nmi_watchdog();
|
|
|
|
trace_printk_seq(&iter.seq);
|
|
}
|
|
|
|
if (!cnt)
|
|
printk(KERN_TRACE " (ftrace buffer empty)\n");
|
|
else
|
|
printk(KERN_TRACE "---------------------------------\n");
|
|
|
|
out_enable:
|
|
tr->trace_flags |= old_userobj;
|
|
|
|
for_each_tracing_cpu(cpu) {
|
|
atomic_dec(&per_cpu_ptr(iter.trace_buffer->data, cpu)->disabled);
|
|
}
|
|
atomic_dec(&dump_running);
|
|
local_irq_restore(flags);
|
|
}
|
|
EXPORT_SYMBOL_GPL(ftrace_dump);
|
|
|
|
__init static int tracer_alloc_buffers(void)
|
|
{
|
|
int ring_buf_size;
|
|
int ret = -ENOMEM;
|
|
|
|
/*
|
|
* Make sure we don't accidently add more trace options
|
|
* than we have bits for.
|
|
*/
|
|
BUILD_BUG_ON(TRACE_ITER_LAST_BIT > TRACE_FLAGS_MAX_SIZE);
|
|
|
|
if (!alloc_cpumask_var(&tracing_buffer_mask, GFP_KERNEL))
|
|
goto out;
|
|
|
|
if (!alloc_cpumask_var(&global_trace.tracing_cpumask, GFP_KERNEL))
|
|
goto out_free_buffer_mask;
|
|
|
|
/* Only allocate trace_printk buffers if a trace_printk exists */
|
|
if (__stop___trace_bprintk_fmt != __start___trace_bprintk_fmt)
|
|
/* Must be called before global_trace.buffer is allocated */
|
|
trace_printk_init_buffers();
|
|
|
|
/* To save memory, keep the ring buffer size to its minimum */
|
|
if (ring_buffer_expanded)
|
|
ring_buf_size = trace_buf_size;
|
|
else
|
|
ring_buf_size = 1;
|
|
|
|
cpumask_copy(tracing_buffer_mask, cpu_possible_mask);
|
|
cpumask_copy(global_trace.tracing_cpumask, cpu_all_mask);
|
|
|
|
raw_spin_lock_init(&global_trace.start_lock);
|
|
|
|
/* Used for event triggers */
|
|
temp_buffer = ring_buffer_alloc(PAGE_SIZE, RB_FL_OVERWRITE);
|
|
if (!temp_buffer)
|
|
goto out_free_cpumask;
|
|
|
|
if (trace_create_savedcmd() < 0)
|
|
goto out_free_temp_buffer;
|
|
|
|
/* TODO: make the number of buffers hot pluggable with CPUS */
|
|
if (allocate_trace_buffers(&global_trace, ring_buf_size) < 0) {
|
|
printk(KERN_ERR "tracer: failed to allocate ring buffer!\n");
|
|
WARN_ON(1);
|
|
goto out_free_savedcmd;
|
|
}
|
|
|
|
if (global_trace.buffer_disabled)
|
|
tracing_off();
|
|
|
|
if (trace_boot_clock) {
|
|
ret = tracing_set_clock(&global_trace, trace_boot_clock);
|
|
if (ret < 0)
|
|
pr_warn("Trace clock %s not defined, going back to default\n",
|
|
trace_boot_clock);
|
|
}
|
|
|
|
/*
|
|
* register_tracer() might reference current_trace, so it
|
|
* needs to be set before we register anything. This is
|
|
* just a bootstrap of current_trace anyway.
|
|
*/
|
|
global_trace.current_trace = &nop_trace;
|
|
|
|
global_trace.max_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
|
|
|
|
ftrace_init_global_array_ops(&global_trace);
|
|
|
|
init_trace_flags_index(&global_trace);
|
|
|
|
register_tracer(&nop_trace);
|
|
|
|
/* All seems OK, enable tracing */
|
|
tracing_disabled = 0;
|
|
|
|
atomic_notifier_chain_register(&panic_notifier_list,
|
|
&trace_panic_notifier);
|
|
|
|
register_die_notifier(&trace_die_notifier);
|
|
|
|
global_trace.flags = TRACE_ARRAY_FL_GLOBAL;
|
|
|
|
INIT_LIST_HEAD(&global_trace.systems);
|
|
INIT_LIST_HEAD(&global_trace.events);
|
|
list_add(&global_trace.list, &ftrace_trace_arrays);
|
|
|
|
apply_trace_boot_options();
|
|
|
|
register_snapshot_cmd();
|
|
|
|
return 0;
|
|
|
|
out_free_savedcmd:
|
|
free_saved_cmdlines_buffer(savedcmd);
|
|
out_free_temp_buffer:
|
|
ring_buffer_free(temp_buffer);
|
|
out_free_cpumask:
|
|
free_cpumask_var(global_trace.tracing_cpumask);
|
|
out_free_buffer_mask:
|
|
free_cpumask_var(tracing_buffer_mask);
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
void __init trace_init(void)
|
|
{
|
|
if (tracepoint_printk) {
|
|
tracepoint_print_iter =
|
|
kmalloc(sizeof(*tracepoint_print_iter), GFP_KERNEL);
|
|
if (WARN_ON(!tracepoint_print_iter))
|
|
tracepoint_printk = 0;
|
|
}
|
|
tracer_alloc_buffers();
|
|
trace_event_init();
|
|
}
|
|
|
|
__init static int clear_boot_tracer(void)
|
|
{
|
|
/*
|
|
* The default tracer at boot buffer is an init section.
|
|
* This function is called in lateinit. If we did not
|
|
* find the boot tracer, then clear it out, to prevent
|
|
* later registration from accessing the buffer that is
|
|
* about to be freed.
|
|
*/
|
|
if (!default_bootup_tracer)
|
|
return 0;
|
|
|
|
printk(KERN_INFO "ftrace bootup tracer '%s' not registered.\n",
|
|
default_bootup_tracer);
|
|
default_bootup_tracer = NULL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
fs_initcall(tracer_init_tracefs);
|
|
late_initcall(clear_boot_tracer);
|