Maynard Johnson | 2 Jul 2012 16:13
Picon
Favicon

Re: [PATCH 0/4] Extend support for ARMv7 processors

On 06/29/2012 12:08 PM, Will Deacon wrote:
> Hello,
> 
> This patch series adds support for Cortex-A{5,7,15} processors to operf.
> I've added some likely strings for oprofilefs support too but I'm not
Those cpu type strings are needed by operf, too.
> sure if I'll merge the corresponding kernel-side changes unless people
> really want them.
> 
> The first patch also reworks many of the common ARMv7 architectural
> events to echo the definitions and terms used by the architecture
> reference manual.
Please remind me when we put out the next release (which should be soon) to add an "Incompatible changes"
section in the release notes to let ARM users know of the event name changes.
> 
> All feedback welcome,
The patches look fine to me, and 'make distcheck' runs clean.  I committed them, but will defer to Richard if
any changes may be required.

By the way, I added the following note in the commit message:

    The part of this patch that adds support for new ARM PMU
    implementations also updates the new function in
    libop/op_cpu_type that was added in the perf-events branch
    so that these new processors can be used with operf.
    For this reason, this patch is currently only being applied
    to the perf-events branch, so support for the new ARM processors
    won't be available in oprofile "mainline" until we merge the
    perf-events branch with the master branch.

(Continue reading)

Maynard Johnson | 2 Jul 2012 21:10
Picon
Favicon

Re: MIPS support for operf (Re: [RFC PATCH 0/2] Add ARM support to operf)

On 06/15/2012 01:55 PM, Maynard Johnson wrote:
> On 06/15/2012 09:48 AM, Gergely Kis wrote:
>> Hello,
>>
>>
>> On Fri, Jun 15, 2012 at 12:07 PM, Will Deacon <will.deacon <at> arm.com <mailto:will.deacon <at> arm.com>> wrote:
>>
>>     I'm posting this as an RFC due to the following hurdles:
>>
>>     1.) I've probably broken ppc64 with my /proc/cpuinfo parser changes but
>>        I don't have a relevant machine on which to test the patch.
>>
>>     2.) Cross-compiling for ARM doesn't work and I see the following error
>>        during configure:
>>
>>            checking kernel version supports perf_events... This kernel has perf_events support
>>            checking for "/usr/include/linux/perf_event.h"... configure: error: cannot check for file
existence when cross compiling
>>
>>        perhaps we should have a --with-perf-events option or something
>>        similar?
>>
>>     3.) operf requests exclude_idle=1 in the perf_event_attr passed to the
>>        kernel. ARM cores do not support this mode exclusion and requesting
>>        it will give you -EPERM (which is the wrong error code -- I'll fix
>>        this in the kernel...).
>>
>>
>> We are working on adding MIPS support to operf, and ran into similar issues. We also plan to use
/proc/cpuinfo for CPU type detection, so we would be happy to use the generalized code from this patch.
(Continue reading)

Will Deacon | 2 Jul 2012 23:57
Favicon

Re: [PATCH 0/4] Extend support for ARMv7 processors

On Mon, Jul 02, 2012 at 03:13:14PM +0100, Maynard Johnson wrote:
> On 06/29/2012 12:08 PM, Will Deacon wrote:
> > This patch series adds support for Cortex-A{5,7,15} processors to operf.
> > I've added some likely strings for oprofilefs support too but I'm not
> Those cpu type strings are needed by operf, too.

Only on the userspace side though, right?

> > The first patch also reworks many of the common ARMv7 architectural
> > events to echo the definitions and terms used by the architecture
> > reference manual.
> Please remind me when we put out the next release (which should be soon) to add an "Incompatible changes"
section in the release notes to let ARM users know of the event name changes.

Sure! At least CPU_CYCLES is the same, which is probably what most people
use in any scripts.

> > All feedback welcome,
> The patches look fine to me, and 'make distcheck' runs clean.  I committed them, but will defer to Richard if
any changes may be required.

Cheers. I tested them on the relevant CPUs and everything seemed to work.

> By the way, I added the following note in the commit message:
> 
>     The part of this patch that adds support for new ARM PMU
>     implementations also updates the new function in
>     libop/op_cpu_type that was added in the perf-events branch
>     so that these new processors can be used with operf.
>     For this reason, this patch is currently only being applied
(Continue reading)

Will Deacon | 3 Jul 2012 00:06
Favicon

Re: MIPS support for operf (Re: [RFC PATCH 0/2] Add ARM support to operf)

On Mon, Jul 02, 2012 at 08:10:26PM +0100, Maynard Johnson wrote:
> On 06/15/2012 01:55 PM, Maynard Johnson wrote:
> > On 06/15/2012 09:48 AM, Gergely Kis wrote:
> >> We also saw that oprofile does not cross-compile nicely, and planned to fix it, if someone else doesn't
fix it first.
> > A patch would be much appreciated.
> 
> Gergely, Will,
> Have either of you come up with a fix to make the perf-events-based oprofile "cross-compile nicely" (e.g.
a --with-perf-events option)?  I would try myself, but cross-compiling is not something I have expertise with.

