Messages in this thread Patch in this message | | | Date | Tue, 22 Jun 2004 10:10:57 -0700 | From | William Lee Irwin III <> | Subject | Re: [profile]: [22/23] put 1 << prof_shift at prof_buffer[0] |
| |
On Tue, Jun 22, 2004 at 08:18:10AM -0700, William Lee Irwin III wrote: > Change the profile buffer format so that prof_buffer[0] contains the > stepsize.
And this actually needs to be the following, to fix up an off-by-one and a hunk that migrated to the wrong patch of the series (to be followed by an mmap() patch that actually applies atop this):
Index: prof-2.6.7/kernel/profile.c =================================================================== --- prof-2.6.7.orig/kernel/profile.c 2004-06-22 08:28:11.401782488 -0700 +++ prof-2.6.7/kernel/profile.c 2004-06-22 10:06:59.034645320 -0700 @@ -32,8 +32,9 @@ return; /* only text is profiled */ - prof_len = (_etext - _stext) >> prof_shift; + prof_len = ((unsigned long)(_etext - _stext) >> prof_shift) + 1; prof_buffer = alloc_bootmem(sizeof(atomic_t)*prof_len); + atomic_set(prof_buffer, 1 << prof_shift); } int profiling_on(void) @@ -48,7 +49,7 @@ if (!prof_on) return; idx = (pc - (unsigned long)_stext) >> prof_shift; - atomic_inc(&prof_buffer[min(idx, prof_len - 1)]); + atomic_inc(&prof_buffer[min(idx + 1, prof_len - 1)]); } /* Profile event notifications */ @@ -176,26 +177,14 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos) { unsigned long p = *ppos; - ssize_t read; - char * pnt; - unsigned int sample_step = 1 << prof_shift; - if (p >= (prof_len+1)*sizeof(atomic_t)) + if (p >= sizeof(atomic_t)*prof_len) return 0; - if (count > (prof_len+1)*sizeof(atomic_t) - p) - count = (prof_len+1)*sizeof(atomic_t) - p; - read = 0; - - while (p < sizeof(atomic_t) && count > 0) { - put_user(*((char *)(&sample_step)+p),buf); - buf++; p++; count--; read++; - } - pnt = (char *)prof_buffer + p - sizeof(atomic_t); - if (copy_to_user(buf,(void *)pnt,count)) + count = min(prof_len*sizeof(atomic_t) - p, count); + if (copy_to_user(buf, (char *)prof_buffer + p, count)) return -EFAULT; - read += count; - *ppos += read; - return read; + *ppos += count; + return count; } /* @@ -221,7 +210,7 @@ } #endif - memset(prof_buffer, 0, prof_len*sizeof(atomic_t)); + memset(&prof_buffer[1], 0, (prof_len-1)*sizeof(atomic_t)); return count; } @@ -240,6 +229,6 @@ if (!entry) return; entry->proc_fops = &proc_profile_operations; - entry->size = (1+prof_len) * sizeof(atomic_t); + entry->size = sizeof(atomic_t)*prof_len; } #endif /* CONFIG_PROC_FS */ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |