From: George Dunlap <dunlapg@umich.edu>
To: Olaf Hering <olaf@aepfle.de>
Cc: xen-devel@lists.xensource.com, George Dunlap <george.dunlap@citrix.com>
Subject: Re: [PATCH 1 of 4] xentrace: reduce trace buffer size to something mfn_offset can reach
Date: Thu, 26 May 2011 11:05:14 +0100 [thread overview]
Message-ID: <BANLkTinfAJZgDgiM9wzhuGR+c0eOa4mcYA@mail.gmail.com> (raw)
In-Reply-To: <8ac937fa527b28243227.1305037956@localhost>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Sorry for the delay!
-George
On Tue, May 10, 2011 at 3:32 PM, Olaf Hering <olaf@aepfle.de> wrote:
> # HG changeset patch
> # User Olaf Hering <olaf@aepfle.de>
> # Date 1305037380 -7200
> # Node ID 8ac937fa527b28243227193bf4749feb3a234c2c
> # Parent 19452acd23045f40c4e18437f0a60f016757e5bd
> xentrace: reduce trace buffer size to something mfn_offset can reach
>
> The start of the array which holds the list of mfns for each cpus
> tracebuffer is stored in an unsigned short. This limits the total amount
> of pages for each cpu as the number of active cpus increases.
>
> Update the math in calculate_tbuf_size() to apply also this rule to the
> max number of trace pages. Without this change the index can overflow.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
>
> diff -r 19452acd2304 -r 8ac937fa527b xen/common/trace.c
> --- a/xen/common/trace.c Fri May 06 11:15:35 2011 +0100
> +++ b/xen/common/trace.c Tue May 10 16:23:00 2011 +0200
> @@ -112,11 +112,14 @@ static int calculate_tbuf_size(unsigned
> typeof(dummy_size.prod) max_size;
> struct t_info dummy_pages;
> typeof(dummy_pages.tbuf_size) max_pages;
> + typeof(dummy_pages.mfn_offset[0]) max_mfn_offset;
> + unsigned int max_cpus = num_online_cpus();
> unsigned int t_info_words;
>
> /* force maximum value for an unsigned type */
> max_size = -1;
> max_pages = -1;
> + max_mfn_offset = -1;
>
> /* max size holds up to n pages */
> max_size /= PAGE_SIZE;
> @@ -124,6 +127,18 @@ static int calculate_tbuf_size(unsigned
> if ( max_size < max_pages )
> max_pages = max_size;
>
> + /*
> + * max mfn_offset holds up to n pages per cpu
> + * The array of mfns for the highest cpu can start at the maximum value
> + * mfn_offset can hold. So reduce the number of cpus and also the mfn_offset.
> + */
> + max_mfn_offset -= t_info_first_offset - 1;
> + max_cpus--;
> + if ( max_cpus )
> + max_mfn_offset /= max_cpus;
> + if ( max_mfn_offset < max_pages )
> + max_pages = max_mfn_offset;
> +
> if ( pages > max_pages )
> {
> printk(XENLOG_INFO "xentrace: requested number of %u pages "
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
>
next prev parent reply other threads:[~2011-05-26 10:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 14:32 [PATCH 0 of 4] xentrace [v2]: non-contiguous allocation of per-cpu buffer Olaf Hering
2011-05-10 14:32 ` [PATCH 1 of 4] xentrace: reduce trace buffer size to something mfn_offset can reach Olaf Hering
2011-05-26 10:05 ` George Dunlap [this message]
2011-05-10 14:32 ` [PATCH 2 of 4] xentrace: fix type of offset to avoid ouf-of-bounds access Olaf Hering
2011-05-26 10:05 ` George Dunlap
2011-05-10 14:32 ` [PATCH 3 of 4] xentrace: update __insert_record() to copy the trace record to individual mfns Olaf Hering
2011-05-26 10:06 ` George Dunlap
2011-05-10 14:32 ` [PATCH 4 of 4] xentrace: allocate non-contiguous per-cpu trace buffers Olaf Hering
2011-05-26 10:06 ` George Dunlap
2011-05-20 8:36 ` [PATCH 0 of 4] xentrace [v2]: non-contiguous allocation of per-cpu buffer Keir Fraser
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTinfAJZgDgiM9wzhuGR+c0eOa4mcYA@mail.gmail.com \
--to=dunlapg@umich.edu \
--cc=george.dunlap@citrix.com \
--cc=olaf@aepfle.de \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).