I was about to, but then a shiny new Cortex-A15 arrived on my desk so I can
build natively now :)

I'll try and find some time to revisit it this week. It's been a while
since I looked at autoconf and I'm not sure I've been the same since.

Will

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Maynard Johnson | 3 Jul 2012 00:44
Picon
Favicon

[PATCH] Add configure option for building operf on systems without perf_events

Will, Gergely,
Can you please test this patch in a cross-compile environment?  I'm not 100%
sure it meets your needs.  It works fine for building a perf_events-enabled
oprofile on a RHEL 5 (no perf_events support), creating an operf binary that
is runnable on RHEL 6.

[PATCH] Add configure option for building operf on systems without perf_events

A new "--with-perf-events" option is added to configure.in to allow
pointing the oprofile build process at a directory of kernel headers
that includes the necessary header files for building libperf_events.a
and operf.  This option should be useful in cross-compile environments
or in situations where the build environment is on an older system
that does not have perf_events support, but where the target runtime
environment does have perf_events support (and, thus, operf should be
built for the target).

Signed-off-by: Maynard Johnson <maynardj <at> us.ibm.com>
---
 configure.in               |   43 ++++++++++++++++++++++++++++++++-----------
 libperf_events/Makefile.am |    3 ++-
 pe_profiling/Makefile.am   |    3 ++-
 utils/Makefile.am          |    1 +
 4 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/configure.in b/configure.in
index 45b0e23..36725e9 100644
--- a/configure.in
+++ b/configure.in
 <at>  <at>  -69,21 +69,36  <at>  <at>  AX_KERNEL_VERSION(2, 6, 31, <=, kernel_has_perf_events_support="yes",
(Continue reading)

Gergely Kis | 3 Jul 2012 08:09

Re: MIPS support for operf (Re: [RFC PATCH 0/2] Add ARM support to operf)



On Mon, Jul 2, 2012 at 9:10 PM, Maynard Johnson <maynardj <at> us.ibm.com> wrote:
On 06/15/2012 01:55 PM, Maynard Johnson wrote:
> On 06/15/2012 09:48 AM, Gergely Kis wrote:
>> Hello,
>>
>>
>> On Fri, Jun 15, 2012 at 12:07 PM, Will Deacon <will.deacon <at> arm.com <mailto:will.deacon <at> arm.com>> wrote:
>> We also saw that oprofile does not cross-compile nicely, and planned to fix it, if someone else doesn't fix it first.
> A patch would be much appreciated.

Gergely, Will,
Have either of you come up with a fix to make the perf-events-based oprofile "cross-compile nicely" (e.g. a --with-perf-events option)?  I would try myself, but cross-compiling is not something I have expertise with.

Maynard,

Sorry, I just saw your mail, and your patch. We have a patch in the works, but we were not ready to publish it just yet, because there were some linker issues with it with some toolchains.

Our approach is a bit different: we added a switch called --with-kernel, which (as you probably guessed) specifies the kernel source root directory. This way the a AX_KERNEL_VERSION macro will use this kernel version, instead of the default one. Of course, the check for the perf_event.h would use this directory also.

We will try to clean up the patch today, and send it in as a proposal.

Best Regards,
Gergely

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
oprofile-list mailing list
oprofile-list <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oprofile-list
Maynard Johnson | 3 Jul 2012 19:49
Picon
Favicon

[PATCH - v2] Add configure option for building operf on systems without perf_events

The first version of this patch had a bug in it -- in configure.in, the line that
does the AM_CONDITIONAL for BUILD_FOR_PERF_EVENT.  Spaces were needed in the
test clause to make the AM_CONDITIONAL do the right thing.

-Maynard

--------------------------------------------------------------------------
[PATCH] Add configure option for building operf on systems without perf_events

A new "--with-perf-events" option is added to configure.in to allow
pointing the oprofile build process at a directory of kernel headers
that includes the necessary header files for building libperf_events.a
and operf.  This option should be useful in cross-compile environments
or in situations where the build environment is on an older system
that does not have perf_events support, but where the target runtime
environment does have perf_events support (and, thus, operf should be
built for the target).

Signed-off-by: Maynard Johnson <maynardj <at> us.ibm.com>
---
 configure.in               |   43 ++++++++++++++++++++++++++++++++-----------
 libperf_events/Makefile.am |    3 ++-
 pe_profiling/Makefile.am   |    3 ++-
 utils/Makefile.am          |    1 +
 4 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/configure.in b/configure.in
index 45b0e23..458ce82 100644
--- a/configure.in
+++ b/configure.in
 <at>  <at>  -69,21 +69,36  <at>  <at>  AX_KERNEL_VERSION(2, 6, 31, <=, kernel_has_perf_events_support="yes",
 kernel_has_perf_events_support="no")

 if test "$kernel_has_perf_events_support" = "no"; then
-	AC_MSG_RESULT([This kernel does not have perf_events support; falling back to legacy oprofile])
+	AC_MSG_RESULT([The host kernel does not have perf_events support])
 else
-	AC_MSG_RESULT([This kernel has perf_events support])
+	AC_MSG_RESULT([The host kernel has perf_events support])
 fi

-AC_CHECK_FILE("/usr/include/linux/perf_event.h",PERF_EVENT_H_EXISTS="yes")
-AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test -n "$PERF_EVENT_H_EXISTS")
-if test "$PERF_EVENT_H_EXISTS" = "yes"; then
+AC_ARG_WITH(perf-events,
+[AS_HELP_STRING([--with-perf-events=dir], [Path to kernel headers to use. Use this option if the host
system 
+does not support perf_events. The binaries built with this option are not executable on the host system.
+The kernel headers used should match the version of the target system.])],
+PERFEVENTSDIR=$withval)
+
+if test "$PERFEVENTSDIR" != ""; then
+	PERF_EVENT_CFLAGS=" -I$PERFEVENTSDIR"
+	PERF_EVENT_CXXFLAGS=" -I$PERFEVENTSDIR"
 	HAVE_PERF_EVENTS='1'
