Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5574820ybl; Tue, 27 Aug 2019 06:47:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSxU2U+UWfCM7KlrafiFdnXlJs8SFCT5N2zGdm2rK9Yk7dOS3iC0HCgQ+tbku81n0HK7YA X-Received: by 2002:a17:902:5a08:: with SMTP id q8mr20457606pli.234.1566913624690; Tue, 27 Aug 2019 06:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566913624; cv=none; d=google.com; s=arc-20160816; b=pT2laiogoE3MFjC3+gk22+2+hKAvadqEsTFgYb3bwnblu17YDhBdbT6xeHdgJQCSiG kFxZAUQZlVjfdg/eQb0zZXlZuP85dddkyfajNre59urqR3sctgq6sqK54hDnb1Lo01hP SP5QFYNMJhyGdRuFYqSpNHK28kVIZKS7w0H4+5P625W6S0njnvbMCNM8sHMRkT0v/Uxr uXc5LrxPegTltT+r+sVwnkWe5WUrrAtfyAn4Cohi0+WePQO3huA4tuRP2FkMhCcszxHX ub0ZuBqCreR9SBE2q85UDXkt6nEFrwaXM7a0tM9Z++wKyCkTj6FCgMdzPTFfyrIL8FI7 137A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hXlXVXRXdhaabHSd8C1eZYIYW9fAq7xfTNbYO5WWwxA=; b=sIxvL3RM1gH03Cclpx3aOLDG27SUmxaJ3qRRVTTjHGA6H7M6Ra9RoN4arIlic9KAOT jUCkNXofzP/a2jbNTTuHcZpHDGtfDvTaPjac/k1rROxvWkdY7vbiqZfUnq4ITnGtxrC3 Zkp6eqZZY7MBkw1TeYIXrnbhl62ZcRf1dl5DcOjv1jNjwg/uP4IpNBwAbA8mz26ri2bX JUUIGu5OFohWpToyOf+jRIGBOEMA7nyvL4s7FxhTxxJNfXzrtly2IAl1+UHV+dYbN/Zq adfifYpUdOYttr+D9d7fONtXakOnH2AOS9X2rwxdAPKwQHXomsqQBRD9PgnriyHCRE+S nAcg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si1205917pll.221.2019.08.27.06.46.48; Tue, 27 Aug 2019 06:47: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729834AbfH0NoO (ORCPT + 99 others); Tue, 27 Aug 2019 09:44:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28000 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbfH0NoO (ORCPT ); Tue, 27 Aug 2019 09:44:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C6C708980E4; Tue, 27 Aug 2019 13:44:09 +0000 (UTC) Received: from sandy.ghostprotocols.net (ovpn-112-23.phx2.redhat.com [10.3.112.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6731F19D7A; Tue, 27 Aug 2019 13:44:08 +0000 (UTC) Received: by sandy.ghostprotocols.net (Postfix, from userid 1000) id 6DEC012E; Tue, 27 Aug 2019 10:44:04 -0300 (BRT) Date: Tue, 27 Aug 2019 10:44:04 -0300 From: Arnaldo Carvalho de Melo To: Igor Lubashev Cc: Jiri Olsa , Mathieu Poirier , Alexander Shishkin , Alexey Budankov , James Morris , Namhyung Kim , Peter Zijlstra , Suzuki Poulouse , linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List Subject: Re: [PATCH 3/5] perf util: kernel profiling is disallowed only when perf_event_paranoid > 1 Message-ID: <20190827134404.GB8761@redhat.com> References: <1566869956-7154-1-git-send-email-ilubashe@akamai.com> <1566869956-7154-4-git-send-email-ilubashe@akamai.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1566869956-7154-4-git-send-email-ilubashe@akamai.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.67]); Tue, 27 Aug 2019 13:44:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Aug 26, 2019 at 09:39:14PM -0400, Igor Lubashev escreveu: > 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. Thanks for following up on this, I added these notes to this cset commit log message: --------------------------------- 8< ------------------------------------ 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 Cc: Alexander Shishkin Cc: Alexey Budankov Cc: James Morris Cc: Jiri Olsa Cc: Mathieu Poirier 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 # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Author: Igor Lubashev # Date: Mon Aug 26 21:39:14 2019 -0400 # # On branch perf/core # Changes to be committed: # modified: tools/perf/util/evsel.c # # Untracked files: # a # a.c # bla # f_mode # perf.data # perf.data.old # q # # ------------------------ >8 ------------------------ # Do not modify or remove the line above. # Everything below it will be ignored. diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 7c704b8f0e5c..d4540bfe4574 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)