Commit graph

549443 commits

Author SHA1 Message Date
Andy Lutomirski 226f1f729c selftests/x86: Add a fork() to entry_from_vm86 to catch fork bugs
Mere possession of vm86 state is strange.  Make sure that nothing
gets corrupted if we fork after calling vm86().

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Stas Sergeev <stsp@list.ru>
Link: http://lkml.kernel.org/r/08f83295460a80e41dc5e3e81ec40d6844d316f5.1446270067.git.luto@kernel.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2015-10-31 09:50:25 +01:00
Linus Torvalds 38dab9ac1c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input layer fixes from Dmitry Torokhov:

 - a change to the ALPS driver where we had limit the quirk for
   trackstick handling from being active on all Dells to just a few
   models

 - a fix for a build dependency issue in the sur40 driver

 - a small clock handling fixup in the LPC32xx touchscreen driver

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
  Input: alps - only the Dell Latitude D420/430/620/630 have separate stick button bits
  Input: sur40 - add dependency on VIDEO_V4L2
  Input: lpc32xx_ts - fix warnings caused by enabling unprepared clock
2015-10-30 18:49:44 -07:00
Linus Torvalds f9793e379b PCI update for v4.3:
NUMA
     - Prevent out of bounds access in sysfs numa_node override (Sasha Levin)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWMqyJAAoJEFmIoMA60/r8PXMP/jk33V2VHXmcdAnRpdUM09at
 VEosZlsPXmAGwlcbf0y9BMdwu8M8Kd1LAtiTXhbFchoWi3NG8ECPsIlYnQfqVzhm
 VEEE4IyMHNfLOgQAf+ZfD5duBjsTDoyl3D2XYa8ugV1jJVs4Vpf2lyWVnwrG32E9
 MTf2plaHWtjsser78PA0hQ5w5jJz41acgv9P88mdWmYyr+u2h+G8w+Ro2bLyVsiW
 dcSIM7L1R6j9Kp52BqXq31rwHXQIF8v+yDaHNTKR6PzcufyuHKsK2fALa7LSam2P
 EJEj7D8FVPFqYs2XRdPiYI+/wjMcM59CETIZ5NtEzjkQvoeTQhLa3iA8LrS4OMNI
 JQWbPIHu9dB2Y2fFyeO31kW8+G8zgSKPcdhg9gAdoPspVX387+KHR+aiSMOlGsTu
 wCyMQsuQSqcNkKGAyPcaQe6AUaI+3Ri3awuBV3/o20tNq2upPqeljvZa6v3W/Ua+
 OSKE9rdRxsMzi1M3sLIDYIg0mD3K+horH52A3cjoOXehhSFX8pucbuk6bvYszPxq
 0rPLX7fasbVo/yTLz4RgIk9LK2yxpg7TO1MRQb4byCbBqVJU+7R9JxakqstmJGXv
 W0huOvn776rtcpxItfbckyfCsVhqcZ13xP1osjCcFLciSe+eq4dKCY1iH0OyvSOu
 S+TkJWdpKEU9L0Tfxjvo
 =nuxn
 -----END PGP SIGNATURE-----

Merge tag 'pci-v4.3-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci

Pull PCI fix from Bjorn Helgaas:
 "Sorry for this last-minute update; it's been in -next for quite a
  while, but I forgot about it until I started getting ready for the
  merge window.

  It's small and fixes a way a user could cause a panic via sysfs, so I
  think it's worth getting it in v4.3.

  NUMA:
    - Prevent out of bounds access in sysfs numa_node override (Sasha Levin)"

* tag 'pci-v4.3-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
  PCI: Prevent out of bounds access in numa_node override
2015-10-30 18:47:18 -07:00
Olof Johansson 53dd186b3f Two omap regression fixes:
- Fix omap3 MUSB with DMA caused by driver core changes
 
 - Fix LCD DMA interrupt number for omap1 that did not
   get changed for sparse IRQ changes
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWMQmFAAoJEBvUPslcq6Vz0yEP/32OMPYtsJ/zic3zEl7yRTjc
 3cTlQlerKrU1oP8Z6eg/Bgvi28yYQlNvuFDYzJ2cLWTbbjoaTjOHYLuoIaScIpM2
 El/d/GvGCndET9HS4DMuMplj3OzXMsso38o6h5F6z51xVPtVpjitc36TcMxkeqD/
 gQcXRORcvOIvVI7pdjfAm8UMd3r/kF/TsZ5nZhoXHd+UlQJ/boB0r/MmH0VXeI2x
 xNCoD9Xl/EaCMLVtWlcXU44CojOhncg5xrfsAsPDBL9aDGijwYRTvtcBatI5Phq/
 6fEO/hQhG503nH9Di9ozE+41c5ZjeLk9oGSIvkTjuttpvkvW6CeCLoqW4CuhmHrQ
 f8/Wj3TSJ4BBGdbEdPK13t4lXozvMsB1MvxlnoCnCANPIPNTt9DUCs27U4i4YWem
 PVLNcR5d7fxSa8mXgKswoRFMimhI9ZZN1MozI2ZwcxqftOgnbNejkmjd9kMwrXen
 X4lY1bMlE942zY+gzQvbFKmz6NM5QAAooF29LB/qJdWpLi3wZDU9bUXYGTlPQqC+
 JzhfBFgPaEQnZJx+HxOpaWUmxeHyYQWmio2x+xi+0o/MfGnia9FYxtVCuoI8mCiR
 fyO4+T8jlnWTZEInm7s45OjsheFbw52PVWJysMWxoyWq0NLa/Af8lKFk/d0/5s8C
 /ditVCYYqxwCdWJe17Se
 =H1PE
 -----END PGP SIGNATURE-----

Merge tag 'omap-for-v4.3/fixes-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into fixes

Two omap regression fixes:

- Fix omap3 MUSB with DMA caused by driver core changes

- Fix LCD DMA interrupt number for omap1 that did not
  get changed for sparse IRQ changes

* tag 'omap-for-v4.3/fixes-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap:
  usb: musb: omap2430: Fix regression caused by driver core change
  ARM: OMAP1: fix incorrect INT_DMA_LCD

Signed-off-by: Olof Johansson <olof@lixom.net>
2015-10-31 01:42:13 +00:00
Maneet Singh 8731b269f0 drm: Correct arguments to list_tail_add in create blob ioctl
Arguments passed to list_add_tail were reversed resulting in deletion
of old blob property everytime the new one is added.

Fixes

commit e2f5d2ea47
Author: Daniel Stone <daniels@collabora.com>
Date:   Fri May 22 13:34:51 2015 +0100

    drm/mode: Add user blob-creation ioctl

Signed-off-by: Maneet Singh <mmaneetsingh@nvidia.com>
[seanpaul tweaked commit subject a little]
Signed-off-by: Sean Paul <seanpaul@chromium.org>
Cc: stable@kernel.org # v4.2
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Dave Airlie <airlied@gmail.com>
2015-10-31 10:22:26 +10:00
NeilBrown d01552a76d Revert "md: allow a partially recovered device to be hot-added to an array."
This reverts commit 7eb418851f.

This commit is poorly justified, I can find not discusison in email,
and it clearly causes a problem.

If a device which is being recovered fails and is subsequently
re-added to an array, there could easily have been changes to the
array *before* the point where the recovery was up to.  So the
recovery must start again from the beginning.

If a spare is being recovered and fails, then when it is re-added we
really should do a bitmap-based recovery up to the recovery-offset,
and then a full recovery from there.  Before this reversion, we only
did the "full recovery from there" which is not corect.  After this
reversion with will do a full recovery from the start, which is safer
but not ideal.

It will be left to a future patch to arrange the two different styles
of recovery.

Reported-and-tested-by: Nate Dailey <nate.dailey@stratus.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Cc: stable@vger.kernel.org (3.14+)
Fixes: 7eb418851f ("md: allow a partially recovered device to be hot-added to an array.")
2015-10-31 11:00:56 +11:00
Dan Carpenter 9ac0934bbe drm: crtc: integer overflow in drm_property_create_blob()
The size here comes from the user via the ioctl, it is a number between
1-u32max so the addition here could overflow on 32 bit systems.

Fixes: f453ba0460 ('DRM: add mode setting support')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Cc: stable@kernel.org # v4.2
Signed-off-by: Dave Airlie <airlied@gmail.com>
2015-10-31 10:00:05 +10:00
Linus Torvalds 9b971e771e arm64 fixes for 4.3
- Fix corruption in SWP emulation when STXR fails due to contention
 - Fix MMU re-initialisation when resuming from a low-power state
 - Fix stack unwinding code to match what ftrace expects
 - Fix relocation code in the EFI stub when DRAM base is not 2MB aligned
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABCgAGBQJWMlK9AAoJELescNyEwWM0iIcH/AmtOcTR9EZjwxD6szeF1/qg
 JuJCW7D0q2TNEw4Ed8TW8W3mSFPBuDWWbypxwpcV7pQZjBKpbDBTd79sdwAbRViZ
 mYGgV3NKt6BuChjxxMxnwRXYdF1J38bpFFyXslPue8zmnTkZ5EQ7IR2hMksX2+er
 KoPY4Gu0nSTaLD55jFfbtA3pMgoT9gRi+UsMGBseb03TLwAxEmYrtzZNTTMrDqbC
 BomRDbE/duOxnhigAMeWb0T/oHY66pZoEjy9YxsSd9HyqZ+l7MbMUkBRkuXj3g5O
 9XLsbBWauKp3nGUgBaxu76JovJhbveWaSB4fBF6t5G2WoP47wFjfxhWxpDg6B3Y=
 =3Rb/
 -----END PGP SIGNATURE-----

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Will Deacon:
 "Apologies for this being so late, but we've uncovered a few nasty
  issues on arm64 which didn't settle down until yesterday and the fixes
  all look suitable for 4.3.  Of the four patches, three of them are
  Cc'd to stable, with the remaining patch fixing an issue that only
  took effect during the merge window.

  Summary:

   - Fix corruption in SWP emulation when STXR fails due to contention
   - Fix MMU re-initialisation when resuming from a low-power state
   - Fix stack unwinding code to match what ftrace expects
   - Fix relocation code in the EFI stub when DRAM base is not 2MB aligned"

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
  arm64/efi: do not assume DRAM base is aligned to 2 MB
  Revert "ARM64: unwind: Fix PC calculation"
  arm64: kernel: fix tcr_el1.t0sz restore on systems with extended idmap
  arm64: compat: fix stxr failure case in SWP emulation
2015-10-30 16:57:55 -07:00
Linus Torvalds 7c0f488fbe Missed adding the kcmp() syscall a long time ago. Now it seems
that it is essential to build systemd.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWMUTSAAoJEKurIx+X31iBgd0QALJD5i2Kqn0UawF0oFLJ7VQx
 PFp4SFjhPB1Dsolxh4oR8gdMCHBWnxl3TcOeotAD/6OzkQX2FTaDYO3rV/blTsfy
 ZfAJOifio4mforhe5IbiHHUNNjqgOcm6/RLVxuJr8a62Y+M2GMDOQ/gSRhOmGCoe
 9Nvbn0FnZisETOvVaYv17AFjLrnuGq2cwozuLyVoIFqOMQV7M6gwK/KH4NDo97nl
 ytL8KihNLNrL7ErbUfU3RdmGmTYqlVUE1dk0iFHV/tmfSKpIakjPHP/AKmpEzgLb
 +niBzZszCYjvv1f63uHl+/tsq6v3Pv01EHmbrKrcGN2S5/mC2drrnq09Q59BEqoK
 AOiZrjYPBWuPIZQOlDbtF+g1xxQX28tGY3Lf1Z2QQnnNqXZqdzGTrzaOe7UHu1xC
 cCOyF2MxJrs8Dfbj/ZaciSNW52b7lNaNlj4cCMx3a7JY3C/pj3jYlYZ7qyuZ/rfE
 h/AtR9vNWR1vSeS9TBJkn2tu2Xo22ydH9pvMO2HX3s9zV6sMAEw2hhvrvWYoenyF
 +KkbfQy3P6FNpGNmVYSZogPkoC5oJaR1o+jWetDX291wH6E8bZOznzWvFt5e1WgH
 QhKnuTidYhOvjG0jeZLTmjoQDvZy/I+rIinmA83NLa66vWTY70LjXNYWWTF1V/mz
 3WjnDYq9TBiS259cfDdO
 =gyuX
 -----END PGP SIGNATURE-----

Merge tag 'please-pull-syscalls' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux

Pull ia64 kcmp syscall from Tony Luck:
 "Missed adding the kcmp() syscall a long time ago.  Now it seems that
  it is essential to build systemd"

* tag 'please-pull-syscalls' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux:
  [IA64] Wire up kcmp syscall
2015-10-30 16:56:44 -07:00
Roman Gushchin b8a9d66d04 md/raid5: fix locking in handle_stripe_clean_event()
After commit 566c09c534 ("raid5: relieve lock contention in get_active_stripe()")
__find_stripe() is called under conf->hash_locks + hash.
But handle_stripe_clean_event() calls remove_hash() under
conf->device_lock.

Under some cirscumstances the hash chain can be circuited,
and we get an infinite loop with disabled interrupts and locked hash
lock in __find_stripe(). This leads to hard lockup on multiple CPUs
and following system crash.

I was able to reproduce this behavior on raid6 over 6 ssd disks.
The devices_handle_discard_safely option should be set to enable trim
support. The following script was used:

for i in `seq 1 32`; do
    dd if=/dev/zero of=large$i bs=10M count=100 &
done

neilb: original was against a 3.x kernel.  I forward-ported
  to 4.3-rc.  This verison is suitable for any kernel since
  Commit: 59fc630b8b ("RAID5: batch adjacent full stripe write")
  (v4.1+).  I'll post a version for earlier kernels to stable.

Signed-off-by: Roman Gushchin <klamm@yandex-team.ru>
Fixes: 566c09c534 ("raid5: relieve lock contention in get_active_stripe()")
Signed-off-by: NeilBrown <neilb@suse.com>
Cc: Shaohua Li <shli@kernel.org>
Cc: <stable@vger.kernel.org> # 3.13 - 4.2
2015-10-31 10:53:50 +11:00
Ronny Hegewald bae818ee15 rbd: require stable pages if message data CRCs are enabled
rbd requires stable pages, as it performs a crc of the page data before
they are send to the OSDs.

But since kernel 3.9 (patch 1d1d1a7672
"mm: only enforce stable page writes if the backing device requires
it") it is not assumed anymore that block devices require stable pages.

This patch sets the necessary flag to get stable pages back for rbd.

In a ceph installation that provides multiple ext4 formatted rbd
devices "bad crc" messages appeared regularly (ca 1 message every 1-2
minutes on every OSD that provided the data for the rbd) in the
OSD-logs before this patch. After this patch this messages are pretty
much gone (only ca 1-2 / month / OSD).

Cc: stable@vger.kernel.org # 3.9+, needs backporting
Signed-off-by: Ronny Hegewald <Ronny.Hegewald@online.de>
[idryomov@gmail.com: require stable pages only in crc case, changelog]
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2015-10-30 19:25:02 +01:00
Guenter Roeck 50224f4d09 hwmon: (nct6775) Introduce separate temperature labels for NCT6792 and NCT6793
NCT6792 and NCT6793 are mostly register compatible to NCT6791, but
temperature sources are different and difficult to manage with a single
temperature label array. Introduce separate temperature label arrays
for those chips to reflect the differences.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-10-30 07:58:58 -07:00
Guenter Roeck 9a38371a8c hwmon: (nct6775) NCT6791D and NCT6792D have an additional temperature source
Both NCT6791D and NCT6792D permit selection of a 'virtual' temperature
register as temperature source. The virtual temperature registers are
registers 0xea to 0xef in bank 0 and can be written by software.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-10-30 07:35:14 -07:00
Mike Looijmans 13e3008fae pinctrl: zynq: Initialize early
Supplying pinmux configuration for e.g. gpio pins leads to deferred
probes because the pinctrl device is probed much later than gpio.
Move the init call to a much earlier stage so it probes before the
devices that may need it.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Tested-by: Sören Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-10-30 10:40:57 +01:00
William Breathitt Gray e25589894e gpio: Add ACCES 104-IDIO-16 driver maintainer entry
Add William Breathitt Gray as the maintainer of the ACCES 104-IDIO-16
GPIO driver.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2015-10-30 10:20:14 +01:00
David Woodhouse d9e4ad5bad Document that IRQ_NONE should be returned when IRQ not actually handled
Our IRQ storm detection works when an interrupt handler returns
IRQ_NONE for thousands of consecutive interrupts in a second. It
doesn't hurt to occasionally return IRQ_NONE when the interrupt is
actually genuine.

Drivers should only be returning IRQ_HANDLED if they have actually
*done* something to stop an interrupt from happening — it doesn't just
mean "this really *was* my device".

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Cc: davem@davemloft.net
Link: http://lkml.kernel.org/r/1446016471.3405.201.camel@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2015-10-30 10:13:26 +01:00
Ingo Molnar bebd23a2ed perf/core improvements and fixes:
New features:
 
 - Allow passing C language eBPF scriptlets via --event in all tools,
   so that it gets built using clang and then pass it to the kernel via
   sys_bpf() (Wang Nan)
 
 - Wire up the loaded ebpf object file with associated kprobes, so that
   it can determine if the kprobes will be filtered or not (Wang Nan)
 
 User visible:
 
 - Add cmd string table to decode sys_bpf first arg in 'trace' (Arnaldo Carvalho de Melo)
 
 - Enable printing of branch stack in 'perf script' (Stephane Eranian)
 
 - Pass the right file with debug info to libunwind (Rabin Vincent)
 
 Build Fixes:
 
 - Make sure fixdep is built before libbpf, fixing a race (Jiri Olsa)
 
 - Fix libiberty feature detection (Rabin Vincent)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWMqXLAAoJENZQFvNTUqpAheYP/0uYHUyYI9cNjF6/85cTotHS
 V+qXWxHAoYzBoTXmDVBEz25sA7yC1M4h+xPqQjI8ZnAe2ChJcqLZSsqkViMDZRV7
 LZhC5WIZ6EN0AaP/KUkTdDEm/bblm0mN1LX6v8BKFD5F8T5K8ur6Ml8w0vN27bbA
 WFb8SXjP3prt1xedR2UDilZqkB712ycOVH9LdePWlzHwsLt6ZyX2S85zwZVZkHnU
 tNHx6d3lG30imFNmq8fp7ShruD+yTmCY7fNdMFgv0t/XfVtyNaZeF/GswQGSRAIm
 osWmB0N23NqmhcQ239pNGlJGggWfemhCWOGxsZx0L1GLTnqA8OxBI1RMtFqjyNzn
 Mqu4WjQuXEGeHo9ZFwwieqa2z0d8j4IE7C/+L9DZiJZiZ+Dfn9v4NQ/3kK6kSNLX
 xvN54Td3flGz0vcHik4tnvU3R1Xocl10nOE0tXwJGns6w9TjteKCwdW5biTX3BCh
 zkbuASVAWrSTQ6/VSQ90UMdhwhgBFvTvVCxhsp37JX94beuA/D7HqwxNTecdS+/D
 ilTXTpLn9e6oeYryvMjlHMgpEh+q9gZEWyuhU8dowAl88UCR26O9SqCu/EgbpMSL
 cJGRbuYIb+IX1yUQmHRLT5JUxDgpXPwWaBoscSyElaAHdLE1dwcyoi/LcogxbdbQ
 OdLCmN2MvBoJzyOrCEPA
 =7aUd
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

New features:

  - Allow passing C language eBPF scriptlets via --event in all tools,
    so that it gets built using clang and then pass it to the kernel via
    sys_bpf(). (Wang Nan)

  - Wire up the loaded ebpf object file with associated kprobes, so that
    it can determine if the kprobes will be filtered or not. (Wang Nan)

User visible changes:

  - Add cmd string table to decode sys_bpf first arg in 'trace'. (Arnaldo Carvalho de Melo)

  - Enable printing of branch stack in 'perf script'. (Stephane Eranian)

  - Pass the right file with debug info to libunwind. (Rabin Vincent)

Build Fixes:

  - Make sure fixdep is built before libbpf, fixing a race. (Jiri Olsa)

  - Fix libiberty feature detection. (Rabin Vincent)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-10-30 10:09:37 +01:00
Dave Airlie 04ccb89073 Merge branch 'drm-fixes-4.3' of git://people.freedesktop.org/~agd5f/linux into drm-fixes
regression fix for backlight on old laptops.

* 'drm-fixes-4.3' of git://people.freedesktop.org/~agd5f/linux:
  drm/radeon: fix dpms when driver backlight control is disabled
  drm/radeon: move bl encoder assignment into bl init
2015-10-30 09:32:59 +10:00
Rabin Vincent 7ed4915ad6 perf unwind: Pass symbol source to libunwind
Even if --symfs is used to point to the debug binaries, we send in the
non-debug filenames to libunwind, which leads to libunwind not finding
the debug frame.  Fix this by preferring the file in --symfs, if it is
available.

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Rabin Vincent <rabinv@axis.com>
Link: http://lkml.kernel.org/r/1446104978-26429-1-git-send-email-rabin.vincent@axis.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 17:48:38 -03:00
Rabin Vincent 3af6ed84eb tools build: Fix libiberty feature detection
Any CFLAGS or LDFLAGS set by the user need to be passed to the feature
build command.  This many include for example -I or -L to point to
libraries and include files in custom paths.

In most of the test-*.bin rules in build/feature/Makefile, we use the BUILD
macro which always sends in CFLAGS and LDFLAGS.  The libiberty build line
however doesn't use the BUILD macro and thus needs to send in CFLAGS and
LDFLAGS explicitly.  Without this, when using custom CFLAGS/LDFLAGS, libiberty
fails to be detected and the perf link fails with something like:

   LINK     perf
  libbfd.a(bfd.o): In function `bfd_errmsg':
  bfd.c:(.text+0x168): undefined reference to `xstrerror'
  bbfd.a(opncls.o): In function `_bfd_new_bfd':
  opncls.c:(.text+0xe8): undefined reference to `objalloc_create'
  ...

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Rabin Vincent <rabinv@axis.com>
Link: http://lkml.kernel.org/r/1446104978-26429-2-git-send-email-rabin.vincent@axis.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 17:46:35 -03:00
Wang Nan d509db0473 perf tools: Compile scriptlets to BPF objects when passing '.c' to --event
This patch provides infrastructure for passing source files to --event
directly using:

 # perf record --event bpf-file.c command

This patch does following works:

 1) Allow passing '.c' file to '--event'. parse_events_load_bpf() is
    expanded to allow caller tell it whether the passed file is source
    file or object.

 2) llvm__compile_bpf() is called to compile the '.c' file, the result
    is saved into memory. Use bpf_object__open_buffer() to load the
    in-memory object.

Introduces a bpf-script-example.c so we can manually test it:

 # perf record --clang-opt "-DLINUX_VERSION_CODE=0x40200" --event ./bpf-script-example.c sleep 1

Note that '--clang-opt' must put before '--event'.

Futher patches will merge it into a testcase so can be tested automatically.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-10-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 17:16:23 -03:00
Wang Nan 71dc232625 perf record: Add clang options for compiling BPF scripts
Although previous patch allows setting BPF compiler related options in
perfconfig, on some ad-hoc situation it still requires passing options
through cmdline. This patch introduces 2 options to 'perf record' for
this propose: --clang-path and --clang-opt.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-9-git-send-email-wangnan0@huawei.com
[ Add the new options to the 'record' man page ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 17:16:22 -03:00
Wang Nan 1f45b1d490 perf bpf: Attach eBPF filter to perf event
This is the final patch which makes basic BPF filter work. After
applying this patch, users are allowed to use BPF filter like:

 # perf record --event ./hello_world.o ls

A bpf_fd field is appended to 'struct evsel', and setup during the
callback function add_bpf_event() for each 'probe_trace_event'.

PERF_EVENT_IOC_SET_BPF ioctl is used to attach eBPF program to a newly
created perf event. The file descriptor of the eBPF program is passed to
perf record using previous patches, and stored into evsel->bpf_fd.

It is possible that different perf event are created for one kprobe
events for different CPUs. In this case, when trying to call the ioctl,
EEXIST will be return. This patch doesn't treat it as an error.

Committer note:

The bpf proggie used so far:

  __attribute__((section("fork=_do_fork"), used))
  int fork(void *ctx)
  {
	  return 0;
  }

  char _license[] __attribute__((section("license"), used)) = "GPL";
  int _version __attribute__((section("version"), used)) = 0x40300;

failed to produce any samples, even with forks happening and it being
running in system wide mode.

That is because now the filter is being associated, and the code above
always returns zero, meaning that all forks will be probed but filtered
away ;-/

Change it to 'return 1;' instead and after that:

  # trace --no-syscalls --event /tmp/foo.o
     0.000 perf_bpf_probe:fork:(ffffffff8109be30))
     2.333 perf_bpf_probe:fork:(ffffffff8109be30))
     3.725 perf_bpf_probe:fork:(ffffffff8109be30))
     4.550 perf_bpf_probe:fork:(ffffffff8109be30))
  ^C#

And it works with all tools, including 'perf trace'.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-8-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 17:16:22 -03:00
Jiri Olsa 50f1e6d043 perf tools: Make sure fixdep is built before libbpf
While doing 'make -C tools/perf build-test':

   LD       fixdep-in.o
   LINK     fixdep
 /bin/sh: /home/acme/git/linux/tools/build/fixdep: Permission denied
 make[6]: *** [bpf.o] Error 1
 make[5]: *** [libbpf-in.o] Error 2
 make[4]: *** [/home/acme/git/linux/tools/lib/bpf/libbpf.a] Error 2
 make[4]: *** Waiting for unfinished jobs....

The fixdep tool needs to be built as the first binary.  Libraries are
built in paralel, so each of them needs to depend on fixdep target.

Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20151028204450.GA25553@krava.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 17:16:21 -03:00
Stephane Eranian dc323ce8e7 perf script: Enable printing of branch stack
This patch improves perf script by enabling printing of the
branch stack via the 'brstack' and 'brstacksym' arguments to
the field selection option -F. The option is off by default
and operates only if the perf.data file has branch stack content.

The branches are printed in to/from pairs. The most recent branch
is printed first. The number of branch entries vary based on the
underlying hardware and filtering used.

The brstack prints FROM/TO addresses in raw hexadecimal format.
The brstacksym prints FROM/TO addresses in symbolic form wherever
possible.

 $ perf script -F ip,brstack
  5d3000 0x401aa0/0x5d2000/M/-/-/-/0 ...

 $ perf script -F ip,brstacksym
  4011e0 noploop+0x0/noploop+0x0/P/-/-/0

The notation F/T/M/X/A/C describes the attributes of the branch.
F=from, T=to, M/P=misprediction/prediction, X=TSX, A=TSX abort, C=cycles (SKL)

Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yuanfang Chen <cyfmxc@gmail.com>
Link: http://lkml.kernel.org/r/1441039273-16260-5-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 17:16:20 -03:00
Ard Biesheuvel 73effccb91 arm64/efi: do not assume DRAM base is aligned to 2 MB
The current arm64 Image relocation code in the UEFI stub assumes that
the dram_base argument it receives is always a multiple of 2 MB. In
reality, it is simply the lowest start address of all RAM entries in
the UEFI memory map, which means it could be any multiple of 4 KB.

Since the arm64 kernel Image needs to reside TEXT_OFFSET bytes beyond
a 2 MB aligned base, or it will fail to boot, make sure we round dram_base
to 2 MB before using it to calculate the relocation address.