+	AC_SUBST(PERF_EVENT_CXXFLAGS)
+	AC_SUBST(PERF_EVENT_CFLAGS)
 else
-	HAVE_PERF_EVENTS='0'
+	AC_CHECK_FILE("/usr/include/linux/perf_event.h",PERF_EVENT_H_EXISTS="yes")
+	if test "$PERF_EVENT_H_EXISTS" = "yes"; then
+		HAVE_PERF_EVENTS='1'
+	else
+		HAVE_PERF_EVENTS='0'
+	fi
 fi
+
+AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test "$HAVE_PERF_EVENTS" = '1')
 AC_DEFINE_UNQUOTED(HAVE_PERF_EVENTS, $HAVE_PERF_EVENTS, [Kernel support for perf_events exists])

-if test "$HAVE_PERF_EVENTS" = "1"; then
+if test "$HAVE_PERF_EVENTS" = '1'; then
 	PFM_LIB=
 	arch="`uname -m`"
 	if test "$arch" = "ppc64"; then
 <at>  <at>  -386,8 +401,14  <at>  <at>  elif test "`getent passwd oprofile 2>/dev/null`" == "" || \
 	fi
 fi

-if  test "$PERF_EVENT_H_EXISTS" != "yes" && test "$kernel_has_perf_events_support" = "yes"; then
-	echo "Warning: perf_event.h not found.  Please install the kernel headers package if you"
-	echo "         want non-root support built into OProfile."
+if  test "$HAVE_PERF_EVENTS" = '1'; then
+	if test "$kernel_has_perf_events_support" = "no"; then
+		echo "Warning: A perf_events-enabled oprofile will be built, but the binaries will not be"
+		echo "         runnable on the host system since it does not support perf_events."
+	fi
+else
+	if test "$kernel_has_perf_events_support" = "yes"; then
+		echo "Warning: perf_event.h not found.  Please install the kernel headers package or use"
+		echo "         the --with-perf-events option if you want non-root support built into OProfile."
+	fi
 fi
-
diff --git a/libperf_events/Makefile.am b/libperf_events/Makefile.am
index dbb3d86..3bd6650 100644
--- a/libperf_events/Makefile.am
+++ b/libperf_events/Makefile.am
 <at>  <at>  -6,7 +6,8  <at>  <at>  AM_CPPFLAGS = \
 	-I ${top_srcdir}/libutil++ \
 	-I ${top_srcdir}/libop \
 	-I ${top_srcdir}/libdb \
-	-I ${top_srcdir}/libperf_events
+	-I ${top_srcdir}/libperf_events \
+	 <at> PERF_EVENT_CFLAGS <at> 

 noinst_LIBRARIES = libperf_events.a
 libperf_events_a_SOURCES =  \
diff --git a/pe_profiling/Makefile.am b/pe_profiling/Makefile.am
index d7ce6da..86d5818 100644
--- a/pe_profiling/Makefile.am
+++ b/pe_profiling/Makefile.am
 <at>  <at>  -5,7 +5,8  <at>  <at>  AM_CPPFLAGS = \
 	-I ${top_srcdir}/libutil \
 	-I ${top_srcdir}/libop \
 	-I ${top_srcdir}/libutil++ \
-	-I ${top_srcdir}/libperf_events
+	-I ${top_srcdir}/libperf_events \
+	 <at> PERF_EVENT_CFLAGS <at> 

 operf_SOURCES = operf.cpp

diff --git a/utils/Makefile.am b/utils/Makefile.am
index 48832e1..f6bfdc6 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
 <at>  <at>  -7,6 +7,7  <at>  <at>  bin_PROGRAMS = ophelp op-check-perfevents
 dist_bin_SCRIPTS = opcontrol

 op_check_perfevents_SOURCES = op_perf_events_checker.c
