From 748716613951e9c295215408e287bcd757e79dd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Sandmann=20Pedersen?= Date: Sat, 30 Oct 2004 04:26:32 +0000 Subject: [PATCH] Seems to work --- sysprof-module.c | 14 ++++++++------ sysprof.c | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sysprof-module.c b/sysprof-module.c index ad07eab8..59b51902 100644 --- a/sysprof-module.c +++ b/sysprof-module.c @@ -21,7 +21,7 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Soeren Sandmann (sandmann@daimi.au.dk)"); -#define SAMPLES_PER_SECOND (10) +#define SAMPLES_PER_SECOND (100) #define INTERVAL (HZ / SAMPLES_PER_SECOND) #define N_TRACES 256 @@ -93,7 +93,7 @@ add_timeout(unsigned int interval, static int read_task_address (struct task_struct *task, unsigned long address, int *result) { - unsigned long page_addr = address & PAGE_MASK; + unsigned long page_addr = (address & PAGE_MASK); int found; struct page *page; void *kaddr; @@ -103,14 +103,16 @@ read_task_address (struct task_struct *task, unsigned long address, int *result) return 0; found = get_user_pages (task, task->mm, page_addr, 1, 0, 0, &page, NULL); - if (!found) return 0; - - kaddr = kmap_atomic (page, KM_SOFTIRQ0); - res = ((int *)kaddr)[(address - page_addr) / 4]; + kaddr = kmap_atomic (page, KM_SOFTIRQ0); + if (get_user (res, (int *)kaddr + (address - page_addr) / 4)) { + kunmap_atomic (page, KM_SOFTIRQ0); + return 0; + } + kunmap_atomic (page, KM_SOFTIRQ0); *result = res; diff --git a/sysprof.c b/sysprof.c index b5f527cc..b25206ad 100644 --- a/sysprof.c +++ b/sysprof.c @@ -110,10 +110,12 @@ on_read (gpointer data) rd = read (app->input_fd, &trace, sizeof (trace)); +#if 0 g_print ("pid: %d\n", trace.pid); for (i=0; i < trace.n_addresses; ++i) g_print ("rd: %08x\n", trace.addresses[i]); g_print ("-=-\n"); +#endif if (rd > 0 && app->profiling && !app->generating_profile) {