|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] [PATCH] Fix check of XENOPROF_get_buffer and XENOPROF_set_pa
Fix code limiting XENOPROF_get_buffer and XENOPROF_set_passive
argument max_samples so that no more than MAX_OPROF_SHARED_PAGES are
used.
Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
---
A few quick tests comparing old to new code:
old code new code
arg checked npages checked npages
0 0 1 0 1
1 1 1 1 1
5457 5457 32 5457 32
5458 5457 32 5457 32
2000000000 2000000000 184415 5457 32
2147483647 2147483647 1 5457 32
-1 -1 1 5457 32
diff -r efea4c3b8bcc xen/arch/x86/oprofile/xenoprof.c
--- a/xen/arch/x86/oprofile/xenoprof.c Fri Oct 13 17:10:27 2006 +0100
+++ b/xen/arch/x86/oprofile/xenoprof.c Fri Oct 13 19:44:01 2006 +0200
@@ -122,6 +122,7 @@ int alloc_xenoprof_struct(struct domain
{
struct vcpu *v;
int nvcpu, npages, bufsize, max_bufsize;
+ unsigned max_max_samples;
int i;
d->xenoprof = xmalloc(struct xenoprof);
@@ -139,17 +140,15 @@ int alloc_xenoprof_struct(struct domain
for_each_vcpu ( d, v )
nvcpu++;
- /* reduce buffer size if necessary to limit pages allocated */
+ /* reduce max_samples if necessary to limit pages allocated */
+ max_bufsize = (MAX_OPROF_SHARED_PAGES * PAGE_SIZE) / nvcpu;
+ max_max_samples = ( (max_bufsize - sizeof(struct xenoprof_buf)) /
+ sizeof(struct event_log) ) + 1;
+ if ( (unsigned)max_samples > max_max_samples )
+ max_samples = max_max_samples;
+
bufsize = sizeof(struct xenoprof_buf) +
(max_samples - 1) * sizeof(struct event_log);
- max_bufsize = (MAX_OPROF_SHARED_PAGES * PAGE_SIZE) / nvcpu;
- if ( bufsize > max_bufsize )
- {
- bufsize = max_bufsize;
- max_samples = ( (max_bufsize - sizeof(struct xenoprof_buf)) /
- sizeof(struct event_log) ) + 1;
- }
-
npages = (nvcpu * bufsize - 1) / PAGE_SIZE + 1;
d->xenoprof->rawbuf = alloc_xenoprof_buf(is_passive ? dom0 : d, npages);
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread> |
- [Xen-devel] [PATCH] Fix check of XENOPROF_get_buffer and XENOPROF_set_passive argument max_samples,
Markus Armbruster <=
|
|
|
|
|