+op_check_perfevents_CPPFLAGS = ${AM_CFLAGS}  <at> PERF_EVENT_CFLAGS <at> 

 ophelp_SOURCES = ophelp.c
 ophelp_LDADD = ../libop/libop.a ../libutil/libutil.a
--

-- 
1.7.1

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Maynard Johnson | 3 Jul 2012 21:30
Picon
Favicon

Re: [RFC] Make opreport use <cur_dir>/oprofile data for default session-dir

On 06/29/2012 11:23 AM, Maynard Johnson wrote:
> On 06/26/2012 02:47 PM, Maynard Johnson wrote:
>> As those of you who have played with operf already know, when the profiling
>> session ends, operf prints the following message:
>>
>> -----------------
>> Use '--session-dir=/home/≤user_name>/oprofile_data'
>> with opreport and other post-processing tools to view your profile data.
>> -----------------
>>
>> This is eventually going to be very annoying to users, and I hate to start
>> a precedent that will be hard to get rid of in the future. So, in light
>> of the new "operf" reality that will soon be the normal oprofile usage
>> model, I have attached below a proposal to change how opreport decides
>> where to look for sample data.  Since the proposed implementation below
>> performs a bit of magic behind the curtain, I think one possible change
>> that could be helpful to the user is for the oprofile post-processing
>> tool to print a message indicating the session-dir it ends up using.
>>
>> I would very much appreciate comments from the community.
> 
> I'll give this topic a few more days to ruminate and then I'll commit the patch to the perf-events branch. 
Speak up now if you have any concerns.
I committed this patch to the perf-events branch with the following minor changes:
  - Updated the man pages for opreport, opannotate, and oparchive to reflect the change in default session-dir
  - Changed operf's "Profiling started" and "Profiling done" messages to go to stderr vs stdout

Review comments are still welcome.

