mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
bitkeeper revision 1.765 (4048b92eZ-VqpZdWj-oHI1tRK9Ft1A)
Update to trace code for new memory protection model.
This commit is contained in:
1 parent
e0cea07f10
commit
ae39e978fc
2 files changed
+22
-11
No files matched your search
@@ -131,19 +131,16 @@ struct t_buf *map_tbufs(unsigned long tbufs_phys, unsigned int num,
|
||||
{
|
||||
int dm_fd; /* file descriptor for /dev/mem */
|
||||
struct t_buf *tbufs_mapped;
|
||||
unsigned int page_size = getpagesize();
|
||||
unsigned int off_in_pg = (tbufs_phys % page_size);
|
||||
|
||||
tbufs_phys -= off_in_pg; /* correct tbufs_phys if not page-aligned */
|
||||
|
||||
dm_fd = open("/dev/mem", O_RDONLY);
|
||||
|
||||
if ( dm_fd < 0 )
|
||||
{
|
||||
PERROR("Open /dev/mem when mapping trace buffers\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
tbufs_mapped = (struct t_buf *)mmap(NULL, size * num + off_in_pg,
|
||||
tbufs_mapped = (struct t_buf *)mmap(NULL, size * num,
|
||||
PROT_READ, MAP_SHARED,
|
||||
dm_fd, (off_t)tbufs_phys);
|
||||
|
||||
@@ -155,8 +152,7 @@ struct t_buf *map_tbufs(unsigned long tbufs_phys, unsigned int num,
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* add offset to get buffers in case original address wasn't pg aligned */
|
||||
return (struct t_buf *)((unsigned long)tbufs_mapped + off_in_pg);
|
||||
return (struct t_buf *)tbufs_mapped;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+19
-4
@@ -49,8 +49,8 @@ int tb_init_done = 0;
|
||||
void init_trace_bufs(void)
|
||||
{
|
||||
extern int opt_tbuf_size;
|
||||
|
||||
int i;
|
||||
int i, pages_order;
|
||||
unsigned long total_size;
|
||||
char *rawbuf;
|
||||
struct t_buf *buf;
|
||||
|
||||
@@ -60,12 +60,27 @@ void init_trace_bufs(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (rawbuf = kmalloc(smp_num_cpus * opt_tbuf_size * PAGE_SIZE,
|
||||
GFP_KERNEL)) == NULL )
|
||||
/* calculate page_order - we'll allocate 2^page_order pages */
|
||||
pages_order = 0;
|
||||
total_size = smp_num_cpus * opt_tbuf_size;
|
||||
|
||||
while( (total_size) >> ( pages_order + 1 ) )
|
||||
pages_order++;
|
||||
|
||||
/* if total_size is not an exact power of two then over-allocate */
|
||||
if( total_size & ~( 1 << pages_order ) )
|
||||
pages_order++;
|
||||
|
||||
/* we allocate 2^page_order pages to hold the data */
|
||||
if ( (rawbuf = (char *)__get_free_pages(GFP_KERNEL, pages_order)) == NULL )
|
||||
{
|
||||
printk("Xen trace buffers: memory allocation failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* share pages so that xentrace can map them */
|
||||
for( i = 0; i < total_size; i++)
|
||||
SHARE_PFN_WITH_DOMAIN( &frame_table[(__pa(rawbuf)>>PAGE_SHIFT)+i], 0);
|
||||
|
||||
for ( i = 0; i < smp_num_cpus; i++ )
|
||||
{
|
||||
|
||||