Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp792555ybe; Fri, 13 Sep 2019 06:28:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzollGvdH0KlJMvyVTgDeKfsslRhsavjDJtD1NFDhVbVe6+ZmLZUsZQuP6eqx1UqKCi+GZc X-Received: by 2002:aa7:db47:: with SMTP id n7mr26042464edt.169.1568381312592; Fri, 13 Sep 2019 06:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568381312; cv=none; d=google.com; s=arc-20160816; b=gSq99kLp9t102Z66BGSZh1kaYnSyTyph3RZZT9cgwUkirvw/dSK7cdyKQ8sojdzo/P qfOfvUmvXx6MRelKPzKkd97aDkfUepdC6U/WMdR1vhuY6BX6iWNVSffbBOzxJt/eSxO7 osAfe41IjH3nRfoHq8HATd5WyjyRSnY7sTLlKdmpXeK1/UsHhW6NmUI2UPQ69xvJnKeH C/Ut+lvlY5B/Lm9uQM4+j0et5LYdp6ghNA/ZYKzCNvL6l0PosCr8t6kNiLSCxpf/d+i9 cmbvhR6I7qA44T4OsyHvLTZHP8VEuniBdJrtXVvE5Jrg6OSRTXpa/6JqxdbwILXNvoNw JIEQ== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QO6gci0aBCAEYrs2p2X2Yz7na01ek2yc4IRhrPOBdns=; b=qymwr6UW022RCjYYOMFNcQdPKIAWIswULzvahc0pW95Eosoi2AgsxEoDCQhXl19Yf6 fCGq3LHwFpS3wj2romIl3p3ROsW0Pbl6ZxjDhn8MF97v0+3p+NTFTUHfMtQrwU18/VCO 4n2XUeTWi46vz+F3ht1ByIs8BUNXfHz//BlIXhP50xsDPejcEpiY7wvPuGPU6Tx6/4/X dPVdHi0HboBGrSr9ApFt7bGxRLe/YpApj+X9+tOVfwWH1ZO9WgwE1BKQL2tMID+5/X4a QDU4RF9aulJHk8hfrpSmDAr9aR52qFSqIgXTTvLM+se/d8yEV64lFhBU8yxY2LSbG6vE Iraw== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f43si18806880edf.422.2019.09.13.06.28.09; Fri, 13 Sep 2019 06:28:32 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391346AbfIMNZX (ORCPT + 99 others); Fri, 13 Sep 2019 09:25:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53350 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390988AbfIMNZV (ORCPT ); Fri, 13 Sep 2019 09:25:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABE8C7F746; Fri, 13 Sep 2019 13:25:20 +0000 (UTC) Received: from krava.brq.redhat.com (unknown [10.43.17.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FE3F5C219; Fri, 13 Sep 2019 13:25:18 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Michael Petlan Subject: [PATCH 32/73] libperf: Move page_size into libperf Date: Fri, 13 Sep 2019 15:23:14 +0200 Message-Id: <20190913132355.21634-33-jolsa@kernel.org> In-Reply-To: <20190913132355.21634-1-jolsa@kernel.org> References: <20190913132355.21634-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Fri, 13 Sep 2019 13:25:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need page_size in libperf, so moving it in there. Adding libperf_init as a global libperf init functon. Link: http://lkml.kernel.org/n/tip-g6auuaej31nsusuevuhcgxli@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/core.c | 7 +++++++ tools/perf/lib/include/internal/lib.h | 2 ++ tools/perf/lib/include/perf/core.h | 1 + tools/perf/lib/lib.c | 2 ++ tools/perf/lib/libperf.map | 1 + tools/perf/perf.c | 4 ++-- tools/perf/util/util.h | 2 -- 7 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/perf/lib/core.c b/tools/perf/lib/core.c index 29d5e3348718..6689d593c2d1 100644 --- a/tools/perf/lib/core.c +++ b/tools/perf/lib/core.c @@ -4,7 +4,9 @@ #include #include +#include #include +#include #include "internal.h" static int __base_pr(enum libperf_print_level level, const char *format, @@ -32,3 +34,8 @@ void libperf_print(enum libperf_print_level level, const char *format, ...) __libperf_pr(level, format, args); va_end(args); } + +void libperf_init(void) +{ + page_size = sysconf(_SC_PAGE_SIZE); +} diff --git a/tools/perf/lib/include/internal/lib.h b/tools/perf/lib/include/internal/lib.h index 0b56f1201dc9..9168b7d2a7e1 100644 --- a/tools/perf/lib/include/internal/lib.h +++ b/tools/perf/lib/include/internal/lib.h @@ -4,6 +4,8 @@ #include +extern unsigned int page_size; + ssize_t readn(int fd, void *buf, size_t n); ssize_t writen(int fd, const void *buf, size_t n); diff --git a/tools/perf/lib/include/perf/core.h b/tools/perf/lib/include/perf/core.h index c341a7b2c874..ba2f4e76a3e2 100644 --- a/tools/perf/lib/include/perf/core.h +++ b/tools/perf/lib/include/perf/core.h @@ -18,5 +18,6 @@ typedef int (*libperf_print_fn_t)(enum libperf_print_level level, const char *, va_list ap); LIBPERF_API void libperf_set_print(libperf_print_fn_t fn); +LIBPERF_API void libperf_init(void); #endif /* __LIBPERF_CORE_H */ diff --git a/tools/perf/lib/lib.c b/tools/perf/lib/lib.c index 2a81819c3b8c..18658931fc71 100644 --- a/tools/perf/lib/lib.c +++ b/tools/perf/lib/lib.c @@ -5,6 +5,8 @@ #include #include +unsigned int page_size; + static ssize_t ion(bool is_read, int fd, void *buf, size_t n) { void *buf_start = buf; diff --git a/tools/perf/lib/libperf.map b/tools/perf/lib/libperf.map index dc4d66363bc4..3fbf050b5add 100644 --- a/tools/perf/lib/libperf.map +++ b/tools/perf/lib/libperf.map @@ -1,5 +1,6 @@ LIBPERF_0.0.1 { global: + libperf_init; libperf_set_print; perf_cpu_map__dummy_new; perf_cpu_map__get; diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 1193b923e801..ead18b712d6c 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -25,6 +25,7 @@ #include "perf-sys.h" #include #include +#include #include #include #include @@ -438,8 +439,7 @@ int main(int argc, const char **argv) exec_cmd_init("perf", PREFIX, PERF_EXEC_PATH, EXEC_PATH_ENVIRONMENT); pager_init(PERF_PAGER_ENVIRONMENT); - /* The page_size is placed in util object. */ - page_size = sysconf(_SC_PAGE_SIZE); + libperf_init(); cmd = extract_argv0_path(argv[0]); if (!cmd) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 45a5c6f20197..d6ae394e67c4 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -33,8 +33,6 @@ int copyfile_offset(int ifd, loff_t off_in, int ofd, loff_t off_out, u64 size); size_t hex_width(u64 v); -extern unsigned int page_size; - int sysctl__max_stack(void); int fetch_kernel_version(unsigned int *puint, -- 2.21.0