public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robert Richter <robert.richter@amd.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	oprofile-list <oprofile-list@lists.sourceforge.net>
Subject: Re: [PATCH 4/5] oprofile: Remove exit function for timer mode
Date: Wed, 19 Oct 2011 18:33:28 +0200	[thread overview]
Message-ID: <20111019163328.GG24346@erda.amd.com> (raw)
In-Reply-To: <20111018061346.GD16304@elte.hu>

On 18.10.11 02:13:47, Ingo Molnar wrote:
> 
> * Robert Richter <robert.richter@amd.com> wrote:
> 
> >  	/* failed */
> > -	if (timer_mode)
> > -		oprofile_timer_exit();
> > -	else
> > +	if (!timer_mode)
> >  		oprofile_arch_exit();
> 
> > -	if (timer_mode)
> > -		oprofile_timer_exit();
> > -	else
> > +	if (!timer_mode)
> >  		oprofile_arch_exit();
> 
> ... and the ugliness didnt improve much here either.
> 
> Any reason why oprofile_arch_exit() couldnt check timer_mode?

The two fixes are the smallest possible solution for stable kernels.
... and they don't look nice.

Moving the check to oprofile_arch_exit() would mean to make timer_mode
global and to touch all oprofile_arch_exit() functions for all archs.
But we could get rid of timer_mode if the exit function would be part
of struct oprofile_operations. For this we would have to touch the
code for all architectures too, and I actually want to avoid this. But
it would be a nice solution.

Anyway, I have some improvements in patch #5 that make the code looks a
bit better. See below for a preview, will post a v2 patch set after
testing. As said, I could remove variable timer_mode completely by
moving exit functions to oprofile_operations. This could be on top of
the changes below.

-Robert



diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index f7cd069..d2994e7 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -246,26 +246,23 @@ static int __init oprofile_init(void)
        int err;
 
        /* always init architecture to setup backtrace support */
+       timer_mode = 0;
        err = oprofile_arch_init(&oprofile_ops);
-
-       timer_mode = err || timer;      /* fall back to timer mode on errors */
-       if (timer_mode) {
-               if (!err)
-                       oprofile_arch_exit();
-               err = oprofile_timer_init(&oprofile_ops);
-               if (err)
-                       return err;
+       if (!err) {
+               if (!timer && oprofilefs_register())
+                       return 0;
+               oprofile_arch_exit();
        }
 
-       err = oprofilefs_register();
-       if (!err)
-               return 0;
-
-       /* failed */
-       if (!timer_mode)
-               oprofile_arch_exit();
+       /* setup timer mode */
+       timer_mode = 1;
+       err = op_nmi_timer_init(&oprofile_ops);
+       if (err)
+               err = oprofile_timer_init(&oprofile_ops);
+       if (err)
+               return err;
 
-       return err;
+       return oprofilefs_register();
 }
 
 




-- 
Advanced Micro Devices, Inc.
Operating System Research Center


  reply	other threads:[~2011-10-19 16:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-17 14:26 [PATCH 0/5] oprofile: Updates and fixes for timer modes Robert Richter
2011-10-17 14:27 ` [PATCH 1/5] oprofile, x86: Add kernel parameter Robert Richter
2011-10-17 14:27 ` [PATCH 2/5] oprofile: Fix crash when unloading module (hr timer Robert Richter
2011-10-18  6:12   ` Ingo Molnar
2011-10-17 14:27 ` [PATCH 3/5] oprofile, x86: Fix crash when unloading module (nmi Robert Richter
2011-10-17 14:27 ` [PATCH 4/5] oprofile: Remove exit function for timer mode Robert Richter
2011-10-18  6:13   ` Ingo Molnar
2011-10-19 16:33     ` Robert Richter [this message]
2011-10-17 14:27 ` [PATCH 5/5] oprofile, x86: Reimplement nmi timer mode using perf Robert Richter
2011-10-18 10:59   ` Peter Zijlstra
2011-10-19 16:52     ` Robert Richter
2011-10-19 18:07   ` [PATCH 4/5] oprofile: Remove exit function for timer mode Robert Richter
2011-10-17 15:22 ` [PATCH 0/5] oprofile: Updates and fixes for timer modes Robert Richter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111019163328.GG24346@erda.amd.com \
    --to=robert.richter@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oprofile-list@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox