All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: "Randy.Dunlap" <rddunlap@osdl.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [announce/OT] kerneltop ver. 0.7
Date: Sun, 23 May 2004 22:31:53 -0700	[thread overview]
Message-ID: <20040524053153.GM1833@holomorphy.com> (raw)
In-Reply-To: <20040523215027.5dc99711.rddunlap@osdl.org>

On Sun, May 23, 2004 at 09:50:27PM -0700, Randy.Dunlap wrote:
> just a little note about kerneltop...
> 'kerneltop' is similar to 'top', but shows only kernel function usage
> (modules not included).
> I have updated it a bit (now version 0.7) and made sure that it
> works OK on Linux 2.6.x.
> It's available here:
> 	http://www.xenotime.net/linux/kerneltop/

GRRR.. this tries to reset /proc/profile. Multiple megabytes of in-
kernel memset() at a frequency of 1Hz are extremely unfriendly.


--- kerneltop.c.orig	2004-05-23 22:11:29.000000000 -0700
+++ kerneltop.c	2004-05-23 22:22:08.000000000 -0700
@@ -491,32 +491,6 @@ int do_key(char c)
 } // end do_key
 
 
-/* reset the profile buffer after each read of it */
-static void profile_reset (void)
-{
-	int multiplier, fd, to_write;
-
-	/*
-	 * When writing the multiplier, if the length of the write is
-	 * not sizeof(int), the multiplier is not changed.
-	 */
-	multiplier = 0;
-	to_write = 1;	/* smth different from sizeof(int) */
-	/* try to become root, just in case */
-	setuid (0);
-	fd = open (defaultpro, O_WRONLY);
-	if (fd < 0) {
-		perror (defaultpro);
-		exit (1);
-	}
-	if (write (fd, &multiplier, to_write) != to_write) {
-		fprintf (stderr, "kerneltop: error writing %s: %s\n",
-			defaultpro, strerror (errno));
-		exit (1);
-	}
-	close (fd);
-} // end profile_reset
-
 /*
  * allocates <buf> for the profile data;
  * returns buffer length;
@@ -753,7 +727,7 @@ main (int argc, char **argv) {
 	char *mapFile, *proFile;
 	unsigned long len = 0;
 	unsigned int step;
-	unsigned int *buf;
+	unsigned int *lastbuf, *buf = NULL;
 	int opt;
 	int optReverse = 0, optProfile = 0;
 	time_t timer;
@@ -824,10 +798,8 @@ main (int argc, char **argv) {
 	heading ();
 
     while (1) {		// get profile data, put it into symbol buckets, print
-
+	lastbuf = buf;
 	len = profile_read (proFile, &buf); // allocates buf & returns its len
-	if (!optProfile)		// don't reset if using non-default file
-		profile_reset ();
 	step = buf[0];
 	vid_curpos (ROW_SAMPLING_RANGE, 1);
 	printf (_("Sampling_step: %i | Address range: 0x%lx - 0x%lx\n"),
@@ -863,7 +835,7 @@ main (int argc, char **argv) {
 	// collect frequency histogram of profile buf.
 	for (ix = 0, lookup_last = 0; ix < mx; ix++) {
 		adr = adr0 + step * ix;
-		ticks = buf [ix + 1];
+		ticks = buf [ix + 1] - (lastbuf ? lastbuf [ix + 1] : 0);
 		total_ticks += ticks;
 		fnx = lookup (adr);
 		if (fnx >= 0)
@@ -897,7 +869,7 @@ main (int argc, char **argv) {
 	total_ticks = 0;
 	// clear freqs for next pass
 	memset (freqs, 0, sizeof(int) * (text_lines + 1));
-	free (buf);	// before next profile_read call
+	free (lastbuf);	// before next profile_read call
 
 	// check for stdin (keyboard) input 1x per second
 	// while sleeping for <sleep_seconds>
@@ -910,6 +882,7 @@ main (int argc, char **argv) {
 	}
 
     } // end while 1
+    free (buf);
 
 fini:
 	printf("\n");

  reply	other threads:[~2004-05-24  5:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-24  4:50 [announce/OT] kerneltop ver. 0.7 Randy.Dunlap
2004-05-24  5:31 ` William Lee Irwin III [this message]
2004-05-24  9:55   ` Cef (LKML)
2004-05-24 21:49     ` Randy.Dunlap
2004-05-24 21:47   ` Randy.Dunlap
2004-05-24  5:53 ` Cef (LKML)
2004-05-24  6:00   ` William Lee Irwin III
2004-05-24  7:18     ` Cef (LKML)
2004-05-25 19:12     ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2004-05-24 23:20 Albert Cahalan

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=20040524053153.GM1833@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rddunlap@osdl.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.