Fixes: e38457c361 ("arm64: efi: prefer AllocatePages() over efi_low_alloc() for vmlinux")
Reported-by: Timur Tabi <timur@codeaurora.org>
Tested-by: Timur Tabi <timur@codeaurora.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-10-29 16:10:58 +00:00
Russell King 116ef0fcc9 Merge branches 'fixes' and 'misc' into for-next 2015-10-29 15:21:30 +00:00
H. Nikolaus Schaller 38850d786a ARM: 8449/1: fix bug in vdsomunge swab32 macro
Commit 8a603f91cc ("ARM: 8445/1: fix vdsomunge not to depend on
glibc specific byteswap.h") unfortunately introduced a bug created but
not found during discussion and patch simplification.

Reported-by: Efraim Yawitz <efraim.yawitz@gmail.com>
Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
Fixes: 8a603f91cc ("ARM: 8445/1: fix vdsomunge not to depend on glibc specific byteswap.h")
Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
2015-10-29 15:20:15 +00:00
Alex Deucher ae93580ee5 drm/radeon: fix dpms when driver backlight control is disabled
If driver backlight control is disabled, either by driver
parameter or default per-asic setting, revert to the old behavior.

Fixes a regression in commit:
4281f46ef8

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
2015-10-29 11:13:40 -04:00
Alex Deucher 4cee6a9057 drm/radeon: move bl encoder assignment into bl init
So that the bl encoder will be null if the GPU does not
control the backlight.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
2015-10-29 11:13:18 -04:00
Arnaldo Carvalho de Melo 729a78417a perf trace: Add cmd string table to decode sys_bpf first arg
# perf trace -e bpf perf record -e /tmp/foo.o -a
   362.779 (0.130 ms): perf/3451 bpf(cmd: PROG_LOAD, uattr: 0x7ffe9a6825d0, size: 48) = 3

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-2b0nknu53baz9e0wj4thcdd8@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-29 11:48:18 -03:00
Hannes Frederic Sowa 89bc7848a9 ipv6: protect mtu calculation of wrap-around and infinite loop by rounding issues
Raw sockets with hdrincl enabled can insert ipv6 extension headers
right into the data stream. In case we need to fragment those packets,
we reparse the options header to find the place where we can insert
the fragment header. If the extension headers exceed the link's MTU we
actually cannot make progress in such a case.

Instead of ending up in broken arithmetic or rounding towards 0 and
entering an endless loop in ip6_fragment, just prevent those cases by
aborting early and signal -EMSGSIZE to user space.

This is the second version of the patch which doesn't use the
overflow_usub function, which got reverted for now.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-29 07:01:50 -07:00
Hannes Frederic Sowa 1e0d69a9cc Revert "Merge branch 'ipv6-overflow-arith'"
Linus dislikes these changes. To not hold up the net-merge let's revert
it for now and fix the bug like Linus suggested.

This reverts commit ec3661b422, reversing
changes made to c80dbe0461.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-29 07:01:48 -07:00
Vineet Gupta 5a364c2a17 ARC: mm: PAE40 support
This is the first working implementation of 40-bit physical address
extension on ARCv2.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2015-10-29 18:41:30 +05:30
Ingo Molnar 66a565c203 perf/ebpf basic integration
Please see the changeset comments, but this is the very basic integration of
 perf with libbpf that, given a .o file built for the 'bpf' target with clang,
 will get it validated and loaded into the kernel via the sys_bpf syscall, which
 can be seen using 'perf trace' to trace the whole thing looking just for the
 bpf and perf_event_open syscalls:
 
   # perf trace -e bpf,perf_event_open perf record -g --event /tmp/foo.o -a
    362.779 ( 0.129 ms): perf/22408 bpf(cmd: 5, uattr: 0x7ffd4edb6db0, size: 48                           ) = 3
    384.192 ( 0.016 ms): perf/22408 perf_event_open(attr_uptr: 0x7ffd4edbace0, pid: -1, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 5
    384.247 ( 0.038 ms): perf/22408 perf_event_open(attr_uptr: 0x37aedd8, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
    384.261 ( 0.007 ms): perf/22408 perf_event_open(attr_uptr: 0x37aedd8, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
    387.680 ( 3.413 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
    387.688 ( 0.005 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 6
    387.693 ( 0.004 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 7
    387.698 ( 0.003 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 8
   ^C[ perf record: Woken up 1 times to write data ]
     [ perf record: Captured and wrote 0.221 MB perf.data (2 samples) ]
   # perf script
   bash 18389 [002] 83446.412607: perf_bpf_probe:fork: (ffffffff8109be30)
                   29be31 _do_fork (/lib/modules/4.3.0-rc6+/build/vmlinux)
                   96d662 tracesys_phase2 (/lib/modules/4.3.0-rc6+/build/vmlinux)
                    bd56c __libc_fork (/usr/lib64/libc-2.17.so)
                    413b2 make_child (/usr/bin/bash)
 
   bash 18389 [002] 83447.227255: perf_bpf_probe:fork: (ffffffff8109be30)
                   29be31 _do_fork (/lib/modules/4.3.0-rc6+/build/vmlinux)
                   96d662 tracesys_phase2 (/lib/modules/4.3.0-rc6+/build/vmlinux)
                    bd56c __libc_fork (/usr/lib64/libc-2.17.so)
                    413b2 make_child (/usr/bin/bash)
 
   # perf evlist -v
   perf_bpf_probe:fork: type: 2, size: 112, config: 0x6cf, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
   #
 
 More work is about to be reviewed, tested and merged that will allow the whole
 process of going from a .c file to an .o file via clang, etc to be done
 automagically. (Wang Nan)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWMPzEAAoJENZQFvNTUqpAib4P/Ronv5SdIHxT1OfVZ6GiK9oG
 b+K72dAFcOZVg0aSRIe0s9jczKEomJBkT8H7JG5JOPGD94E/asWnItjuS9EwTaQG
 E2m/+OMwb0LhL4OeF7KH4YBAhNFMpBzlIO+IgHky8FNwuk2sa/dgPK8Xav3NLHzn
 yNunz+282RcSt9XE06Pm/tMCkcMQIvPbjRcXV5McA0zJYkCZDCYDKl3i11ypJY3K
 7t5sdz2Rau0wwG5XEsr5ZxQB4jphlzeYA+5YxiYxFigHlg/nSskzrwwSwxzQBSJb
 tHVBV9GQYVj2KEqS60kO4lNNTUPdhF92GNh3GSKa/laxtUYu+fBm224oz3cES86B
 oh8B8B05eSyj9WM4u23TSHir7Z8ppbtzTVfBXJNDO63dMZ/EhlL8r6uzfKNB3zM2
 aXMyUfcrF9wK8wnds4MA9VGwmkkXx3ailOH5zIskTNSzU5FK6WWAPptNFI1ykxJb
 56poai9g5F1VqE5X90yHgzRFC/Vc6GC4KuOjtw9ixzPZ6zA8TLYrDEtIeP5eZoC6
 ZaI8jF6+8+nOVoDwsYIoEYE+IFi/zhmpOOQ0eNoAv2+o6FaPJ7tSNmDMMcgE1CQN
 x9jVvAb3eVFuh5dLhLiCPxkE7qv8kAARt2qNncscMBTEVRJ3mNGSvjQcYB5ScOnp
 /W6no1caIEPGr/AZIXch
 =xGPO
 -----END PGP SIGNATURE-----

Merge tag 'perf-ebpf-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull basic perf/ebpf integration:

 "Please see the changeset comments, but this is the very basic integration of
  perf with libbpf that, given a .o file built for the 'bpf' target with clang,
  will get it validated and loaded into the kernel via the sys_bpf syscall, which
  can be seen using 'perf trace' to trace the whole thing looking just for the
  bpf and perf_event_open syscalls:

    # perf trace -e bpf,perf_event_open perf record -g --event /tmp/foo.o -a
     362.779 ( 0.129 ms): perf/22408 bpf(cmd: 5, uattr: 0x7ffd4edb6db0, size: 48                           ) = 3
     384.192 ( 0.016 ms): perf/22408 perf_event_open(attr_uptr: 0x7ffd4edbace0, pid: -1, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 5
     384.247 ( 0.038 ms): perf/22408 perf_event_open(attr_uptr: 0x37aedd8, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
     384.261 ( 0.007 ms): perf/22408 perf_event_open(attr_uptr: 0x37aedd8, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
     387.680 ( 3.413 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 5
     387.688 ( 0.005 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 6
     387.693 ( 0.004 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 7
     387.698 ( 0.003 ms): perf/22408 perf_event_open(attr_uptr: 0x3222f08, pid: -1, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 8
    ^C[ perf record: Woken up 1 times to write data ]
      [ perf record: Captured and wrote 0.221 MB perf.data (2 samples) ]
    # perf script
    bash 18389 [002] 83446.412607: perf_bpf_probe:fork: (ffffffff8109be30)
                    29be31 _do_fork (/lib/modules/4.3.0-rc6+/build/vmlinux)
                    96d662 tracesys_phase2 (/lib/modules/4.3.0-rc6+/build/vmlinux)
                     bd56c __libc_fork (/usr/lib64/libc-2.17.so)
                     413b2 make_child (/usr/bin/bash)

    bash 18389 [002] 83447.227255: perf_bpf_probe:fork: (ffffffff8109be30)
                    29be31 _do_fork (/lib/modules/4.3.0-rc6+/build/vmlinux)
                    96d662 tracesys_phase2 (/lib/modules/4.3.0-rc6+/build/vmlinux)
                     bd56c __libc_fork (/usr/lib64/libc-2.17.so)
                     413b2 make_child (/usr/bin/bash)

    # perf evlist -v
    perf_bpf_probe:fork: type: 2, size: 112, config: 0x6cf, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|RAW, disabled: 1, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
    #

  More work is about to be reviewed, tested and merged that will allow the whole
  process of going from a .c file to an .o file via clang, etc to be done
  automagically. (Wang Nan)"

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-10-29 13:17:56 +01:00
Jaehoon Chung 7cc8d58022 mmc: dw_mmc: fix the wrong setting for UHS-DDR50 mode
When card is running with DDR mode, dwmmc needs to set DDR_REG bit at
UHS_REG register.
Before this patch, dwmmc controller doesn't consider this.
If this patch is not applied, CRC or other error shoulds be occurred.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2015-10-29 11:00:43 +01:00
Jaehoon Chung 98daafd8a0 mmc: dw_mmc: fix the CardThreshold boundary at CardThrCtl register
According to DesignWare DoC file, CardThreshold bit should be
bit[27:16].
So it's correct to use (0xFFF << 16), not (0x1FFF << 16).

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2015-10-29 11:00:37 +01:00
Dan Carpenter 4539d36ef2 mmc: dw_mmc: NULL dereference in error message
The "host->dms->ch" pointer is NULL here so we can't use it to print the
error message.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2015-10-29 11:00:03 +01:00
Ingo Molnar 6fc774ef4c perf/core improvements and fixes:
User visible:
 
 - Enable per-event perf_event_attr.inherit setting by config terms, i.e.
   this becomes possible:
 
       $ perf record -e cycles/inherit/ -e instructions/no-inherit/
 
   This affects the default, that can be changed globally using the --no-inherit
   option.
 
   This fine grained control appeared in the eBPF patchkit, but this added
   flexibility may end up being useful in other scenarios (Wang Nan)
 
 - Setup pager when printing usage and help, we have long lists of options,
   better use the pager like we do with normal tooling output, i.e. when needed,
   and including any error messages in the paged output (Namhyung Kim)
 
 - Search for more options when passing args to -h, e.g.: (Arnaldo Carvalho de Melo)
 
   $ perf report -h interface
 
    Usage: perf report [<options>]
 
     --gtk    Use the GTK2 interface
     --stdio  Use the stdio interface
     --tui    Use the TUI interface
 
 - Fix reading separate debuginfo files based on a build-id, problem
   found on a Debian system (Dima Kogan)
 
 - Fix endless loop when splitting kallsyms symbols per section for
   handling kcore files, problem found on a s390x system (Jiri Olsa)
 
 Infrastructure:
 
 - Prep work for the 'perf stat record' work that will allow generating
   perf.data files with counting data in addition to the sampling mode
   we have now (Jiri Olsa)
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJWMOlbAAoJENZQFvNTUqpAZ6AQALTc4D/DvHRRwy7fypFPeSmy
 SNHp8ScgbNxrfXuc94UXF73G2afGO3IlH2duAlEF8wUbKXWSHpEWGb7exd/vGY2M
 6GdLVgE4j+3pWbjv6PzE41tExozb2MsmDN2KGlXdklqrjf9PVXgMT/eJLNm/9wEX
 Wuh+4fwDpoHTk7WS7aRWAQYF9qhxt5a4mk3tVgbHZskFL4xF9wJIs3ihTxuI1IOU
 rxmfyzORgcM9wFFdfqiFG4JHrjmtzmXGi8qQTqiStPUcWMP6H9TZLMnh0JPpSiyZ
 33vZVuXGszFQnWJkoAmg6EC2mxXXcv1Q/Z1AbRxuHHotC2Syq6B/vUVB7GobWwDB
 QkqgesAX6dke3JrmVheUSBmQv205oBTXsEqCk+Z+PesvufVBGaYO/uuwAs99bS9r
 f8bsYSsacGmqdFJECIuPrXGq5BHM/jaTAtISlsvos8pVWCMKpHke/OdG5f1apHKf
 iJRJ13zCkxnbq5O+HwlUZftVOw4EnKd7dhcYnVpRAtlE8wFnshjyYYMwVKTXyiZF
 VLAlUMc0/MK3AKybAwvmgrysGNTK1jKjzhWAKHdZ+qokeoeafwl9Q/hFjHeZvNhz
 n49CxBX00mmOerjZFdSlDfiqX0gEPRp5Wzmu+v3SBtPz81+hODR3vfFOI975lvxT
 b2v8kyW8lw8Sgr1ocDcK
 =wuI+
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - Enable per-event perf_event_attr.inherit setting by config terms, i.e.
    this becomes possible:

        $ perf record -e cycles/inherit/ -e instructions/no-inherit/

    This affects the default, that can be changed globally using the --no-inherit
    option.

    This fine grained control appeared in the eBPF patchkit, but this added
    flexibility may end up being useful in other scenarios. (Wang Nan)

  - Setup pager when printing usage and help, we have long lists of options,
    better use the pager like we do with normal tooling output, i.e. when needed,
    and including any error messages in the paged output. (Namhyung Kim)

  - Search for more options when passing args to -h, e.g.: (Arnaldo Carvalho de Melo)

    $ perf report -h interface

     Usage: perf report [<options>]

      --gtk    Use the GTK2 interface
      --stdio  Use the stdio interface
      --tui    Use the TUI interface

  - Fix reading separate debuginfo files based on a build-id, problem
    found on a Debian system. (Dima Kogan)

  - Fix endless loop when splitting kallsyms symbols per section for
    handling kcore files, problem found on a s390x system. (Jiri Olsa)

Infrastructure changes:

  - Prep work for the 'perf stat record' work that will allow generating
    perf.data files with counting data in addition to the sampling mode
    we have now (Jiri Olsa)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-10-29 10:29:18 +01:00
Marc Titinger 001e2e730c hwmon: (ina2xx) give precedence to DT over checking for platform data.
when checking for the value of the shunt resistor.

Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-10-28 21:53:15 -07:00
Marc Titinger a0de56c81f hwmon: (ina2xx) convert driver to using regmap
Any sysfs "show" read access from the client app will result in reading
all registers (8 with ina226). Depending on the host this can limit the
best achievable read rate.

This changeset allows for individual register accesses through regmap.

Tested with BeagleBone Black (Baylibre-ACME) and ina226.

Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-10-28 21:53:00 -07:00
Émeric MASCHINO d305c47734 [IA64] Wire up kcmp syscall
systemd > 218 fails to compile on ia64 with:

     error: ‘__NR_kcmp’ undeclared [1].

I've been told that this is because the kcmp syscall hasn't been wired up
for the ia64 arch [2].

The proposed patch thus wire up the kcmp syscall for the ia64 arch.

[1] https://bugs.gentoo.org/show_bug.cgi?id=560492
[2] https://bugs.gentoo.org/show_bug.cgi?id=560492#c17

Signed-off-by: Émeric MASCHINO <emeric.maschino@gmail.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
2015-10-28 14:22:59 -07:00
Tony Lindgren 8f2279d5d9 usb: musb: omap2430: Fix regression caused by driver core change
Commit ddef08dd00 ("Driver core: wakeup the parent device before trying
probe") started automatically ensuring the parent device is enabled when
the child gets probed.

This however caused a regression for MUSB omap2430 interface as the
runtime PM for the parent device needs the child initialized to access
the MUSB hardware registers.

Let's delay the enabling of PM runtime for the parent until the child
has been properly initialized as suggested in an earlier patch by
Grygorii Strashko <grygorii.strashko@ti.com>.

In addition to delaying pm_runtime_enable, we now also need to make sure
the parent is enabled during omap2430_musb_init. We also want to propagate
an error from omap2430_runtime_resume if struct musb is not initialized.

Note that we use pm_runtime_put_noidle here for both the child and parent
to prevent an extra runtime_suspend/resume cycle.

Let's also add some comments to avoid confusion between the
two different devices.

Fixes: ddef08dd00 ("Driver core: wakeup the parent device before
trying probe")
Suggested-by: Grygorii Strashko <grygorii.strashko@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2015-10-28 10:16:04 -07:00
Will Deacon 9702970c7b Revert "ARM64: unwind: Fix PC calculation"
This reverts commit e306dfd06f.

With this patch applied, we were the only architecture making this sort
of adjustment to the PC calculation in the unwinder. This causes
problems for ftrace, where the PC values are matched against the
contents of the stack frames in the callchain and fail to match any
records after the address adjustment.

Whilst there has been some effort to change ftrace to workaround this,
those patches are not yet ready for mainline and, since we're the odd
architecture in this regard, let's just step in line with other
architectures (like arch/arm/) for now.

Cc: <stable@vger.kernel.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-10-28 17:07:07 +00:00
Lorenzo Pieralisi e13d918a19 arm64: kernel: fix tcr_el1.t0sz restore on systems with extended idmap
Commit dd006da216 ("arm64: mm: increase VA range of identity map")
introduced a mechanism to extend the virtual memory map range
to support arm64 systems with system RAM located at very high offset,
where the identity mapping used to enable/disable the MMU requires
additional translation levels to map the physical memory at an equal
virtual offset.

The kernel detects at boot time the tcr_el1.t0sz value required by the
identity mapping and sets-up the tcr_el1.t0sz register field accordingly,
any time the identity map is required in the kernel (ie when enabling the
MMU).

After enabling the MMU, in the cold boot path the kernel resets the
tcr_el1.t0sz to its default value (ie the actual configuration value for
the system virtual address space) so that after enabling the MMU the
memory space translated by ttbr0_el1 is restored as expected.

Commit dd006da216 ("arm64: mm: increase VA range of identity map")
also added code to set-up the tcr_el1.t0sz value when the kernel resumes
from low-power states with the MMU off through cpu_resume() in order to
effectively use the identity mapping to enable the MMU but failed to add
the code required to restore the tcr_el1.t0sz to its default value, when
the core returns to the kernel with the MMU enabled, so that the kernel
might end up running with tcr_el1.t0sz value set-up for the identity
mapping which can be lower than the value required by the actual virtual
address space, resulting in an erroneous set-up.

This patchs adds code in the resume path that restores the tcr_el1.t0sz
default value upon core resume, mirroring this way the cold boot path
behaviour therefore fixing the issue.

Cc: <stable@vger.kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Fixes: dd006da216 ("arm64: mm: increase VA range of identity map")
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-10-28 17:07:07 +00:00
Will Deacon 589cb22bbe arm64: compat: fix stxr failure case in SWP emulation
If the STXR instruction fails in the SWP emulation code, we leave *data
overwritten with the loaded value, therefore corrupting the data written
by a subsequent, successful attempt.

This patch re-jigs the code so that we only write back to *data once we
know that the update has happened.

Cc: <stable@vger.kernel.org>
Fixes: bd35a4adc4 ("arm64: Port SWP/SWPB emulation support from arm")
Reported-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Reported-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-10-28 17:06:35 +00:00
Aaro Koskinen 1bd5dfe41b ARM: OMAP1: fix incorrect INT_DMA_LCD
Commit 685e2d08c5 ("ARM: OMAP1: Change interrupt numbering for
sparse IRQ") turned on SPARSE_IRQ on OMAP1, but forgot to change
the number of INT_DMA_LCD. This broke the boot at least on Nokia 770,
where the device hangs during framebuffer initialization.

Fix by defining INT_DMA_LCD like the other interrupts.

Cc: stable@vger.kernel.org # v4.2+
Fixes: 685e2d08c5 ("ARM: OMAP1: Change interrupt numbering for sparse IRQ")
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Tony Lindgren <tony@atomide.com>
2015-10-28 10:05:58 -07:00
Wang Nan 4edf30e39e perf bpf: Collect perf_evsel in BPF object files
This patch creates a 'struct perf_evsel' for every probe in a BPF object
file(s) and fills 'struct evlist' with them. The previously introduced
dummy event is now removed. After this patch, the following command:

 # perf record --event filter.o ls

Can trace on each of the probes defined in filter.o.

The core of this patch is bpf__foreach_tev(), which calls a callback
function for each 'struct probe_trace_event' event for a bpf program
with each associated file descriptors. The add_bpf_event() callback
creates evsels by calling parse_events_add_tracepoint().

Since bpf-loader.c will not be built if libbpf is turned off, an empty
bpf__foreach_tev() is defined in bpf-loader.h to avoid build errors.

Committer notes:

Before:

  # /tmp/oldperf record --event /tmp/foo.o -a usleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.198 MB perf.data ]
  # perf evlist
  /tmp/foo.o
  # perf evlist -v
  /tmp/foo.o: type: 1, size: 112, config: 0x9, { sample_period,
  sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD, disabled: 1,
  inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1,
  exclude_guest: 1, mmap2: 1, comm_exec: 1

I.e. we create just the PERF_TYPE_SOFTWARE (type: 1),
PERF_COUNT_SW_DUMMY(config 0x9) event, now, with this patch:

  # perf record --event /tmp/foo.o -a usleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.210 MB perf.data ]
  # perf evlist -v
  perf_bpf_probe:fork: type: 2, size: 112, config: 0x6bd, { sample_period,
  sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW, disabled: 1,
  inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, exclude_guest:
  1, mmap2: 1, comm_exec: 1
  #

We now have a PERF_TYPE_SOFTWARE (type: 1), but the config states 0x6bd,
which is how, after setting up the event via the kprobes interface, the
'perf_bpf_probe:fork' event is accessible via the perf_event_open
syscall. This is all transient, as soon as the 'perf record' session
ends, these probes will go away.

To see how it looks like, lets try doing a neverending session, one that
expects a control+C to end:

  # perf record --event /tmp/foo.o -a

So, with that in place, we can use 'perf probe' to see what is in place:

  # perf probe -l
    perf_bpf_probe:fork  (on _do_fork@acme/git/linux/kernel/fork.c)

We also can use debugfs:

  [root@felicio ~]# cat /sys/kernel/debug/tracing/kprobe_events
  p:perf_bpf_probe/fork _text+638512

Ok, now lets stop and see if we got some forks:

  [root@felicio linux]# perf record --event /tmp/foo.o -a
  ^C[ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.325 MB perf.data (111 samples) ]

  [root@felicio linux]# perf script
      sshd  1271 [003] 81797.507678: perf_bpf_probe:fork: (ffffffff8109be30)
      sshd 18309 [000] 81797.524917: perf_bpf_probe:fork: (ffffffff8109be30)
      sshd 18309 [001] 81799.381603: perf_bpf_probe:fork: (ffffffff8109be30)
      sshd 18309 [001] 81799.408635: perf_bpf_probe:fork: (ffffffff8109be30)
  <SNIP>

Sure enough, we have 111 forks :-)

Callchains seems to work as well:

  # perf report --stdio --no-child
  # To display the perf.data header info, please use --header/--header-only options.
  #
  # Total Lost Samples: 0
  #
  # Samples: 562  of event 'perf_bpf_probe:fork'
  # Event count (approx.): 562
  #
  # Overhead  Command   Shared Object     Symbol
  # ........  ........  ................  ............
  #
      44.66%  sh        [kernel.vmlinux]  [k] _do_fork
                    |
                    ---_do_fork
                       entry_SYSCALL_64_fastpath
                       __libc_fork
                       make_child

    26.16%  make      [kernel.vmlinux]  [k] _do_fork
<SNIP>
  #

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-7-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-28 13:11:59 -03:00
Wang Nan 1e5e3ee8ff perf tools: Load eBPF object into kernel
This patch utilizes bpf_object__load() provided by libbpf to load all
objects into kernel.

Committer notes:

Testing it:

When using an incorrect kernel version number, i.e., having this in your
eBPF proggie:

  int _version __attribute__((section("version"), used)) = 0x40100;

For a 4.3.0-rc6+ kernel, say, this happens and needs checking at event
parsing time, to provide a better error report to the user:

  # perf record --event /tmp/foo.o sleep 1
  libbpf: load bpf program failed: Invalid argument
  libbpf: -- BEGIN DUMP LOG ---
  libbpf:

  libbpf: -- END LOG --
  libbpf: failed to load program 'fork=_do_fork'
  libbpf: failed to load object '/tmp/foo.o'
  event syntax error: '/tmp/foo.o'
                       \___ Invalid argument: Are you root and runing a CONFIG_BPF_SYSCALL kernel?

  (add -v to see detail)
  Run 'perf list' for a list of valid events

   Usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list available events

If we instead make it match, i.e. use 0x40300 on this v4.3.0-rc6+
kernel, the whole process goes thru:

  # perf record --event /tmp/foo.o -a usleep 1
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.202 MB perf.data ]
  # perf evlist -v
  /tmp/foo.o: type: 1, size: 112, config: 0x9, { sample_period,
  sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD, disabled: 1,
  inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1,
  exclude_guest: 1, mmap2: 1, comm_exec: 1
  #

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-6-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-28 13:09:50 -03:00
Wang Nan aa3abf30bb perf tools: Create probe points for BPF programs
This patch introduces bpf__{un,}probe() functions to enable callers to
create kprobe points based on section names a BPF program. It parses the
section names in the program and creates corresponding 'struct
perf_probe_event' structures. The parse_perf_probe_command() function is
used to do the main parsing work. The resuling 'struct perf_probe_event'
is stored into program private data for further using.

By utilizing the new probing API, this patch creates probe points during
event parsing.

To ensure probe points be removed correctly, register an atexit hook so
even perf quit through exit() bpf__clear() is still called, so probing
points are cleared. Note that bpf_clear() should be registered before
bpf__probe() is called, so failure of bpf__probe() can still trigger
bpf__clear() to remove probe points which are already probed.

strerror style error reporting scaffold is created by this patch.
bpf__strerror_probe() is the first error reporting function in
bpf-loader.c.

Committer note:

Trying it:

To build a test eBPF object file:

I am testing using a script I built from the 'perf test -v LLVM' output:

  $ cat ~/bin/hello-ebpf
  export KERNEL_INC_OPTIONS="-nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/4.8.3/include -I/home/acme/git/linux/arch/x86/include -Iarch/x86/include/generated/uapi -Iarch/x86/include/generated -I/home/acme/git/linux/include -Iinclude -I/home/acme/git/linux/arch/x86/include/uapi -Iarch/x86/include/generated/uapi -I/home/acme/git/linux/include/uapi -Iinclude/generated/uapi -include /home/acme/git/linux/include/linux/kconfig.h"
  export WORKING_DIR=/lib/modules/4.2.0/build
  export CLANG_SOURCE=-
  export CLANG_OPTIONS=-xc

  OBJ=/tmp/foo.o
  rm -f $OBJ
  echo '__attribute__((section("fork=do_fork"), used)) int fork(void *ctx) {return 0;} char _license[] __attribute__((section("license"), used)) = "GPL";int _version __attribute__((section("version"), used)) = 0x40100;' | \
  clang -D__KERNEL__ $CLANG_OPTIONS $KERNEL_INC_OPTIONS -Wno-unused-value -Wno-pointer-sign -working-directory $WORKING_DIR -c "$CLANG_SOURCE" -target bpf -O2 -o /tmp/foo.o && file $OBJ

 ---

First asking to put a probe in a function not present in the kernel
(misses the initial _):

  $ perf record --event /tmp/foo.o sleep 1
  Probe point 'do_fork' not found.
  event syntax error: '/tmp/foo.o'
                       \___ You need to check probing points in BPF file

  (add -v to see detail)
  Run 'perf list' for a list of valid events

   Usage: perf record [<options>] [<command>]
      or: perf record [<options>] -- <command> [<options>]

      -e, --event <event>   event selector. use 'perf list' to list available events
  $

 ---

Now, with "__attribute__((section("fork=_do_fork"), used)):

 $ grep _do_fork /proc/kallsyms
 ffffffff81099ab0 T _do_fork
 $ perf record --event /tmp/foo.o sleep 1
 Failed to open kprobe_events: Permission denied
 event syntax error: '/tmp/foo.o'
                      \___ Permission denied

 ---

Cool, we need to provide some better hints, "kprobe_events" is too low
level, one doesn't strictly need to know the precise details of how
these things are put in place, so something that shows the command
needed to fix the permissions would be more helpful.

Lets try as root instead:

  # perf record --event /tmp/foo.o sleep 1
  Lowering default frequency rate to 1000.
  Please consider tweaking /proc/sys/kernel/perf_event_max_sample_rate.
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 0.013 MB perf.data ]
  # perf evlist
  /tmp/foo.o
  [root@felicio ~]# perf evlist -v
  /tmp/foo.o: type: 1, size: 112, config: 0x9, { sample_period,
  sample_freq }: 1000, sample_type: IP|TID|TIME|PERIOD, disabled: 1,
  inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1,
  sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1

 ---

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@gmail.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kaixu Xia <xiakaixu@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1444826502-49291-5-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-10-28 12:48:13 -03:00