Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2731138ybl; Thu, 29 Aug 2019 12:05:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiJAJsHI8+MqatYQ1XrLadxtu4bKuhCZ2Z4KQOtaKnsDN688MAQ0BtUCEdCV0T8z3n17Ji X-Received: by 2002:a17:90a:a47:: with SMTP id o65mr30432pjo.90.1567105504182; Thu, 29 Aug 2019 12:05:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567105504; cv=none; d=google.com; s=arc-20160816; b=q+KKYxxjS1+cryBjXJn3lmiPAc7Ttei/VecXovXGrn0zDEj6pkcKAbLUEuyK8AE1AT Nsj0w65xrgwVerBDZbroi/7lBBYTG/TOgzB/hHxWMZi4yd5GFD5bNwF24bV53t1TaxTZ sAYYiOr+AdWbwP2RKJUagn83ss2ynhehyPz+uSRaVZ0p5ZFrITwWzQ7pIIz+8YTOpKNd ufC86vScF+GejydbcWOzpjBlCNMd/vuJMHVa2iM71wW5s7RuoQepiqguW9GDjPJ4doRJ ro6tMPYyx9BSXSYzycI8mbav/BcEtUrgUI4qtaMr+YJlkUk4ssWFwzCUU8r9MqQJDp1w 15dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=rdhIslopPfrhrD+0nzex7I2d6kAbD0S3+2QXHQp9oLc=; b=AyzmgMSVUS+TfC0tEREsLfdtqGa2Tu97dIgbQ+L4DXOgwQL6Gicn+jDMONWU/zz1n7 2P1d5U8x8wb4eRj2V9sKGfw6mEYw/3d5V2Nn1V8EdRahwE1zEHpB4WfHYFxwCHmkdUK9 eVZf5jw8xDxZ4LBMCp+KVEghePjz/gSq0Rf90OlZwq4JHECn1vMBbbf8Nemu14CCI1dC YhVri83DeJzd/0C+7/BB+z0tmSW8ZoXjfJ89FCEl6qMhI78oQuVPQwqPnU17aoIXdj4G VCt4uhEYAjvk7S9eENq8BjJuSrp2jim/YlYMj8IQuBfxbDM5eRMXIsu+5W6VgKfPs8C/ 6yaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ck3si2617364plb.429.2019.08.29.12.04.48; Thu, 29 Aug 2019 12:05:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728808AbfH2TCK (ORCPT + 99 others); Thu, 29 Aug 2019 15:02:10 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:51476 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728753AbfH2TCH (ORCPT ); Thu, 29 Aug 2019 15:02:07 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i3Pg3-00051f-S7; Thu, 29 Aug 2019 21:01:48 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 5DB431C0DE6; Thu, 29 Aug 2019 21:01:47 +0200 (CEST) Date: Thu, 29 Aug 2019 19:01:47 -0000 From: "tip-bot2 for Igor Lubashev" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/core] perf evsel: Kernel profiling is disallowed only when perf_event_paranoid > 1 Cc: Arnaldo Carvalho de Melo , Igor Lubashev , Mathieu Poirier , Alexander Shishkin , Alexey Budankov , James Morris , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <1566869956-7154-4-git-send-email-ilubashe@akamai.com> References: <1566869956-7154-4-git-send-email-ilubashe@akamai.com> MIME-Version: 1.0 Message-ID: <156710530726.10517.14742815139500868393.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/core branch of tip: Commit-ID: aa97293ff129f504e7c8589e56007ecfe3e3e835 Gitweb: https://git.kernel.org/tip/aa97293ff129f504e7c8589e56007ecfe3e3e835 Author: Igor Lubashev AuthorDate: Mon, 26 Aug 2019 21:39:14 -04:00 Committer: Arnaldo Carvalho de Melo CommitterDate: Wed, 28 Aug 2019 17:19:05 -03:00 perf evsel: Kernel profiling is disallowed only when perf_event_paranoid > 1 Perf was too restrictive about sysctl kernel.perf_event_paranoid. The kernel only disallows profiling when perf_event_paranoid > 1. Make perf do the same. Committer testing: For a non-root user: $ id uid=1000(acme) gid=1000(acme) groups=1000(acme),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 $ Before: We were restricting it to just userspace (:u suffix) even for a workload started by the user: $ perf record sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.001 MB perf.data (8 samples) ] $ perf evlist cycles:u $ perf evlist -v cycles:u: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, exclude_kernel: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1 $ perf report --stdio # To display the perf.data header info, please use --header/--header-only options. # # Total Lost Samples: 0 # # Samples: 8 of event 'cycles:u' # Event count (approx.): 1040396 # # Overhead Command Shared Object Symbol # ........ ....... ................ ...................... # 68.36% sleep libc-2.29.so [.] _dl_addr 27.33% sleep ld-2.29.so [.] dl_main 3.80% sleep ld-2.29.so [.] _dl_setup_hash # # (Tip: Order by the overhead of source file name and line number: perf report -s srcline) # $ $ After: When the kernel allows profiling the kernel in that scenario: $ perf record sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.023 MB perf.data (11 samples) ] $ perf evlist cycles $ perf evlist -v cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1 $ $ perf report --stdio # To display the perf.data header info, please use --header/--header-only options. # # Total Lost Samples: 0 # # Samples: 11 of event 'cycles' # Event count (approx.): 1601964 # # Overhead Command Shared Object Symbol # ........ ....... ................ .......................... # 28.14% sleep [kernel.vmlinux] [k] __rb_erase_color 27.21% sleep [kernel.vmlinux] [k] unmap_page_range 27.20% sleep ld-2.29.so [.] __tunable_get_val 15.24% sleep [kernel.vmlinux] [k] thp_get_unmapped_area 1.96% perf [kernel.vmlinux] [k] perf_event_exec 0.22% perf [kernel.vmlinux] [k] native_sched_clock 0.02% perf [kernel.vmlinux] [k] intel_bts_enable_local 0.00% perf [kernel.vmlinux] [k] native_write_msr # # (Tip: Boolean options have negative forms, e.g.: perf report --no-children) # $ Reported-by: Arnaldo Carvalho de Melo Signed-off-by: Igor Lubashev Tested-by: Arnaldo Carvalho de Melo Tested-by: Mathieu Poirier Cc: Alexander Shishkin Cc: Alexey Budankov Cc: James Morris Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Suzuki Poulouse Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1566869956-7154-4-git-send-email-ilubashe@akamai.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evsel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 7c704b8..d4540bf 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -282,7 +282,7 @@ struct evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx) static bool perf_event_can_profile_kernel(void) { - return perf_event_paranoid_check(-1); + return perf_event_paranoid_check(1); } struct evsel *perf_evsel__new_cycles(bool precise)