From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap 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 Message-ID: References: <8ac937fa527b28243227.1305037956@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <8ac937fa527b28243227.1305037956@localhost> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Olaf Hering Cc: xen-devel@lists.xensource.com, George Dunlap List-Id: xen-devel@lists.xenproject.org Acked-by: George Dunlap Sorry for the delay! -George On Tue, May 10, 2011 at 3:32 PM, Olaf Hering wrote: > # HG changeset patch > # User Olaf Hering > # Date 1305037380 -7200 > # Node ID 8ac937fa527b28243227193bf4749feb3a234c2c > # Parent =A019452acd23045f40c4e18437f0a60f016757e5bd > 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 > > diff -r 19452acd2304 -r 8ac937fa527b xen/common/trace.c > --- a/xen/common/trace.c =A0 =A0 =A0 =A0Fri May 06 11:15:35 2011 +0100 > +++ b/xen/common/trace.c =A0 =A0 =A0 =A0Tue May 10 16:23:00 2011 +0200 > @@ -112,11 +112,14 @@ static int calculate_tbuf_size(unsigned > =A0 =A0 typeof(dummy_size.prod) max_size; > =A0 =A0 struct t_info dummy_pages; > =A0 =A0 typeof(dummy_pages.tbuf_size) max_pages; > + =A0 =A0typeof(dummy_pages.mfn_offset[0]) max_mfn_offset; > + =A0 =A0unsigned int max_cpus =3D num_online_cpus(); > =A0 =A0 unsigned int t_info_words; > > =A0 =A0 /* force maximum value for an unsigned type */ > =A0 =A0 max_size =3D -1; > =A0 =A0 max_pages =3D -1; > + =A0 =A0max_mfn_offset =3D -1; > > =A0 =A0 /* max size holds up to n pages */ > =A0 =A0 max_size /=3D PAGE_SIZE; > @@ -124,6 +127,18 @@ static int calculate_tbuf_size(unsigned > =A0 =A0 if ( max_size < max_pages ) > =A0 =A0 =A0 =A0 max_pages =3D max_size; > > + =A0 =A0/* > + =A0 =A0 * max mfn_offset holds up to n pages per cpu > + =A0 =A0 * The array of mfns for the highest cpu can start at the maximu= m value > + =A0 =A0 * mfn_offset can hold. So reduce the number of cpus and also th= e mfn_offset. > + =A0 =A0 */ > + =A0 =A0max_mfn_offset -=3D t_info_first_offset - 1; > + =A0 =A0max_cpus--; > + =A0 =A0if ( max_cpus ) > + =A0 =A0 =A0 =A0max_mfn_offset /=3D max_cpus; > + =A0 =A0if ( max_mfn_offset < max_pages ) > + =A0 =A0 =A0 =A0max_pages =3D max_mfn_offset; > + > =A0 =A0 if ( pages > max_pages ) > =A0 =A0 { > =A0 =A0 =A0 =A0 printk(XENLOG_INFO "xentrace: requested number of %u page= s " > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel >