From: John L. <mov...@us...> - 2001-09-18 10:00:11
|
Update of /cvsroot/oprofile/oprofile In directory usw-pr-cvs1:/tmp/cvs-serv32574 Modified Files: ChangeLog Makefile.in op_syscalls.c oprofile.c oprofile.h Added Files: op_util.c Log Message: nothing interesting ... --- NEW FILE: op_util.c --- /* COPYRIGHT (C) 2000,2001 THE VICTORIA UNIVERSITY OF MANCHESTER and John Levon * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <linux/vmalloc.h> #include <linux/wrapper.h> /* Given PGD from the address space's page table, return the kernel * virtual mapping of the physical memory mapped at ADR. */ static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr) { unsigned long ret = 0UL; pmd_t *pmd; pte_t *ptep, pte; if (!pgd_none(*pgd)) { pmd = pmd_offset(pgd, adr); if (!pmd_none(*pmd)) { ptep = pte_offset(pmd, adr); pte = *ptep; if(pte_present(pte)) { ret = (unsigned long) page_address(pte_page(pte)); ret |= (adr & (PAGE_SIZE - 1)); } } } return ret; } /* Here we want the physical address of the memory. * This is used when initializing the contents of the * area and marking the pages as reserved. */ unsigned long kvirt_to_pa(unsigned long adr) { unsigned long va, kva, ret; va = VMALLOC_VMADDR(adr); kva = uvirt_to_kva(pgd_offset_k(va), va); ret = __pa(kva); return ret; } void * rvmalloc(signed long size) { void * mem; unsigned long adr, page; mem=vmalloc_32(size); if (!mem) return NULL; memset(mem, 0, size); adr=(unsigned long) mem; while (size > 0) { page = kvirt_to_pa(adr); mem_map_reserve(virt_to_page(__va(page))); adr += PAGE_SIZE; size -= PAGE_SIZE; } return mem; } void rvfree(void * mem, signed long size) { unsigned long adr, page; if (!mem) return; adr=(unsigned long) mem; while (size > 0) { page = kvirt_to_pa(adr); mem_map_unreserve(virt_to_page(__va(page))); adr += PAGE_SIZE; size -= PAGE_SIZE; } vfree(mem); } Index: ChangeLog =================================================================== RCS file: /cvsroot/oprofile/oprofile/ChangeLog,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -r1.122 -r1.123 --- ChangeLog 2001/09/18 02:16:55 1.122 +++ ChangeLog 2001/09/18 10:00:07 1.123 @@ -1,5 +1,14 @@ 2001-09-18 John Levon <mo...@co...> + * Makefile.in: + * op_syscalls.c: + * op_util.c: + * oprofile.h: move some code around + + * oprofile.c: fix a tiny bug + +2001-09-18 John Levon <mo...@co...> + * dae/opd_proc.c: * dae/oprofiled.h: implement hashing of images Index: Makefile.in =================================================================== RCS file: /cvsroot/oprofile/oprofile/Makefile.in,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Makefile.in 2001/09/15 20:55:45 1.26 +++ Makefile.in 2001/09/18 10:00:07 1.27 @@ -74,13 +74,16 @@ KCFLAGS := $(BKCFLAGS) -march=i686 ASMFLAGS := -D__ASSEMBLY__ -DMODULE -D__KERNEL__ -traditional -oprofile.o: op_init.o oprofile_c.o oprofile_nmi.o op_syscalls.o op_events.o op_x86.o +oprofile.o: op_init.o op_util.o oprofile_c.o oprofile_nmi.o op_syscalls.o op_events.o op_x86.o ld -r -o $@ op_init.o oprofile_c.o oprofile_nmi.o op_syscalls.o op_events.o op_x86.o oprofile.h: op_user.h version.h op_init.o: op_init.c oprofile.h $(CC) $(BKCFLAGS) -c -o $@ $< + +op_util.o: op_util.c + $(CC) $(KCFLAGS) -c -o $@ $< oprofile_c.o: oprofile.c oprofile.h $(CC) $(KCFLAGS) -c -o $@ $< Index: op_syscalls.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/op_syscalls.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- op_syscalls.c 2001/09/18 01:00:33 1.18 +++ op_syscalls.c 2001/09/18 10:00:07 1.19 @@ -19,93 +19,13 @@ #include <linux/unistd.h> #include <linux/mman.h> #include <linux/file.h> -#include <linux/wrapper.h> - -#include <asm/io.h> #include "oprofile.h" -extern u32 oprof_ready[NR_CPUS]; -extern wait_queue_head_t oprof_wait; extern pid_t pid_filter; extern pid_t pgrp_filter; extern u32 prof_on; -/* Given PGD from the address space's page table, return the kernel - * virtual mapping of the physical memory mapped at ADR. - */ -static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr) -{ - unsigned long ret = 0UL; - pmd_t *pmd; - pte_t *ptep, pte; - - if (!pgd_none(*pgd)) { - pmd = pmd_offset(pgd, adr); - if (!pmd_none(*pmd)) { - ptep = pte_offset(pmd, adr); - pte = *ptep; - if(pte_present(pte)) { - ret = (unsigned long) page_address(pte_page(pte)); - ret |= (adr & (PAGE_SIZE - 1)); - } - } - } - return ret; -} - -/* Here we want the physical address of the memory. - * This is used when initializing the contents of the - * area and marking the pages as reserved. - */ -static inline unsigned long kvirt_to_pa(unsigned long adr) -{ - unsigned long va, kva, ret; - - va = VMALLOC_VMADDR(adr); - kva = uvirt_to_kva(pgd_offset_k(va), va); - ret = __pa(kva); - return ret; -} - -static void * rvmalloc(signed long size) -{ - void * mem; - unsigned long adr, page; - - mem=vmalloc_32(size); - if (!mem) - return NULL; - - memset(mem, 0, size); - - adr=(unsigned long) mem; - while (size > 0) { - page = kvirt_to_pa(adr); - mem_map_reserve(virt_to_page(__va(page))); - adr += PAGE_SIZE; - size -= PAGE_SIZE; - } - return mem; -} - -static void rvfree(void * mem, signed long size) -{ - unsigned long adr, page; - - if (!mem) - return; - - adr=(unsigned long) mem; - while (size > 0) { - page = kvirt_to_pa(adr); - mem_map_unreserve(virt_to_page(__va(page))); - adr += PAGE_SIZE; - size -= PAGE_SIZE; - } - vfree(mem); -} - static uint dname_top; static struct qstr **dname_stack; static uint hash_map_open; @@ -443,7 +363,7 @@ (pgrp_filter && current->pgrp != pgrp_filter)) goto out; - if ((prot&PROT_EXEC) && ret >= 0) + if ((prot & PROT_EXEC) && ret >= 0) out_mmap(ret, len, prot, flags, fd, pgoff << PAGE_SHIFT); goto out; out: Index: oprofile.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/oprofile.c,v retrieving revision 1.89 retrieving revision 1.90 diff -u -d -r1.89 -r1.90 --- oprofile.c 2001/09/18 01:00:33 1.89 +++ oprofile.c 2001/09/18 10:00:07 1.90 @@ -429,6 +429,20 @@ return 0; } +static int check_buffer_amount(struct _oprof_data * data) +{ + int size = data->buf_size; + int num = data->nextbuf; + if (num < size - OP_PRE_WATERMARK && oprof_ready[cpu_num] != 2) { + printk(KERN_ERR "oprofile: Detected overflow of size %d. You must increase the " + "hash table size or reduce the interrupt frequency (%d)\n", + num, oprof_ready[cpu_num]); + num = size; + } else + data->nextbuf=0; + return num; +} + static int oprof_read(struct file *file, char *buf, size_t count, loff_t *ppos) { struct op_sample *mybuf; @@ -451,7 +465,7 @@ if (*ppos || count != sizeof(struct op_sample) + max) return -EINVAL; - mybuf = vmalloc(sizeof(struct op_sample) + max); + mybuf = vmalloc(max); if (!mybuf) return -EFAULT; @@ -469,20 +483,14 @@ pmc_select_stop(cpu_num); spin_lock(¬e_lock); - num = oprof_data[cpu_num].nextbuf; - /* might have overflowed from map buffer or ejection buffer */ - if (num < oprof_data[cpu_num].buf_size-OP_PRE_WATERMARK && oprof_ready[cpu_num] != 2) { - printk(KERN_ERR "oprofile: Detected overflow of size %d. You must increase the " - "hash table size or reduce the interrupt frequency (%d)\n", - num, oprof_ready[cpu_num]); - num = oprof_data[cpu_num].buf_size; - } else - oprof_data[cpu_num].nextbuf=0; - + /* buffer might have overflowed */ + num = check_buffer_amount(&oprof_data[cpu_num]); + oprof_ready[cpu_num] = 0; count = num * sizeof(struct op_sample); + /* FIXME: can eliminate this bounce buffer when note_lock dies */ if (count) memcpy(mybuf, oprof_data[cpu_num].buffer, count); Index: oprofile.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/oprofile.h,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- oprofile.h 2001/09/18 01:00:33 1.53 +++ oprofile.h 2001/09/18 10:00:07 1.54 @@ -209,6 +209,9 @@ extern uint perfctr_msr[OP_MAX_COUNTERS]; extern uint eventsel_msr[OP_MAX_COUNTERS]; +void * rvmalloc(signed long size); +void rvfree(void * mem, signed long size); +unsigned long kvirt_to_pa(unsigned long adr); int oprof_init(void); void oprof_exit(void); void my_set_fixmap(void); |