-Maynard
> 
> -Maynard
> 
>>
>>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> [RFC] Make opreport use <cur_dir>/oprofile data for default session-dir
>>
>> Since operf will be the recommended profiling tool in the future
>> (instead of opcontrol) and since operf stores the sample data by
>> default in <cur_dir>/oprofile_data, it makes sense for opreport
>> and other oprofile post-processing tools to look first in
>> <cur_dir/oprofile_data; then, if no samples are found there, the
>> tool should fall back to the "standard" /var/lib/oprofile session-dir.
>>
>> Signed-off-by: Maynard Johnson <maynardj <at> us.ibm.com>
>> ---
>>  doc/operf.1.in             |    3 +-
>>  libpp/profile_spec.cpp     |    2 +-
>>  libutil++/op_exception.cpp |    9 ++++++++
>>  libutil++/op_exception.h   |    5 ++++
>>  pe_profiling/operf.cpp     |    4 +--
>>  pp/common_option.cpp       |   45 ++++++++++++++++++++++++++++++++++++++++++-
>>  pp/common_option.h         |    6 +++++
>>  pp/opannotate_options.cpp  |   11 +++++++++-
>>  pp/oparchive_options.cpp   |   19 +++++++++++++++++-
>>  pp/opreport_options.cpp    |   14 +++++++++++-
>>  10 files changed, 107 insertions(+), 11 deletions(-)
>>
>> diff --git a/doc/operf.1.in b/doc/operf.1.in
>> index 0de46b1..e3a1d7f 100644
>> --- a/doc/operf.1.in
>> +++ b/doc/operf.1.in
>>  <at>  <at>  -97,7 +97,8  <at>  <at>  be added to it, and the 'previous' profile (if one existed) will remain untouche
>>  To access the 'previous' profile, simply add a session specification to the normal
>>  invocation of oprofile post-processing tools.  For example:
>>  .br
>> -.I "   opreport --session-dir=`pwd`/oprofile_data session:previous"
>> +.BI "   opreport"
>> +.BI session:previous
>>  .br
>>  .TP
>>  .BI "--events / -e " event1[,event2[,...]]
>> diff --git a/libpp/profile_spec.cpp b/libpp/profile_spec.cpp
>> index 0a77a74..b699671 100644
>> --- a/libpp/profile_spec.cpp
>> +++ b/libpp/profile_spec.cpp
>>  <at>  <at>  -563,7 +563,7  <at>  <at>  list<string> profile_spec::generate_file_list(bool exclude_dependent,
>>  		ostringstream os;
>>  		os  << "No sample file found: try running opcontrol --dump\n"
>>  		    << "or specify a session containing sample files\n";
>> -		throw op_fatal_error(os.str());
>> +		throw op_no_samples_exception(os.str());
>>  	}
>>
>>  	list<string> result;
>> diff --git a/libutil++/op_exception.cpp b/libutil++/op_exception.cpp
>> index 235b9bc..c78ef66 100644
>> --- a/libutil++/op_exception.cpp
>> +++ b/libutil++/op_exception.cpp
>>  <at>  <at>  -30,6 +30,15  <at>  <at>  char const * op_exception::what() const throw()
>>  	return message.c_str();
>>  }
>>
>> +op_no_samples_exception::op_no_samples_exception(string const & msg)
>> +	:
>> +	op_exception(msg)
>> +{
>> +}
>> +
>> +op_no_samples_exception::~op_no_samples_exception(void) throw()
>> +{
>> +}
>>
>>  op_fatal_error::op_fatal_error(string const & msg)
>>  	:
>> diff --git a/libutil++/op_exception.h b/libutil++/op_exception.h
>> index af344ed..f51ff4e 100644
>> --- a/libutil++/op_exception.h
>> +++ b/libutil++/op_exception.h
>>  <at>  <at>  -35,6 +35,11  <at>  <at>  private:
>>  	std::string message;
>>  };
>>
>> +class op_no_samples_exception : public op_exception {
>> +public:
>> +	explicit op_no_samples_exception(std::string const & msg);
>> +	~op_no_samples_exception() throw();
>> +};
>>
>>  /**
>>   * fatal exception, never catch it except at top level (likely main or
>> diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
>> index ff9334b..41a8a36 100644
>> --- a/pe_profiling/operf.cpp
>> +++ b/pe_profiling/operf.cpp
>>  <at>  <at>  -1595,9 +1595,7  <at>  <at>  int main(int argc, char * const argv[])
>>  			cerr << "WARNING: Profile results may be incomplete due to to abend of profiled app." << endl;
>>  		}
>>  	} else {
>> -		cout << endl << "Use '--session-dir=" << operf_options::session_dir << "'" << endl
>> -		     << "with opreport and other post-processing tools to view your profile data."
>> -		     << endl;
>> +		cout << endl << "Profiling done." << endl;
>>  	}
>>  	cleanup();
>>  	return run_result;;
>> diff --git a/pp/common_option.cpp b/pp/common_option.cpp
>> index 99e0e96..6b398e6 100644
>> --- a/pp/common_option.cpp
>> +++ b/pp/common_option.cpp
>>  <at>  <at>  -24,12 +24,17  <at>  <at> 
>>  #include "common_option.h"
>>  #include "file_manip.h"
>>
>> +#include <sys/types.h>
>> +#include <sys/stat.h>
>> +#include <unistd.h>
>> +#include <limits.h>
>> +
>>  using namespace std;
>>
>>  namespace options {
>>  	double threshold = 0.0;
>>  	string threshold_opt;
>> -	string session_dir = OP_SESSION_DIR_DEFAULT;
>> +	string session_dir;
>>  	string command_options;
>>  	vector<string> image_path;
>>  	string root_path;
>>  <at>  <at>  -37,6 +42,7  <at>  <at>  namespace options {
>>
>>  namespace {
>>
>> +
>>  vector<string> verbose_strings;
>>
>>  popt::option common_options_array[] = {
>>  <at>  <at>  -51,6 +57,8  <at>  <at>  popt::option common_options_array[] = {
>>  		     "path to filesystem to search for missing binaries", "path"),
>>  };
>>
>> +int session_dir_supplied;
>> +int trying_default_session_dir;
>>
>>  double handle_threshold(string threshold)
>>  {
>>  <at>  <at>  -163,13 +171,34  <at>  <at>  fail:
>>  	exit(EXIT_FAILURE);
>>  }
>>
>> -
>>  options::spec get_options(int argc, char const * argv[])
>>  {
>>  	vector<string> non_options;
>>  	popt::parse_options(argc, argv, non_options);
>>
>>  	// initialize paths in op_config.h
>> +	if (options::session_dir.empty()) {
>> +		char * cwd;
>> +		struct stat sb;
>> +		// First try <curr_dir>/oprofile_data session-dir (i.e., used by operf)
>> +		cwd = new char[PATH_MAX];
>> +		options::session_dir = getcwd(cwd, PATH_MAX);
>> +		delete cwd;
>> +		options::session_dir +="/oprofile_data";
>> +		if ((stat(options::session_dir.c_str(), &sb) < 0) ||
>> +				((sb.st_mode & S_IFMT) != S_IFDIR)) {
>> +			// Try the standard default session dir instead
>> +			options::session_dir = "/var/lib/oprofile";
>> +			trying_default_session_dir = 1;
>> +		} else {
>> +			// OK, we'll try <cur_dir>/oprofile_data first; then, if we don't find
>> +			// any samples there, we'll also try the default session dir /var/lib/oprofile.
>> +			trying_default_session_dir = 0;
>> +		}
>> +		session_dir_supplied = 0;
>> +	} else {
>> +		session_dir_supplied = 1;
>> +	}
>>  	init_op_config_dirs(options::session_dir.c_str());
>>
>>  	if (!options::threshold_opt.empty())
>>  <at>  <at>  -290,3 +319,15  <at>  <at>  merge_option handle_merge_option(vector<string> const & mergespec,
>>
>>  	return merge_by;
>>  }
>> +
>> +int try_another_session_dir(void)
>> +{
>> +	if (!session_dir_supplied && !trying_default_session_dir) {
>> +		trying_default_session_dir = 1;
>> +		options::session_dir = "/var/lib/oprofile";
>> +		init_op_config_dirs(options::session_dir.c_str());
>> +		return 1;
>> +	} else {
>> +		return 0;
>> +	}
>> +}
>> diff --git a/pp/common_option.h b/pp/common_option.h
>> index b54ef7c..f054612 100644
>> --- a/pp/common_option.h
>> +++ b/pp/common_option.h
>>  <at>  <at>  -69,4 +69,10  <at>  <at>  demangle_type handle_demangle_option(std::string const & option);
>>  merge_option handle_merge_option(std::vector<std::string> const & mergespec,
>>         bool allow_lib, bool exclude_dependent);
>>
>> +/**
>> + * Determine if tool should look at any other potential locations for
>> + * a session dir.  Returns '0' for "no" and '1' for "yes".
>> + */
>> +int try_another_session_dir(void);
>> +
>>  #endif /* !COMMON_OPTION_H */
>> diff --git a/pp/opannotate_options.cpp b/pp/opannotate_options.cpp
>> index 57a5924..9b6f6db 100644
>> --- a/pp/opannotate_options.cpp
>> +++ b/pp/opannotate_options.cpp
>>  <at>  <at>  -125,7 +125,16  <at>  <at>  void handle_options(options::spec const & spec)
>>  		profile_spec::create(spec.common, options::image_path,
>>  				     options::root_path);
>>
>> -	list<string> sample_files = pspec.generate_file_list(exclude_dependent, true);
>> +	list<string> sample_files;
>> +again:
>> +	try {
>> +		sample_files = pspec.generate_file_list(exclude_dependent, true);
>> +	} catch (op_no_samples_exception & e) {
>> +		if (try_another_session_dir())
>> +			goto again;
>> +		else
>> +			throw op_fatal_error(e.what());
>> +	}
>>
>>  	cverb << vsfile << "Archive: " << pspec.get_archive_path() << endl;
>>
>> diff --git a/pp/oparchive_options.cpp b/pp/oparchive_options.cpp
>> index 4b33aec..011fc3d 100644
>> --- a/pp/oparchive_options.cpp
>> +++ b/pp/oparchive_options.cpp
>>  <at>  <at>  -15,7 +15,9  <at>  <at> 
>>  #include <algorithm>
>>  #include <iterator>
>>  #include <fstream>
>> +#include <string.h>
>>
>> +#include "op_config.h"
>>  #include "profile_spec.h"
>>  #include "arrange_profiles.h"
>>  #include "oparchive_options.h"
>>  <at>  <at>  -23,6 +25,7  <at>  <at> 
>>  #include "string_filter.h"
>>  #include "file_manip.h"
>>  #include "cverb.h"
>> +#include "op_exception.h"
>>
>>
>>  using namespace std;
>>  <at>  <at>  -99,7 +102,15  <at>  <at>  void handle_options(options::spec const & spec)
>>  	profile_spec const pspec =
>>  		profile_spec::create(spec.common, image_path, root_path);
>>
>> -	sample_files = pspec.generate_file_list(exclude_dependent, false);
>> +again:
>> +	try {
>> +		sample_files = pspec.generate_file_list(exclude_dependent, false);
>> +	} catch (op_no_samples_exception & e) {
>> +		if (try_another_session_dir())
>> +			goto again;
>> +		else
>> +			throw op_fatal_error(e.what());
>> +	}
>>
>>  	cverb << vsfile << "Matched sample files: " << sample_files.size()
>>  	      << endl;
>>  <at>  <at>  -116,4 +127,10  <at>  <at>  void handle_options(options::spec const & spec)
>>  		     "too strict ?" << endl;
>>  		exit(EXIT_FAILURE);
>>  	}
>> +
>> +	if (strncmp(op_session_dir, "/var/lib/oprofile", strlen("/var/lib/oprofile")))
>> +		cerr << "NOTE: The sample data in this archive is located at " << op_session_dir << endl
>> +		     << "instead of the standard location of /var/lib/oprofile.  Hence, when using opreport" << endl
>> +		     << "and other post-processing tools on this archive, you must pass the following option:" << endl
>> +		     << "\t--session-dir=" << op_session_dir << endl;
>>  }
>> diff --git a/pp/opreport_options.cpp b/pp/opreport_options.cpp
>> index 95d219c..08d5e8c 100644
>> --- a/pp/opreport_options.cpp
>> +++ b/pp/opreport_options.cpp
>>  <at>  <at>  -25,6 +25,7  <at>  <at> 
>>  #include "xml_output.h"
>>  #include "xml_utils.h"
>>  #include "cverb.h"
>> +#include "op_exception.h"
>>
>>  using namespace std;
>>
>>  <at>  <at>  -253,8 +254,17  <at>  <at>  void process_spec(profile_classes & classes, list<string> const & spec)
>>  		profile_spec::create(spec, options::image_path,
>>  				     options::root_path);
>>
>> -	list<string> sample_files = pspec.generate_file_list(exclude_dependent,
>> -	                                                     !options::callgraph);
>> +	list<string> sample_files;
>> +again:
>> +	try {
>> +		sample_files = pspec.generate_file_list(exclude_dependent,
>> +		                                        !options::callgraph);
>> +	} catch (op_no_samples_exception e) {
>> +		if (try_another_session_dir())
>> +			goto again;
>> +		else
>> +			throw op_fatal_error(e.what());
>> +	}
>>
>>  	cverb << vsfile << "Archive: " << pspec.get_archive_path() << endl;
>>
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> oprofile-list mailing list
> oprofile-list <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/oprofile-list
> 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
SourceForge.net | 3 Jul 2012 21:55
Picon

[ oprofile-Bugs-3082197 ] oprofile leaves a world-writable /var/lib/oprofile/jitdump/

Bugs item #3082197, was opened at 2010-10-06 07:21
Message generated for change (Comment added) made by maynardj
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116191&aid=3082197&group_id=16191

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Shlomi Fish (shlomif)
Assigned to: hanseld (hanseld)
Summary: oprofile leaves a world-writable /var/lib/oprofile/jitdump/

Initial Comment:
On Mandriva Cooker with oprofile-0.9.6-1mdv2010.1 after doing opcontrol
--vmlinux=/boot/vmlinux-2.6.36-desktop-0.rc6.2.1mnb and opcontrol --start I'm getting this:

{{{
[root <at> telaviv1 ~]# ls -ld /var/lib/oprofile/jitdump
drwxrwxrwx 2 root root 6 2010-10-06 09:34 /var/lib/oprofile/jitdump/
}}}

It stays this way after I run oprofile --stop and reboot the machine. This is a world-writable directory to
which every user can write into until the partition is filled, and that msec (the Mandriva security
monitor) reports and complains about.

Please fix it.

Regards,

-- Shlomi Fish

----------------------------------------------------------------------

>Comment By: Maynard Johnson (maynardj)
Date: 2012-07-03 12:55

