Re: [PATCH] mm/slab_common.c: fix possible spectre-v1 in kmalloc_slab()
On Thu, May 30, 2019 at 2:24 PM Michal Hocko wrote: > I understand the general mechanism of spectre v1. What I was asking for > is an example of where userspace directly controls the allocation size > as this is usually bounded to an in kernel object size. I can see how > and N * sizeof(object) where N is controlled by the userspace could be > the target. But calling that out explicitly would be appreciated. In the syscall call poll, the user can control the `nfds`, when call the function `do_sys_poll` it can pass the nfds to function `do_sys_poll`, and pass to variable `len`, although there exit compare instruction llike `len = min_t(unsigned int, nfds, N_STACK_PPS)`, `len = min(todo, POLLFD_PER_PAGE);`, but it can also bypass by speculation, as the speculation windows are large, and in the next `size = sizeof(struct poll_list) + sizeof(struct pollfd) * len`, which can indirect control the size. > Please mention that in the changelog as well. ok, thanks for suggestion.
[PATCH v3] riscv: Fix udelay in RV32.
In RV32, udelay would delay the wrong cycle. When it shifts right "UDELAY_SHITFT" bits, it either delays 0 cycle or 1 cycle. It only works correctly in RV64. Because the 'ucycles' always needs to be 64 bits variable. Signed-off-by: Nick Hu Reviewed-by: Palmer Dabbelt --- arch/riscv/lib/delay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/lib/delay.c b/arch/riscv/lib/delay.c index dce8ae24c6d3..ee6853c1e341 100644 --- a/arch/riscv/lib/delay.c +++ b/arch/riscv/lib/delay.c @@ -88,7 +88,7 @@ EXPORT_SYMBOL(__delay); void udelay(unsigned long usecs) { - unsigned long ucycles = usecs * lpj_fine * UDELAY_MULT; + u64 ucycles = (u64)usecs * lpj_fine * UDELAY_MULT; if (unlikely(usecs > MAX_UDELAY_US)) { __delay((u64)usecs * riscv_timebase / 100ULL); -- 2.17.0
Re: [PATCH 4.19 000/276] 4.19.47-stable review
stable-rc/linux-4.19.y boot: 118 boots: 0 failed, 118 passed (v4.19.46-277-g9c8c1a222a6b) Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.19.y/kernel/v4.19.46-277-g9c8c1a222a6b/ Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.19.y/kernel/v4.19.46-277-g9c8c1a222a6b/ Tree: stable-rc Branch: linux-4.19.y Git Describe: v4.19.46-277-g9c8c1a222a6b Git Commit: 9c8c1a222a6b10169a5d95dd02011515ff85f709 Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git Tested: 63 unique boards, 22 SoC families, 14 builds out of 206 --- For more info write to
Re: [PATCH 5.1 000/405] 5.1.6-stable review
stable-rc/linux-5.1.y boot: 125 boots: 1 failed, 122 passed with 2 untried/unknown (v5.1.5-406-ge151dd0525b9) Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-5.1.y/kernel/v5.1.5-406-ge151dd0525b9/ Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-5.1.y/kernel/v5.1.5-406-ge151dd0525b9/ Tree: stable-rc Branch: linux-5.1.y Git Describe: v5.1.5-406-ge151dd0525b9 Git Commit: e151dd0525b9aaeac84987d2790c30d8a89ae274 Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git Tested: 69 unique boards, 22 SoC families, 14 builds out of 209 Boot Failure Detected: arm: multi_v7_defconfig: gcc-8: bcm4708-smartrg-sr400ac: 1 failed lab --- For more info write to
Re: [PATCH v4] ipvs: add checksum support for gue encapsulation
Hello, On Thu, 30 May 2019, Jacky Hu wrote: > Add checksum support for gue encapsulation with the tun_flags parameter, > which could be one of the values below: > IP_VS_TUNNEL_ENCAP_FLAG_NOCSUM > IP_VS_TUNNEL_ENCAP_FLAG_CSUM > IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM > > Signed-off-by: Jacky Hu Looks good to me, thanks! Signed-off-by: Julian Anastasov > --- > v4->v3: > 1) defer pd assignment after data += GUE_LEN_PRIV > > v3->v2: > 1) fixed CHECK: spaces preferred around that '<<' (ctx:VxV) > > v2->v1: > 1) removed unnecessary changes to ip_vs_core.c > 2) use correct nla_get/put function for tun_flags > 3) use correct gue hdrlen for skb_push in ipvs_gue_encap > 4) moved declaration of gue_hdrlen and gue_optlen > > include/net/ip_vs.h | 2 + > include/uapi/linux/ip_vs.h | 7 ++ > net/netfilter/ipvs/ip_vs_ctl.c | 11 ++- > net/netfilter/ipvs/ip_vs_xmit.c | 143 > 4 files changed, 146 insertions(+), 17 deletions(-) > > diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h > index b01a94ebfc0e..cb1ad0cc5c7b 100644 > --- a/include/net/ip_vs.h > +++ b/include/net/ip_vs.h > @@ -603,6 +603,7 @@ struct ip_vs_dest_user_kern { > > u16 tun_type; /* tunnel type */ > __be16 tun_port; /* tunnel port */ > + u16 tun_flags; /* tunnel flags */ > }; > > > @@ -665,6 +666,7 @@ struct ip_vs_dest { > atomic_tlast_weight;/* server latest weight */ > __u16 tun_type; /* tunnel type */ > __be16 tun_port; /* tunnel port */ > + __u16 tun_flags; /* tunnel flags */ > > refcount_t refcnt; /* reference counter */ > struct ip_vs_stats stats; /* statistics */ > diff --git a/include/uapi/linux/ip_vs.h b/include/uapi/linux/ip_vs.h > index e34f436fc79d..e4f18061a4fd 100644 > --- a/include/uapi/linux/ip_vs.h > +++ b/include/uapi/linux/ip_vs.h > @@ -131,6 +131,11 @@ enum { > IP_VS_CONN_F_TUNNEL_TYPE_MAX, > }; > > +/* Tunnel encapsulation flags */ > +#define IP_VS_TUNNEL_ENCAP_FLAG_NOCSUM (0) > +#define IP_VS_TUNNEL_ENCAP_FLAG_CSUM (1 << 0) > +#define IP_VS_TUNNEL_ENCAP_FLAG_REMCSUM (1 << 1) > + > /* > * The struct ip_vs_service_user and struct ip_vs_dest_user are > * used to set IPVS rules through setsockopt. > @@ -403,6 +408,8 @@ enum { > > IPVS_DEST_ATTR_TUN_PORT,/* tunnel port */ > > + IPVS_DEST_ATTR_TUN_FLAGS, /* tunnel flags */ > + > __IPVS_DEST_ATTR_MAX, > }; > > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c > index d5847e06350f..ad19ac08622f 100644 > --- a/net/netfilter/ipvs/ip_vs_ctl.c > +++ b/net/netfilter/ipvs/ip_vs_ctl.c > @@ -893,6 +893,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct > ip_vs_dest *dest, > /* set the tunnel info */ > dest->tun_type = udest->tun_type; > dest->tun_port = udest->tun_port; > + dest->tun_flags = udest->tun_flags; > > /* set the IP_VS_CONN_F_NOOUTPUT flag if not masquerading/NAT */ > if ((conn_flags & IP_VS_CONN_F_FWD_MASK) != IP_VS_CONN_F_MASQ) { > @@ -2967,6 +2968,7 @@ static const struct nla_policy > ip_vs_dest_policy[IPVS_DEST_ATTR_MAX + 1] = { > [IPVS_DEST_ATTR_ADDR_FAMILY]= { .type = NLA_U16 }, > [IPVS_DEST_ATTR_TUN_TYPE] = { .type = NLA_U8 }, > [IPVS_DEST_ATTR_TUN_PORT] = { .type = NLA_U16 }, > + [IPVS_DEST_ATTR_TUN_FLAGS] = { .type = NLA_U16 }, > }; > > static int ip_vs_genl_fill_stats(struct sk_buff *skb, int container_type, > @@ -3273,6 +3275,8 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, > struct ip_vs_dest *dest) > dest->tun_type) || > nla_put_be16(skb, IPVS_DEST_ATTR_TUN_PORT, >dest->tun_port) || > + nla_put_u16(skb, IPVS_DEST_ATTR_TUN_FLAGS, > + dest->tun_flags) || > nla_put_u32(skb, IPVS_DEST_ATTR_U_THRESH, dest->u_threshold) || > nla_put_u32(skb, IPVS_DEST_ATTR_L_THRESH, dest->l_threshold) || > nla_put_u32(skb, IPVS_DEST_ATTR_ACTIVE_CONNS, > @@ -3393,7 +3397,8 @@ static int ip_vs_genl_parse_dest(struct > ip_vs_dest_user_kern *udest, > /* If a full entry was requested, check for the additional fields */ > if (full_entry) { > struct nlattr *nla_fwd, *nla_weight, *nla_u_thresh, > - *nla_l_thresh, *nla_tun_type, *nla_tun_port; > + *nla_l_thresh, *nla_tun_type, *nla_tun_port, > + *nla_tun_flags; > > nla_fwd = attrs[IPVS_DEST_ATTR_FWD_METHOD]; > nla_weight = attrs[IPVS_DEST_ATTR_WEIGHT]; > @@ -3401,6 +3406,7 @@ static int ip_vs_genl_parse_dest(struct > ip_vs_dest_user_kern *
[PATCH] media: wl128x: Fix some error handling in fm_v4l2_init_video_device()
The fm_v4l2_init_video_device() forget to unregister v4l2/video device in the error path, it could lead to UAF issue, eg, BUG: KASAN: use-after-free in atomic64_read include/asm-generic/atomic-instrumented.h:836 [inline] BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:28 [inline] BUG: KASAN: use-after-free in __mutex_unlock_slowpath+0x92/0x690 kernel/locking/mutex.c:1206 Read of size 8 at addr 8881e84a7c70 by task v4l_id/3659 CPU: 1 PID: 3659 Comm: v4l_id Not tainted 5.1.0 #8 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xa9/0x10e lib/dump_stack.c:113 print_address_description+0x65/0x270 mm/kasan/report.c:187 kasan_report+0x149/0x18d mm/kasan/report.c:317 atomic64_read include/asm-generic/atomic-instrumented.h:836 [inline] atomic_long_read include/asm-generic/atomic-long.h:28 [inline] __mutex_unlock_slowpath+0x92/0x690 kernel/locking/mutex.c:1206 fm_v4l2_fops_open+0xac/0x120 [fm_drv] v4l2_open+0x191/0x390 [videodev] chrdev_open+0x20d/0x570 fs/char_dev.c:417 do_dentry_open+0x700/0xf30 fs/open.c:777 do_last fs/namei.c:3416 [inline] path_openat+0x7c4/0x2a90 fs/namei.c:3532 do_filp_open+0x1a5/0x2b0 fs/namei.c:3563 do_sys_open+0x302/0x490 fs/open.c:1069 do_syscall_64+0x9f/0x450 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7f8180c17c8e ... Allocated by task 3642: set_track mm/kasan/common.c:87 [inline] __kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:497 fm_drv_init+0x13/0x1000 [fm_drv] do_one_initcall+0xbc/0x47d init/main.c:901 do_init_module+0x1b5/0x547 kernel/module.c:3456 load_module+0x6405/0x8c10 kernel/module.c:3804 __do_sys_finit_module+0x162/0x190 kernel/module.c:3898 do_syscall_64+0x9f/0x450 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 3642: set_track mm/kasan/common.c:87 [inline] __kasan_slab_free+0x130/0x180 mm/kasan/common.c:459 slab_free_hook mm/slub.c:1429 [inline] slab_free_freelist_hook mm/slub.c:1456 [inline] slab_free mm/slub.c:3003 [inline] kfree+0xe1/0x270 mm/slub.c:3958 fm_drv_init+0x1e6/0x1000 [fm_drv] do_one_initcall+0xbc/0x47d init/main.c:901 do_init_module+0x1b5/0x547 kernel/module.c:3456 load_module+0x6405/0x8c10 kernel/module.c:3804 __do_sys_finit_module+0x162/0x190 kernel/module.c:3898 do_syscall_64+0x9f/0x450 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Add relevant unregister functions to fix it. Cc: Mauro Carvalho Chehab Cc: Hans Verkuil Reported-by: Hulk Robot Signed-off-by: Kefeng Wang --- drivers/media/radio/wl128x/fmdrv_v4l2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c index e25fd4d4d280..a1eaea19a81c 100644 --- a/drivers/media/radio/wl128x/fmdrv_v4l2.c +++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c @@ -550,6 +550,7 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr) /* Register with V4L2 subsystem as RADIO device */ if (video_register_device(&gradio_dev, VFL_TYPE_RADIO, radio_nr)) { + v4l2_device_unregister(&fmdev->v4l2_dev); fmerr("Could not register video device\n"); return -ENOMEM; } @@ -563,6 +564,8 @@ int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr) if (ret < 0) { fmerr("(fmdev): Can't init ctrl handler\n"); v4l2_ctrl_handler_free(&fmdev->ctrl_handler); + video_unregister_device(fmdev->radio_dev); + v4l2_device_unregister(&fmdev->v4l2_dev); return -EBUSY; } -- 2.20.1
Re: [LKP] [SUNRPC] 0472e47660: fsmark.app_overhead 16.0% regression
On 5/30/2019 10:00 AM, Trond Myklebust wrote: Hi Xing, On Thu, 2019-05-30 at 09:35 +0800, Xing Zhengjun wrote: Hi Trond, On 5/20/2019 1:54 PM, kernel test robot wrote: Greeting, FYI, we noticed a 16.0% improvement of fsmark.app_overhead due to commit: commit: 0472e476604998c127f3c80d291113e77c5676ac ("SUNRPC: Convert socket page send code to use iov_iter()") https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master in testcase: fsmark on test machine: 40 threads Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz with 384G memory with following parameters: iterations: 1x nr_threads: 64t disk: 1BRD_48G fs: xfs fs2: nfsv4 filesize: 4M test_size: 40G sync_method: fsyncBeforeClose cpufreq_governor: performance test-description: The fsmark is a file system benchmark to test synchronous write workloads, for example, mail servers workload. test-url: https://sourceforge.net/projects/fsmark/ Details are as below: - -> To reproduce: git clone https://github.com/intel/lkp-tests.git cd lkp-tests bin/lkp install job.yaml # job file is attached in this email bin/lkp run job.yaml === == compiler/cpufreq_governor/disk/filesize/fs2/fs/iterations/kconfig/n r_threads/rootfs/sync_method/tbox_group/test_size/testcase: gcc-7/performance/1BRD_48G/4M/nfsv4/xfs/1x/x86_64-rhel- 7.6/64t/debian-x86_64-2018-04-03.cgz/fsyncBeforeClose/lkp-ivb- ep01/40G/fsmark commit: e791f8e938 ("SUNRPC: Convert xs_send_kvec() to use iov_iter_kvec()") 0472e47660 ("SUNRPC: Convert socket page send code to use iov_iter()") e791f8e9380d945e 0472e476604998c127f3c80d291 --- fail:runs %reproductionfail:runs | | | :4 50% 2:4 dmesg.WARNING:at#for _ip_interrupt_entry/0x %stddev %change %stddev \ |\ 15118573 ± 2% +16.0% 17538083fsmark.app_overhead 510.93 -22.7% 395.12fsmark.files_per_sec 24.90 +22.8% 30.57fsmark.time.elapsed_ time 24.90 +22.8% 30.57fsmark.time.elapsed_ time.max 288.00 ± 2% - 27.8% 208.00fsmark.time.percent_of_cpu_this_job_got 70.03 ± 2% - 11.3% 62.14fsmark.time.system_time Do you have time to take a look at this regression? From your stats, it looks to me as if the problem is increased NUMA overhead. Pretty much everything else appears to be the same or actually performing better than previously. Am I interpreting that correctly? The real regression is the throughput(fsmark.files_per_sec) is decreased by 22.7%. If my interpretation above is correct, then I'm not seeing where this patch would be introducing new NUMA regressions. It is just converting from using one method of doing socket I/O to another. Could it perhaps be a memory artefact due to your running the NFS client and server on the same machine? Apologies for pushing back a little, but I just don't have the hardware available to test NUMA configurations, so I'm relying on external testing for the above kind of scenario. Thanks for looking at this. If you need more information, please let me know. Thanks Trond -- Zhengjun Xing
Re: [PATCH V5 0/3] arm64/mm: Enable memory hot remove
On 30.05.19 06:23, Anshuman Khandual wrote: > > > On 05/30/2019 03:36 AM, Andrew Morton wrote: >> On Wed, 29 May 2019 14:46:24 +0530 Anshuman Khandual >> wrote: >> >>> This series enables memory hot remove on arm64 after fixing a memblock >>> removal ordering problem in generic __remove_memory() and one possible >>> arm64 platform specific kernel page table race condition. This series >>> is based on latest v5.2-rc2 tag. >> >> Unfortunately this series clashes syntactically and semantically with >> David Hildenbrand's series "mm/memory_hotplug: Factor out memory block >> devicehandling". Could you and David please figure out what we should >> do here? >> > > Hello Andrew, > > I was able to apply the above mentioned V3 series [1] from David with some > changes > listed below which tests positively on arm64. These changes assume that the > arm64 > hot-remove series (current V5) gets applied first. > > Changes to David's series > > A) Please drop (https://patchwork.kernel.org/patch/10962565/) [v3,04/11] > > - arch_remove_memory() is already being added through hot-remove series > > B) Rebase (https://patchwork.kernel.org/patch/10962575/) [v3, 06/11] > > - arm64 hot-remove series adds CONFIG_MEMORY_HOTREMOVE wrapper around > arch_remove_memory() which can be dropped in the rebased patch > > C) Rebase (https://patchwork.kernel.org/patch/10962589/) [v3, 09/11] > > - hot-remove series moves arch_remove_memory() before > memblock_[free|remove]() > - So remove_memory_block_devices() should be moved before > arch_remove_memory() > in it's new position > > David, > > Please do let me know if the plan sounds good or you have some other > suggestions. That's exactly what I had in mind :) Andrew, you can drop my series and pick up Anshumans series first. I can then rebase and resend. Cheers! -- Thanks, David / dhildenb
Re: [HELP] How to get task_struct from mm
On 5/30/19 2:57 PM, Yang Shi wrote: Hi folks, As what we discussed about page demotion for PMEM at LSF/MM, the demotion should respect to the mempolicy and allowed mems of the process which the page (anonymous page only for now) belongs to. The vma that the page is mapped to can be retrieved from rmap walk easily, but we need know the task_struct that the vma belongs to. It looks there is not such API, and container_of seems not work with pointer member. Any suggestion? mm->owner is defined for CONFIG_MEMCG only, I'm wondering whether we can extend this to !CONFIG_MEMCG case or not? Thanks, Yang
Re: [PATCH] perf: Fix oops when kthread execs user process
On Wed, May 29, 2019 at 06:44:07PM +0200, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 05:25:28PM +0100, Will Deacon wrote: > > > > > > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > > > > > On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > > > > > > > > > > > > if (user_mode(regs)) { > > > > > > > > > > > > Hmm, so it just occurred to me that Mark's observation is that the > > > > > > regs > > > > > > can be junk in some cases. In which case, should we be checking for > > > > > > kthreads first? > > > Sorry, I'm not trying to catch you out! Just trying to understand what the > > semantics are supposed to be. > > > > I do find the concept of user_mode(regs) bizarre for the idle task. By the > > above, we definitely have a bug on arm64 (user_mode(regs) tends to be > > true for the idle task), and I couldn't figure out how you avoided it on > > x86. I guess it happens to work because the stack is zero-initialised or > > something? > > So lets take the whole thing: > > static void perf_sample_regs_user(struct perf_regs *regs_user, > struct pt_regs *regs, > struct pt_regs *regs_user_copy) > { > if (user_mode(regs)) { > regs_user->abi = perf_reg_abi(current); > regs_user->regs = regs; > } else if (!(current->flags & PF_KTHREAD)) { > perf_get_regs_user(regs_user, regs, regs_user_copy); > } else { > regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE; > regs_user->regs = NULL; > } > } > > This is called from the perf-generate-a-sample path, which is typically > an exception (IRQ/NMI/whatever) or a software/tracepoint thing. Yes, sorry, fell into the same trap as Mark here and misunderstood your assertion about user_mode(regs) always needing to be valid. Then I went down a stupid rabbit hole and dragged you with me. I can't ack a patch twice, so I'll just go do something else for a bit... Thanks for your patience! Will
Re: [v3 PATCH] usb: create usb_debug_root for gadget only
Hi Felipe, On Tue, 2019-05-28 at 11:11 +0300, Felipe Balbi wrote: > Hi, > > Chunfeng Yun writes: > > diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c > > index 7fcb9f782931..88b3ee03a12d 100644 > > --- a/drivers/usb/core/usb.c > > +++ b/drivers/usb/core/usb.c > > @@ -1190,7 +1190,7 @@ EXPORT_SYMBOL_GPL(usb_debug_root); > > > > static void usb_debugfs_init(void) > > { > > - usb_debug_root = debugfs_create_dir("usb", NULL); > > + usb_debug_root = debugfs_create_dir(USB_DEBUG_ROOT_NAME, NULL); > > debugfs_create_file("devices", 0444, usb_debug_root, NULL, > > &usbfs_devices_fops); > > } > > might be a better idea to move this to usb common. Then have a function > which can be called by both host and gadget to maybe create the > directory: > > static struct dentry *usb_debug_root; > > struct dentry *usb_debugfs_init(void) > { > if (!usb_debug_root) > usb_debug_root = debugfs_create_dir("usb", NULL); > > return usb_debug_root; > } > > > Then usb core would be updated to something like: > > static void usb_core_debugfs_init(void) > { > struct dentry *root = usb_debugfs_init(); > > debugfs_create_file("devices", 0444, root, NULL, &usbfs_devices_fops); > } > I find a problem when move usb_debugfs_init() and usb_debugfs_cleanup() into usb common, it's easy to create "usb" directory, but difficult to cleanup it: common/common.c struct dentry *usb_debugfs_init(void) { if (!usb_debug_root) usb_debug_root = debugfs_create_dir("usb", NULL); return usb_debug_root; } void usb_debugfs_cleanup(void) { debugfs_remove_recursive(usb_debug_root); usb_debug_root = NULL; } core/usb.c static void usb_core_debugfs_init(void) { struct dentry *root = usb_debugfs_init(); debugfs_create_file("devices", 0444, root, NULL, &usbfs_devices_fops); } static int __init usb_init(void) { ... usb_core_debugfs_init(); ... } static void __exit usb_exit(void) { ... usb_debugfs_cleanup(); // will be error, gadget may use it. ... } gadget/udc/core.c static int __init usb_udc_init(void) { ... usb_debugfs_init(); ... } static void __exit usb_udc_exit(void) { ... usb_debugfs_cleanup(); // can't cleanup in fact, usb core may use it. } How to handle this case? introduce a reference count? do you have any suggestion? Thanks a lot
Re: [PATCH v2 11/17] locking/lockdep: Adjust lockdep selftest cases
Thanks for review. On Wed, 29 May 2019 at 19:44, Boqun Feng wrote: > > > @@ -424,7 +424,7 @@ static void rwsem_ABBA2(void) > > ML(Y1); > > RSL(X1); > > RSU(X1); > > - MU(Y1); // should fail > > + MU(Y1); // should NOT fail > > I'm afraid you get this wrong ;-) reader of rwsem is non-recursive if I > understand correctly, so case like: > > Task 0 Task 1 > > down_read(A); > mutex_lock(B); > > down_read(A); > mutex_lock(B); > > can be a deadlock, if we consider a third independent task: > > Task 0 Task 1 Task 2 > > down_read(A); > mutex_lock(B); > down_write(A); > down_read(A); > mutex_lock(B); > > in this case, Task 1 can not get it's lock for A, therefore, deadlock. Well, yes. This situation is damn counterintuitive and looks suboptimal, but I guess I can understand why this is done so. It is a shame read locks are not 100% concurrent. I wish I were bright enough to have figured this out on my own. Ok, now this perhaps can be easily remedied. it is merely a matter that finally I can set straight the lock exclusiveness table, and then from there the only change seems to be now only recursive-read locks are no deadlock. Thanks, Yuyang
Re: [RESEND PATCH v4 6/6] leds: lm36274: Introduce the TI LM36274 LED driver
On Wed, 29 May 2019, Jacek Anaszewski wrote: > On 5/29/19 3:58 PM, Lee Jones wrote: > > On Fri, 24 May 2019, Jacek Anaszewski wrote: > > > > > Hi, > > > > > > On 5/23/19 9:09 PM, Dan Murphy wrote: > > > > Pavel > > > > > > > > Thanks for the review > > > > > > > > On 5/23/19 7:50 AM, Pavel Machek wrote: > > > > > Hi! > > > > > > > > > > > +++ b/drivers/leds/leds-lm36274.c > > > > > > > > > > > +static int lm36274_parse_dt(struct lm36274 *lm36274_data) > > > > > > +{ > > > > > > + struct fwnode_handle *child = NULL; > > > > > > + char label[LED_MAX_NAME_SIZE]; > > > > > > + struct device *dev = &lm36274_data->pdev->dev; > > > > > > + const char *name; > > > > > > + int child_cnt; > > > > > > + int ret = -EINVAL; > > > > > > + > > > > > > + /* There should only be 1 node */ > > > > > > + child_cnt = device_get_child_node_count(dev); > > > > > > + if (child_cnt != 1) > > > > > > + return ret; > > > > > > > > > > I'd do explicit "return -EINVAL" here. > > > > > > > > > > > > > ACK > > > > > > > > > > +static int lm36274_probe(struct platform_device *pdev) > > > > > > +{ > > > > > > + struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent); > > > > > > + struct lm36274 *lm36274_data; > > > > > > + int ret; > > > > > > + > > > > > > + lm36274_data = devm_kzalloc(&pdev->dev, sizeof(*lm36274_data), > > > > > > + GFP_KERNEL); > > > > > > + if (!lm36274_data) { > > > > > > + ret = -ENOMEM; > > > > > > + return ret; > > > > > > + } > > > > > > > > > > And certainly do "return -ENOMEM" explicitly here. > > > > > > > > > > > > > ACK > > > > > > > > > Acked-by: Pavel Machek > > > > > > I've done all amendments requested by Pavel and updated branch > > > ib-leds-mfd-regulator on linux-leds.git, but in the same time > > > > What do you mean by updated? You cannot update an 'ib' (immutable > > branch). Immutable means that it cannot change, by definition. > > We have already talked about that. Nobody has pulled so the branch > could have been safely updated. You have no sure way to know that. And since I have no way to know, or faith that you won't update it again, pulling it now/at all would seem like a foolish thing to do. Until you can provide me with an assurance that you will not keep updating/changing the supposedly immutable pull-requests you send out, I won't be pulling any more in. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH] hooks: fix a missing-check bug in selinux_sb_eat_lsm_opts()
On Wed, May 29, 2019 at 09:39:50PM -0700, William Roberts wrote: > On Wed, May 29, 2019 at 8:55 PM Gen Zhang wrote: > > > > In selinux_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul(). It > > returns NULL when fails. So 'arg' should be checked. > > > > Signed-off-by: Gen Zhang > > --- > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > > index 3ec702c..5a9e959 100644 > > --- a/security/selinux/hooks.c > > +++ b/security/selinux/hooks.c > > @@ -2635,6 +2635,8 @@ static int selinux_sb_eat_lsm_opts(char *options, > > void **mnt_opts) > > *q++ = c; > > } > > arg = kmemdup_nul(arg, q - arg, GFP_KERNEL); > > + if (!arg) > > + return 0; > > The routine seems to return 0 on success, why would it return 0 on ENOMEM? > Thanks for your reply, William. I re-examined the source code and didn't figure out what the return value should be in this situation. Could it be a -ENOMEM? Do you have any idea? Thanks Gen > > } > > rc = selinux_add_opt(token, arg, mnt_opts); > > if (unlikely(rc)) {
Re: [PATCH net-next 3/5] net: dsa: mv88e6xxx: Let taggers specify a can_timestamp function
On Thu, 30 May 2019 at 06:51, Richard Cochran wrote: > > On Wed, May 29, 2019 at 11:33:31PM +0300, Vladimir Oltean wrote: > > I would like to avoid keeping meta frames in their own RX queue, > > because then I'm complicating (or rather put, making impossible) the > > association between a meta frame and the frame it holds a timestamp > > of. > > We have an example of how a driver can match meta time stamp packets > with received packets. See drivers/net/phy/dp83640.c to see how it > can be done completely within the driver. > > Thanks, > Richard The meta frames generated by the SJA1105 do not contain any seqid. They contain: * A globally programmable DMAC * A globally programmable SMAC * The 0x8 EtherType * A partial (24-bit or 32-bit) RX timestamp * Two bytes from the initial (pre follow-up) frame's DMAC, before the switch mangled those with the source port and switch id. The driver is supposed to patch these bytes from the follow-up back into the initial frame before passing them up the stack. * The source port that generated the meta frame * The switch id that generated the meta frame Regards, -Vladimir
Re: [PATCH] vmalloc: Don't use flush flag when no exec perm
The addition of VM_FLUSH_RESET_PERMS for BPF JIT allocations was bisected to prevent boot on an UltraSparc III machine. It was found that sometime shortly after the TLB flush this flag does on vfree of the BPF program, the machine hung. Further investigation showed that before any of the changes for this flag were introduced, with CONFIG_DEBUG_PAGEALLOC configured (which does a similar TLB flush of the vmalloc range on every vfree), this machine also hung shortly after the first vmalloc unmap/free. So the evidence points to there being some existing issue with the vmalloc TLB flushes, but it's still unknown exactly why these hangs are happening on sparc. It is also unknown when someone with this hardware could resolve this, and in the meantime using this flag on it turns a lurking behavior into something that prevents boot. The sparc TLB flush issue has been bisected and is being worked on now, so hopefully we won't need this patch: https://marc.info/?l=linux-sparc&m=155915694304118&w=2 And the sparc64 patch that fixes CONFIG_DEBUG_PAGEALLOC also fixes booting of the latest git kernel on Sun V445 where my problem initially happened. -- Meelis Roos
Re: [PATCH 2/5] clocksource/drivers/timer-microchip-pit64b: add Microchip PIT64B support
Hi Daniel, Taking into account the discussion on this tread and the fact that we have no answer from Rob on this topic (I'm talking about [1]), what do you think it would be best for this driver to be accepted the soonest? Would it be OK for you to mimic the approach done by: drivers/clocksource/timer-integrator-ap.c with the following bindings in DT: aliases { arm,timer-primary = &timer2; arm,timer-secondary = &timer1; }; also in PIT64B driver? Or do you think re-spinning the Alexandre's patches at [2] (which seems to me like the generic way to do it) would be better? Thank you, Claudiu Beznea [1] https://lore.kernel.org/lkml/20190408151155.20279-1-alexandre.bell...@bootlin.com/#t [2] https://lore.kernel.org/lkml/20171213185313.20017-1-alexandre.bell...@free-electrons.com/ On 08.04.2019 15:11, Alexandre Belloni wrote: > External E-Mail > > > Hi Daniel, > > On 08/04/2019 10:43:26+0200, Daniel Lezcano wrote: >> Hi Claudiu, >> >> On 14/03/2019 17:26, claudiu.bez...@microchip.com wrote: >>> From: Claudiu Beznea >>> >>> Add driver for Microchip PIT64B timer. Timer could be used in continuous >>> mode or oneshot mode. The hardware has 2x32 bit registers for period >>> emulating a 64 bit timer. The LSB_PR and MSB_PR registers are used to set >>> the period value (compare value). TLSB and TMSB keeps the current value >>> of the counter. After a compare the TLSB and TMSB register resets. Apart >>> from this the hardware has SMOD bit in mode register that allow to >>> reconfigure the timer without reset and start commands (start command >>> while timer is active is ignored). >>> The driver uses PIT64B timer as clocksource or clockevent. First requested >>> timer would be registered as clockevent, second one would be registered as >>> clocksource. >> >> Even if that was done this way before, assuming the DT describes the >> clockevent at the first place and then the clocksource, it is a fragile >> approach. >> >> What about using one of these approach? >> >> eg. >> >> arch/arm/boot/dts/at91sam9261ek.dts >> >> chosen { >> bootargs = "rootfstype=ubifs ubi.mtd=5 root=ubi0:rootfs rw"; >> stdout-path = "serial0:115200n8"; >> >> clocksource { >> timer = <&timer0>; >> }; >> >> clockevent { >> timer = <&timer1>; >> }; >> }; >> > > I suggested and implemented exactly that back in 2017 and it was shot > down by both Rob and Mark: > > https://lore.kernel.org/lkml/20171213185313.20017-1-alexandre.bell...@free-electrons.com/ > > At the time, you didn't do *anything* to get it accepted, you stayed > silent. I can respin the series but then I see two options: > - either you back up the series and really push for it > - or you simply take this driver as it is. There is nothing in it that >couldn't be reworked later once you reached a conclusion with the DT > maintainers. > >> or >> >> arch/arm/boot/dts/integratorap.dts >> >> aliases { >> arm,timer-primary = &timer2; >> arm,timer-secondary = &timer1; >> }; >> >> So we can have control of what is the clocksource or the clockevent. >> That is particulary handy in case of multiple channels. >> >> Not sure if we can replace the 'arm,timer_primary' to 'clocksource'. >> >> Rob? What is your opinion? >> >>> Individual PIT64B hardware resources were used for clocksource >>> and clockevent to be able to support high resolution timers with this >>> hardware implementation. >>> >>> Signed-off-by: Claudiu Beznea >>> --- >>> drivers/clocksource/Kconfig | 6 + >>> drivers/clocksource/Makefile | 1 + >>> drivers/clocksource/timer-microchip-pit64b.c | 464 >>> +++ >>> 3 files changed, 471 insertions(+) >>> create mode 100644 drivers/clocksource/timer-microchip-pit64b.c >>> >>> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig >>> index 5d93e580e5dc..2ad6f881a0bb 100644 >>> --- a/drivers/clocksource/Kconfig >>> +++ b/drivers/clocksource/Kconfig >>> @@ -448,6 +448,12 @@ config OXNAS_RPS_TIMER >>> config SYS_SUPPORTS_SH_CMT >>> bool >>> >>> +config MICROCHIP_PIT64B >>> + bool "Microchip PIT64B support" >>> + depends on OF || COMPILE_TEST >>> + help >>> + This option enables Microchip PIT64B timer. >>> + >>> config MTK_TIMER >>> bool "Mediatek timer driver" if COMPILE_TEST >>> depends on HAS_IOMEM >>> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile >>> index c4a8e9ef932a..c53fa12b9b94 100644 >>> --- a/drivers/clocksource/Makefile >>> +++ b/drivers/clocksource/Makefile >>> @@ -35,6 +35,7 @@ obj-$(CONFIG_U300_TIMER) += timer-u300.o >>> obj-$(CONFIG_SUN4I_TIMER) += timer-sun4i.o >>> obj-$(CONFIG_SUN5I_HSTIMER)+= timer-sun5i.o >>> obj-$(CONFIG_MESON6_TIMER) += timer-meson6.o >>> +obj-$(CONFIG_MICROCHIP_PIT64B) += timer-microchip-pit64b.o >>> obj-$(CONFIG_TEGRA_TIMER) += timer-tegra20.o >>> obj-$(CONFIG_VT8500_TIMER) += timer-vt
Re: [PATCH] x86: intel_epb: Do not build when CONFIG_PM is unset
* Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Commit 9ed0985332a6 ("x86: intel_epb: Take CONFIG_PM into account") > prevented the majority of the Performance and Energy Bias Hint (EPB) > handling code from being built when CONFIG_PM is unset to fix a > regression introduced by commit b9c273babce7 ("PM / arch: x86: > MSR_IA32_ENERGY_PERF_BIAS sysfs interface"). > > In hindsight, however, it would be better to skip all of the EPB > handling code for CONFIG_PM unset as there really is no reason for > it to be there in that case. Namely, if the EPB is not touched > by the kernel at all with CONFIG_PM unset, there is no need to > worry about modifying the EPB inadvertently on CPU online and since > the system will not suspend or hibernate then, there is no need to > worry about possible modifications of the EPB by the platform > firmware during system-wide PM transitions. > > For this reason, revert the changes made by commit 9ed0985332a6 > and only allow intel_epb.o to be built when CONFIG_PM is set. > > Note that this changes the behavior of the kernels built with > CONFIG_PM unset as they will not modify the EPB on boot if it is > zero initially any more, so it is not a fix strictly speaking, but > users building their kernels with CONFIG_PM unset really should not > expect them to take energy efficiency into account. Moreover, if > CONFIG_PM is unset for performance reasons, leaving EPB as set > initially by the platform firmware will actually be consistent > with the user's expectations. > > Signed-off-by: Rafael J. Wysocki > --- > > This is complementary to the EPB handling changes made in the current > development cycle, so IMO it would be good to do it in this cycle too > if there are no technical concerns or objections regarding it. Sure: Acked-by: Ingo Molnar Thanks, Ingo
Re: [PATCH v5] mfd: cros_ec_dev: Register cros_ec_accel_legacy driver as a subdevice
On Wed, 29 May 2019, Gwendal Grignou wrote: > On Wed, May 29, 2019 at 4:44 AM Lee Jones wrote: > > > > On Tue, 28 May 2019, Gwendal Grignou wrote: > > > > > On Mon, Apr 1, 2019 at 8:46 PM Lee Jones wrote: > > > > > > > > On Wed, 27 Feb 2019, Gwendal Grignou wrote: > > > > > > > > > From: Enric Balletbo i Serra > > > > > > > > > > With this patch, the cros_ec_ctl driver will register the legacy > > > > > accelerometer driver (named cros_ec_accel_legacy) if it fails to > > > > > register sensors through the usual path cros_ec_sensors_register(). > > > > > This legacy device is present on Chromebook devices with older EC > > > > > firmware only supporting deprecated EC commands (Glimmer based > > > > > devices). > > > > > > > > > > Tested-by: Gwendal Grignou > > > > > Signed-off-by: Enric Balletbo i Serra > > > > > Reviewed-by: Gwendal Grignou > > > > > Reviewed-by: Andy Shevchenko > > > > > --- > > > > > Changes in v5: > > > > > - Remove unnecessary white lines. > > > > > > > > > > Changes in v4: > > > > > - [5/8] Nit: EC -> ECs (Lee Jones) > > > > > - [5/8] Statically define cros_ec_accel_legacy_cells (Lee Jones) > > > > > > > > > > Changes in v3: > > > > > - [5/8] Add the Reviewed-by Andy Shevchenko. > > > > > > > > > > Changes in v2: > > > > > - [5/8] Add the Reviewed-by Gwendal. > > > > > > > > > > drivers/mfd/cros_ec_dev.c | 66 > > > > > +++ > > > > > 1 file changed, 66 insertions(+) > > > > > > > > > > diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c > > > > > index d275deaecb12..64567bd0a081 100644 > > > > > --- a/drivers/mfd/cros_ec_dev.c > > > > > +++ b/drivers/mfd/cros_ec_dev.c > > > > > @@ -376,6 +376,69 @@ static void cros_ec_sensors_register(struct > > > > > cros_ec_dev *ec) > > > > > kfree(msg); > > > > > } > > > > > > > > > > +static struct cros_ec_sensor_platform sensor_platforms[] = { > > > > > + { .sensor_num = 0 }, > > > > > + { .sensor_num = 1 } > > > > > +}; > > > > > > > > I'm still very uncomfortable with this struct. > > > > > > > > Other than these indices, the sensors have no other distinguishing > > > > features, thus there should be no need to identify or distinguish > > > > between them in this way. > > > When initializing the sensors, the IIO driver expect to find in the > > > data structure pointed by dev_get_platdata(dev), in field sensor_num > > > is stored the index assigned by the embedded controller to talk to a > > > given sensor. > > > cros_ec_sensors_register() use the same mechanism; in that function, > > > the sensor_num field is populated from the output of an EC command > > > MOTIONSENSE_CMD_INFO. In case of legacy mode, that command may not be > > > available and in any case we know the EC has only either 2 > > > accelerometers present or nothing. > > > > > > For instance, let's compare a legacy device with a more recent one: > > > > > > legacy: > > > type | id | sensor_num | device name > > > accelerometer | 0 | 0 | cros-ec-accel.0 > > > accelerometer | 1 | 1 | cros-ec-accel.1 > > > > > > Modern: > > > type | id | sensor_num | device name > > > accelerometer | 0 | 0 | cros-ec-accel.0 > > > accelerometer | 1 | 1 | cros-ec-accel.1 > > > gyroscope|0 |2 | cros-ec-gyro.0 > > > magnetometer |0 | 3 | cros-ec-mag.0 > > > light |0 | 4 | > > > cros-ec-light.0 > > > ... > > > > Why can't these numbers be assigned at runtime? > I assume you want to know why IIO drivers need to know "sensor_num" > ahead of time. It is because each IIO driver is independent from the > other. > Let assume there was 2 light sensors in the device: > type | id | sensor_num | device name > light |0 | 4 | > cros-ec-light.0 > light |1 | 5 | > cros-ec-light.1 > > In case of sensors of the same type without sensor_num, cros-ec-light > driver has no information at probe time if it should bind to sensors > named by the EC 4 or 5. > > We could get away with cros-ec-accel, as EC always presents > accelerometers with sensor_num 0 and 1, but I don't want to rely on > this property in the general case. > Only cros_ec_dev MFD driver has the global view of all sensors available. Well seeing as this implementation has already been accepted and you're only *using* it, rather than creating it, I think this conversation is moot. It looks like the original implementation patch was not reviewed by me, which is frustrating since I would have NACKed it. Just so you know, pointlessly enumerating identical devices manually is not a good practice. It is one we reject all the time. This imp. should t
Re: [GIT PULL] perf/core improvements and fixes for 5.3
* Arnaldo Carvalho de Melo wrote: > Hi Ingo, > > Please consider pulling, > > Best regards, > > - Arnaldo > > Test results at the end of this message, as usual, this time with the > versions for the clang compilers used accross the various containers, to > give a further view of the build test coverage for perf, libbpf, > libtraceevent, etc. > > Test results: > > The following changes since commit 849e96f30068d4f6f8352715e02a10533a46deba: > > Merge tag 'perf-urgent-for-mingo-5.2-20190528' of > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent > (2019-05-28 23:16:22 +0200) > > are available in the Git repository at: > > git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git > tags/perf-core-for-mingo-5.3-20190529 > > for you to fetch changes up to 14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c: > > perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid > (2019-05-28 18:37:45 -0300) > > > perf/core improvements and fixes: > > BPF: > > Jiri Olsa: > > - Preserve eBPF maps when loading kcore. > > - Fix up DSO name padding in 'perf script --call-trace', as BPF DSO names > are > much larger than what we used to have there. > > - Add --show-bpf-events to 'perf script'. > > perf trace: > > Arnaldo Carvalho de Melo: > > - Add string table generators and beautify arguments for the new fspick, > fsmount, fsconfig, fsopen, move_mount and open_tree syscalls, as well > as new values for arguments of clone and sync_file_range syscalls. > > perf version: > > Arnaldo Carvalho de Melo: > > - Append 12 git SHA chars to the version string. > > Namespaces: > > Namhyung Kim: > > - Add missing --namespaces option to 'perf top', to generate and process > namespace events, just like present for 'perf record'. > > Intel PT: > > Andrian Hunter: > > - Fix itrace defaults for 'perf script', not using the 'use_browser' > variable > to figure out what options are better for 'script' and 'report' > > - Allow root fixing up buildid cache permissions in the perf-with-kcore.sh > script when sharing that cache with another user. > > - Improve sync_switch, a facility used to synchronize decoding of HW > traces more closely with the point in the kerne where a context > switch took place, by processing the PERF_RECORD_CONTEXT_SWITCH "in" > metadata records too. > > - Make the exported-sql-viewer.py GUI also support pyside2, which > upgrades from qt4 used in pyside to qt5. Use the argparser module > for more easily addition of new command line args. > > Signed-off-by: Arnaldo Carvalho de Melo > > > Adrian Hunter (11): > perf-with-kcore.sh: Always allow fix_buildid_cache_permissions > perf intel-pt: Fix itrace defaults for perf script > perf auxtrace: Fix itrace defaults for perf script > perf intel-pt: Fix itrace defaults for perf script intel-pt > documentation > perf scripts python: exported-sql-viewer.py: Change python2 to python > perf scripts python: exported-sql-viewer.py: Use argparse module for > argument parsing > perf scripts python: exported-sql-viewer.py: Add support for pyside2 > perf scripts python: export-to-sqlite.py: Add support for pyside2 > perf scripts python: export-to-postgresql.py: Add support for pyside2 > perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in > events > perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid > > Arnaldo Carvalho de Melo (17): > perf augmented_raw_syscalls: Fix up comment > perf beauty: Add generator for 'move_mount' flags argument > perf trace: Beautify 'move_mount' arguments > perf beauty: Add generator for fspick's 'flags' arg values > perf trace: Beautify 'fspick' arguments > perf beauty: Add generator for fsconfig's 'cmd' arg values > perf trace: Beautify 'fsconfig' arguments > perf beauty: Add generator for fsmount's 'attr_flags' arg values > perf trace: Introduce syscall_arg__scnprintf_strarray_flags > perf trace: Beautify 'fsmount' arguments > perf trace beauty clone: Handle CLONE_PIDFD > perf beauty: Add generator for sync_file_range's 'flags' arg values > perf trace: Beautify 'sync_file_range' arguments > perf version: Append 12 git SHA chars to the version string > perf annotate TUI browser: Do not use member from variable within its > own initialization > perf python: Remove -fstack-protector-strong if clang doesn't have it > perf top: Lower message level for failure on synthesizing events for > pre-existing BPF programs > > Donald Yandt (1): > perf machine: Return NULL instead of null-terminating /proc/version > array > > Jiri Olsa (10): > perf machine: Keep zero in pgo
[PATCH] w1: ds2413: fix state byte comparision
This commit is fixing a smatch warning: drivers/w1/slaves/w1_ds2413.c:61 state_read() warn: impossible condition '(*buf == 255) => ((-128)-127 == 255)' by creating additional u8 variable for the bus reading and comparision Reported-by: kbuild test robot Reported-by: Dan Carpenter Cc: Dan Carpenter Fixes: 3856032a0628 ("w1: ds2413: when the slave is not responding during read, select it again") Signed-off-by: Mariusz Bialonczyk --- drivers/w1/slaves/w1_ds2413.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/w1/slaves/w1_ds2413.c b/drivers/w1/slaves/w1_ds2413.c index 21f08ac8a4e0..3364ad276b15 100644 --- a/drivers/w1/slaves/w1_ds2413.c +++ b/drivers/w1/slaves/w1_ds2413.c @@ -33,6 +33,7 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj, struct w1_slave *sl = kobj_to_w1_slave(kobj); unsigned int retries = W1_F3A_RETRIES; ssize_t bytes_read = -EIO; + u8 state; dev_dbg(&sl->dev, "Reading %s kobj: %p, off: %0#10x, count: %zu, buff addr: %p", @@ -53,12 +54,13 @@ static ssize_t state_read(struct file *filp, struct kobject *kobj, while (retries--) { w1_write_8(sl->master, W1_F3A_FUNC_PIO_ACCESS_READ); - *buf = w1_read_8(sl->master); - if ((*buf & 0x0F) == ((~*buf >> 4) & 0x0F)) { + state = w1_read_8(sl->master); + if ((state & 0x0F) == ((~state >> 4) & 0x0F)) { /* complement is correct */ + *buf = state; bytes_read = 1; goto out; - } else if (*buf == W1_F3A_INVALID_PIO_STATE) { + } else if (state == W1_F3A_INVALID_PIO_STATE) { /* slave didn't respond, try to select it again */ dev_warn(&sl->dev, "slave device did not respond to PIO_ACCESS_READ, " \ "reselecting, retries left: %d\n", retries); -- 2.19.0.rc1
[tip:perf/core] perf-with-kcore.sh: Always allow fix_buildid_cache_permissions
Commit-ID: a685c7a4a25c80f1f022b55830f2d894ee8847eb Gitweb: https://git.kernel.org/tip/a685c7a4a25c80f1f022b55830f2d894ee8847eb Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:28 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf-with-kcore.sh: Always allow fix_buildid_cache_permissions The user's buildid cache may contain entries added by root even if root has its own home directory (e.g. by using perfconfig to specify the same buildid dir), so remove that validation. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-7-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/perf-with-kcore.sh | 5 - 1 file changed, 5 deletions(-) diff --git a/tools/perf/perf-with-kcore.sh b/tools/perf/perf-with-kcore.sh index 7e47a7cbc195..2ad2fffdb209 100644 --- a/tools/perf/perf-with-kcore.sh +++ b/tools/perf/perf-with-kcore.sh @@ -111,11 +111,6 @@ fix_buildid_cache_permissions() USER_HOME=$(bash <<< "echo ~$SUDO_USER") - if [ "$HOME" != "$USER_HOME" ] ; then - echo "Fix unnecessary because root has a home: $HOME" >&2 - exit 1 - fi - echo "Fixing buildid cache permissions" find "$USER_HOME/.debug" -xdev -type d ! -user "$SUDO_USER" -ls -exec chown"$SUDO_USER" \{\} \;
[tip:perf/core] perf intel-pt: Fix itrace defaults for perf script
Commit-ID: 26f19c2eb7e54015564ff133b91983a74e84541b Gitweb: https://git.kernel.org/tip/26f19c2eb7e54015564ff133b91983a74e84541b Author: Adrian Hunter AuthorDate: Mon, 20 May 2019 14:37:07 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf intel-pt: Fix itrace defaults for perf script Commit 4eb068157121 ("perf script: Make itrace script default to all calls") does not work because 'use_browser' is being used to determine whether to default to periodic sampling (i.e. better for perf report). The result is that nothing but CBR events display for perf script when no --itrace option is specified. Fix by using 'default_no_sample' and 'inject' instead. Example: Before: $ perf record -e intel_pt/cyc/u ls $ perf script > cmp1.txt $ perf script --itrace=cepwx > cmp2.txt $ diff -sq cmp1.txt cmp2.txt Files cmp1.txt and cmp2.txt differ After: $ perf script > cmp1.txt $ perf script --itrace=cepwx > cmp2.txt $ diff -sq cmp1.txt cmp2.txt Files cmp1.txt and cmp2.txt are identical Signed-off-by: Adrian Hunter Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: sta...@vger.kernel.org # v4.20+ Fixes: 90e457f7be08 ("perf tools: Add Intel PT support") Link: http://lkml.kernel.org/r/20190520113728.14389-2-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-pt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 6d288237887b..03b1da6d1da4 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -2588,7 +2588,8 @@ int intel_pt_process_auxtrace_info(union perf_event *event, } else { itrace_synth_opts__set_default(&pt->synth_opts, session->itrace_synth_opts->default_no_sample); - if (use_browser != -1) { + if (!session->itrace_synth_opts->default_no_sample && + !session->itrace_synth_opts->inject) { pt->synth_opts.branches = false; pt->synth_opts.callchain = true; }
[PATCH] nbd: no need to check all the connections one by one if all are dead
From: Xiubo Li If all connections are dead the live_connections should be already set to 0. And set the nsock->fallback to -1 again if all connections are dead. Signed-off-by: Xiubo Li --- drivers/block/nbd.c | 23 +++ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 98be6ca..6da42aa 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -783,13 +783,16 @@ static int find_fallback(struct nbd_device *nbd, int index) return new_index; } + if (atomic_read(&config->live_connections) <= 0) { + dev_err_ratelimited(disk_to_dev(nbd->disk), + "Dead connection, failed to find a fallback\n"); + goto out; + } + if (fallback >= 0 && fallback < config->num_connections && - !config->socks[fallback]->dead) + !config->socks[fallback]->dead) { return fallback; - - if (nsock->fallback_index < 0 || - nsock->fallback_index >= config->num_connections || - config->socks[nsock->fallback_index]->dead) { + } else { int i; for (i = 0; i < config->num_connections; i++) { if (i == index) @@ -799,14 +802,10 @@ static int find_fallback(struct nbd_device *nbd, int index) break; } } - nsock->fallback_index = new_index; - if (new_index < 0) { - dev_err_ratelimited(disk_to_dev(nbd->disk), - "Dead connection, failed to find a fallback\n"); - return new_index; - } } - new_index = nsock->fallback_index; + +out: + nsock->fallback_index = new_index; return new_index; } -- 1.8.3.1
[tip:perf/core] perf auxtrace: Fix itrace defaults for perf script
Commit-ID: 355200e0f6a9ce14771625014aa469f5ecbd8977 Gitweb: https://git.kernel.org/tip/355200e0f6a9ce14771625014aa469f5ecbd8977 Author: Adrian Hunter AuthorDate: Mon, 20 May 2019 14:37:08 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf auxtrace: Fix itrace defaults for perf script Commit 4eb068157121 ("perf script: Make itrace script default to all calls") does not work for the case when '--itrace' only is used, because default_no_sample is not being passed. Example: Before: $ perf record -e intel_pt/cyc/u ls $ perf script --itrace > cmp1.txt $ perf script --itrace=cepwx > cmp2.txt $ diff -sq cmp1.txt cmp2.txt Files cmp1.txt and cmp2.txt differ After: $ perf script --itrace > cmp1.txt $ perf script --itrace=cepwx > cmp2.txt $ diff -sq cmp1.txt cmp2.txt Files cmp1.txt and cmp2.txt are identical Signed-off-by: Adrian Hunter Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: sta...@vger.kernel.org Fixes: 4eb068157121 ("perf script: Make itrace script default to all calls") Link: http://lkml.kernel.org/r/20190520113728.14389-3-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/auxtrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index fb76b6b232d4..5dd9d1893b89 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -1010,7 +1010,8 @@ int itrace_parse_synth_opts(const struct option *opt, const char *str, } if (!str) { - itrace_synth_opts__set_default(synth_opts, false); + itrace_synth_opts__set_default(synth_opts, + synth_opts->default_no_sample); return 0; }
[tip:perf/core] perf intel-pt: Fix itrace defaults for perf script intel-pt documentation
Commit-ID: a2d8a1585e35444789c1c8cf7e2e51fb15589880 Gitweb: https://git.kernel.org/tip/a2d8a1585e35444789c1c8cf7e2e51fb15589880 Author: Adrian Hunter AuthorDate: Mon, 20 May 2019 14:37:09 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf intel-pt: Fix itrace defaults for perf script intel-pt documentation Fix intel-pt documentation to reflect the change of itrace defaults for perf script. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Cc: sta...@vger.kernel.org Fixes: 4eb068157121 ("perf script: Make itrace script default to all calls") Link: http://lkml.kernel.org/r/20190520113728.14389-4-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/intel-pt.txt | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/perf/Documentation/intel-pt.txt b/tools/perf/Documentation/intel-pt.txt index 115eaacc455f..60d99e5e7921 100644 --- a/tools/perf/Documentation/intel-pt.txt +++ b/tools/perf/Documentation/intel-pt.txt @@ -88,16 +88,16 @@ smaller. To represent software control flow, "branches" samples are produced. By default a branch sample is synthesized for every single branch. To get an idea what -data is available you can use the 'perf script' tool with no parameters, which -will list all the samples. +data is available you can use the 'perf script' tool with all itrace sampling +options, which will list all the samples. perf record -e intel_pt//u ls - perf script + perf script --itrace=ibxwpe An interesting field that is not printed by default is 'flags' which can be displayed as follows: - perf script -Fcomm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr,symoff,flags + perf script --itrace=ibxwpe -F+flags The flags are "bcrosyiABEx" which stand for branch, call, return, conditional, system, asynchronous, interrupt, transaction abort, trace begin, trace end, and @@ -713,7 +713,7 @@ Having no option is the same as which, in turn, is the same as - --itrace=ibxwpe + --itrace=cepwx The letters are:
[tip:perf/core] perf machine: Keep zero in pgoff BPF map
Commit-ID: 8529f2e67313fb623da7ce81bc14cf12ccc0e12f Gitweb: https://git.kernel.org/tip/8529f2e67313fb623da7ce81bc14cf12ccc0e12f Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:04 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf machine: Keep zero in pgoff BPF map With pgoff set to zero, the map__map_ip function will return BPF addresses based from 0, which is what we need when we read the data from a BPF DSO. Adding BPF symbols with mapped IP addresses as well. Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-7-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index dc7aafe45a2b..f5569f005cf3 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -704,12 +704,12 @@ static int machine__process_ksymbol_register(struct machine *machine, return -ENOMEM; map->start = event->ksymbol_event.addr; - map->pgoff = map->start; map->end = map->start + event->ksymbol_event.len; map_groups__insert(&machine->kmaps, map); } - sym = symbol__new(event->ksymbol_event.addr, event->ksymbol_event.len, + sym = symbol__new(map->map_ip(map, map->start), + event->ksymbol_event.len, 0, 0, event->ksymbol_event.name); if (!sym) return -ENOMEM;
[tip:perf/core] perf trace: Beautify 'move_mount' arguments
Commit-ID: 566e30229e1f4be67c4771afc057152d62016c9c Gitweb: https://git.kernel.org/tip/566e30229e1f4be67c4771afc057152d62016c9c Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 20 May 2019 14:58:03 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf trace: Beautify 'move_mount' arguments Use existing beautifiers for the first 4 args (to/from fds, pathnames) and wire up the recently introduced move_mount flags table generator. Now it should be possible to just use: perf trace -e move_mount As root and see all move_mount syscalls with its args beautified, except for the filenames, that need work in the augmented_raw_syscalls.c eBPF helper to pass more than one, see comment in the augmented_raw_syscalls.c source code, the other args should work in all cases, i.e. all that is needed can be obtained directly from the raw_syscalls:sys_enter tracepoint args. Running without the strace "skin" (.perfconfig setting output formatting switches to look like strace output + BPF to collect strings, as we still need to support collecting multiple string args for the same syscall, like with move_mount): # cat sys_move_mount.c #define _GNU_SOURCE /* See feature_test_macros(7) */ #include #include/* For SYS_xxx definitions */ #define __NR_move_mount 429 #define MOVE_MOUNT_F_SYMLINKS 0x0001 /* Follow symlinks on from path */ #define MOVE_MOUNT_F_AUTOMOUNTS 0x0002 /* Follow automounts on from path */ #define MOVE_MOUNT_F_EMPTY_PATH 0x0004 /* Empty from path permitted */ #define MOVE_MOUNT_T_SYMLINKS 0x0010 /* Follow symlinks on to path */ #define MOVE_MOUNT_T_AUTOMOUNTS 0x0020 /* Follow automounts on to path */ #define MOVE_MOUNT_T_EMPTY_PATH 0x0040 /* Empty to path permitted */ static inline int sys_move_mount(int from_fd, const char *from_pathname, int to_fd, const char *to_pathname, int flags) { syscall(__NR_move_mount, from_fd, from_pathname, to_fd, to_pathname, flags); } int main(int argc, char *argv[]) { int flags = 0, from_fd = 0, to_fd = 100; sys_move_mount(from_fd++, "/foo", to_fd++, "bar", flags); flags |= MOVE_MOUNT_F_SYMLINKS; sys_move_mount(from_fd++, "/foo1", to_fd++, "bar1", flags); flags |= MOVE_MOUNT_F_AUTOMOUNTS; sys_move_mount(from_fd++, "/foo2", to_fd++, "bar2", flags); flags |= MOVE_MOUNT_F_EMPTY_PATH; sys_move_mount(from_fd++, "/foo3", to_fd++, "bar3", flags); flags |= MOVE_MOUNT_T_SYMLINKS; sys_move_mount(from_fd++, "/foo4", to_fd++, "bar4", flags); flags |= MOVE_MOUNT_T_AUTOMOUNTS; sys_move_mount(from_fd++, "/foo5", to_fd++, "bar5", flags); flags |= MOVE_MOUNT_T_EMPTY_PATH; return sys_move_mount(from_fd++, "/foo6", to_fd++, "bar6", flags); } # mv ~/.perfconfig ~/.perfconfig.OFF # perf trace -e move_mount ./sys_move_mount 0.000 ( 0.009 ms): sys_move_mount/28971 move_mount(from_pathname: 0x402010, to_dfd: 100, to_pathname: 0x402015) = -1 ENOENT (No such file or directory) 0.011 ( 0.003 ms): sys_move_mount/28971 move_mount(from_dfd: 1, from_pathname: 0x40201e, to_dfd: 101, to_pathname: 0x402019, flags: F_SYMLINKS) = -1 ENOENT (No such file or directory) 0.016 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 2, from_pathname: 0x402029, to_dfd: 102, to_pathname: 0x402024, flags: F_SYMLINKS|F_AUTOMOUNTS) = -1 ENOENT (No such file or directory) 0.020 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 3, from_pathname: 0x402034, to_dfd: 103, to_pathname: 0x40202f, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH) = -1 ENOENT (No such file or directory) 0.023 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 4, from_pathname: 0x40203f, to_dfd: 104, to_pathname: 0x40203a, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS) = -1 ENOENT (No such file or directory) 0.027 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 5, from_pathname: 0x40204a, to_dfd: 105, to_pathname: 0x402045, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS|T_AUTOMOUNTS) = -1 ENOENT (No such file or directory) 0.031 ( 0.017 ms): sys_move_mount/28971 move_mount(from_dfd: 6, from_pathname: 0x402055, to_dfd: 106, to_pathname: 0x402050, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS|T_AUTOMOUNTS|T_EMPTY_PATH) = -1 ENOENT (No such file or directory) # Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: David Howells Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-83rim8g4k0s4gieieh5nn...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf | 8 tools/perf/builtin-trace.c | 6 ++ tools/perf/examples
[tip:perf/core] perf beauty: Add generator for 'move_mount' flags argument
Commit-ID: eefa09b499d12883f2fad46f93379101c8da6fec Gitweb: https://git.kernel.org/tip/eefa09b499d12883f2fad46f93379101c8da6fec Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 20 May 2019 14:16:49 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf beauty: Add generator for 'move_mount' flags argument $ tools/perf/trace/beauty/move_mount_flags.sh static const char *move_mount_flags[] = { [ilog2(0x0001) + 1] = "F_SYMLINKS", [ilog2(0x0002) + 1] = "F_AUTOMOUNTS", [ilog2(0x0004) + 1] = "F_EMPTY_PATH", [ilog2(0x0010) + 1] = "T_SYMLINKS", [ilog2(0x0020) + 1] = "T_AUTOMOUNTS", [ilog2(0x0040) + 1] = "T_EMPTY_PATH", }; $ Will be wired up to the 'perf trace' arg in a followup patch. Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: David Howells Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-px7v33suw1k2ehst52l7b...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/move_mount_flags.sh | 17 + 1 file changed, 17 insertions(+) diff --git a/tools/perf/trace/beauty/move_mount_flags.sh b/tools/perf/trace/beauty/move_mount_flags.sh new file mode 100755 index ..55e59241daa4 --- /dev/null +++ b/tools/perf/trace/beauty/move_mount_flags.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1 + +if [ $# -ne 1 ] ; then + linux_header_dir=tools/include/uapi/linux +else + linux_header_dir=$1 +fi + +linux_mount=${linux_header_dir}/mount.h + +printf "static const char *move_mount_flags[] = {\n" +regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MOVE_MOUNT_([FT]_[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' +egrep $regex ${linux_mount} | \ + sed -r "s/$regex/\2 \1/g" | \ + xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n" +printf "};\n"
Re: [PATCH] kernel/sys.c: fix possible spectre-v1 in do_prlimit()
On Thu, May 30, 2019 at 01:45:16PM +0800, Dianzhang Chen wrote: > > Though syscall `getrlimit` , it seems not works after > check_prlimit_permission. > > And the speculation windows are large, as said[1]: > >> Can the speculation proceed past the task_lock()? Or is the policy to > >> ignore such happy happenstances even if they are available? > > > > Locks are not in the way of speculation. Speculation has almost no limits > > except serializing instructions. At least they respect the magic AND > > limitation in array_index_nospec(). > > [1] https://do-db2.lkml.org/lkml/2018/5/15/1056 Please, stop top-posting, it trashes conversation context. You miss the point: before bpu hits misprediction we've a number of branches, second in case of misprediction the kernel's stack value is cached, so I'm not convinced at all that teaching bpu and read the cache is easy here (or possible at all). Thus, the final solution is up to maintainers. Another reason why I complaining about the patch -- it is not the patch body, as I said I'm fine with it, but the patch title: it implies the fix should go in stable kernels, that's what I dont agree with. But again, I'm not a maintainer and might be wrong. > > On Wed, May 29, 2019 at 8:18 PM Cyrill Gorcunov wrote: > > > > On Wed, May 29, 2019 at 10:39:52AM +0800, Dianzhang Chen wrote: > > > Hi, > > > > > > Although when detect it is misprediction and drop the execution, but > > > it can not drop all the effects of speculative execution, like the > > > cache state. During the speculative execution, the: > > > > > > > > > rlim = tsk->signal->rlim + resource;// use resource as index > > > > > > ... > > > > > > *old_rlim = *rlim; > > > > > > > > > may read some secret data into cache. > > > > > > and then the attacker can use side-channel attack to find out what the > > > secret data is. > > > > This code works after check_prlimit_permission call, which means you already > > should have a permission granted. And you implies that misprediction gonna > > be that deep which involves a number of > > calls/read/writes/jumps/locks-rb-wb-flushes > > and a bunch or other instructions, moreover all conditions are > > "mispredicted". > > This is very bold and actually unproved claim! > > > > Note that I pointed the patch is fine in cleanup context but seriously I > > don't see how this all can be exploitable in sense of spectre. > Cyrill
[tip:perf/core] perf augmented_raw_syscalls: Fix up comment
Commit-ID: 8a70c6b162e3112ce87b40b1705da5c4e7566ac8 Gitweb: https://git.kernel.org/tip/8a70c6b162e3112ce87b40b1705da5c4e7566ac8 Author: Arnaldo Carvalho de Melo AuthorDate: Thu, 23 May 2019 13:21:36 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf augmented_raw_syscalls: Fix up comment Cut'n'paste error, the second comment is about the syscalls that have as its second arg a string. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-zo5s6rloy42u41acsf6q3...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/examples/bpf/augmented_raw_syscalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/examples/bpf/augmented_raw_syscalls.c b/tools/perf/examples/bpf/augmented_raw_syscalls.c index 2422894a8194..b292e763f3c7 100644 --- a/tools/perf/examples/bpf/augmented_raw_syscalls.c +++ b/tools/perf/examples/bpf/augmented_raw_syscalls.c @@ -87,7 +87,7 @@ struct augmented_filename { #define SYS_SYMLINKAT 266 #define SYS_MEMFD_CREATE 319 -/* syscalls where the first arg is a string */ +/* syscalls where the second arg is a string */ #define SYS_PWRITE6418 #define SYS_EXECVE 59
[tip:perf/core] perf beauty: Add generator for fspick's 'flags' arg values
Commit-ID: a1c729a5f62c090ba3c510142a6685a1989cc24b Gitweb: https://git.kernel.org/tip/a1c729a5f62c090ba3c510142a6685a1989cc24b Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 20 May 2019 16:17:55 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf beauty: Add generator for fspick's 'flags' arg values $ tools/perf/trace/beauty/fspick.sh static const char *fspick_flags[] = { [ilog2(0x0001) + 1] = "CLOEXEC", [ilog2(0x0002) + 1] = "SYMLINK_NOFOLLOW", [ilog2(0x0004) + 1] = "NO_AUTOMOUNT", [ilog2(0x0008) + 1] = "EMPTY_PATH", }; $ Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: David Howells Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-8i16btocq1ax2u6542ya7...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/{move_mount_flags.sh => fspick.sh} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/trace/beauty/move_mount_flags.sh b/tools/perf/trace/beauty/fspick.sh similarity index 63% copy from tools/perf/trace/beauty/move_mount_flags.sh copy to tools/perf/trace/beauty/fspick.sh index 55e59241daa4..b220e07ef452 100755 --- a/tools/perf/trace/beauty/move_mount_flags.sh +++ b/tools/perf/trace/beauty/fspick.sh @@ -9,8 +9,8 @@ fi linux_mount=${linux_header_dir}/mount.h -printf "static const char *move_mount_flags[] = {\n" -regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MOVE_MOUNT_([FT]_[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' +printf "static const char *fspick_flags[] = {\n" +regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+FSPICK_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' egrep $regex ${linux_mount} | \ sed -r "s/$regex/\2 \1/g" | \ xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n"
[PATCH] x86/mm/tlb: Do partial TLB flush when possible
This is a small optimization to stale TLB flush, if there is one new TLB flush, let it choose to do partial or full flush. or else, the stale flush take over and do full flush. Add unlikely() to info->freed_tables check as freeing page tables is relatively less. Signed-off-by: Zhenzhong Duan Cc: Dave Hansen Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Srinivas Eeda Cc: x...@kernel.org --- arch/x86/mm/tlb.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 91f6db9..63a8125 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -569,6 +569,17 @@ static void flush_tlb_func_common(const struct flush_tlb_info *f, return; } + if (unlikely(f->new_tlb_gen <= local_tlb_gen && + local_tlb_gen + 1 == mm_tlb_gen)) { + /* +* For stale TLB flush request, if there will be one new TLB +* flush coming, we leave the work to the new IPI as it knows +* partial or full TLB flush to take, or else we do the full +* flush. +*/ + trace_tlb_flush(reason, 0); + return; + } WARN_ON_ONCE(local_tlb_gen > mm_tlb_gen); WARN_ON_ONCE(f->new_tlb_gen > mm_tlb_gen); @@ -577,7 +588,8 @@ static void flush_tlb_func_common(const struct flush_tlb_info *f, * This does not strictly imply that we need to flush (it's * possible that f->new_tlb_gen <= local_tlb_gen), but we're * going to need to flush in the very near future, so we might -* as well get it over with. +* as well get it over with in case we know there will be more +* than one outstanding TLB flush request. * * The only question is whether to do a full or partial flush. * @@ -609,9 +621,7 @@ static void flush_tlb_func_common(const struct flush_tlb_info *f, *local_tlb_gen all the way to mm_tlb_gen and we can probably *avoid another flush in the very near future. */ - if (f->end != TLB_FLUSH_ALL && - f->new_tlb_gen == local_tlb_gen + 1 && - f->new_tlb_gen == mm_tlb_gen) { + if (f->end != TLB_FLUSH_ALL && local_tlb_gen + 1 == mm_tlb_gen) { /* Partial flush */ unsigned long nr_invalidate = (f->end - f->start) >> f->stride_shift; unsigned long addr = f->start; @@ -703,7 +713,7 @@ void native_flush_tlb_others(const struct cpumask *cpumask, * up on the new contents of what used to be page tables, while * doing a speculative memory access. */ - if (info->freed_tables) + if (unlikely(info->freed_tables)) smp_call_function_many(cpumask, flush_tlb_func_remote, (void *)info, 1); else -- 1.8.3.1
[tip:perf/core] perf trace: Beautify 'fspick' arguments
Commit-ID: 693bd3949be6c73218e3666d85e37841d678ea7b Gitweb: https://git.kernel.org/tip/693bd3949be6c73218e3666d85e37841d678ea7b Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 20 May 2019 16:24:15 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf trace: Beautify 'fspick' arguments Use existing beautifiers for the first 2 args (dfd, path) and wire up the recently introduced fspick flags table generator. Now it should be possible to just use: perf trace -e fspick As root and see all move_mount syscalls with its args beautified, either using the vfs_getname perf probe method or using the augmented_raw_syscalls.c eBPF helper to get the pathnames, the other args should work in all cases, i.e. all that is needed can be obtained directly from the raw_syscalls:sys_enter tracepoint args. # cat sys_fspick.c #define _GNU_SOURCE/* See feature_test_macros(7) */ #include #include/* For SYS_xxx definitions */ #include #define __NR_fspick 433 #define FSPICK_CLOEXEC 0x0001 #define FSPICK_SYMLINK_NOFOLLOW 0x0002 #define FSPICK_NO_AUTOMOUNT 0x0004 #define FSPICK_EMPTY_PATH 0x0008 static inline int sys_fspick(int fd, const char *path, int flags) { syscall(__NR_fspick, fd, path, flags); } int main(int argc, char *argv[]) { int flags = 0, fd = 0; open("/foo", 0); sys_fspick(fd++, "/foo1", flags); flags |= FSPICK_CLOEXEC; sys_fspick(fd++, "/foo2", flags); flags |= FSPICK_SYMLINK_NOFOLLOW; sys_fspick(fd++, "/foo3", flags); flags |= FSPICK_NO_AUTOMOUNT; sys_fspick(fd++, "/foo4", flags); flags |= FSPICK_EMPTY_PATH; return sys_fspick(fd++, "/foo5", flags); } # perf trace -e fspick ./sys_fspick LLVM: dumping /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o fspick(0, "/foo1", 0) = -1 ENOENT (No such file or directory) fspick(1, "/foo2", FSPICK_CLOEXEC) = -1 ENOENT (No such file or directory) fspick(2, "/foo3", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory) fspick(3, "/foo4", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW|FSPICK_NO_AUTOMOUNT) = -1 ENOENT (No such file or directory) fspick(4, "/foo5", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW|FSPICK_NO_AUTOMOUNT|FSPICK_EMPTY_PATH) = -1 ENOENT (No such file or directory) # Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-erau5xjtt8wvgnhvdbchs...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf | 8 tools/perf/builtin-trace.c | 4 tools/perf/examples/bpf/augmented_raw_syscalls.c | 2 ++ tools/perf/trace/beauty/Build| 1 + tools/perf/trace/beauty/beauty.h | 3 +++ tools/perf/trace/beauty/fspick.c | 24 6 files changed, 42 insertions(+) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 20448d8cc162..fe93f8c46080 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -419,6 +419,12 @@ fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh $(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl) $(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@ +fspick_arrays := $(beauty_outdir)/fspick_arrays.c +fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh + +$(fspick_arrays): $(linux_uapi_dir)/fs.h $(fspick_tbls) + $(Q)$(SHELL) '$(fspick_tbls)' $(linux_uapi_dir) > $@ + pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh @@ -634,6 +640,7 @@ build-dir = $(if $(__build-dir),$(__build-dir),.) prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \ $(fadvise_advice_array) \ + $(fspick_arrays) \ $(pkey_alloc_access_rights_array) \ $(sndrv_pcm_ioctl_array) \ $(sndrv_ctl_ioctl_array) \ @@ -929,6 +936,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ $(OUTPUT)pmu-events/pmu-events.c \ $(OUTPUT)$(fadvise_advice_array) \ + $(OUTPUT)$(fspick_arrays) \ $(OUTPUT)$(madvise_behavior_array) \ $(OUTPUT)$(mmap_flags_array) \ $(OUTPUT)$(mount_flags_array) \ diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index b76c950e4393..1643da631699 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -713,6 +71
[tip:perf/core] perf beauty: Add generator for fsconfig's 'cmd' arg values
Commit-ID: d35293004a5e40c330ae5bf3667d716e702fe94a Gitweb: https://git.kernel.org/tip/d35293004a5e40c330ae5bf3667d716e702fe94a Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 21 May 2019 15:07:43 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf beauty: Add generator for fsconfig's 'cmd' arg values $ tools/perf/trace/beauty/fsconfig.sh static const char *fsconfig_cmds[] = { [0] = "SET_FLAG", [1] = "SET_STRING", [2] = "SET_BINARY", [3] = "SET_PATH", [4] = "SET_PATH_EMPTY", [5] = "SET_FD", [6] = "CMD_CREATE", [7] = "CMD_RECONFIGURE", }; $ Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: David Howells Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-u721396rkqmawmt91dwws...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/{fspick.sh => fsconfig.sh} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/trace/beauty/fspick.sh b/tools/perf/trace/beauty/fsconfig.sh similarity index 55% copy from tools/perf/trace/beauty/fspick.sh copy to tools/perf/trace/beauty/fsconfig.sh index b220e07ef452..83fb24df05c9 100755 --- a/tools/perf/trace/beauty/fspick.sh +++ b/tools/perf/trace/beauty/fsconfig.sh @@ -9,9 +9,9 @@ fi linux_mount=${linux_header_dir}/mount.h -printf "static const char *fspick_flags[] = {\n" -regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+FSPICK_([[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' +printf "static const char *fsconfig_cmds[] = {\n" +regex='^[[:space:]]*+FSCONFIG_([[:alnum:]_]+)[[:space:]]*=[[:space:]]*([[:digit:]]+)[[:space:]]*,[[:space:]]*.*' egrep $regex ${linux_mount} | \ sed -r "s/$regex/\2 \1/g" | \ - xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n" + xargs printf "\t[%s] = \"%s\",\n" printf "};\n"
Re: [RFC 6/7] mm: extend process_madvise syscall to support vector arrary
On Thu, May 30, 2019 at 08:57:55AM +0200, Michal Hocko wrote: > On Thu 30-05-19 11:17:48, Minchan Kim wrote: > > On Wed, May 29, 2019 at 12:33:52PM +0200, Michal Hocko wrote: > > > On Wed 29-05-19 03:08:32, Daniel Colascione wrote: > > > > On Mon, May 27, 2019 at 12:49 AM Minchan Kim wrote: > > > > > > > > > > On Tue, May 21, 2019 at 12:37:26PM +0200, Michal Hocko wrote: > > > > > > On Tue 21-05-19 19:26:13, Minchan Kim wrote: > > > > > > > On Tue, May 21, 2019 at 08:24:21AM +0200, Michal Hocko wrote: > > > > > > > > On Tue 21-05-19 11:48:20, Minchan Kim wrote: > > > > > > > > > On Mon, May 20, 2019 at 11:22:58AM +0200, Michal Hocko wrote: > > > > > > > > > > [Cc linux-api] > > > > > > > > > > > > > > > > > > > > On Mon 20-05-19 12:52:53, Minchan Kim wrote: > > > > > > > > > > > Currently, process_madvise syscall works for only one > > > > > > > > > > > address range > > > > > > > > > > > so user should call the syscall several times to give > > > > > > > > > > > hints to > > > > > > > > > > > multiple address range. > > > > > > > > > > > > > > > > > > > > Is that a problem? How big of a problem? Any numbers? > > > > > > > > > > > > > > > > > > We easily have 2000+ vma so it's not trivial overhead. I will > > > > > > > > > come up > > > > > > > > > with number in the description at respin. > > > > > > > > > > > > > > > > Does this really have to be a fast operation? I would expect > > > > > > > > the monitor > > > > > > > > is by no means a fast path. The system call overhead is not > > > > > > > > what it used > > > > > > > > to be, sigh, but still for something that is not a hot path it > > > > > > > > should be > > > > > > > > tolerable, especially when the whole operation is quite > > > > > > > > expensive on its > > > > > > > > own (wrt. the syscall entry/exit). > > > > > > > > > > > > > > What's different with process_vm_[readv|writev] and vmsplice? > > > > > > > If the range needed to be covered is a lot, vector operation > > > > > > > makes senese > > > > > > > to me. > > > > > > > > > > > > I am not saying that the vector API is wrong. All I am trying to > > > > > > say is > > > > > > that the benefit is not really clear so far. If you want to push it > > > > > > through then you should better get some supporting data. > > > > > > > > > > I measured 1000 madvise syscall vs. a vector range syscall with 1000 > > > > > ranges on ARM64 mordern device. Even though I saw 15% improvement but > > > > > absoluate gain is just 1ms so I don't think it's worth to support. > > > > > I will drop vector support at next revision. > > > > > > > > Please do keep the vector support. Absolute timing is misleading, > > > > since in a tight loop, you're not going to contend on mmap_sem. We've > > > > seen tons of improvements in things like camera start come from > > > > coalescing mprotect calls, with the gains coming from taking and > > > > releasing various locks a lot less often and bouncing around less on > > > > the contended lock paths. Raw throughput doesn't tell the whole story, > > > > especially on mobile. > > > > > > This will always be a double edge sword. Taking a lock for longer can > > > improve a throughput of a single call but it would make a latency for > > > anybody contending on the lock much worse. > > > > > > Besides that, please do not overcomplicate the thing from the early > > > beginning please. Let's start with a simple and well defined remote > > > madvise alternative first and build a vector API on top with some > > > numbers based on _real_ workloads. > > > > First time, I didn't think about atomicity about address range race > > because MADV_COLD/PAGEOUT is not critical for the race. > > However you raised the atomicity issue because people would extend > > hints to destructive ones easily. I agree with that and that's why > > we discussed how to guarantee the race and Daniel comes up with good idea. > > Just for the clarification, I didn't really mean atomicity but rather a > _consistency_ (essentially time to check to time to use consistency). What do you mean by *consistency*? Could you elaborate it more? > > > - vma configuration seq number via process_getinfo(2). > > > > We discussed the race issue without _read_ workloads/requests because > > it's common sense that people might extend the syscall later. > > > > Here is same. For current workload, we don't need to support vector > > for perfomance point of view based on my experiment. However, it's > > rather limited experiment. Some configuration might have 1+ vmas > > or really slow CPU. > > > > Furthermore, I want to have vector support due to atomicity issue > > if it's really the one we should consider. > > With vector support of the API and vma configuration sequence number > > from Daniel, we could support address ranges operations's atomicity. > > I am not sure what do you mean here. Perform all ranges atomicaly wrt. > other address space modifications? If yes I am not sure we want that Yub, I
[tip:perf/core] perf trace: Beautify 'fsconfig' arguments
Commit-ID: dcc6fd64f2e9448ccc1c3e1ccd46a9ff5286b861 Gitweb: https://git.kernel.org/tip/dcc6fd64f2e9448ccc1c3e1ccd46a9ff5286b861 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 21 May 2019 15:36:44 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf trace: Beautify 'fsconfig' arguments Use existing beautifiers for the first arg, fd, assigned using the heuristic that looks for syscall arg names and associates SCA_FD with 'fd' named argumes, and wire up the recently introduced fsconfig cmd table generator. Now it should be possible to just use: perf trace -e fsconfig As root and see all fsconfig syscalls with its args beautified, more work needed to look at the command and according to it handle the 'key', 'value' and 'aux' args, using the 'fcntl' and 'futex' beautifiers as a starting point to see how to suppress sets of these last three args that may not be used by the 'cmd' arg, etc. # cat sys_fsconfig.c #define _GNU_SOURCE /* See feature_test_macros(7) */ #include #include/* For SYS_xxx definitions */ #include #define __NR_fsconfig 431 enum fsconfig_command { FSCONFIG_SET_FLAG = 0,/* Set parameter, supplying no value */ FSCONFIG_SET_STRING = 1,/* Set parameter, supplying a string value */ FSCONFIG_SET_BINARY = 2,/* Set parameter, supplying a binary blob value */ FSCONFIG_SET_PATH = 3,/* Set parameter, supplying an object by path */ FSCONFIG_SET_PATH_EMPTY = 4,/* Set parameter, supplying an object by (empty) path */ FSCONFIG_SET_FD = 5,/* Set parameter, supplying an object by fd */ FSCONFIG_CMD_CREATE = 6,/* Invoke superblock creation */ FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ }; static inline int sys_fsconfig(int fd, int cmd, const char *key, const void *value, int aux) { syscall(__NR_fsconfig, fd, cmd, key, value, aux); } int main(int argc, char *argv[]) { int fd = 0, aux = 0; open("/foo", 0); sys_fsconfig(fd++, FSCONFIG_SET_FLAG,"/foo1", "/bar1", aux++); sys_fsconfig(fd++, FSCONFIG_SET_STRING, "/foo2", "/bar2", aux++); sys_fsconfig(fd++, FSCONFIG_SET_BINARY, "/foo3", "/bar3", aux++); sys_fsconfig(fd++, FSCONFIG_SET_PATH,"/foo4", "/bar4", aux++); sys_fsconfig(fd++, FSCONFIG_SET_PATH_EMPTY, "/foo5", "/bar5", aux++); sys_fsconfig(fd++, FSCONFIG_SET_FD, "/foo6", "/bar6", aux++); sys_fsconfig(fd++, FSCONFIG_CMD_CREATE, "/foo7", "/bar7", aux++); sys_fsconfig(fd++, FSCONFIG_CMD_RECONFIGURE, "/foo8", "/bar8", aux++); return 0; } # trace -e fsconfig ./sys_fsconfig fsconfig(0, FSCONFIG_SET_FLAG, 0x40201b, 0x402015, 0) = -1 EINVAL (Invalid argument) fsconfig(1, FSCONFIG_SET_STRING, 0x402027, 0x402021, 1) = -1 EINVAL (Invalid argument) fsconfig(2, FSCONFIG_SET_BINARY, 0x402033, 0x40202d, 2) = -1 EINVAL (Invalid argument) fsconfig(3, FSCONFIG_SET_PATH, 0x40203f, 0x402039, 3) = -1 EBADF (Bad file descriptor) fsconfig(4, FSCONFIG_SET_PATH_EMPTY, 0x40204b, 0x402045, 4) = -1 EBADF (Bad file descriptor) fsconfig(5, FSCONFIG_SET_FD, 0x402057, 0x402051, 5) = -1 EINVAL (Invalid argument) fsconfig(6, FSCONFIG_CMD_CREATE, 0x402063, 0x40205d, 6) = -1 EINVAL (Invalid argument) fsconfig(7, FSCONFIG_CMD_RECONFIGURE, 0x40206f, 0x402069, 7) = -1 EINVAL (Invalid argument) # Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-fb04b76cm59zfuv1wzu40...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf | 8 tools/perf/builtin-trace.c | 6 ++ 2 files changed, 14 insertions(+) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index fe93f8c46080..22e92a9ee871 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -425,6 +425,12 @@ fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh $(fspick_arrays): $(linux_uapi_dir)/fs.h $(fspick_tbls) $(Q)$(SHELL) '$(fspick_tbls)' $(linux_uapi_dir) > $@ +fsconfig_arrays := $(beauty_outdir)/fsconfig_arrays.c +fsconfig_tbls := $(srctree)/tools/perf/trace/beauty/fsconfig.sh + +$(fsconfig_arrays): $(linux_uapi_dir)/fs.h $(fsconfig_tbls) + $(Q)$(SHELL) '$(fsconfig_tbls)' $(linux_uapi_dir) > $@ + pkey_alloc_access_rights_array := $(beauty_outdir)/pkey_alloc_access_rights_array.c asm_generic_hdr_dir := $(srctree)/tools/include/uapi/asm-generic/ pkey_alloc_access_rights_tbl := $(srctree)/tools/perf/trace/beauty/pkey_alloc_access_rights.sh @@ -640,6 +646,7 @@ build-dir = $(if $(__build-dir),$(__build-dir),.) prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioctl_array) \ $(fadvise_advice_array) \ + $(fsconfig_arrays) \ $(fsp
[tip:perf/core] perf trace: Introduce syscall_arg__scnprintf_strarray_flags
Commit-ID: f5b91dbba1a51d30a3fe78a5c6096392fa99471e Gitweb: https://git.kernel.org/tip/f5b91dbba1a51d30a3fe78a5c6096392fa99471e Author: Arnaldo Carvalho de Melo AuthorDate: Thu, 23 May 2019 18:05:03 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf trace: Introduce syscall_arg__scnprintf_strarray_flags So that one can just define a strarray and process it as a set of flags, similar to syscall_arg__scnprintf_strarray() with plain arrays. Cc: Adrian Hunter Cc: Brendan Gregg Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-nnt25wkpkow2w0yefhi6s...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 5 + tools/perf/trace/beauty/beauty.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 87b6dd3c33f5..16bb8c04c689 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -403,6 +403,11 @@ static size_t syscall_arg__scnprintf_strarray(char *bf, size_t size, #define SCA_STRARRAY syscall_arg__scnprintf_strarray +size_t syscall_arg__scnprintf_strarray_flags(char *bf, size_t size, struct syscall_arg *arg) +{ + return strarray__scnprintf_flags(arg->parm, bf, size, arg->show_string_prefix, arg->val); +} + size_t strarrays__scnprintf(struct strarrays *sas, char *bf, size_t size, const char *intfmt, bool show_prefix, int val) { size_t printed; diff --git a/tools/perf/trace/beauty/beauty.h b/tools/perf/trace/beauty/beauty.h index 90c1ee708dc9..ad874e0beba5 100644 --- a/tools/perf/trace/beauty/beauty.h +++ b/tools/perf/trace/beauty/beauty.h @@ -108,6 +108,9 @@ struct syscall_arg { unsigned long syscall_arg__val(struct syscall_arg *arg, u8 idx); +size_t syscall_arg__scnprintf_strarray_flags(char *bf, size_t size, struct syscall_arg *arg); +#define SCA_STRARRAY_FLAGS syscall_arg__scnprintf_strarray_flags + size_t syscall_arg__scnprintf_strarrays(char *bf, size_t size, struct syscall_arg *arg); #define SCA_STRARRAYS syscall_arg__scnprintf_strarrays
[tip:perf/core] perf beauty: Add generator for fsmount's 'attr_flags' arg values
Commit-ID: 3637c64731a78ebe81fba0c282208a860c839307 Gitweb: https://git.kernel.org/tip/3637c64731a78ebe81fba0c282208a860c839307 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 21 May 2019 15:57:16 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf beauty: Add generator for fsmount's 'attr_flags' arg values $ tools/perf/trace/beauty/fsmount.sh static const char *fsmount_attr_flags[] = { [ilog2(0x0001) + 1] = "RDONLY", [ilog2(0x0002) + 1] = "NOSUID", [ilog2(0x0004) + 1] = "NODEV", [ilog2(0x0008) + 1] = "NOEXEC", [ilog2(0x0010) + 1] = "NOATIME", [ilog2(0x0020) + 1] = "STRICTATIME", [ilog2(0x0080) + 1] = "NODIRATIME", } MOUNT_ATTR__ATIME and MOUNT_ATTR_RELATIME will be special cased in the fsmount__scnprintf_flags() beautifier. Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: David Howells Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-sl24d7m2ge82mfmrbaf1m...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/fsmount.sh | 22 ++ 1 file changed, 22 insertions(+) diff --git a/tools/perf/trace/beauty/fsmount.sh b/tools/perf/trace/beauty/fsmount.sh new file mode 100755 index ..615cc0fcf4f9 --- /dev/null +++ b/tools/perf/trace/beauty/fsmount.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1 + +if [ $# -ne 1 ] ; then + linux_header_dir=tools/include/uapi/linux +else + linux_header_dir=$1 +fi + +linux_mount=${linux_header_dir}/mount.h + +# Remove MOUNT_ATTR_RELATIME as it is zeros, handle it a special way in the beautifier +# Only handle MOUNT_ATTR_ followed by a capital letter/num as __ is special case +# for things like MOUNT_ATTR__ATIME that is a mask for the possible ATIME handling +# bits. Special case it as well in the beautifier + +printf "static const char *fsmount_attr_flags[] = {\n" +regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MOUNT_ATTR_([[:alnum:]][[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' +egrep $regex ${linux_mount} | grep -v MOUNT_ATTR_RELATIME | \ + sed -r "s/$regex/\2 \1/g" | \ + xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n" +printf "};\n"
Re: [PATCH] block: fix a crash in do_task_dead()
On Wed, May 29, 2019 at 04:25:26PM -0400, Qian Cai wrote: > Fixes: 0619317ff8ba ("block: add polled wakeup task helper") What is the purpose of that patch ?! The Changelog doesn't mention any benefit or performance gain. So why not revert that? > Signed-off-by: Qian Cai > --- > include/linux/blkdev.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index 592669bcc536..290eb7528f54 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -1803,7 +1803,7 @@ static inline void blk_wake_io_task(struct task_struct > *waiter) >* that case, we don't need to signal a wakeup, it's enough to just >* mark us as RUNNING. >*/ > - if (waiter == current) > + if (waiter == current && in_task()) > __set_current_state(TASK_RUNNING); NAK, No that's broken too. The right fix is something like: if (waiter == current) { barrier(); if (current->state & TASK_NORAL) __set_current_state(TASK_RUNNING); } But even that is yuck to do outside of the scheduler code, as it looses tracepoints and stats. So can we please just revert that original patch and start over -- if needed? > else > wake_up_process(waiter); > -- > 1.8.3.1 >
[tip:perf/core] perf trace: Beautify 'fsmount' arguments
Commit-ID: f6af095668b7799a7514378824dcc74869df3994 Gitweb: https://git.kernel.org/tip/f6af095668b7799a7514378824dcc74869df3994 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 21 May 2019 16:34:03 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf trace: Beautify 'fsmount' arguments Use existing beautifiers for the first arg, fd, assigned using the heuristic that looks for syscall arg names and associates SCA_FD with 'fd' named argumes, and wire up the recently introduced fsmount attr_flags table generator. Now it should be possible to just use: perf trace -e fsmount As root and see all fsmount syscalls with its args beautified. # cat sys_fsmount.c #define _GNU_SOURCE/* See feature_test_macros(7) */ #include #include/* For SYS_xxx definitions */ #define __NR_fsmount 432 #define MOUNT_ATTR_RDONLY 0x0001 /* Mount read-only */ #define MOUNT_ATTR_NOSUID 0x0002 /* Ignore suid and sgid bits */ #define MOUNT_ATTR_NODEV 0x0004 /* Disallow access to device special files */ #define MOUNT_ATTR_NOEXEC 0x0008 /* Disallow program execution */ #define MOUNT_ATTR__ATIME 0x0070 /* Setting on how atime should be updated */ #define MOUNT_ATTR_RELATIME0x /* - Update atime relative to mtime/ctime. */ #define MOUNT_ATTR_NOATIME 0x0010 /* - Do not update access times. */ #define MOUNT_ATTR_STRICTATIME 0x0020 /* - Always perform atime updates */ #define MOUNT_ATTR_NODIRATIME 0x0080 /* Do not update directory access times */ static inline int sys_fsmount(int fs_fd, int flags, int attr_flags) { syscall(__NR_fsmount, fs_fd, flags, attr_flags); } int main(int argc, char *argv[]) { int attr_flags = 0, fs_fd = 0; sys_fsmount(fs_fd++, 0, attr_flags); attr_flags |= MOUNT_ATTR_RDONLY; sys_fsmount(fs_fd++, 1, attr_flags); attr_flags |= MOUNT_ATTR_NOSUID; sys_fsmount(fs_fd++, 0, attr_flags); attr_flags |= MOUNT_ATTR_NODEV; sys_fsmount(fs_fd++, 1, attr_flags); attr_flags |= MOUNT_ATTR_NOEXEC; sys_fsmount(fs_fd++, 0, attr_flags); attr_flags |= MOUNT_ATTR_NOATIME; sys_fsmount(fs_fd++, 1, attr_flags); attr_flags |= MOUNT_ATTR_STRICTATIME; sys_fsmount(fs_fd++, 0, attr_flags); attr_flags |= MOUNT_ATTR_NODIRATIME; sys_fsmount(fs_fd++, 0, attr_flags); return 0; } # # perf trace -e fsmount ./sys_fsmount fsmount(0, 0, MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument) fsmount(1, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument) fsmount(2, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument) fsmount(3, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor) fsmount(4, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor) fsmount(5, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME) = -1 EBADF (Bad file descriptor) fsmount(6, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME) = -1 EINVAL (Invalid argument) fsmount(7, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME|MOUNT_ATTR_NODIRATIME) = -1 EINVAL (Invalid argument) # Cc: Adrian Hunter Cc: Al Viro Cc: Brendan Gregg Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-w71uge0sfo6ns9uclhwtt...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf | 8 tools/perf/builtin-trace.c| 12 tools/perf/trace/beauty/Build | 1 + tools/perf/trace/beauty/beauty.h | 3 +++ tools/perf/trace/beauty/fsmount.c | 34 ++ 5 files changed, 58 insertions(+) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 22e92a9ee871..326ca5d6a7ef 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -419,6 +419,12 @@ fadvise_advice_tbl := $(srctree)/tools/perf/trace/beauty/fadvise.sh $(fadvise_advice_array): $(linux_uapi_dir)/in.h $(fadvise_advice_tbl) $(Q)$(SHELL) '$(fadvise_advice_tbl)' $(linux_uapi_dir) > $@ +fsmount_arrays := $(beauty_outdir)/fsmount_arrays.c +fsmount_tbls := $(srctree)/tools/perf/trace/beauty/fsmount.sh + +$(fsmount_arrays): $(linux_uapi_dir)/fs.h $(fsmount_tbls) + $(Q)$(SHELL) '$(fsmount_tbls)' $(linux_uapi_dir) > $@ + fspick_arrays := $(beauty_outdir)/fspick_arrays.c fspick_tbls := $(srctree)/tools/perf/trace/beauty/fspick.sh @@ -647,6 +653,7 @@ build-dir = $(if $(__build-dir),$(__build-dir),.) prepare: $(OUTPUT)PERF-V
[tip:perf/core] perf beauty: Add generator for sync_file_range's 'flags' arg values
Commit-ID: 8ef6d74e1dd5ac830fa8b7943255ad9a44a94914 Gitweb: https://git.kernel.org/tip/8ef6d74e1dd5ac830fa8b7943255ad9a44a94914 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 21 May 2019 21:43:39 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf beauty: Add generator for sync_file_range's 'flags' arg values $ tools/perf/trace/beauty/sync_file_range.sh static const char *sync_file_range_flags[] = { [ilog2(1) + 1] = "WAIT_BEFORE", [ilog2(2) + 1] = "WRITE", [ilog2(4) + 1] = "WAIT_AFTER", }; $ When all are the above are present, then we have something called SYNC_FILE_RANGE_WRITE_AND_WAIT, that will be special cased in the upcoming scnprintf beautifier for this flags arg. Cc: Adrian Hunter Cc: Amir Goldstein Cc: Brendan Gregg Cc: Jiri Olsa Cc: Linus Torvalds Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-uf2vd7bc8fkz65j7yit8d...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/sync_file_range.sh | 17 + 1 file changed, 17 insertions(+) diff --git a/tools/perf/trace/beauty/sync_file_range.sh b/tools/perf/trace/beauty/sync_file_range.sh new file mode 100755 index ..7a9282d04e44 --- /dev/null +++ b/tools/perf/trace/beauty/sync_file_range.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: LGPL-2.1 + +if [ $# -ne 1 ] ; then + linux_header_dir=tools/include/uapi/linux +else + linux_header_dir=$1 +fi + +linux_fs=${linux_header_dir}/fs.h + +printf "static const char *sync_file_range_flags[] = {\n" +regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+SYNC_FILE_RANGE_([[:alnum:]_]+)[[:space:]]+([[:xdigit:]]+)[[:space:]]*.*' +egrep $regex ${linux_fs} | \ + sed -r "s/$regex/\2 \1/g" | \ + xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n" +printf "};\n"
[tip:perf/core] perf trace beauty clone: Handle CLONE_PIDFD
Commit-ID: ee364dcdcd008530883efc0e690fc8e85622f9b5 Gitweb: https://git.kernel.org/tip/ee364dcdcd008530883efc0e690fc8e85622f9b5 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 21 May 2019 16:51:08 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf trace beauty clone: Handle CLONE_PIDFD In addition to the older flags. This will allow something like this to be implemented in 'perf trace" perf trace -e clone/PIDFD in flags/ I.e. ask for strace like tracing, system wide, looking for 'clone' syscalls that have the CLONE_PIDFD bit set in the 'flags' arg. For now we'll just see PIDFD if it is set in the 'flags' arg. Cc: Christian Brauner Cc: Adrian Hunter Cc: Brendan Gregg Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-drq9h7s8gcv8b87064fp6...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/clone.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/trace/beauty/clone.c b/tools/perf/trace/beauty/clone.c index 6eb9a6636171..1a8d3be2030e 100644 --- a/tools/perf/trace/beauty/clone.c +++ b/tools/perf/trace/beauty/clone.c @@ -25,6 +25,7 @@ static size_t clone__scnprintf_flags(unsigned long flags, char *bf, size_t size, P_FLAG(FS); P_FLAG(FILES); P_FLAG(SIGHAND); + P_FLAG(PIDFD); P_FLAG(PTRACE); P_FLAG(VFORK); P_FLAG(PARENT);
[tip:perf/core] perf trace: Beautify 'sync_file_range' arguments
Commit-ID: a9a187a749f95dda24302aae5c9a0b6b9ee74c99 Gitweb: https://git.kernel.org/tip/a9a187a749f95dda24302aae5c9a0b6b9ee74c99 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 21 May 2019 21:47:07 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf trace: Beautify 'sync_file_range' arguments Use existing beautifiers for the first arg, fd, assigned using the heuristic that looks for syscall arg names and associates SCA_FD with 'fd' named argumes, and wire up the recently introduced sync_file_range flags table generator. Now it should be possible to just use: perf trace -e sync_file_range As root and see all sync_file_range syscalls with its args beautified. Doing a syscall strace like session looking for this syscall, then run postgresql's initdb command: # perf trace -e sync_file_range initdb/1332 sync_file_range(6, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(6, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(7, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(6, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(7, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(6, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(5, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(4, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 initdb/1332 sync_file_range(4, 0, 0, SYNC_FILE_RANGE_WRITE) = 0 ^C # Cc: Adrian Hunter Cc: Amir Goldstein Cc: Brendan Gregg Cc: Jiri Olsa Cc: Linus Torvalds Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-8tqy34xhpg8gwnaiv74xy...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Makefile.perf | 12 ++-- tools/perf/builtin-trace.c| 2 ++ tools/perf/trace/beauty/Build | 1 + tools/perf/trace/beauty/beauty.h | 3 +++ tools/perf/trace/beauty/sync_file_range.c | 31 +++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 326ca5d6a7ef..92b5236c 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -549,6 +549,12 @@ arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh $(arch_errno_name_array): $(arch_errno_tbl) $(Q)$(SHELL) '$(arch_errno_tbl)' $(CC) $(arch_errno_hdr_dir) > $@ +sync_file_range_arrays := $(beauty_outdir)/sync_file_range_arrays.c +sync_file_range_tbls := $(srctree)/tools/perf/trace/beauty/sync_file_range.sh + +$(sync_file_range_arrays): $(linux_uapi_dir)/fs.h $(sync_file_range_tbls) + $(Q)$(SHELL) '$(sync_file_range_tbls)' $(linux_uapi_dir) > $@ + all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) # Create python binding output directory if not already present @@ -671,7 +677,8 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc $(usbdevfs_ioctl_array) \ $(x86_arch_prctl_code_array) \ $(rename_flags_array) \ - $(arch_errno_name_array) + $(arch_errno_name_array) \ + $(sync_file_range_arrays) $(OUTPUT)%.o: %.c prepare FORCE $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ @@ -970,7 +977,8 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea $(OUTPUT)$(usbdevfs_ioctl_array) \ $(OUTPUT)$(x86_arch_prctl_code_array) \ $(OUTPUT)$(rename_flags_array) \ - $(OUTPUT)$(arch_errno_name_array) + $(OUTPUT)$(arch_errno_name_array) \ + $(OUTPUT)$(sync_file_range_arrays) $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean # diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 3a2ab68a8b85..54b2d0fd0d02 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -912,6 +912,8 @@ static struct syscall_fmt { .arg = { [0] = { .scnprintf = SCA_FILENAME, /* specialfile */ }, }, }, { .name = "symlinkat", .arg = { [0] = { .scnprintf = SCA_FDAT, /* dfd */ }, }, }, + { .name = "sync_file_r
[PATCH] hooks: fix a missing-check bug in selinux_add_mnt_opt()
In selinux_add_mnt_opt(), 'val' is allcoted by kmemdup_nul(). It returns NULL when fails. So 'val' should be checked. Signed-off-by: Gen Zhang --- diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 3ec702c..4797c63 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1052,8 +1052,11 @@ static int selinux_add_mnt_opt(const char *option, const char *val, int len, if (token == Opt_error) return -EINVAL; - if (token != Opt_seclabel) - val = kmemdup_nul(val, len, GFP_KERNEL); + if (token != Opt_seclabel) { + val = kmemdup_nul(val, len, GFP_KERNEL); + if (!val) + return -ENOMEM; + } rc = selinux_add_opt(token, val, mnt_opts); if (unlikely(rc)) { kfree(val);
[tip:perf/core] perf top: Add --namespaces option
Commit-ID: a0c0a4ac021b017e385d0328541ccfebeef165fc Gitweb: https://git.kernel.org/tip/a0c0a4ac021b017e385d0328541ccfebeef165fc Author: Namhyung Kim AuthorDate: Wed, 22 May 2019 14:32:50 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf top: Add --namespaces option Since 'perf record' already have this option, let's have it for 'perf top' as well. Signed-off-by: Namhyung Kim Cc: Hari Bathini Cc: Jiri Olsa Cc: Krister Johansen Link: http://lkml.kernel.org/r/20190522053250.207156-4-namhy...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-top.txt | 5 + tools/perf/builtin-top.c | 5 + 2 files changed, 10 insertions(+) diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index 44d89fb9c788..cfea87c6f38e 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -262,6 +262,11 @@ Default is to monitor all CPUS. The number of threads to run when synthesizing events for existing processes. By default, the number of threads equals to the number of online CPUs. +--namespaces:: + Record events of type PERF_RECORD_NAMESPACES and display it with the + 'cgroup_id' sort key. + + INTERACTIVE PROMPTING KEYS -- diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index fbbb0da43abb..31d78d874fc7 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1208,6 +1208,9 @@ static int __cmd_top(struct perf_top *top) init_process_thread(top); + if (opts->record_namespaces) + top->tool.namespace_events = true; + ret = perf_event__synthesize_bpf_events(top->session, perf_event__process, &top->session->machines.host, &top->record_opts); @@ -1500,6 +1503,8 @@ int cmd_top(int argc, const char **argv) OPT_BOOLEAN(0, "force", &symbol_conf.force, "don't complain, do it"), OPT_UINTEGER(0, "num-thread-synthesize", &top.nr_threads_synthesize, "number of thread to run event synthesize"), + OPT_BOOLEAN(0, "namespaces", &opts->record_namespaces, + "Record namespaces events"), OPT_END() }; struct perf_evlist *sb_evlist = NULL;
[tip:perf/core] perf tools: Remove const from thread read accessors
Commit-ID: 7cb10a08df98e643b87d4bc8422e50e9c43b5c60 Gitweb: https://git.kernel.org/tip/7cb10a08df98e643b87d4bc8422e50e9c43b5c60 Author: Namhyung Kim AuthorDate: Mon, 27 May 2019 15:11:49 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf tools: Remove const from thread read accessors The namespaces and comm fields of a thread are protected by rwsem and require write access for it. So it ended up using a cast to remove the const qualifier. Let's get rid of the const then. Signed-off-by: Namhyung Kim Suggested-by: Arnaldo Carvalho de Melo Cc: Hari Bathini Cc: Jiri Olsa Cc: Krister Johansen Link: http://lkml.kernel.org/r/20190527061149.168640-1-namhy...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/hist.c | 2 +- tools/perf/util/thread.c | 12 ++-- tools/perf/util/thread.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 7ace7a10054d..fb3271fd420c 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -2561,7 +2561,7 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool sh char unit; int printed; const struct dso *dso = hists->dso_filter; - const struct thread *thread = hists->thread_filter; + struct thread *thread = hists->thread_filter; int socket_id = hists->socket_filter; unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; u64 nr_events = hists->stats.total_period; diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index b413ba5b9835..aab7807d445f 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -141,13 +141,13 @@ static struct namespaces *__thread__namespaces(const struct thread *thread) return list_first_entry(&thread->namespaces_list, struct namespaces, list); } -struct namespaces *thread__namespaces(const struct thread *thread) +struct namespaces *thread__namespaces(struct thread *thread) { struct namespaces *ns; - down_read((struct rw_semaphore *)&thread->namespaces_lock); + down_read(&thread->namespaces_lock); ns = __thread__namespaces(thread); - up_read((struct rw_semaphore *)&thread->namespaces_lock); + up_read(&thread->namespaces_lock); return ns; } @@ -271,13 +271,13 @@ static const char *__thread__comm_str(const struct thread *thread) return comm__str(comm); } -const char *thread__comm_str(const struct thread *thread) +const char *thread__comm_str(struct thread *thread) { const char *str; - down_read((struct rw_semaphore *)&thread->comm_lock); + down_read(&thread->comm_lock); str = __thread__comm_str(thread); - up_read((struct rw_semaphore *)&thread->comm_lock); + up_read(&thread->comm_lock); return str; } diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index cf8375c017a0..e97ef6977eb9 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -76,7 +76,7 @@ static inline void thread__exited(struct thread *thread) thread->dead = true; } -struct namespaces *thread__namespaces(const struct thread *thread); +struct namespaces *thread__namespaces(struct thread *thread); int thread__set_namespaces(struct thread *thread, u64 timestamp, struct namespaces_event *event); @@ -93,7 +93,7 @@ int thread__set_comm_from_proc(struct thread *thread); int thread__comm_len(struct thread *thread); struct comm *thread__comm(const struct thread *thread); struct comm *thread__exec_comm(const struct thread *thread); -const char *thread__comm_str(const struct thread *thread); +const char *thread__comm_str(struct thread *thread); int thread__insert_map(struct thread *thread, struct map *map); int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp, bool do_maps_clone); size_t thread__fprintf(struct thread *thread, FILE *fp);
[tip:perf/core] perf dso: Separate generic code in dso__data_file_size()
Commit-ID: 5523769ee15f27a1bc2009346736b22cb907bff8 Gitweb: https://git.kernel.org/tip/5523769ee15f27a1bc2009346736b22cb907bff8 Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:19:59 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:43 -0300 perf dso: Separate generic code in dso__data_file_size() Moving file specific code in dso__data_file_size function into separate file_size function. I'll add bpf specific code in following patches. Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-2-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.c | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index e059976d9d93..cb6199c1390a 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -898,18 +898,12 @@ static ssize_t cached_read(struct dso *dso, struct machine *machine, return r; } -int dso__data_file_size(struct dso *dso, struct machine *machine) +static int file_size(struct dso *dso, struct machine *machine) { int ret = 0; struct stat st; char sbuf[STRERR_BUFSIZE]; - if (dso->data.file_size) - return 0; - - if (dso->data.status == DSO_DATA_STATUS_ERROR) - return -1; - pthread_mutex_lock(&dso__data_open_lock); /* @@ -938,6 +932,17 @@ out: return ret; } +int dso__data_file_size(struct dso *dso, struct machine *machine) +{ + if (dso->data.file_size) + return 0; + + if (dso->data.status == DSO_DATA_STATUS_ERROR) + return -1; + + return file_size(dso, machine); +} + /** * dso__data_size - Return dso data size * @dso: dso object
RISC-V Hypervisors
Hi All, It's a great pleasure to inform everyone that we have RISC-V hypervisor extension available for QEMU and along with it we also have Xvisor (a baremetal type-1 hypervisor) working on QEMU with RISC-V hypervisor extension. Currently, we are able to boot two Linux RV64 Guests on Xvisor RV64. This will be very useful to RISC-V CPU designers in validating their implementation of RISC-V hypervisor extensions. The QEMU RISC-V hypervisor emulation is done by Alistair and is available in riscv-hyp-work.next branch at: https://github.com/alistair23/qemu.git. At the moment, QEMU RISC-V hypervisor emulation patches are on QEMU mailing list for review. (Refer, https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg06064.html) The Xvisor RISC-V port is done by myself (Anup) and Atish. It can be found in master branch of Xvisor staging repo at: https://github.com/avpatel/xvisor-next.git. For more details on Xvisor, refer http://xhypervisor.org/ http://xhypervisor.org/index.php?page=news/20150427 The SBI runtime needs to support RISC-V hypervisor extensions. Particularly, we need to handle trap redirection, misaligned load/store emulation, and missing CSR emulation differently for HS-mode and VS-mode. We have extended OpenSBI to support RISC-V hypervisor extension and it is available in hyp_ext_changes_v1 branch at: https://github.com/riscv/opensbi.git We have made great progress in KVM RISC-V (type-2 hypervisor) as well. Currently, we are debugging KVM RISC-V and KVMTOOL RISC-V port on QEMU. You can expect RFC patches soon in June/July 2019. The KVM RISC-V can be found in riscv_kvm_v1 branch at: https://github.com/avpatel/linux.git The KVMTOOL RISC-V port can be found in riscv_v1 branch at: https://github.com/avpatel/kvmtool.git There is an early work on Xen RISC-V port which is avaliable in alistair/riscv-port branch at: https://github.com/alistair23/xen.git We will be showing a demo of QEMU+OpenSBI+Xvisor+Linux at up-coming RISC-V Zurich Workshop. (Refer, https://tmt.knect365.com/risc-v-workshop-zurich/) Stay tuned for more exciting updates on RISC-V hypervisors. Regards, Anup
[tip:perf/core] perf dso: Simplify dso_cache__read function
Commit-ID: cacddfe7b0804752528e8100461266ec33dc6b64 Gitweb: https://git.kernel.org/tip/cacddfe7b0804752528e8100461266ec33dc6b64 Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:01 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf dso: Simplify dso_cache__read function There's no need for the while loop now, also we can connect two (ret > 0) condition legs together. Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Song Liu Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-4-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.c | 17 ++--- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 7734f50a6912..1e6a045adb8c 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -823,25 +823,20 @@ static ssize_t dso_cache__read(struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size) { + u64 cache_offset = offset & DSO__DATA_CACHE_MASK; struct dso_cache *cache; struct dso_cache *old; ssize_t ret; - do { - u64 cache_offset = offset & DSO__DATA_CACHE_MASK; - - cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE); - if (!cache) - return -ENOMEM; - - ret = file_read(dso, machine, cache_offset, cache->data); + cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE); + if (!cache) + return -ENOMEM; + ret = file_read(dso, machine, cache_offset, cache->data); + if (ret > 0) { cache->offset = cache_offset; cache->size = ret; - } while (0); - - if (ret > 0) { old = dso_cache__insert(dso, cache); if (old) { /* we lose the race */
[tip:perf/core] perf dso: Separate generic code in dso_cache__read
Commit-ID: ea5db1bd5a04b865bc86bb8e3267c27939dfb5ee Gitweb: https://git.kernel.org/tip/ea5db1bd5a04b865bc86bb8e3267c27939dfb5ee Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:00 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf dso: Separate generic code in dso_cache__read Move the file specific code in the dso_cache__read function to a separate file_read function. I'll add BPF specific code in the following patches. Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-3-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.c | 48 +++- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index cb6199c1390a..7734f50a6912 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -794,6 +794,31 @@ dso_cache__memcpy(struct dso_cache *cache, u64 offset, return cache_size; } +static ssize_t file_read(struct dso *dso, struct machine *machine, +u64 offset, char *data) +{ + ssize_t ret; + + pthread_mutex_lock(&dso__data_open_lock); + + /* +* dso->data.fd might be closed if other thread opened another +* file (dso) due to open file limit (RLIMIT_NOFILE). +*/ + try_to_open_dso(dso, machine); + + if (dso->data.fd < 0) { + dso->data.status = DSO_DATA_STATUS_ERROR; + ret = -errno; + goto out; + } + + ret = pread(dso->data.fd, data, DSO__DATA_CACHE_SIZE, offset); +out: + pthread_mutex_unlock(&dso__data_open_lock); + return ret; +} + static ssize_t dso_cache__read(struct dso *dso, struct machine *machine, u64 offset, u8 *data, ssize_t size) @@ -803,37 +828,18 @@ dso_cache__read(struct dso *dso, struct machine *machine, ssize_t ret; do { - u64 cache_offset; + u64 cache_offset = offset & DSO__DATA_CACHE_MASK; cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE); if (!cache) return -ENOMEM; - pthread_mutex_lock(&dso__data_open_lock); - - /* -* dso->data.fd might be closed if other thread opened another -* file (dso) due to open file limit (RLIMIT_NOFILE). -*/ - try_to_open_dso(dso, machine); - - if (dso->data.fd < 0) { - ret = -errno; - dso->data.status = DSO_DATA_STATUS_ERROR; - break; - } - - cache_offset = offset & DSO__DATA_CACHE_MASK; - - ret = pread(dso->data.fd, cache->data, DSO__DATA_CACHE_SIZE, cache_offset); - if (ret <= 0) - break; + ret = file_read(dso, machine, cache_offset, cache->data); cache->offset = cache_offset; cache->size = ret; } while (0); - pthread_mutex_unlock(&dso__data_open_lock); if (ret > 0) { old = dso_cache__insert(dso, cache);
[tip:perf/core] perf dso: Add BPF DSO read and size hooks
Commit-ID: 6c398d723a6a6d27485e701ae21e50304ec95595 Gitweb: https://git.kernel.org/tip/6c398d723a6a6d27485e701ae21e50304ec95595 Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:02 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf dso: Add BPF DSO read and size hooks Add BPF related code into DSO reading paths to return size (bpf_size) and read the BPF code (bpf_read). Signed-off-by: Jiri Olsa Acked-by: Song Liu Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-5-jo...@kernel.org [ Use uintptr_t when casting from u64 to u8 pointers ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.c | 49 - 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 1e6a045adb8c..1fb18292c2d3 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include "bpf-event.h" #include "compress.h" #include "namespaces.h" #include "path.h" @@ -706,6 +708,44 @@ bool dso__data_status_seen(struct dso *dso, enum dso_data_status_seen by) return false; } +static ssize_t bpf_read(struct dso *dso, u64 offset, char *data) +{ + struct bpf_prog_info_node *node; + ssize_t size = DSO__DATA_CACHE_SIZE; + u64 len; + u8 *buf; + + node = perf_env__find_bpf_prog_info(dso->bpf_prog.env, dso->bpf_prog.id); + if (!node || !node->info_linear) { + dso->data.status = DSO_DATA_STATUS_ERROR; + return -1; + } + + len = node->info_linear->info.jited_prog_len; + buf = (u8 *)(uintptr_t)node->info_linear->info.jited_prog_insns; + + if (offset >= len) + return -1; + + size = (ssize_t)min(len - offset, (u64)size); + memcpy(data, buf + offset, size); + return size; +} + +static int bpf_size(struct dso *dso) +{ + struct bpf_prog_info_node *node; + + node = perf_env__find_bpf_prog_info(dso->bpf_prog.env, dso->bpf_prog.id); + if (!node || !node->info_linear) { + dso->data.status = DSO_DATA_STATUS_ERROR; + return -1; + } + + dso->data.file_size = node->info_linear->info.jited_prog_len; + return 0; +} + static void dso_cache__free(struct dso *dso) { @@ -832,7 +872,11 @@ dso_cache__read(struct dso *dso, struct machine *machine, if (!cache) return -ENOMEM; - ret = file_read(dso, machine, cache_offset, cache->data); + if (dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO) + ret = bpf_read(dso, cache_offset, cache->data); + else + ret = file_read(dso, machine, cache_offset, cache->data); + if (ret > 0) { cache->offset = cache_offset; cache->size = ret; @@ -941,6 +985,9 @@ int dso__data_file_size(struct dso *dso, struct machine *machine) if (dso->data.status == DSO_DATA_STATUS_ERROR) return -1; + if (dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO) + return bpf_size(dso); + return file_size(dso, machine); }
[tip:perf/core] perf script: Pad DSO name for --call-trace
Commit-ID: 1c4924220c96392d17e0222c113509fd7b9a0854 Gitweb: https://git.kernel.org/tip/1c4924220c96392d17e0222c113509fd7b9a0854 Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:05 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf script: Pad DSO name for --call-trace Pad the DSO name in --call-trace so we don't have the indent screwed by different DSO name lengths, as now for kernel there's also BPF code displayed. # perf-with-kcore record pt -e intel_pt//ku -- sleep 1 # perf-core/perf-with-kcore script pt --call-trace Before: sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]) kretprobe_perf_func sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]) trace_call_bpf sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 3660 [16] 57036.806464404: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 3660 [16] 57036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_get_current_pid_tgid sleep 3660 [16] 57036.806464725: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_ktime_get_ns sleep 3660 [16] 57036.806464725: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 3660 [16] 57036.806464725: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 3660 [16] 57036.806465045: (bpf_prog_da4fe6b3d2c29b25_trace_return) __htab_map_lookup_elem sleep 3660 [16] 57036.806465366: ([kernel.kallsyms]) memcmp sleep 3660 [16] 57036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_probe_read sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) probe_kernel_read sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) __check_object_size sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) check_stack_object sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) copy_user_enhanced_fast_string sleep 3660 [16] 57036.806465687: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_probe_read sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) probe_kernel_read sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) __check_object_size sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) check_stack_object sleep 3660 [16] 57036.806465687: ([kernel.kallsyms]) copy_user_enhanced_fast_string sleep 3660 [16] 57036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_get_current_uid_gid sleep 3660 [16] 57036.806466008: ([kernel.kallsyms]) from_kgid sleep 3660 [16] 57036.806466008: ([kernel.kallsyms]) from_kuid sleep 3660 [16] 57036.806466008: (bpf_prog_da4fe6b3d2c29b25_trace_return) bpf_perf_event_output sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]) perf_event_output sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]) perf_prepare_sample sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]) perf_misc_flags sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 3660 [16] 57036.806466328: ([kernel.kallsyms]) __x86_indirect_thunk_rax sleep 3660 [16] 57036.806466328: ([kvm]) kvm_is_in_guest sleep 3660 [16] 57036.806466649: ([kernel.kallsyms]) __perf_event_header__init_id.isra.0 sleep 3660 [16] 57036.806466649: ([kernel.kallsyms]) perf_output_begin After: sleep 3660 [16] 57036.806464404: ([kernel.kallsyms] ) kretprobe_perf_func sleep 3660 [16] 57036.806464404: ([kernel.kallsyms] ) trace_call_bpf sleep 3660 [16] 57036.806464404: ([kernel.kallsyms] ) __x86_indirect_thunk_rax sleep 3660 [16] 57036.806464404: ([kernel.kallsyms] ) __x86_indirect_
[tip:perf/core] perf tests: Add map_groups__merge_in test
Commit-ID: 4f600bcf657d4d0476d0d96cb38077a72b8fb2af Gitweb: https://git.kernel.org/tip/4f600bcf657d4d0476d0d96cb38077a72b8fb2af Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:07 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf tests: Add map_groups__merge_in test Add map_groups__merge_in test to test the map_groups__merge_in function usage - merging kcore maps into existing eBPF maps. Committer testing: # perf test merge 59: map_groups__merge_in : Ok # perf test -v merge 59: map_groups__merge_in : --- start --- test child forked, pid 8349 test child finished with 0 end map_groups__merge_in: Ok # Signed-off-by: Jiri Olsa Acked-by: Song Liu Tested-by: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-10-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 ++ tools/perf/tests/map_groups.c | 120 tools/perf/tests/tests.h| 1 + tools/perf/util/map_groups.h| 2 + tools/perf/util/symbol.c| 2 +- 6 files changed, 129 insertions(+), 1 deletion(-) diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index 0b2b8305c965..4afb6319ed51 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build @@ -50,6 +50,7 @@ perf-y += perf-hooks.o perf-y += clang.o perf-y += unit_number__scnprintf.o perf-y += mem2node.o +perf-y += map_groups.o $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build $(call rule_mkdir) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 9852b5d624a5..941c5456d625 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -289,6 +289,10 @@ static struct test generic_tests[] = { .desc = "mem2node", .func = test__mem2node, }, + { + .desc = "map_groups__merge_in", + .func = test__map_groups__merge_in, + }, { .func = NULL, }, diff --git a/tools/perf/tests/map_groups.c b/tools/perf/tests/map_groups.c new file mode 100644 index ..70d96acc6dcf --- /dev/null +++ b/tools/perf/tests/map_groups.c @@ -0,0 +1,120 @@ +#include +#include +#include "tests.h" +#include "map.h" +#include "map_groups.h" +#include "dso.h" +#include "debug.h" + +struct map_def { + const char *name; + u64 start; + u64 end; +}; + +static int check_maps(struct map_def *merged, unsigned int size, struct map_groups *mg) +{ + struct map *map; + unsigned int i = 0; + + map = map_groups__first(mg); + while (map) { + TEST_ASSERT_VAL("wrong map start", map->start == merged[i].start); + TEST_ASSERT_VAL("wrong map end",map->end == merged[i].end); + TEST_ASSERT_VAL("wrong map name", !strcmp(map->dso->name, merged[i].name)); + TEST_ASSERT_VAL("wrong map refcnt", refcount_read(&map->refcnt) == 2); + + i++; + map = map_groups__next(map); + + TEST_ASSERT_VAL("less maps expected", (map && i < size) || (!map && i == size)); + } + + return TEST_OK; +} + +int test__map_groups__merge_in(struct test *t __maybe_unused, int subtest __maybe_unused) +{ + struct map_groups mg; + unsigned int i; + struct map_def bpf_progs[] = { + { "bpf_prog_1", 200, 300 }, + { "bpf_prog_2", 500, 600 }, + { "bpf_prog_3", 800, 900 }, + }; + struct map_def merged12[] = { + { "kcore1", 100, 200 }, + { "bpf_prog_1", 200, 300 }, + { "kcore1", 300, 500 }, + { "bpf_prog_2", 500, 600 }, + { "kcore1", 600, 800 }, + { "bpf_prog_3", 800, 900 }, + { "kcore1", 900, 1000 }, + }; + struct map_def merged3[] = { + { "kcore1", 100, 200 }, + { "bpf_prog_1", 200, 300 }, + { "kcore1", 300, 500 }, + { "bpf_prog_2", 500, 600 }, + { "kcore1", 600, 800 }, + { "bpf_prog_3", 800, 900 }, + { "kcore1", 900, 1000 }, + { "kcore3", 1000, 1100 }, + }; + struct map *map_kcore1, *map_kcore2, *map_kcore3; + int ret; + + map_groups__init(&mg, NULL); + + for (i = 0; i < ARRAY_SIZE(bpf_progs); i++) { + struct map *map; + + map = dso__new_map(bpf_progs[i].name); + TEST_ASSERT_VAL("failed to create map", map); + + map->start = bpf_progs[i].start; +
[tip:perf/core] perf script: Add --show-bpf-events to show eBPF related events
Commit-ID: 490c8cc949eca14bfdbee0ad1cd1c6d3ddf46b77 Gitweb: https://git.kernel.org/tip/490c8cc949eca14bfdbee0ad1cd1c6d3ddf46b77 Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:08 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf script: Add --show-bpf-events to show eBPF related events Add the --show-bpf-events command line option to show the eBPF related events: PERF_RECORD_KSYMBOL PERF_RECORD_BPF_EVENT Usage: # perf record -a ... # perf script --show-bpf-events ... swapper 0 [000] 0.00: PERF_RECORD_KSYMBOL ksymbol event with addr c0ef971d len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 swapper 0 [000] 0.00: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 36 ... Committer testing: # perf script --show-bpf-events | egrep -i 'PERF_RECORD_(BPF|KSY)' 0 PERF_RECORD_KSYMBOL ksymbol event with addr c029a6c3 len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 47 0 PERF_RECORD_KSYMBOL ksymbol event with addr c029c1ae len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 48 0 PERF_RECORD_KSYMBOL ksymbol event with addr c02ddd1c len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 49 0 PERF_RECORD_KSYMBOL ksymbol event with addr c02dfc11 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 50 0 PERF_RECORD_KSYMBOL ksymbol event with addr c045da0a len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 51 0 PERF_RECORD_KSYMBOL ksymbol event with addr c04ef4b4 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 52 0 PERF_RECORD_KSYMBOL ksymbol event with addr c09e15da len 229 type 1 flags 0x0 name bpf_prog_7be49e3934a125ba 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 53 0 PERF_RECORD_KSYMBOL ksymbol event with addr c0d2b1a3 len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 54 0 PERF_RECORD_KSYMBOL ksymbol event with addr c0fd9850 len 381 type 1 flags 0x0 name bpf_prog_819967866022f1e1_sys_enter 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 179 0 PERF_RECORD_KSYMBOL ksymbol event with addr c0feb1ec len 191 type 1 flags 0x0 name bpf_prog_c1bd85c092d6e4aa_sys_exit 0 PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 180 ^C[root@quaco pt]# perf evlist intel_pt//ku dummy:u # Signed-off-by: Jiri Olsa Acked-by: Song Liu Tested-by: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-11-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-script.txt | 3 +++ tools/perf/builtin-script.c | 42 2 files changed, 45 insertions(+) diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt index 9b0d04dd2a61..af8282782911 100644 --- a/tools/perf/Documentation/perf-script.txt +++ b/tools/perf/Documentation/perf-script.txt @@ -313,6 +313,9 @@ OPTIONS --show-round-events Display finished round events i.e. events of type PERF_RECORD_FINISHED_ROUND. +--show-bpf-events + Display bpf events i.e. events of type PERF_RECORD_KSYMBOL and PERF_RECORD_BPF_EVENT. + --demangle:: Demangle symbol names to human readable form. It's enabled by default, disable with --no-demangle. diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 7adaa6c63a0b..3a48a2627670 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -1606,6 +1606,7 @@ struct perf_script { boolshow_namespace_events; boolshow_lost_events; boolshow_round_events; + boolshow_bpf_events; boolallocated; boolper_event_dump; struct cpu_map *cpus; @@ -2318,6 +2319,41 @@ process_finished_round_event(struct perf_tool *tool __maybe_unused, return 0; } +static int +process_bpf_events(struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_sample *sample, + struct machine *machine) +{ + struct thread *thread; + struct perf_script *script = container_of(tool, struct perf_script, tool); + struct perf_ses
iwl_mvm_add_new_dqa_stream_wk BUG in lib/list_debug.c:56
Hi, on my primary notebook, a Lenovo X260, with an Intel Wireless 8260 (8086:24f3), running Debian unstable, I have started to see network hangs since upgrading to kernel 5.1. In this situation, I cannot restart Network-Manager (the call just hangs), I can log out of X, but the system does not cleanly shut down and I need to Magic SysRq myself out of the running system. This happens about once every two days. dmesg: [38083.673678] lanw0: authenticate with 92:2a:a8:cb:8b:6c [38083.682971] lanw0: send auth to 92:2a:a8:cb:8b:6c (try 1/3) [38083.693860] lanw0: authenticated [38083.697711] lanw0: associate with 92:2a:a8:cb:8b:6c (try 1/3) [38083.703029] lanw0: RX ReassocResp from 92:2a:a8:cb:8b:6c (capab=0x411 status=0 aid=1) [38083.705838] lanw0: associated [38114.658765] lanw0: disconnect from AP 92:2a:a8:cb:8b:6c for new auth to 02:9f:c2:ab:b6:9f [38114.671649] lanw0: authenticate with 02:9f:c2:ab:b6:9f [38114.680074] lanw0: send auth to 02:9f:c2:ab:b6:9f (try 1/3) [38114.692359] lanw0: authenticated [38114.693609] lanw0: associate with 02:9f:c2:ab:b6:9f (try 1/3) [38114.698697] lanw0: RX ReassocResp from 02:9f:c2:ab:b6:9f (capab=0x411 status=0 aid=1) [38114.700878] lanw0: associated [38179.708187] lanw0: disconnect from AP 02:9f:c2:ab:b6:9f for new auth to 92:2a:a8:cb:8b:6c [38179.720183] lanw0: authenticate with 92:2a:a8:cb:8b:6c [38179.728924] lanw0: send auth to 92:2a:a8:cb:8b:6c (try 1/3) [38179.741439] lanw0: authenticated [38179.745606] lanw0: associate with 92:2a:a8:cb:8b:6c (try 1/3) [38179.750579] lanw0: RX ReassocResp from 92:2a:a8:cb:8b:6c (capab=0x411 status=0 aid=1) [38179.752854] lanw0: associated [38179.854525] list_del corruption. next->prev should be 88839d6167f8, but was 88839d616108 [38179.854533] [ cut here ] [38179.854535] kernel BUG at lib/list_debug.c:56! [38179.854539] invalid opcode: [#2] SMP PTI [38179.854542] CPU: 0 PID: 1869 Comm: kworker/0:2 Tainted: G DO 5.1.1-zgws1 #5.1.1.20190514.3 [38179.854543] Hardware name: LENOVO 20F5S5X100/20F5S5X100, BIOS R02ET63W (1.36 ) 12/15/2017 [38179.854552] Workqueue: events iwl_mvm_add_new_dqa_stream_wk [iwlmvm] [38179.854556] RIP: 0010:__list_del_entry_valid.cold.1+0x20/0x4c [38179.854557] Code: e3 d8 81 e8 a7 f2 da ff 0f 0b 48 89 fe 48 89 c2 48 c7 c7 20 e4 d8 81 e8 93 f2 da ff 0f 0b 48 c7 c7 d0 e4 d8 81 e8 85 f2 da ff <0f> 0b 48 89 f2 48 89 fe 48 c7 c7 90 e4 d8 81 e8 71 f2 da ff 0f 0b 38179.854559] RSP: 0018:c9000844fde8 EFLAGS: 00010246 [38179.854560] RAX: 0054 RBX: 88839d6167f8 RCX: [38179.854561] RDX: RSI: 8884318164d8 RDI: 8884318164d8 [38179.854562] RBP: 888150a56888 R08: 042a R09: 0063 [38179.854563] R10: R11: c9000844fc88 R12: 000a [38179.854564] R13: R14: 88842bdfe388 R15: [38179.854566] FS: () GS:88843180() knlGS: [38179.854567] CS: 0010 DS: ES: CR0: 80050033 [38179.854568] CR2: 7f87c26a5000 CR3: 00033154a006 CR4: 003626f0 [38179.854569] DR0: DR1: DR2: [38179.854570] DR3: DR6: fffe0ff0 DR7: 0400 [38179.854571] Call Trace: [38179.854578] iwl_mvm_add_new_dqa_stream_wk+0x2b2/0x760 [iwlmvm] [38179.854582] process_one_work+0x195/0x3d0 [38179.854584] worker_thread+0x2b/0x390 [38179.854586] ? create_worker+0x190/0x190 [38179.854588] kthread+0x111/0x130 [38179.854589] ? kthread_bind+0x20/0x20 [38179.854592] ret_from_fork+0x35/0x40 [38179.854594] Modules linked in: vhost_net vhost tap ext2 mmc_block tun hid_generic usbhid hid ctr ccm rfcomm fuse acpi_call(O) cpufreq_userspace cpufreq_powersave cpufreq_conservative cmac bnep option cdc_ether btusb usbnet btbcm btintel usb_wwan mii usbserial bluetooth hmac drbg ansi_cprng ecdh_generic msr bridge stp llc dummy ip6t_REJECT arc4 nf_reject_ipv6 ip6_tables nft_chain_nat ipt_MASQUERADE nf_nat wmi_bmof nft_chain_route_ipv4 snd_hda_codec_hdmi iwlmvm xt_TCPMSS mac80211 snd_hda_codec_realtek nft_counter snd_hda_codec_generic iwlwifi snd_hda_intel intel_rapl snd_hda_codec x86_pkg_temp_thermal intel_powerclamp ipt_REJECT nf_reject_ipv4 kvm_intel xt_tcpudp snd_hda_core kvm irqbypass snd_hwdep xt_conntrack intel_cstate intel_rapl_perf nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 snd_pcm nft_compat input_leds serio_raw snd_timer cfg80211 thinkpad_acpi nf_tables sg nvram mei_hdcp ledtrig_audio intel_pch_thermal tpm_tis snd nfnetlink tpm_tis_core soundcore tpm rfkill wmi rng_core ac battery [38179.854623] evdev pcc_cpufreq button tcp_bbr sch_fq nfsd auth_rpcgss nfs_acl lockd grace coretemp sunrpc loop ip_tables x_tables autofs4 btrfs zlib_deflate ext4 crc16 mbcache jbd2 algif_skcipher af_alg dm_crypt dm_mod raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor uas usb_storage
[PATCH] habanalabs: fix bug in checking huge page optimization
This patch fix a bug in the mmu code that checks whether we can use huge page mappings for host pages. The code is supposed to enable huge page mappings only if ALL DMA addresses are aligned to 2MB AND the number of pages in each DMA chunk is a modulo of the number of pages in 2MB. However, the code ignored the first requirement for the first DMA chunk. This patch fix that issue by making sure the requirement of address alignment is validated against all DMA chunks. Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/memory.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/misc/habanalabs/memory.c b/drivers/misc/habanalabs/memory.c index d67d24c13efd..693877e37fd8 100644 --- a/drivers/misc/habanalabs/memory.c +++ b/drivers/misc/habanalabs/memory.c @@ -675,11 +675,6 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx, total_npages += npages; - if (first) { - first = false; - dma_addr &= PAGE_MASK_2MB; - } - if ((npages % PGS_IN_2MB_PAGE) || (dma_addr & (PAGE_SIZE_2MB - 1))) is_huge_page_opt = false; @@ -704,7 +699,6 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx, phys_pg_pack->total_size = total_npages * page_size; j = 0; - first = true; for_each_sg(userptr->sgt->sgl, sg, userptr->sgt->nents, i) { npages = get_sg_info(sg, &dma_addr); -- 2.17.1
[tip:perf/core] perf version: Append 12 git SHA chars to the version string
Commit-ID: 80ec26d110c5c5a81b60c444db851e5734dee09a Gitweb: https://git.kernel.org/tip/80ec26d110c5c5a81b60c444db851e5734dee09a Author: Arnaldo Carvalho de Melo AuthorDate: Fri, 24 May 2019 15:50:18 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf version: Append 12 git SHA chars to the version string Bumping it from just 4: Before: $ perf -v perf version 5.2.rc1.g80978f $ After: $ perf -v perf version 5.2.rc1.g80978fc864c5 $ Requested-by: Ingo Molnar Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-p4yun2nxlo7eeeohyx5v4...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/PERF-VERSION-GEN | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN index 3802cee5e188..59241ff342be 100755 --- a/tools/perf/util/PERF-VERSION-GEN +++ b/tools/perf/util/PERF-VERSION-GEN @@ -19,7 +19,7 @@ TAG= if test -d ../../.git -o -f ../../.git then TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null ) - CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" + CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID" elif test -f ../../PERF-VERSION-FILE then TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
[tip:perf/core] perf script: Remove superfluous BPF event titles
Commit-ID: 8201787cbb723a20bf262ecb41b74962ad27e659 Gitweb: https://git.kernel.org/tip/8201787cbb723a20bf262ecb41b74962ad27e659 Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:09 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf script: Remove superfluous BPF event titles There's no need to display "ksymbol event with" text for the PERF_RECORD_KSYMBOL event and "bpf event with" test for the PERF_RECORD_BPF_EVENT event. Remove it so it also goes along with other side-band events display. Before: # perf script --show-bpf-events ... swapper 0 [000] 0.00: PERF_RECORD_KSYMBOL ksymbol event with addr c0ef971d len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 swapper 0 [000] 0.00: PERF_RECORD_BPF_EVENT bpf event with type 1, flags 0, id 36 After: # perf script --show-bpf-events ... swapper 0 [000] 0.00: PERF_RECORD_KSYMBOL addr c0ef971d len 229 type 1 flags 0x0 name bpf_prog_2a142ef67aaad174 swapper 0 [000] 0.00: PERF_RECORD_BPF_EVENT type 1, flags 0, id 36 Signed-off-by: Jiri Olsa Acked-by: Song Liu Tested-by: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-12-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index d1ad6c419724..c9c6857360e4 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -1486,7 +1486,7 @@ static size_t perf_event__fprintf_lost(union perf_event *event, FILE *fp) size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) { - return fprintf(fp, " ksymbol event with addr %" PRIx64 " len %u type %u flags 0x%x name %s\n", + return fprintf(fp, " addr %" PRIx64 " len %u type %u flags 0x%x name %s\n", event->ksymbol_event.addr, event->ksymbol_event.len, event->ksymbol_event.ksym_type, event->ksymbol_event.flags, event->ksymbol_event.name); @@ -1494,7 +1494,7 @@ size_t perf_event__fprintf_ksymbol(union perf_event *event, FILE *fp) size_t perf_event__fprintf_bpf_event(union perf_event *event, FILE *fp) { - return fprintf(fp, " bpf event with type %u, flags %u, id %u\n", + return fprintf(fp, " type %u, flags %u, id %u\n", event->bpf_event.type, event->bpf_event.flags, event->bpf_event.id); }
[tip:perf/core] perf machine: Return NULL instead of null-terminating /proc/version array
Commit-ID: 34b65affe18daad31fed83e50d1f3b817786a2b7 Gitweb: https://git.kernel.org/tip/34b65affe18daad31fed83e50d1f3b817786a2b7 Author: Donald Yandt AuthorDate: Tue, 28 May 2019 09:41:28 -0400 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf machine: Return NULL instead of null-terminating /proc/version array Return NULL instead of null-terminating version char array when fgets fails due to end-of-file or error. Signed-off-by: Donald Yandt Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Peter Zijlstra Cc: Yanmin Zhang Fixes: 30ba5b0e66c8 ("perf machine: Null-terminate version char array upon fgets(/proc/version) error") Link: http://lkml.kernel.org/r/20190528134128.30841-1-donald.ya...@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index f5569f005cf3..17eec39e775e 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1241,9 +1241,9 @@ static char *get_kernel_version(const char *root_dir) return NULL; tmp = fgets(version, sizeof(version), file); - if (!tmp) - *version = '\0'; fclose(file); + if (!tmp) + return NULL; name = strstr(version, prefix); if (!name)
[tip:perf/core] perf annotate TUI browser: Do not use member from variable within its own initialization
Commit-ID: da2019633f0b5c105ce658aada333422d8cb28fe Gitweb: https://git.kernel.org/tip/da2019633f0b5c105ce658aada333422d8cb28fe Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 28 May 2019 16:02:56 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf annotate TUI browser: Do not use member from variable within its own initialization Some compilers will complain when using a member of a struct to initialize another member, in the same struct initialization. For instance: debian:8 Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0) oraclelinux:7 clang version 3.4.2 (tags/RELEASE_34/dot2-final) Produce: ui/browsers/annotate.c:104:12: error: variable 'ops' is uninitialized when used within its own initialization [-Werror,-Wuninitialized] (!ops.current_entry || ^~~ 1 error generated. So use an extra variable, initialized just before that struct, to have the value used in the expressions used to init two of the struct members. Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Fixes: c298304bd747 ("perf annotate: Use a ops table for annotation_line__write()") Link: https://lkml.kernel.org/n/tip-f9nexro58q62l3o9hez8h...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 98d934a36d86..b0d089a95dac 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -97,11 +97,12 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); struct annotation *notes = browser__annotation(browser); struct annotation_line *al = list_entry(entry, struct annotation_line, node); + const bool is_current_entry = ui_browser__is_current_entry(browser, row); struct annotation_write_ops ops = { .first_line = row == 0, - .current_entry = ui_browser__is_current_entry(browser, row), + .current_entry = is_current_entry, .change_color= (!notes->options->hide_src_code && - (!ops.current_entry || + (!is_current_entry || (browser->use_navkeypressed && !browser->navkeypressed))), .width = browser->width,
Re: [PATCH -next] platform/chrome: cros_ec_lpc: Make some symbols static
On 2019/5/29 23:12, Guenter Roeck wrote: > On Wed, May 29, 2019 at 8:08 AM YueHaibing wrote: >> >> Fix sparse warning: >> >> drivers/platform/chrome/cros_ec_debugfs.c:256:30: warning: symbol >> 'cros_ec_console_log_fops' was not declared. Should it be static? >> drivers/platform/chrome/cros_ec_debugfs.c:265:30: warning: symbol >> 'cros_ec_pdinfo_fops' was not declared. Should it be static? >> drivers/platform/chrome/cros_ec_lightbar.c:550:24: warning: symbol >> 'cros_ec_lightbar_attr_group' was not declared. Should it be static? >> drivers/platform/chrome/cros_ec_sysfs.c:338:24: warning: symbol >> 'cros_ec_attr_group' was not declared. Should it be static? >> drivers/platform/chrome/cros_ec_vbc.c:104:24: warning: symbol >> 'cros_ec_vbc_attr_group' was not declared. Should it be static? >> drivers/platform/chrome/cros_ec_lpc.c:408:25: warning: symbol >> 'cros_ec_lpc_pm_ops' was not declared. Should it be static? >> > > The subject is misleading: The patch does not only affect cros_ec_lpc. Sorry, will fix it in v2. > > Guenter > >> Reported-by: Hulk Robot >> Signed-off-by: YueHaibing >> --- >> drivers/platform/chrome/cros_ec_debugfs.c | 4 ++-- >> drivers/platform/chrome/cros_ec_lightbar.c | 2 +- >> drivers/platform/chrome/cros_ec_lpc.c | 2 +- >> drivers/platform/chrome/cros_ec_sysfs.c| 2 +- >> drivers/platform/chrome/cros_ec_vbc.c | 2 +- >> 5 files changed, 6 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/platform/chrome/cros_ec_debugfs.c >> b/drivers/platform/chrome/cros_ec_debugfs.c >> index 4c2a27f6a6d0..4578eb3e0731 100644 >> --- a/drivers/platform/chrome/cros_ec_debugfs.c >> +++ b/drivers/platform/chrome/cros_ec_debugfs.c >> @@ -241,7 +241,7 @@ static ssize_t cros_ec_pdinfo_read(struct file *file, >>read_buf, p - read_buf); >> } >> >> -const struct file_operations cros_ec_console_log_fops = { >> +static const struct file_operations cros_ec_console_log_fops = { >> .owner = THIS_MODULE, >> .open = cros_ec_console_log_open, >> .read = cros_ec_console_log_read, >> @@ -250,7 +250,7 @@ const struct file_operations cros_ec_console_log_fops = { >> .release = cros_ec_console_log_release, >> }; >> >> -const struct file_operations cros_ec_pdinfo_fops = { >> +static const struct file_operations cros_ec_pdinfo_fops = { >> .owner = THIS_MODULE, >> .open = simple_open, >> .read = cros_ec_pdinfo_read, >> diff --git a/drivers/platform/chrome/cros_ec_lightbar.c >> b/drivers/platform/chrome/cros_ec_lightbar.c >> index d30a6650b0b5..23a82ee4c785 100644 >> --- a/drivers/platform/chrome/cros_ec_lightbar.c >> +++ b/drivers/platform/chrome/cros_ec_lightbar.c >> @@ -547,7 +547,7 @@ static struct attribute *__lb_cmds_attrs[] = { >> NULL, >> }; >> >> -struct attribute_group cros_ec_lightbar_attr_group = { >> +static struct attribute_group cros_ec_lightbar_attr_group = { >> .name = "lightbar", >> .attrs = __lb_cmds_attrs, >> }; >> diff --git a/drivers/platform/chrome/cros_ec_lpc.c >> b/drivers/platform/chrome/cros_ec_lpc.c >> index c9c240fbe7c6..aaa21803633a 100644 >> --- a/drivers/platform/chrome/cros_ec_lpc.c >> +++ b/drivers/platform/chrome/cros_ec_lpc.c >> @@ -405,7 +405,7 @@ static int cros_ec_lpc_resume(struct device *dev) >> } >> #endif >> >> -const struct dev_pm_ops cros_ec_lpc_pm_ops = { >> +static const struct dev_pm_ops cros_ec_lpc_pm_ops = { >> SET_LATE_SYSTEM_SLEEP_PM_OPS(cros_ec_lpc_suspend, cros_ec_lpc_resume) >> }; >> >> diff --git a/drivers/platform/chrome/cros_ec_sysfs.c >> b/drivers/platform/chrome/cros_ec_sysfs.c >> index fe0b7614ae1b..3edb237bf8ed 100644 >> --- a/drivers/platform/chrome/cros_ec_sysfs.c >> +++ b/drivers/platform/chrome/cros_ec_sysfs.c >> @@ -335,7 +335,7 @@ static umode_t cros_ec_ctrl_visible(struct kobject *kobj, >> return a->mode; >> } >> >> -struct attribute_group cros_ec_attr_group = { >> +static struct attribute_group cros_ec_attr_group = { >> .attrs = __ec_attrs, >> .is_visible = cros_ec_ctrl_visible, >> }; >> diff --git a/drivers/platform/chrome/cros_ec_vbc.c >> b/drivers/platform/chrome/cros_ec_vbc.c >> index 8392a1ec33a7..2aaefed87eb4 100644 >> --- a/drivers/platform/chrome/cros_ec_vbc.c >> +++ b/drivers/platform/chrome/cros_ec_vbc.c >> @@ -101,7 +101,7 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = { >> NULL >> }; >> >> -struct attribute_group cros_ec_vbc_attr_group = { >> +static struct attribute_group cros_ec_vbc_attr_group = { >> .name = "vbc", >> .bin_attrs = cros_ec_vbc_bin_attrs, >> }; >> -- >> 2.17.1 >> >> > > . >
[tip:perf/core] perf python: Remove -fstack-protector-strong if clang doesn't have it
Commit-ID: 7952fa3b54bf6834dca22a21363c7caf78525720 Gitweb: https://git.kernel.org/tip/7952fa3b54bf6834dca22a21363c7caf78525720 Author: Arnaldo Carvalho de Melo AuthorDate: Tue, 28 May 2019 17:36:46 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:44 -0300 perf python: Remove -fstack-protector-strong if clang doesn't have it Some distros put -fstack-protector-strong in the compiler flags to be used to build python extensions, but then, the clang version in that distro doesn't know about that, only gcc does. Check if that is the case and remove it from the set of options used to build the python binding with clang. Case at hand: oraclelinux:7 $ head -2 /etc/os-release NAME="Oracle Linux Server" VERSION="7.6" $ grep stack-protector /usr/lib64/python2.7/_sysconfigdata.py | head -1 | cut -c-120 'CFLAGS': '-fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --para $ gcc version 4.8.5 20150623 (Red Hat 4.8.5-36.0.1) (GCC) clang version 3.4.2 (tags/RELEASE_34/dot2-final) clang: error: unknown argument: '-fstack-protector-strong' clang: error: unknown argument: '-fstack-protector-strong' error: command 'clang' failed with exit status 1 cp: cannot stat '/tmp/build/perf/python_ext_build/lib/perf*.so': No such file or directory make[2]: *** [/tmp/build/perf/python/perf.so] Error 1 Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-brmp2415zxpbhz45etkgj...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py index 5b5a167b43ce..a1a68a2fa917 100644 --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py @@ -17,6 +17,8 @@ if cc == "clang": vars[var] = sub("-fcf-protection", "", vars[var]) if not clang_has_option("-fstack-clash-protection"): vars[var] = sub("-fstack-clash-protection", "", vars[var]) +if not clang_has_option("-fstack-protector-strong"): +vars[var] = sub("-fstack-protector-strong", "", vars[var]) from distutils.core import setup, Extension
[tip:perf/core] perf top: Lower message level for failure on synthesizing events for pre-existing BPF programs
Commit-ID: 2d45ef7033ec90104ae8e4c3996227bdad24dc76 Gitweb: https://git.kernel.org/tip/2d45ef7033ec90104ae8e4c3996227bdad24dc76 Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 20 May 2019 11:04:08 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf top: Lower message level for failure on synthesizing events for pre-existing BPF programs Move it from being a pr_warning() to a pr_debug(). Also capitalize BPF and explain what gets missing when we're not able to synthesize these events: we'll not be able to resolve symbols, etc. Reported-by: Ingo Molnar Cc: Adrian Hunter Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Daniel Borkmann Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Martin KaFai Lau Cc: Namhyung Kim Cc: Song Liu Cc: Wang Nan Cc: Yonghong Song Link: https://lkml.kernel.org/n/tip-whpnfnw6xtd939odgt9bw...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-top.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 31d78d874fc7..6651377fd762 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1215,7 +1215,7 @@ static int __cmd_top(struct perf_top *top) &top->session->machines.host, &top->record_opts); if (ret < 0) - pr_warning("Couldn't synthesize bpf events.\n"); + pr_debug("Couldn't synthesize BPF events: Pre-existing BPF programs won't have symbols resolved.\n"); machine__synthesize_threads(&top->session->machines.host, &opts->target, top->evlist->threads, false,
User Stack Tracer Causes Crash 2
Hi, https://lore.kernel.org/lkml/20190320221534.165ab...@oasis.local.home/ didn't get merged. And the crash it was trying to fix still happens on the latest master branch. If rebasing the patch on the latest top, the following new crash come up. Sometimes, root@intel-x86-64:~# echo 1 > /sys/kernel/debug/tracing/options/userstacktrace root@intel-x86-64:~# echo 1 > /sys/kernel/debug/tracing/events/preemptirq/irq_disable/enable root@intel-x86-64:~# echo 1 > /proc/sys/kernel/stack_tracer_enabled hangs... Sometimes, root@intel-x86-64:~# echo 1 > /sys/kernel/debug/tracing/options/userstacktrace root@intel-x86-64:~# echo 1 > /sys/kernel/debug/tracing/events/preemptirq/irq_disable/enable root@intel-x86-64:~# echo 1 > /proc/sys/kernel/stack_tracer_enabled PANIC: double fault, error_code: 0x0 CPU: 0 PID: 492 Comm: sh Not tainted 5.2.0-rc2 #1 Hardware name: Intel Corporation Broadwell Client platform/Basking Ridge, BIOS BDW-E2R1.86C.0118.R01.1503110618 03/11/2015 RIP: 0010:error_entry+0x32/0x100 Code: 89 7c 24 08 52 31 d2 51 31 c9 50 41 50 45 31 c0 41 51 45 31 c9 41 52 45 31 d2 41 53 45 31 db 53 31 db 55 31 ed 41 54 45 31 e4 <41> 55 45 31 ed 41 56 45 31 f6 41 57 45 31 ff 56 48 8d 6c 24 09 f6 RSP: 0018:9ab68000 EFLAGS: 00010046 RAX: ae200a97 RBX: RCX: RDX: RSI: ae200ec9 RDI: ae201176 RBP: R08: R09: R10: R11: R12: R13: R14: R15: FS: 7f2c078a4740() GS:988fb8a0() knlGS: CS: 0010 DS: ES: CR0: 80050033 CR2: 9ab67ff8 CR3: 5b8ee003 CR4: 003606f0 Call Trace: ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_thunk_cr2+0x1a/0x1c ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? error_entry+0x86/0x100 ? int3+0x29/0x40 ? native_iret+0x7/0x7 ? int3+0x29/0x40 ? error_entry+0x86/0x100 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardirqs_off_caller_cr2+0x1/0x20 ? trace_hardi
[tip:perf/core] perf tools: Preserve eBPF maps when loading kcore
Commit-ID: fb5a88d4131a9ee8bec3f4bb7c034d7a4e9cf5ea Gitweb: https://git.kernel.org/tip/fb5a88d4131a9ee8bec3f4bb7c034d7a4e9cf5ea Author: Jiri Olsa AuthorDate: Wed, 8 May 2019 15:20:06 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:42 -0300 perf tools: Preserve eBPF maps when loading kcore We need to preserve eBPF maps even if they are covered by kcore, because we need to access eBPF dso for source data. Add the map_groups__merge_in function to do that. It merges a map into map_groups by splitting the new map within the existing map regions. Suggested-by: Adrian Hunter Signed-off-by: Jiri Olsa Acked-by: Song Liu Tested-by: Arnaldo Carvalho de Melo Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stanislav Fomichev Link: http://lkml.kernel.org/r/20190508132010.14512-9-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/symbol.c | 97 ++-- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 5cbad55cd99d..29780fcd049c 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1166,6 +1166,85 @@ static int kcore_mapfn(u64 start, u64 len, u64 pgoff, void *data) return 0; } +/* + * Merges map into map_groups by splitting the new map + * within the existing map regions. + */ +static int map_groups__merge_in(struct map_groups *kmaps, struct map *new_map) +{ + struct map *old_map; + LIST_HEAD(merged); + + for (old_map = map_groups__first(kmaps); old_map; +old_map = map_groups__next(old_map)) { + + /* no overload with this one */ + if (new_map->end < old_map->start || + new_map->start >= old_map->end) + continue; + + if (new_map->start < old_map->start) { + /* +* |new.. +* |old +*/ + if (new_map->end < old_map->end) { + /* +* |new..| -> |new..| +* |old| -> |old| +*/ + new_map->end = old_map->start; + } else { + /* +* |new.| -> |new..| |new..| +* |old|-> |old| +*/ + struct map *m = map__clone(new_map); + + if (!m) + return -ENOMEM; + + m->end = old_map->start; + list_add_tail(&m->node, &merged); + new_map->start = old_map->end; + } + } else { + /* +* |new.. +* |old +*/ + if (new_map->end < old_map->end) { + /* +* |new..| -> x +* |old.| -> |old.| +*/ + map__put(new_map); + new_map = NULL; + break; + } else { + /* +* |new..| -> |new...| +* |old|-> |old| +*/ + new_map->start = old_map->end; + } + } + } + + while (!list_empty(&merged)) { + old_map = list_entry(merged.next, struct map, node); + list_del_init(&old_map->node); + map_groups__insert(kmaps, old_map); + map__put(old_map); + } + + if (new_map) { + map_groups__insert(kmaps, new_map); + map__put(new_map); + } + return 0; +} + static int dso__load_kcore(struct dso *dso, struct map *map, const char *kallsyms_filename) { @@ -1222,7 +1301,12 @@ static int dso__load_kcore(struct dso *dso, struct map *map, while (old_map) { struct map *next = map_groups__next(old_map); - if (old_map != map) + /* +* We need to preserve eBPF maps even if they are +* covered by kcore, because we need to access +* eBPF dso for source data. +*/ + if (old_map != map && !__map__is_bpf_prog(old_map)) map_
[tip:perf/core] perf scripts python: exported-sql-viewer.py: Change python2 to python
Commit-ID: c6aba1bf258ff1ce201f112dafe1bdde601573dd Gitweb: https://git.kernel.org/tip/c6aba1bf258ff1ce201f112dafe1bdde601573dd Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:23 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf scripts python: exported-sql-viewer.py: Change python2 to python Now that there is also support for python3, there is no need to specify python2 explicitly. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-2-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/exported-sql-viewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index affed7d149be..9ff92a130655 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # SPDX-License-Identifier: GPL-2.0 # exported-sql-viewer.py: view data from sql database # Copyright (c) 2014-2018, Intel Corporation.
[tip:perf/core] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing
Commit-ID: 1ed7f47fd3af3c09d2cd64d1aff1c5b96d238111 Gitweb: https://git.kernel.org/tip/1ed7f47fd3af3c09d2cd64d1aff1c5b96d238111 Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:24 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing The argparse module makes it easier to add new arguments. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-3-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/exported-sql-viewer.py | 21 +++-- 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index 9ff92a130655..498b79454012 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -91,6 +91,7 @@ from __future__ import print_function import sys +import argparse import weakref import threading import string @@ -3361,18 +3362,26 @@ class DBRef(): # Main def Main(): - if (len(sys.argv) < 2): - printerr("Usage is: exported-sql-viewer.py { | --help-only}"); - raise Exception("Too few arguments") - - dbname = sys.argv[1] - if dbname == "--help-only": + usage_str = "exported-sql-viewer.py [--pyside-version-1] \n" \ + " or: exported-sql-viewer.py --help-only" + ap = argparse.ArgumentParser(usage = usage_str, add_help = False) + ap.add_argument("dbname", nargs="?") + ap.add_argument("--help-only", action='store_true') + args = ap.parse_args() + + if args.help_only: app = QApplication(sys.argv) mainwindow = HelpOnlyWindow() mainwindow.show() err = app.exec_() sys.exit(err) + dbname = args.dbname + if dbname is None: + ap.print_usage() + print("Too few arguments") + sys.exit(1) + is_sqlite3 = False try: f = open(dbname, "rb")
[tip:perf/core] perf scripts python: exported-sql-viewer.py: Add support for pyside2
Commit-ID: df8ea22a8fd9e4e8502f4fa917622801e1b4d09e Gitweb: https://git.kernel.org/tip/df8ea22a8fd9e4e8502f4fa917622801e1b4d09e Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:25 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf scripts python: exported-sql-viewer.py: Add support for pyside2 pyside2 is the future for pyside support. Note pyside use Qt4 whereas pyside2 uses Qt5. Committer testing: On a system with just: # rpm -qa| grep -i pyside python2-pyside-1.2.4-7.fc29.x86_64 # Running: $ python ~acme/libexec/perf-core/scripts/python/exported-sql-viewer.py ~/c/adrian.hunter/simple-retpoline.db & [1] 7438 Makes it use the pyside 1 files: $ grep -i pyside /proc/7438/maps | cut -d ' ' -f 6- | sort -u /usr/lib64/libpyside-python2.7.so.1.2.4 /usr/lib64/python2.7/site-packages/PySide/QtCore.so /usr/lib64/python2.7/site-packages/PySide/QtGui.so /usr/lib64/python2.7/site-packages/PySide/QtSql.so $ rpm -qf /usr/lib64/libpyside-python2.7.so.1.2.4 python2-pyside-1.2.4-7.fc29.x86_64 $ To get PySide2 I guess one needs to do: $ pip install PySide2 But thats a 142MiB download I can't do right now, perhaps before pushing upstream... Signed-off-by: Adrian Hunter Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-4-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/exported-sql-viewer.py | 28 ++-- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index 498b79454012..6fe553258ce5 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -105,10 +105,23 @@ except ImportError: glb_nsz = 16 import re import os -from PySide.QtCore import * -from PySide.QtGui import * -from PySide.QtSql import * + pyside_version_1 = True +if not "--pyside-version-1" in sys.argv: + try: + from PySide2.QtCore import * + from PySide2.QtGui import * + from PySide2.QtSql import * + from PySide2.QtWidgets import * + pyside_version_1 = False + except: + pass + +if pyside_version_1: + from PySide.QtCore import * + from PySide.QtGui import * + from PySide.QtSql import * + from decimal import * from ctypes import * from multiprocessing import Process, Array, Value, Event @@ -2755,7 +2768,7 @@ class WindowMenu(): action = self.window_menu.addAction(label) action.setCheckable(True) action.setChecked(sub_window == self.mdi_area.activeSubWindow()) - action.triggered.connect(lambda x=nr: self.setActiveSubWindow(x)) + action.triggered.connect(lambda a=None,x=nr: self.setActiveSubWindow(x)) self.window_menu.addAction(action) nr += 1 @@ -3115,14 +3128,14 @@ class MainWindow(QMainWindow): event = event.split(":")[0] if event == "branches": label = "All branches" if branches_events == 1 else "All branches " + "(id=" + dbid + ")" - reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewBranchView(x), self)) + reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewBranchView(x), self)) label = "Selected branches" if branches_events == 1 else "Selected branches " + "(id=" + dbid + ")" - reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda x=dbid: self.NewSelectedBranchView(x), self)) + reports_menu.addAction(CreateAction(label, "Create a new window displaying branch events", lambda a=None,x=dbid: self.NewSelectedBranchView(x), self)) def TableMenu(self, tables, menu): table_menu = menu.addMenu("&Tables") for table in tables: - table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda t=table: self.NewTableView(t), self)) + table_menu.addAction(CreateAction(table, "Create a new window containing a table view", lambda a=None,t=table: self.NewTableView(t), self)) def NewCallGraph(self): CallGraphWindow(self.glb, self) @@ -3365,6 +3378,7 @@ def Main(): usage_str = "exported-sql-viewer.py [--pyside-version-1] \n" \ " or: exported-sql-viewer.py --help-only" ap = argparse.Argumen
[tip:perf/core] perf scripts python: export-to-postgresql.py: Add support for pyside2
Commit-ID: 3cd3216dbb421244b96b992f193e778a3baa2220 Gitweb: https://git.kernel.org/tip/3cd3216dbb421244b96b992f193e778a3baa2220 Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:27 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf scripts python: export-to-postgresql.py: Add support for pyside2 pyside2 is the future for pyside support. Note pyside use Qt4 whereas pyside2 uses Qt5. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-6-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/export-to-postgresql.py | 43 ++- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py index c3eae1d77d36..b2f481b0d28d 100644 --- a/tools/perf/scripts/python/export-to-postgresql.py +++ b/tools/perf/scripts/python/export-to-postgresql.py @@ -27,18 +27,31 @@ import datetime # # fedora: # -# $ sudo yum install postgresql postgresql-server python-pyside qt-postgresql +# $ sudo yum install postgresql postgresql-server qt-postgresql # $ sudo su - postgres -c initdb # $ sudo service postgresql start # $ sudo su - postgres -# $ createuser +# $ createuser -s # Older versions may not support -s, in which case answer the prompt below: # Shall the new role be a superuser? (y/n) y +# $ sudo yum install python-pyside +# +# Alternately, to use Python3 and/or pyside 2, one of the following: +# $ sudo yum install python3-pyside +# $ pip install --user PySide2 +# $ pip3 install --user PySide2 # # ubuntu: # -# $ sudo apt-get install postgresql python-pyside.qtsql libqt4-sql-psql +# $ sudo apt-get install postgresql # $ sudo su - postgres # $ createuser -s +# $ sudo apt-get install python-pyside.qtsql libqt4-sql-psql +# +# Alternately, to use Python3 and/or pyside 2, one of the following: +# +# $ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql +# $ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql +# $ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql # # An example of using this script with Intel PT: # @@ -199,7 +212,16 @@ import datetime # print "{0:>6} {1:>10} {2:>9} {3:<30} {4:>6} {5:<30}".format(query.value(0), query.value(1), query.value(2), query.value(3), query.value(4), query.value(5)) # call_path_id = query.value(6) -from PySide.QtSql import * +pyside_version_1 = True +if not "pyside-version-1" in sys.argv: + try: + from PySide2.QtSql import * + pyside_version_1 = False + except: + pass + +if pyside_version_1: + from PySide.QtSql import * if sys.version_info < (3, 0): def toserverstr(str): @@ -255,11 +277,12 @@ def printdate(*args, **kw_args): print(datetime.datetime.today(), *args, sep=' ', **kw_args) def usage(): - printerr("Usage is: export-to-postgresql.py [] [] []") - printerr("where:columns 'all' or 'branches'") - printerr(" calls 'calls' => create calls and call_paths table") - printerr(" callchains 'callchains' => create call_paths table") - raise Exception("Too few arguments") + printerr("Usage is: export-to-postgresql.py [] [] [] []"); + printerr("where: columns'all' or 'branches'"); + printerr("calls 'calls' => create calls and call_paths table"); + printerr("callchains 'callchains' => create call_paths table"); + printerr("pyside-version-1 'pyside-version-1' => use pyside version 1"); + raise Exception("Too few or bad arguments") if (len(sys.argv) < 2): usage() @@ -281,6 +304,8 @@ for i in range(3,len(sys.argv)): perf_db_export_calls = True elif (sys.argv[i] == "callchains"): perf_db_export_callchains = True + elif (sys.argv[i] == "pyside-version-1"): + pass else: usage()
[tip:perf/core] perf scripts python: export-to-sqlite.py: Add support for pyside2
Commit-ID: bfb3170e2481b76a4f8aae94176e45d681a37f3e Gitweb: https://git.kernel.org/tip/bfb3170e2481b76a4f8aae94176e45d681a37f3e Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:26 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf scripts python: export-to-sqlite.py: Add support for pyside2 pyside2 is the future for pyside support. Note pyside use Qt4 whereas pyside2 uses Qt5. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-5-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/export-to-sqlite.py | 44 +++ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/tools/perf/scripts/python/export-to-sqlite.py b/tools/perf/scripts/python/export-to-sqlite.py index bf271fbc3a88..f617e518332f 100644 --- a/tools/perf/scripts/python/export-to-sqlite.py +++ b/tools/perf/scripts/python/export-to-sqlite.py @@ -21,6 +21,26 @@ import datetime # provides LGPL-licensed Python bindings for Qt. You will also need the package # libqt4-sql-sqlite for Qt sqlite3 support. # +# Examples of installing pyside: +# +# ubuntu: +# +# $ sudo apt-get install python-pyside.qtsql libqt4-sql-psql +# +# Alternately, to use Python3 and/or pyside 2, one of the following: +# +# $ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql +# $ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql +# $ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql +# fedora: +# +# $ sudo yum install python-pyside +# +# Alternately, to use Python3 and/or pyside 2, one of the following: +# $ sudo yum install python3-pyside +# $ pip install --user PySide2 +# $ pip3 install --user PySide2 +# # An example of using this script with Intel PT: # # $ perf record -e intel_pt//u ls @@ -49,7 +69,16 @@ import datetime # difference is the 'transaction' column of the 'samples' table which is # renamed 'transaction_' in sqlite because 'transaction' is a reserved word. -from PySide.QtSql import * +pyside_version_1 = True +if not "pyside-version-1" in sys.argv: + try: + from PySide2.QtSql import * + pyside_version_1 = False + except: + pass + +if pyside_version_1: + from PySide.QtSql import * sys.path.append(os.environ['PERF_EXEC_PATH'] + \ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') @@ -69,11 +98,12 @@ def printdate(*args, **kw_args): print(datetime.datetime.today(), *args, sep=' ', **kw_args) def usage(): - printerr("Usage is: export-to-sqlite.py [] [] []"); - printerr("where:columns 'all' or 'branches'"); - printerr(" calls 'calls' => create calls and call_paths table"); - printerr(" callchains 'callchains' => create call_paths table"); - raise Exception("Too few arguments") + printerr("Usage is: export-to-sqlite.py [] [] [] []"); + printerr("where: columns'all' or 'branches'"); + printerr("calls 'calls' => create calls and call_paths table"); + printerr("callchains 'callchains' => create call_paths table"); + printerr("pyside-version-1 'pyside-version-1' => use pyside version 1"); + raise Exception("Too few or bad arguments") if (len(sys.argv) < 2): usage() @@ -95,6 +125,8 @@ for i in range(3,len(sys.argv)): perf_db_export_calls = True elif (sys.argv[i] == "callchains"): perf_db_export_callchains = True + elif (sys.argv[i] == "pyside-version-1"): + pass else: usage()
[tip:perf/core] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events
Commit-ID: c7b4f15ff79b539fed4c382e52e988548081bc9d Gitweb: https://git.kernel.org/tip/c7b4f15ff79b539fed4c382e52e988548081bc9d Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:29 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events sync_switch is a facility to synchronize decoding more closely with the point in the kernel when the context actually switched. Improve it by processing "context switch in" events. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-8-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-pt.c | 40 +++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 03b1da6d1da4..6aaba1146fc8 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -1914,6 +1914,44 @@ static int intel_pt_process_switch(struct intel_pt *pt, return machine__set_current_tid(pt->machine, cpu, -1, tid); } +static int intel_pt_context_switch_in(struct intel_pt *pt, + struct perf_sample *sample) +{ + pid_t pid = sample->pid; + pid_t tid = sample->tid; + int cpu = sample->cpu; + + if (pt->sync_switch) { + struct intel_pt_queue *ptq; + + ptq = intel_pt_cpu_to_ptq(pt, cpu); + if (ptq && ptq->sync_switch) { + ptq->next_tid = -1; + switch (ptq->switch_state) { + case INTEL_PT_SS_NOT_TRACING: + case INTEL_PT_SS_UNKNOWN: + case INTEL_PT_SS_TRACING: + break; + case INTEL_PT_SS_EXPECTING_SWITCH_EVENT: + case INTEL_PT_SS_EXPECTING_SWITCH_IP: + ptq->switch_state = INTEL_PT_SS_TRACING; + break; + default: + break; + } + } + } + + /* +* If the current tid has not been updated yet, ensure it is now that +* a "switch in" event has occurred. +*/ + if (machine__get_current_tid(pt->machine, cpu) == tid) + return 0; + + return machine__set_current_tid(pt->machine, cpu, pid, tid); +} + static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event, struct perf_sample *sample) { @@ -1925,7 +1963,7 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event, if (pt->have_sched_switch == 3) { if (!out) - return 0; + return intel_pt_context_switch_in(pt, sample); if (event->header.type != PERF_RECORD_SWITCH_CPU_WIDE) { pr_err("Expecting CPU-wide context switch event\n"); return -EINVAL;
[tip:perf/core] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid
Commit-ID: 14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c Gitweb: https://git.kernel.org/tip/14f1cfd4f7b4794e2f9d2ae214bcf049654b0b5c Author: Adrian Hunter AuthorDate: Fri, 12 Apr 2019 14:38:30 +0300 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 28 May 2019 18:37:45 -0300 perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Returning 1 from intel_pt_sync_switch() causes the current tid to be set. That negates the need to keep next_tid anymore. Rationalize the code to that effect. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: http://lkml.kernel.org/r/20190412113830.4126-9-adrian.hun...@intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-pt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c index 6aaba1146fc8..7a70693c1b91 100644 --- a/tools/perf/util/intel-pt.c +++ b/tools/perf/util/intel-pt.c @@ -1859,7 +1859,6 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid, switch (ptq->switch_state) { case INTEL_PT_SS_NOT_TRACING: - ptq->next_tid = -1; break; case INTEL_PT_SS_UNKNOWN: case INTEL_PT_SS_TRACING: @@ -1879,13 +1878,14 @@ static int intel_pt_sync_switch(struct intel_pt *pt, int cpu, pid_t tid, ptq->switch_state = INTEL_PT_SS_TRACING; break; case INTEL_PT_SS_EXPECTING_SWITCH_IP: - ptq->next_tid = tid; intel_pt_log("ERROR: cpu %d expecting switch ip\n", cpu); break; default: break; } + ptq->next_tid = -1; + return 1; }
Re: [PATCH v4] perf record: collect user registers set jointly with dwarf stacks
On 29.05.2019 22:25, Arnaldo Carvalho de Melo wrote: > Em Wed, May 29, 2019 at 05:30:49PM +0300, Alexey Budankov escreveu: >> >> --- >> tools/perf/util/evsel.c | 11 ++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c >> index a6f572a40deb..426dfefeecda 100644 >> --- a/tools/perf/util/evsel.c >> +++ b/tools/perf/util/evsel.c >> @@ -669,6 +669,9 @@ int perf_evsel__group_desc(struct perf_evsel *evsel, >> char *buf, size_t size) >> return ret; >> } >> >> +#define DWARF_REGS_MASK ((1ULL << PERF_REG_IP) | \ >> + (1ULL << PERF_REG_SP)) >> + >> static void __perf_evsel__config_callchain(struct perf_evsel *evsel, >> struct record_opts *opts, >> struct callchain_param *param) >> @@ -702,7 +705,13 @@ static void __perf_evsel__config_callchain(struct >> perf_evsel *evsel, >> if (!function) { >> perf_evsel__set_sample_bit(evsel, REGS_USER); >> perf_evsel__set_sample_bit(evsel, STACK_USER); >> -attr->sample_regs_user |= PERF_REGS_MASK; >> +if (opts->sample_user_regs) { > > Where are you checking that opts->sample_user_regs doesn't have either > IP or SP? Sure. The the intention was to avoid such a complication, merge two masks and provide explicit warning that the resulting mask is extended. If you still see the checking and auto detection of the exact mask extension as essential it can be implemented. > > So, __perf_evsel__config_callchain its the routine that sets up the > attr->sample_regs_user when callchains are asked for, and what was it > doing? Asking for _all_ user regs, right? > > I.e. what you're saying is that when --callgraph-dwarf is asked for, > then only IP and BP are needed, and we should stop doing that, so that > would be a first patch, if that is the case. I.e. a patch that doesn't > even mention opts->sample_user_regs. > > Then, a second patch would fix the opt->sample_user_regs request clash > with --callgraph dwarf, i.e. it would do something like: > > if ((opts->sample_regs_user & DWARF_REGS_MASK) != > DWARF_REGS_MASK) { > char * ip = (opts->sample_regs_user & (1ULL << > PERF_REG_IP)) ? NULL : "IP", >* sp = (opts->sample_regs_user & (1ULL << > PERF_REG_SP)) ? NULL : "SP", >* all = (!ip && !sp) ? "s" : ""; > > pr_warning("WARNING: specified --user-regs register set > doesn't include register%s " > "needed by also specified > --call-graph=dwarf, auto adding %s%s%s register%s.\n", > all, ip, all : ", " : "", sp, all); > } > > This if and only if all the registers that are needed to do DWARF > unwinding are just IP and BP, which doesn't look like its true, since > when no --user_regs is set (i.e. opts->user_regs is not set) then we > continue asking for PERF_REGS_MASK... > > Can you check where I'm missing something? 1. -g call-graph dwarf,K full_regs 2. --user-regs=user_regs user_regs 3. -g call-graph dwarf,K --user-regs=user_regs user_regs + dwarf_regs The default behavior stays the same for cases 1, 2 above. For case 3 register set becomes the one asked using --user_regs option. If the option value misses IP or SP or the both then they are explicitly added to the option value and a warning message mentioning the exact added registers is provided. > > Jiri DWARF unwind uses just IP and SP? Looking at > tools/perf/util/unwind-libunwind-local.c's access_reg() I don't think > so, right? If you ask me, AFAIK, DWARF unwind rules sometimes can refer additional general purpose registers for frames boundaries calculation. Thanks, Alexey > > - Arnaldo > >> +attr->sample_regs_user |= DWARF_REGS_MASK; >> +pr_warning("WARNING: specified --user-regs >> register set doesn't include registers " >> + "needed by also specified >> --call-graph=dwarf, auto adding IP, SP registers.\n"); >> +} else { >> +attr->sample_regs_user |= PERF_REGS_MASK; >> +} >> attr->sample_stack_user = param->dump_size; >> attr->exclude_callchain_user = 1; >> } else { >> -- >> 2.20.1 >
Re: [PATCH net-next] ethtool: copy reglen to userspace
On Thu, May 30, 2019 at 08:48:48AM +0200, Michal Kubecek wrote: > On Wed, May 29, 2019 at 10:17:44PM -0700, David Miller wrote: > > From: Vivien Didelot > > Date: Tue, 28 May 2019 16:58:48 -0400 > > > > > ethtool_get_regs() allocates a buffer of size reglen obtained from > > > ops->get_regs_len(), thus only this value must be used when copying > > > the buffer back to userspace. Also no need to check regbuf twice. > > > > > > Signed-off-by: Vivien Didelot > > > > Hmmm, can't regs.len be modified by the driver potentially? > > The driver certainly shouldn't raise it as that could result in kernel > writing past the buffer provided by userspace. (I'll check some drivers > to see if they truncate the dump or return an error if regs.len from > userspace is insufficient.) And lowering it would be also wrong as that > would mean dump would be shorter than what ops->get_regs_len() returned. I looked around a bit. First of all, the driver cannot actually return error as ethtool_ops::get_regs() returns void. Most drivers do not touch regs->len and only fill data and possibly regs->version which is fine. There are few drivers which modify regs->len: s2io_ethtool_gdrvinfo() neterion/s2io vxge_ethtool_gregs() neterion/vxge ixgb_get_regs() intel/ixgb emac_get_regs_len() qualcomm/emac ql_get_regs() qlogic/qlge axienet_ethtools_get_regs() xilinx/axienet All of these set regs->len to the same value as ->get_regs_len() returns (ixgb does it in rather fragile way). This means that if userspace passes insufficient buffer size, current code would write pass that buffer; but proposed patch would make things worse as with it, kernel would always write past the userspace buffer in such case. Note: ieee80211_get_regs() in net/mac80211/ethtool.c also sets regs->len but it always sets it to 0 which is also what ->get_regs_len() returns so that it does not actually modify the value. I believe this should be handled by ethtool_get_regs(), either by returning an error or by only copying data up to original regs.len passed by userspace. The former seems more correct but broken userspace software would suddenly start to fail where it "used to work". The latter would be closer to current behaviour but it would mean that broken userspace software might nerver notice there is something wrong. Michal Kubecek
Re: [PATCH] hooks: fix a missing-check bug in selinux_sb_eat_lsm_opts()
On Thu, May 30, 2019 at 5:53 AM Gen Zhang wrote: > In selinux_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul(). It > returns NULL when fails. So 'arg' should be checked. > > Signed-off-by: Gen Zhang Since it looks like you are going to respin this patch, please add: Fixes: 99dbbb593fe6 ("selinux: rewrite selinux_sb_eat_lsm_opts()") to the commit message so that there is a record of which commit introduced the issue (then it can be picked up automatically for backport into the relevant stable kernels). Thanks for spotting the issue and sending the patch(es)! > --- > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index 3ec702c..5a9e959 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -2635,6 +2635,8 @@ static int selinux_sb_eat_lsm_opts(char *options, void > **mnt_opts) > *q++ = c; > } > arg = kmemdup_nul(arg, q - arg, GFP_KERNEL); > + if (!arg) > + return 0; > } > rc = selinux_add_opt(token, arg, mnt_opts); > if (unlikely(rc)) { -- Ondrej Mosnacek Software Engineer, Security Technologies Red Hat, Inc.
Re: [PATCH 4.14 000/193] 4.14.123-stable review
stable-rc/linux-4.14.y boot: 115 boots: 0 failed, 115 passed (v4.14.122-194-g0352fa2fdaa6) Full Boot Summary: https://kernelci.org/boot/all/job/stable-rc/branch/linux-4.14.y/kernel/v4.14.122-194-g0352fa2fdaa6/ Full Build Summary: https://kernelci.org/build/stable-rc/branch/linux-4.14.y/kernel/v4.14.122-194-g0352fa2fdaa6/ Tree: stable-rc Branch: linux-4.14.y Git Describe: v4.14.122-194-g0352fa2fdaa6 Git Commit: 0352fa2fdaa68f3e27866e6f6a5125aa9efcefe4 Git URL: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git Tested: 59 unique boards, 22 SoC families, 14 builds out of 201 --- For more info write to
Re: [PATCH] hooks: fix a missing-check bug in selinux_add_mnt_opt()
On Thu, May 30, 2019 at 10:06 AM Gen Zhang wrote: > In selinux_add_mnt_opt(), 'val' is allcoted by kmemdup_nul(). It returns > NULL when fails. So 'val' should be checked. > > Signed-off-by: Gen Zhang Please add a Fixes tag here, too: Fixes: 757cbe597fe8 ("LSM: new method: ->sb_add_mnt_opt()") > --- > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index 3ec702c..4797c63 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -1052,8 +1052,11 @@ static int selinux_add_mnt_opt(const char *option, > const char *val, int len, > if (token == Opt_error) > return -EINVAL; > > - if (token != Opt_seclabel) > - val = kmemdup_nul(val, len, GFP_KERNEL); > + if (token != Opt_seclabel) { > + val = kmemdup_nul(val, len, GFP_KERNEL); > + if (!val) > + return -ENOMEM; There is one extra tab character in the above three lines ^^^ > + } > rc = selinux_add_opt(token, val, mnt_opts); > if (unlikely(rc)) { > kfree(val); Thanks, -- Ondrej Mosnacek Software Engineer, Security Technologies Red Hat, Inc.
Re: [PATCH 10/22] docs: amd-memory-encryption.rst get rid of warnings
On 30/05/19 01:23, Mauro Carvalho Chehab wrote: > Get rid of those warnings: > > Documentation/virtual/kvm/amd-memory-encryption.rst:244: WARNING: > Citation [white-paper] is not referenced. > Documentation/virtual/kvm/amd-memory-encryption.rst:246: WARNING: > Citation [amd-apm] is not referenced. > Documentation/virtual/kvm/amd-memory-encryption.rst:247: WARNING: > Citation [kvm-forum] is not referenced. > > For references that aren't mentioned at the text by adding an > explicit reference to them. > > Signed-off-by: Mauro Carvalho Chehab > --- > Documentation/virtual/kvm/amd-memory-encryption.rst | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/Documentation/virtual/kvm/amd-memory-encryption.rst > b/Documentation/virtual/kvm/amd-memory-encryption.rst > index 33d697ab8a58..6c37ff9a0a3c 100644 > --- a/Documentation/virtual/kvm/amd-memory-encryption.rst > +++ b/Documentation/virtual/kvm/amd-memory-encryption.rst > @@ -243,6 +243,9 @@ Returns: 0 on success, -negative on error > References > == > > + > +See [white-paper]_, [api-spec]_, [amd-apm]_ and [kvm-forum]_ for more info. > + > .. [white-paper] > http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/AMD_Memory_Encryption_Whitepaper_v7-Public.pdf > .. [api-spec] > http://support.amd.com/TechDocs/55766_SEV-KM_API_Specification.pdf > .. [amd-apm] http://support.amd.com/TechDocs/24593.pdf (section 15.34) > Acked-by: Paolo Bonzini
Re: [PATCH 0/3] Add mclk0 clock source for SAI
On Wed, 2019-05-29 at 16:03 -0700, Nicolin Chen wrote: > On Tue, May 28, 2019 at 01:20:46PM +, Daniel Baluta wrote: > > > 1) SAI clock source select MUX is really part of the hardware > > 2) flexibility! We let DT tell us which is the option for MUX > > option 0. > > I think the "MUX" is plausible comparing to your previous version. > As long as DT maintainers ack the DT binding doc, I would be okay > to ack too. Just one comments at the dts/dtsi changes, I know the > driver would just warn old DTs, but it does change the behavior at > the mclk_clk[0] from previously bus_clk to NULL after this series. Thanks for review, will fix in v2.
Re: [PATCH] perf: Fix oops when kthread execs user process
On 5/29/19 6:25 PM, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 11:20:22AM +0100, Will Deacon wrote: >> Anyway, you can add my ack to your patch, but I bet we can remove that mm >> check :D > > I've ended up with the below. Ravi, can you test if that does indeed > obsolete your PPC patch? Checking. > > --- > Subject: perf: Fix perf_sample_regs_user() > From: Peter Zijlstra > Date: Wed May 29 14:37:24 CEST 2019 > > perf_sample_regs_user() uses 'current->mm' to test for the presence of > userspace, but this is insufficient, consider use_mm(). > > A better test is: '!(current->flags & PF_KTHREAD)', exec() clears > PF_KTHREAD after it sets the new ->mm but before it drops to userspace > for the first time. This looks correct. I'll give it a try. > > Possibly obsoletes: bf05fc25f268 ("powerpc/perf: Fix oops when kthread execs > user process") > > Reported-by: Ravi Bangoria > Reported-by: Young Xiao <92siuy...@gmail.com> > Cc: Ravi Bangoria > Cc: Naveen N. Rao > Cc: Michael Ellerman > Cc: Jiri Olsa > Cc: Frederic Weisbecker > Cc: Stephane Eranian > Cc: Arnaldo Carvalho de Melo > Acked-by: Will Deacon > Fixes: 4018994f3d87 ("perf: Add ability to attach user level registers dump > to sample") > Signed-off-by: Peter Zijlstra (Intel) > --- > kernel/events/core.c |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -5923,7 +5923,7 @@ static void perf_sample_regs_user(struct > if (user_mode(regs)) { > regs_user->abi = perf_reg_abi(current); > regs_user->regs = regs; > - } else if (current->mm) { > + } else if (!(current->flags & PF_KTHREAD)) { > perf_get_regs_user(regs_user, regs, regs_user_copy); > } else { > regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE; >
[PATCH 2/3] habanalabs: clear sobs and monitors in context switch
On context switch we need to ensure that each user is not be affected by other user, so we need to clear sync objects and monitors in context switch instead of in restore_phase_topology function. Signed-off-by: Dalit Ben Zoor --- drivers/misc/habanalabs/goya/goya.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index e0fc511acaec..87859c55b4b8 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -3919,6 +3919,11 @@ void goya_update_eq_ci(struct hl_device *hdev, u32 val) } void goya_restore_phase_topology(struct hl_device *hdev) +{ + +} + +static void goya_clear_sm_regs(struct hl_device *hdev) { int i, num_of_sob_in_longs, num_of_mon_in_longs; @@ -4569,6 +4574,8 @@ int goya_context_switch(struct hl_device *hdev, u32 asid) WREG32(mmTPC_PLL_CLK_RLX_0, 0x200020); goya_mmu_prepare(hdev, asid); + goya_clear_sm_regs(hdev); + return 0; } -- 2.17.1
[PATCH 3/3] habanalabs: restore unsecured registers default values
unsecured registers can be changed by the user, and hence should be restored to their default values in context switch Signed-off-by: Dalit Ben Zoor --- drivers/misc/habanalabs/goya/goya.c | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index 87859c55b4b8..81c1d576783f 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -786,7 +786,6 @@ static void goya_init_dma_ch(struct hl_device *hdev, int dma_id) else sob_addr = CFG_BASE + mmSYNC_MNGR_SOB_OBJ_1007; - WREG32(mmDMA_CH_0_WR_COMP_ADDR_LO + reg_off, lower_32_bits(sob_addr)); WREG32(mmDMA_CH_0_WR_COMP_ADDR_HI + reg_off, upper_32_bits(sob_addr)); WREG32(mmDMA_CH_0_WR_COMP_WDATA + reg_off, 0x8001); } @@ -4560,10 +4559,12 @@ static int goya_memset_device_memory(struct hl_device *hdev, u64 addr, u64 size, int goya_context_switch(struct hl_device *hdev, u32 asid) { struct asic_fixed_properties *prop = &hdev->asic_prop; - u64 addr = prop->sram_base_address; + u64 addr = prop->sram_base_address, sob_addr; u32 size = hdev->pldm ? 0x1 : prop->sram_size; u64 val = 0xull; - int rc; + int rc, dma_id; + u32 channel_off = mmDMA_CH_1_WR_COMP_ADDR_LO - + mmDMA_CH_0_WR_COMP_ADDR_LO; rc = goya_memset_device_memory(hdev, addr, size, val, false); if (rc) { @@ -4571,7 +4572,19 @@ int goya_context_switch(struct hl_device *hdev, u32 asid) return rc; } + /* we need to reset registers that the user is allowed to change */ + sob_addr = CFG_BASE + mmSYNC_MNGR_SOB_OBJ_1007; + WREG32(mmDMA_CH_0_WR_COMP_ADDR_LO, lower_32_bits(sob_addr)); + + for (dma_id = 1 ; dma_id < NUMBER_OF_EXT_HW_QUEUES ; dma_id++) { + sob_addr = CFG_BASE + mmSYNC_MNGR_SOB_OBJ_1000 + + (dma_id - 1) * 4; + WREG32(mmDMA_CH_0_WR_COMP_ADDR_LO + channel_off * dma_id, + lower_32_bits(sob_addr)); + } + WREG32(mmTPC_PLL_CLK_RLX_0, 0x200020); + goya_mmu_prepare(hdev, asid); goya_clear_sm_regs(hdev); -- 2.17.1
[PATCH 1/3] habanalabs: make tpc registers secured
Set protection bits for some tpc registers that should to be secured. Signed-off-by: Dalit Ben Zoor --- drivers/misc/habanalabs/goya/goya_security.c | 16 1 file changed, 16 insertions(+) diff --git a/drivers/misc/habanalabs/goya/goya_security.c b/drivers/misc/habanalabs/goya/goya_security.c index d95d1b2f860d..d6ec12b3e692 100644 --- a/drivers/misc/habanalabs/goya/goya_security.c +++ b/drivers/misc/habanalabs/goya/goya_security.c @@ -677,6 +677,17 @@ static void goya_init_tpc_protection_bits(struct hl_device *hdev) goya_pb_set_block(hdev, mmTPC0_RD_REGULATOR_BASE); goya_pb_set_block(hdev, mmTPC0_WR_REGULATOR_BASE); + pb_addr = (mmTPC0_CFG_SEMAPHORE & ~0xFFF) + PROT_BITS_OFFS; + word_offset = ((mmTPC0_CFG_SEMAPHORE & PROT_BITS_OFFS) >> 7) << 2; + + mask = 1 << ((mmTPC0_CFG_SEMAPHORE & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_VFLAGS & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_SFLAGS & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_LFSR_POLYNOM & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_STATUS & 0x7F) >> 2); + + WREG32(pb_addr + word_offset, ~mask); + pb_addr = (mmTPC0_CFG_CFG_BASE_ADDRESS_HIGH & ~0xFFF) + PROT_BITS_OFFS; word_offset = ((mmTPC0_CFG_CFG_BASE_ADDRESS_HIGH & PROT_BITS_OFFS) >> 7) << 2; @@ -684,6 +695,11 @@ static void goya_init_tpc_protection_bits(struct hl_device *hdev) mask |= 1 << ((mmTPC0_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2); mask |= 1 << ((mmTPC0_CFG_SM_BASE_ADDRESS_LOW & 0x7F) >> 2); mask |= 1 << ((mmTPC0_CFG_SM_BASE_ADDRESS_HIGH & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_TPC_STALL & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_MSS_CONFIG & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_TPC_INTR_CAUSE & 0x7F) >> 2); + mask |= 1 << ((mmTPC0_CFG_TPC_INTR_MASK & 0x7F) >> 2); WREG32(pb_addr + word_offset, ~mask); -- 2.17.1
Re: [PATCH v4] x86/power: Fix 'nosmt' vs. hibernation triple fault during resume
On Thu, May 30, 2019 at 12:09 AM Jiri Kosina wrote: > > From: Jiri Kosina > > As explained in > > 0cc3cd21657b ("cpu/hotplug: Boot HT siblings at least once") > > we always, no matter what, have to bring up x86 HT siblings during boot at > least once in order to avoid first MCE bringing the system to its knees. > > That means that whenever 'nosmt' is supplied on the kernel command-line, > all the HT siblings are as a result sitting in mwait or cpudile after > going through the online-offline cycle at least once. > > This causes a serious issue though when a kernel, which saw 'nosmt' on its > commandline, is going to perform resume from hibernation: if the resume > from the hibernated image is successful, cr3 is flipped in order to point > to the address space of the kernel that is being resumed, which in turn > means that all the HT siblings are all of a sudden mwaiting on address > which is no longer valid. > > That results in triple fault shortly after cr3 is switched, and machine > reboots. > > Fix this by always waking up all the SMT siblings before initiating the > 'restore from hibernation' process; this guarantees that all the HT > siblings will be properly carried over to the resumed kernel waiting in > resume_play_dead(), and acted upon accordingly afterwards, based on the > target kernel configuration. > Symmetricaly, the resumed kernel has to push the SMT siblings to mwait > again in case it has SMT disabled; this means it has to online all > the siblings when resuming (so that they come out of hlt) and offline > them again to let them reach mwait. > > Cc: sta...@vger.kernel.org # v4.19+ > Debugged-by: Thomas Gleixner > Fixes: 0cc3cd21657b ("cpu/hotplug: Boot HT siblings at least once") > Signed-off-by: Jiri Kosina LGTM And I would prefer this one to go in through the PM tree due to the hibernate core changes, so can I get an ACK from the x86 arch side here, please? > --- > > v1 -> v2: > - restructure error handling as suggested by peterz > - add Rafael's ack > > v2 -> v3: > - added extra online/offline dance for nosmt case during > resume, as we want the siblings to be in mwait, not hlt > - dropped peterz's and Rafael's acks for now due to the above > > v3 -> v4: > - fix undefined return value from arch_resume_nosmt() in case > it's not overriden by arch > > arch/x86/power/cpu.c | 10 ++ > arch/x86/power/hibernate.c | 33 + > include/linux/cpu.h| 4 > kernel/cpu.c | 4 ++-- > kernel/power/hibernate.c | 9 + > 5 files changed, 58 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c > index a7d966964c6f..513ce09e9950 100644 > --- a/arch/x86/power/cpu.c > +++ b/arch/x86/power/cpu.c > @@ -299,7 +299,17 @@ int hibernate_resume_nonboot_cpu_disable(void) > * address in its instruction pointer may not be possible to resolve > * any more at that point (the page tables used by it previously may > * have been overwritten by hibernate image data). > +* > +* First, make sure that we wake up all the potentially disabled SMT > +* threads which have been initially brought up and then put into > +* mwait/cpuidle sleep. > +* Those will be put to proper (not interfering with hibernation > +* resume) sleep afterwards, and the resumed kernel will decide itself > +* what to do with them. > */ > + ret = cpuhp_smt_enable(); > + if (ret) > + return ret; > smp_ops.play_dead = resume_play_dead; > ret = disable_nonboot_cpus(); > smp_ops.play_dead = play_dead; > diff --git a/arch/x86/power/hibernate.c b/arch/x86/power/hibernate.c > index 4845b8c7be7f..fc413717a45f 100644 > --- a/arch/x86/power/hibernate.c > +++ b/arch/x86/power/hibernate.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > > #include > > @@ -245,3 +246,35 @@ int relocate_restore_code(void) > __flush_tlb_all(); > return 0; > } > + > +int arch_resume_nosmt(void) > +{ > + int ret = 0; > + /* > +* We reached this while coming out of hibernation. This means > +* that SMT siblings are sleeping in hlt, as mwait is not safe > +* against control transition during resume (see comment in > +* hibernate_resume_nonboot_cpu_disable()). > +* > +* If the resumed kernel has SMT disabled, we have to take all the > +* SMT siblings out of hlt, and offline them again so that they > +* end up in mwait proper. > +* > +* Called with hotplug disabled. > +*/ > + cpu_hotplug_enable(); > + if (cpu_smt_control == CPU_SMT_DISABLED || > + cpu_smt_control == CPU_SMT_FORCE_DISABLED) { > + enum cpuhp_smt_control old = cpu_smt_control; > + > + ret = cpuhp
[PATCH v2 -next] platform/chrome: cros_ec: Make some symbols static
Fix sparse warning: drivers/platform/chrome/cros_ec_debugfs.c:256:30: warning: symbol 'cros_ec_console_log_fops' was not declared. Should it be static? drivers/platform/chrome/cros_ec_debugfs.c:265:30: warning: symbol 'cros_ec_pdinfo_fops' was not declared. Should it be static? drivers/platform/chrome/cros_ec_lightbar.c:550:24: warning: symbol 'cros_ec_lightbar_attr_group' was not declared. Should it be static? drivers/platform/chrome/cros_ec_sysfs.c:338:24: warning: symbol 'cros_ec_attr_group' was not declared. Should it be static? drivers/platform/chrome/cros_ec_vbc.c:104:24: warning: symbol 'cros_ec_vbc_attr_group' was not declared. Should it be static? drivers/platform/chrome/cros_ec_lpc.c:408:25: warning: symbol 'cros_ec_lpc_pm_ops' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: YueHaibing --- v2: fix patch title --- drivers/platform/chrome/cros_ec_debugfs.c | 4 ++-- drivers/platform/chrome/cros_ec_lightbar.c | 2 +- drivers/platform/chrome/cros_ec_lpc.c | 2 +- drivers/platform/chrome/cros_ec_sysfs.c| 2 +- drivers/platform/chrome/cros_ec_vbc.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c index 4c2a27f6a6d0..4578eb3e0731 100644 --- a/drivers/platform/chrome/cros_ec_debugfs.c +++ b/drivers/platform/chrome/cros_ec_debugfs.c @@ -241,7 +241,7 @@ static ssize_t cros_ec_pdinfo_read(struct file *file, read_buf, p - read_buf); } -const struct file_operations cros_ec_console_log_fops = { +static const struct file_operations cros_ec_console_log_fops = { .owner = THIS_MODULE, .open = cros_ec_console_log_open, .read = cros_ec_console_log_read, @@ -250,7 +250,7 @@ const struct file_operations cros_ec_console_log_fops = { .release = cros_ec_console_log_release, }; -const struct file_operations cros_ec_pdinfo_fops = { +static const struct file_operations cros_ec_pdinfo_fops = { .owner = THIS_MODULE, .open = simple_open, .read = cros_ec_pdinfo_read, diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c index d30a6650b0b5..23a82ee4c785 100644 --- a/drivers/platform/chrome/cros_ec_lightbar.c +++ b/drivers/platform/chrome/cros_ec_lightbar.c @@ -547,7 +547,7 @@ static struct attribute *__lb_cmds_attrs[] = { NULL, }; -struct attribute_group cros_ec_lightbar_attr_group = { +static struct attribute_group cros_ec_lightbar_attr_group = { .name = "lightbar", .attrs = __lb_cmds_attrs, }; diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c index c9c240fbe7c6..aaa21803633a 100644 --- a/drivers/platform/chrome/cros_ec_lpc.c +++ b/drivers/platform/chrome/cros_ec_lpc.c @@ -405,7 +405,7 @@ static int cros_ec_lpc_resume(struct device *dev) } #endif -const struct dev_pm_ops cros_ec_lpc_pm_ops = { +static const struct dev_pm_ops cros_ec_lpc_pm_ops = { SET_LATE_SYSTEM_SLEEP_PM_OPS(cros_ec_lpc_suspend, cros_ec_lpc_resume) }; diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c index fe0b7614ae1b..3edb237bf8ed 100644 --- a/drivers/platform/chrome/cros_ec_sysfs.c +++ b/drivers/platform/chrome/cros_ec_sysfs.c @@ -335,7 +335,7 @@ static umode_t cros_ec_ctrl_visible(struct kobject *kobj, return a->mode; } -struct attribute_group cros_ec_attr_group = { +static struct attribute_group cros_ec_attr_group = { .attrs = __ec_attrs, .is_visible = cros_ec_ctrl_visible, }; diff --git a/drivers/platform/chrome/cros_ec_vbc.c b/drivers/platform/chrome/cros_ec_vbc.c index 8392a1ec33a7..2aaefed87eb4 100644 --- a/drivers/platform/chrome/cros_ec_vbc.c +++ b/drivers/platform/chrome/cros_ec_vbc.c @@ -101,7 +101,7 @@ static struct bin_attribute *cros_ec_vbc_bin_attrs[] = { NULL }; -struct attribute_group cros_ec_vbc_attr_group = { +static struct attribute_group cros_ec_vbc_attr_group = { .name = "vbc", .bin_attrs = cros_ec_vbc_bin_attrs, }; -- 2.17.1
[GIT PULL] sound fixes for 5.2-rc3
Linus, please pull sound fixes for v5.2-rc3 from: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git tags/sound-5.2-rc3 The topmost commit is 6954158a16404e7091cea494cd0a435ca2f90388 sound fixes for 5.2-rc3 No big surprises here, just a few device-specific fixes. HD-audio received several fixes for Acer, Dell, Huawei and other laptops as well as the workaround for the new Intel chipset. One significant one-liner fix is the disablement of the node-power saving on Realtek codecs, which may potentially cover annoying bugs like the background noises or click noises on many devices. Other than that, a fix for FireWire bit definitions, and another fix for LINE6 USB audio bug that was discovered by syzkaller. Ayman Bagabas (1): ALSA: hda/realtek - Enable micmute LED for Huawei laptops Bard Liao (1): ALSA: hda - Force polling mode on CNL for fixing codec communication Geert Uytterhoeven (1): ALSA: fireface: Use ULL suffixes for 64-bit constants Hui Wang (1): ALSA: hda/realtek - Improve the headset mic for Acer Aspire laptops Kailang Yang (2): ALSA: hda/realtek - Check headset type by unplug and resume ALSA: hda/realtek - Set default power save node to 0 Takashi Iwai (1): ALSA: line6: Assure canceling delayed work at disconnection --- sound/firewire/fireface/ff-protocol-latter.c | 10 sound/pci/hda/hda_intel.c| 5 ++-- sound/pci/hda/patch_realtek.c| 38 ++-- sound/usb/line6/driver.c | 12 + sound/usb/line6/driver.h | 4 +++ sound/usb/line6/toneport.c | 15 +++ 6 files changed, 51 insertions(+), 33 deletions(-) diff --git a/sound/firewire/fireface/ff-protocol-latter.c b/sound/firewire/fireface/ff-protocol-latter.c index c8236ff89b7f..b30d02d359b1 100644 --- a/sound/firewire/fireface/ff-protocol-latter.c +++ b/sound/firewire/fireface/ff-protocol-latter.c @@ -9,11 +9,11 @@ #include "ff.h" -#define LATTER_STF 0x0004 -#define LATTER_ISOC_CHANNELS 0x0008 -#define LATTER_ISOC_START 0x000c -#define LATTER_FETCH_MODE 0x0010 -#define LATTER_SYNC_STATUS 0x801c +#define LATTER_STF 0x0004ULL +#define LATTER_ISOC_CHANNELS 0x0008ULL +#define LATTER_ISOC_START 0x000cULL +#define LATTER_FETCH_MODE 0x0010ULL +#define LATTER_SYNC_STATUS 0x801cULL static int parse_clock_bits(u32 data, unsigned int *rate, enum snd_ff_clock_src *src) diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 0741eae23f10..a4b0414dda3b 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -375,6 +375,7 @@ enum { #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98) #define IS_CFL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa348) +#define IS_CNL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9dc8) static char *driver_short_names[] = { [AZX_DRIVER_ICH] = "HDA Intel", @@ -1700,8 +1701,8 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, else chip->bdl_pos_adj = bdl_pos_adj[dev]; - /* Workaround for a communication error on CFL (bko#199007) */ - if (IS_CFL(pci)) + /* Workaround for a communication error on CFL (bko#199007) and CNL */ + if (IS_CFL(pci) || IS_CNL(pci)) chip->polling_mode = 1; err = azx_bus_init(chip, model[dev], &pci_hda_io_ops); diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 2c1942dc6147..974244978509 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -821,6 +821,8 @@ static void alc_pre_init(struct hda_codec *codec) alc_fill_eapd_coef(codec); } +#define is_s3_resume(codec) \ + ((codec)->core.dev.power.power_state.event == PM_EVENT_RESUME) #define is_s4_resume(codec) \ ((codec)->core.dev.power.power_state.event == PM_EVENT_RESTORE) @@ -4888,6 +4890,8 @@ static void alc_update_headset_mode(struct hda_codec *codec) switch (new_headset_mode) { case ALC_HEADSET_MODE_UNPLUGGED: alc_headset_mode_unplugged(codec); + spec->current_headset_mode = ALC_HEADSET_MODE_UNKNOWN; + spec->current_headset_type = ALC_HEADSET_TYPE_UNKNOWN; spec->gen.hp_jack_present = false; break; case ALC_HEADSET_MODE_HEADSET: @@ -4930,8 +4934,6 @@ static void alc_update_headset_mode_hook(struct hda_codec *codec, static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_callback *jack) { - struct alc_spec *spec = codec->spec; - s
[PATCH v2] hooks: fix a missing-check bug in selinux_sb_eat_lsm_opts()
In selinux_sb_eat_lsm_opts(), 'arg' is allocated by kmemdup_nul(). It returns NULL when fails. So 'arg' should be checked. Signed-off-by: Gen Zhang Fixes: 99dbbb593fe6 ("selinux: rewrite selinux_sb_eat_lsm_opts()") --- diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 3ec702c..5a9e959 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -2635,6 +2635,8 @@ static int selinux_sb_eat_lsm_opts(char *options, void **mnt_opts) *q++ = c; } arg = kmemdup_nul(arg, q - arg, GFP_KERNEL); + if (!arg) + return -ENOMEM; } rc = selinux_add_opt(token, arg, mnt_opts); if (unlikely(rc)) {
[GIT PULL] configfs fix for 5.2
The following changes since commit cd6c84d8f0cdc911df435bb075ba22ce3c605b07: Linux 5.2-rc2 (2019-05-26 16:49:19 -0700) are available in the Git repository at: git://git.infradead.org/users/hch/configfs.git tags/configfs-for-5.2-2 for you to fetch changes up to f6122ed2a4f9c9c1c073ddf6308d1b2ac10e0781: configfs: Fix use-after-free when accessing sd->s_dentry (2019-05-28 08:11:58 +0200) configs fix for 5.2 - fix a use after free in configfs_d_iput (Sahitya Tummala) Sahitya Tummala (1): configfs: Fix use-after-free when accessing sd->s_dentry fs/configfs/dir.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-)
[PATCH 4/4] net: stmmac: dwmac4: fix flow control issue
Current dwmac4_flow_ctrl will not clear GMAC_RX_FLOW_CTRL_RFE/GMAC_RX_FLOW_CTRL_RFE bits, so MAC hw will keep flow control on although expecting flow control off by ethtool. Add codes to fix it. Fixes: 477286b53f55 ("stmmac: add GMAC4 core support") Signed-off-by: Biao Huang --- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 2544cff..9322b71 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -488,8 +488,9 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, if (fc & FLOW_RX) { pr_debug("\tReceive Flow-Control ON\n"); flow |= GMAC_RX_FLOW_CTRL_RFE; - writel(flow, ioaddr + GMAC_RX_FLOW_CTRL); } + writel(flow, ioaddr + GMAC_RX_FLOW_CTRL); + if (fc & FLOW_TX) { pr_debug("\tTransmit Flow-Control ON\n"); @@ -497,7 +498,7 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, pr_debug("\tduplex mode: PAUSE %d\n", pause_time); for (queue = 0; queue < tx_cnt; queue++) { - flow |= GMAC_TX_FLOW_CTRL_TFE; + flow = GMAC_TX_FLOW_CTRL_TFE; if (duplex) flow |= @@ -505,6 +506,9 @@ static void dwmac4_flow_ctrl(struct mac_device_info *hw, unsigned int duplex, writel(flow, ioaddr + GMAC_QX_TX_FLOW_CTRL(queue)); } + } else { + for (queue = 0; queue < tx_cnt; queue++) + writel(0, ioaddr + GMAC_QX_TX_FLOW_CTRL(queue)); } } -- 1.7.9.5
[PATCH 0/4] complete dwmac-mediatek driver and fix flow control issue
This series mainly complete dwmac-mediatek driver: 1. add power on/off operations for dwmac-mediatek. 2. disable rx watchdog to reduce rx path reponding time. 3. change the default value of tx-frames from 25 to 1, so ptp4l will test pass by default. and also fix the issue that flow control won't be disabled any more once being enabled. Biao Huang (4): net: stmmac: dwmac-mediatek: enable Ethernet power domain net: stmmac: dwmac-mediatek: disable rx watchdog net: stmmac: modify default value of tx-frames net: stmmac: dwmac4: fix flow control issue drivers/net/ethernet/stmicro/stmmac/common.h |2 +- .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 19 ++- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c |8 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) -- 1.7.9.5
[PATCH 3/4] net: stmmac: modify default value of tx-frames
the default value of tx-frames is 25, it's too late when passing tstamp to stack, then the ptp4l will fail: ptp4l -i eth0 -f gPTP.cfg -m ptp4l: selected /dev/ptp0 as PTP clock ptp4l: port 1: INITIALIZING to LISTENING on INITIALIZE ptp4l: port 0: INITIALIZING to LISTENING on INITIALIZE ptp4l: port 1: link up ptp4l: timed out while polling for tx timestamp ptp4l: increasing tx_timestamp_timeout may correct this issue, but it is likely caused by a driver bug ptp4l: port 1: send peer delay response failed ptp4l: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED) ptp4l tests pass when changing the tx-frames from 25 to 1 with ethtool -C option. It should be fine to set tx-frames default value to 1, so ptp4l will pass by default. Signed-off-by: Biao Huang --- drivers/net/ethernet/stmicro/stmmac/common.h |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 26bbcd8..6a08cec 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -261,7 +261,7 @@ struct stmmac_safety_stats { #define STMMAC_COAL_TX_TIMER 1000 #define STMMAC_MAX_COAL_TX_TICK10 #define STMMAC_TX_MAX_FRAMES 256 -#define STMMAC_TX_FRAMES 25 +#define STMMAC_TX_FRAMES 1 /* Packets types */ enum packets_types { -- 1.7.9.5
[PATCH 1/4] net: stmmac: dwmac-mediatek: enable Ethernet power domain
add Ethernet power on/off operations in init/exit flow. Signed-off-by: Biao Huang --- .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c index 126b66b..3c7a60f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -298,6 +299,9 @@ static int mediatek_dwmac_init(struct platform_device *pdev, void *priv) return ret; } + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + return 0; } @@ -307,6 +311,9 @@ static void mediatek_dwmac_exit(struct platform_device *pdev, void *priv) const struct mediatek_dwmac_variant *variant = plat->variant; clk_bulk_disable_unprepare(variant->num_clks, plat->clks); + + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); } static int mediatek_dwmac_probe(struct platform_device *pdev) @@ -364,6 +371,15 @@ static int mediatek_dwmac_probe(struct platform_device *pdev) return 0; } +static int mediatek_dwmac_remove(struct platform_device *pdev) +{ + int ret; + + ret = stmmac_pltfr_remove(pdev); + + return ret; +} + static const struct of_device_id mediatek_dwmac_match[] = { { .compatible = "mediatek,mt2712-gmac", .data = &mt2712_gmac_variant }, @@ -374,7 +390,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev) static struct platform_driver mediatek_dwmac_driver = { .probe = mediatek_dwmac_probe, - .remove = stmmac_pltfr_remove, + .remove = mediatek_dwmac_remove, .driver = { .name = "dwmac-mediatek", .pm = &stmmac_pltfr_pm_ops, -- 1.7.9.5
[PATCH v2] hooks: fix a missing-check bug in selinux_add_mnt_opt()
In selinux_add_mnt_opt(), 'val' is allcoted by kmemdup_nul(). It returns NULL when fails. So 'val' should be checked. Signed-off-by: Gen Zhang Fixes: 757cbe597fe8 ("LSM: new method: ->sb_add_mnt_opt()") --- diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 3ec702c..4797c63 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1052,8 +1052,11 @@ static int selinux_add_mnt_opt(const char *option, const char *val, int len, if (token == Opt_error) return -EINVAL; - if (token != Opt_seclabel) - val = kmemdup_nul(val, len, GFP_KERNEL); + if (token != Opt_seclabel) { + val = kmemdup_nul(val, len, GFP_KERNEL); + if (!val) + return -ENOMEM; + } rc = selinux_add_opt(token, val, mnt_opts); if (unlikely(rc)) { kfree(val);
[PATCH 2/4] net: stmmac: dwmac-mediatek: disable rx watchdog
disable rx watchdog for dwmac-mediatek, then the hw will issue a rx interrupt once receiving a packet, so the responding time for rx path will be reduced. Signed-off-by: Biao Huang --- .../net/ethernet/stmicro/stmmac/dwmac-mediatek.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c index 3c7a60f..38cd054 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-mediatek.c @@ -356,6 +356,7 @@ static int mediatek_dwmac_probe(struct platform_device *pdev) plat_dat->has_gmac4 = 1; plat_dat->has_gmac = 0; plat_dat->pmt = 0; + plat_dat->riwt_off = 1; plat_dat->maxmtu = ETH_DATA_LEN; plat_dat->bsp_priv = priv_plat; plat_dat->init = mediatek_dwmac_init; -- 1.7.9.5
RE: [PATCHv4 3/3] vfio/mdev: Synchronize device create/remove with parent removal
Hi Alex, > -Original Message- > From: Alex Williamson > Sent: Wednesday, May 29, 2019 8:27 PM [..] > > > > diff --git a/drivers/vfio/mdev/mdev_core.c > > b/drivers/vfio/mdev/mdev_core.c index 0bef0cae1d4b..c5401a8c6843 > > 100644 > > --- a/drivers/vfio/mdev/mdev_core.c > > +++ b/drivers/vfio/mdev/mdev_core.c > > @@ -102,11 +102,36 @@ static void mdev_put_parent(struct mdev_parent > *parent) > > kref_put(&parent->ref, mdev_release_parent); } > > > > Some sort of locking semantics comment would be useful here, ex: > > /* Caller holds parent unreg_sem read or write lock */ > Added. > > + > > static int mdev_device_remove_cb(struct device *dev, void *data) { > > - if (dev_is_mdev(dev)) > > - mdev_device_remove(dev); > > + struct mdev_parent *parent; > > + struct mdev_device *mdev; > > > > + if (!dev_is_mdev(dev)) > > + return 0; > > + > > + mdev = to_mdev_device(dev); > > + parent = mdev->parent; > > + mdev_device_remove_common(mdev); > > 'parent' is unused here and we only use mdev once, so we probably don't need > to put it in a local variable. > Right left out from previous code. Removed and refactored the code now. > > return 0; > > } > > > > @@ -148,6 +173,7 @@ int mdev_register_device(struct device *dev, const > struct mdev_parent_ops *ops) > > } > > > > kref_init(&parent->ref); > > + init_rwsem(&parent->unreg_sem); > > > > parent->dev = dev; > > parent->ops = ops; > > @@ -206,13 +232,17 @@ void mdev_unregister_device(struct device *dev) > > dev_info(dev, "MDEV: Unregistering\n"); > > > > list_del(&parent->next); > > + mutex_unlock(&parent_list_lock); > > + > > + down_write(&parent->unreg_sem); > > + > > class_compat_remove_link(mdev_bus_compat_class, dev, NULL); > > > > device_for_each_child(dev, NULL, mdev_device_remove_cb); > > > > parent_remove_sysfs_files(parent); > > + up_write(&parent->unreg_sem); > > > > - mutex_unlock(&parent_list_lock); > > mdev_put_parent(parent); > > } > > EXPORT_SYMBOL(mdev_unregister_device); > > @@ -265,6 +295,12 @@ int mdev_device_create(struct kobject *kobj, > > > > mdev->parent = parent; > > > > + ret = down_read_trylock(&parent->unreg_sem); > > + if (!ret) { > > + ret = -ENODEV; > > I would have expected -EAGAIN or -EBUSY here, but I guess that since we > consider the lock-out to deterministically be the parent going away that - > ENODEV makes sense. Ok. > Yeah, I agree that ENODEV is more accurate error code as we don't want to tell user to retry so EAGAIN is less appropriate. Sending v5.
Re: [PATCH] [trivial] HID: Typo s/to back 0/back to 0/
On 27/05/2019 14:25, Geert Uytterhoeven wrote: > Fix a silly word ordering typo. > > Fixes: 42337b9d4d958daa ("HID: add driver for U2F Zero built-in LED and RNG") > Signed-off-by: Geert Uytterhoeven > --- > drivers/hid/Kconfig | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig > index c3c390ca369022f0..735223f90035b2bf 100644 > --- a/drivers/hid/Kconfig > +++ b/drivers/hid/Kconfig > @@ -1028,7 +1028,7 @@ config HID_U2FZERO > > U2F Zero only supports blinking its LED, so this driver doesn't > allow setting the brightness to anything but 1, which will > - trigger a single blink and immediately reset to back 0. > + trigger a single blink and immediately reset back to 0. > > config HID_WACOM > tristate "Wacom Intuos/Graphire tablet support (USB)" That was a silly typo indeed :D Not sure this is needed, but just in case: Acked-by: Andrej Shadura -- Cheers, Andrej
Re: [PATCH net-next 0/5] PTP support for the SJA1105 DSA driver
On Thu, 30 May 2019 at 06:45, Richard Cochran wrote: > > On Wed, May 29, 2019 at 11:41:22PM +0300, Vladimir Oltean wrote: > > I'm sorry, then what does this code from raw.c do? > > It is a fallback for HW that doesn't support multicast filtering. > > Care to look a few lines above? If you did, you would have seen this: > > memset(&mreq, 0, sizeof(mreq)); > mreq.mr_ifindex = index; > mreq.mr_type = PACKET_MR_MULTICAST; > mreq.mr_alen = MAC_LEN; > memcpy(mreq.mr_address, addr1, MAC_LEN); > > err1 = setsockopt(fd, SOL_PACKET, option, &mreq, sizeof(mreq)); > You're right. In fact that's why it doesn't work: because linuxptp adds ptp_dst_mac (01-1B-19-00-00-00) and (01-80-C2-00-00-0E) to the MAC's multicast filter, but the switch in its great wisdom mangles bytes 01-1B-19-xx-xx-00 of the DMAC to place the switch id and source port there (a rudimentary tagging mechanism). So the frames are no longer accepted by this multicast MAC filter on the DSA master port unless it's put in ALLMULTI or PROMISC. > > > No. The root cause is the time stamps delivered by the hardware or > > > your driver. That needs to be addressed before going forward. > > > > > > > How can I check that the timestamps are valid? > > Well, you can see that there is something wrong. Perhaps you are not > matching the meta frames to the received packets. That is one > possible explanation, but you'll have to figure out what is happening. > If the meta frames weren't associated with the correct link-local frame, then the whole expect_meta -> SJA1105_STATE_META_ARRIVED mechanism would go haywire, but it doesn't. I was actually thinking it has something to do with the fact that I shouldn't apply frequency corrections on timestamps of PTP delay messages. Does that make any sense? Regards, -Vladimir > Thanks, > Richard
Re: linux-next: build warning after merge of the akpm-current tree
On Thu, May 30, 2019 at 6:55 AM Stephen Rothwell wrote: > > Hi all, > > After merging the akpm-current tree, today's linux-next build (x86_64 > allmodconfig) produced this warning: > > net/tipc/sysctl.c:42:12: warning: 'one' defined but not used > [-Wunused-variable] > static int one = 1; > ^~~ > net/tipc/sysctl.c:41:12: warning: 'zero' defined but not used > [-Wunused-variable] > static int zero; > ^~~~ > > Introduced by commit > > 6a33853c5773 ("proc/sysctl: add shared variables for range check") > > -- > Cheers, > Stephen Rothwell Hi, this is due the merge of: commit 4bcd4ec1017205644a2697bccbc3b5143f522f5f Author: Jie Liu Date: Tue Apr 16 13:10:09 2019 +0800 tipc: set sysctl_tipc_rmem and named_timeout right range I'm making a patch to suppress the warning. Regards, -- Matteo Croce per aspera ad upstream
[PATCH] orangefs-debugfs: fix a missing-check bug in debug_string_to_mask()
In debug_string_to_mask(), 'strsep_fodder' is allocated by kstrdup(). It returns NULL when fails. So 'strsep_fodder' should be checked. Signed-off-by: Gen Zhang --- diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c index 87b1a6f..a9a9aac 100644 --- a/fs/orangefs/orangefs-debugfs.c +++ b/fs/orangefs/orangefs-debugfs.c @@ -888,6 +888,8 @@ static void debug_string_to_mask(char *debug_string, void *mask, int type) char *unchecked_keyword; int i; char *strsep_fodder = kstrdup(debug_string, GFP_KERNEL); + if (!strsep_fodder) + return; char *original_pointer; int element_count = 0; struct client_debug_mask *c_mask = NULL;