Message:
Daniel,
Since I'm going to be putting out a new release in the not too distant
future, I'd like to close out as many bugs as possible.  Can you please
take a look at this one.  It seems that this directory could be made
writable by root and readable by all.  But if we make such a change, that's
going to break operf, as it currently will generate jit dump files into
/var/lib/oprofile/jitdump even when it's run by a normal user.  So if you
change the permissions on this dir, it will have a ripple effect.

----------------------------------------------------------------------

Comment By: hanseld (hanseld)
Date: 2011-06-06 08:16

Message:
Hi Shlomi Fish,

we've discussed that problem.
We want to change the location for JIT dump files from
/var/lib/oprofile/jitdump to /tmp/jitdump.
Additionally we have to document this new location due to the fact that
/tmp could be cleaned up sometimes.

The new location is necessary due to the fact that oprofile JIT dump files
could be created by any user.

Can you tell me if the new location is ok for your Mandriva security
monitor?

Kind regards.

----------------------------------------------------------------------

Comment By: William Cohen (wcohen)
Date: 2011-05-20 14:52

Message:
This directory is being used to store the jvmti/jvmpi opagents so there is
information to map samples back to the java method. The java program are
running as normal users, so the opagent code that are recording data into
/var/lib/oprofile/jitdump is also being run as normal users.

When reviewing the opagent code I found that the jitdump directory location
is statically compiled into the code due to 

libopagent/opagent.c:#define AGENT_DIR OP_SESSION_DIR_DEFAULT "jitdump"

And:

libop/op_config.h:#define OP_SESSION_DIR_DEFAULT "/var/lib/oprofile/"

If someone starts uses "opcontrol --session-dir=..." then java opagent is
going to put things in the wrong place.

Would it make sense for the oprofile to do something like this:

-opagent attempts to write to a pipe that oprofiled has open (maybe in
/tmp)
-oprofiled creates the file in SESSION_DIR/jitdump with permissions
	   oprofiled makes link /tmp/filename to SESSION_DIR/jitdump/file
-opcontrol can remove group and world write to SESSION_DIR/jitdump

----------------------------------------------------------------------

Comment By: Maynard Johnson (maynardj)
Date: 2011-04-20 07:26

Message:
Daniel, please take a look at this bug.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116191&aid=3082197&group_id=16191

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Gergely Kis | 3 Jul 2012 23:03

[PATCH] Build system changes for cross-compiling

From: Balazs Kilvady <kilvadyb <at> homejinni.com>

Added --with-kernel option to specify the kernel source location,
where perf_event.h is located. 

Removed libpopt from operf Makefile to match the getopt patch

Signed-off-by: Balazs Kilvady <kilvadyb <at> homejinni.com>
Signed-off-by: Gergely Kis <gergely <at> homejinni.com>
---
 configure.in               |   21 ++++++++++++++++++++-
 libperf_events/Makefile.am |    3 ++-
 pe_profiling/Makefile.am   |    5 +++--
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/configure.in b/configure.in
index 45b0e23..b230ba7 100644
--- a/configure.in
+++ b/configure.in
 <at>  <at>  -39,6 +39,7  <at>  <at>  if test "$BINUTILSDIR" != ""; then
 	fi
 	CFLAGS="$CFLAGS -I$BINUTILSDIR/include"
 	CXXFLAGS="$CXXFLAGS -I$BINUTILSDIR/include"
+	CPPFLAGS="$CPPFLAGS -I$BINUTILSDIR/include"
 	AC_ARG_WITH(binutils-libname,
 		[  --with-binutils-libname       Lib dir name under binutils installation;  <at> <: <at> lib <at> :> <at> ]],
 		BINUTILSLIB=$withval)
 <at>  <at>  -63,8 +64,15  <at>  <at>  AC_PROG_CXX
 AC_CHECK_PROG(LD,ld,ld,)
 test "$LD" || AC_ERROR(ld not found)

+# --with-kernel for cross compilation
+AC_ARG_WITH(kernel,
+[  --with-kernel=dir		Path to kernel include directory (...include/linux/perf_event.h) to use], KERNELDIR=$withval)
+
 dnl Check kernel version for perf_events supported
 AC_MSG_CHECKING([kernel version supports perf_events])
+if test "$KERNELDIR" != ""; then
+	KINC="$KERNELDIR/include"
+fi
 AX_KERNEL_VERSION(2, 6, 31, <=, kernel_has_perf_events_support="yes",
 kernel_has_perf_events_support="no")

 <at>  <at>  -74,10 +82,21  <at>  <at>  else
 	AC_MSG_RESULT([This kernel has perf_events support])
 fi

-AC_CHECK_FILE("/usr/include/linux/perf_event.h",PERF_EVENT_H_EXISTS="yes")
+if test "$KERNELDIR" == ""; then
+	PERF_EVENT_H="/usr/include/linux/perf_event.h"
+else
+	PERF_EVENT_H="$KERNELDIR/include/linux/perf_event.h"
+fi
+AC_CHECK_HEADER($PERF_EVENT_H,PERF_EVENT_H_EXISTS="yes")
 AM_CONDITIONAL(BUILD_FOR_PERF_EVENT, test -n "$PERF_EVENT_H_EXISTS")
 if test "$PERF_EVENT_H_EXISTS" = "yes"; then
 	HAVE_PERF_EVENTS='1'
+	if test "$KERNELDIR" != ""; then
+		PERF_EVENT_CFLAGS=" -I$KERNELDIR/include"
+		PERF_EVENT_CXXFLAGS=" -I$KERNELDIR/include"
+		AC_SUBST(PERF_EVENT_CXXFLAGS)
+		AC_SUBST(PERF_EVENT_CFLAGS)
+	fi
 else
 	HAVE_PERF_EVENTS='0'
 fi
diff --git a/libperf_events/Makefile.am b/libperf_events/Makefile.am
index dbb3d86..3bd6650 100644
--- a/libperf_events/Makefile.am
+++ b/libperf_events/Makefile.am
 <at>  <at>  -6,7 +6,8  <at>  <at>  AM_CPPFLAGS = \
 	-I ${top_srcdir}/libutil++ \
 	-I ${top_srcdir}/libop \
 	-I ${top_srcdir}/libdb \
-	-I ${top_srcdir}/libperf_events
+	-I ${top_srcdir}/libperf_events \
+	 <at> PERF_EVENT_CFLAGS <at> 

 noinst_LIBRARIES = libperf_events.a
 libperf_events_a_SOURCES =  \
diff --git a/pe_profiling/Makefile.am b/pe_profiling/Makefile.am
index d7ce6da..f9dcc78 100644
--- a/pe_profiling/Makefile.am
+++ b/pe_profiling/Makefile.am
 <at>  <at>  -1,11 +1,12  <at>  <at> 
-LIBS= <at> POPT_LIBS <at>   <at> LIBERTY_LIBS <at>   <at> PFM_LIB <at> 
+LIBS= <at> LIBERTY_LIBS <at>   <at> PFM_LIB <at> 
 if BUILD_FOR_PERF_EVENT

 AM_CPPFLAGS = \
 	-I ${top_srcdir}/libutil \
 	-I ${top_srcdir}/libop \
 	-I ${top_srcdir}/libutil++ \
-	-I ${top_srcdir}/libperf_events
+	-I ${top_srcdir}/libperf_events \
+	 <at> PERF_EVENT_CXXFLAGS <at> 

 operf_SOURCES = operf.cpp

--

-- 
1.7.0.4

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

Gmane