From: George Dunlap <george.dunlap@citrix.com>
To: Olaf Hering <olaf@aepfle.de>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 2 of 3] xentrace: use tbuf_size for overflow check
Date: Fri, 01 Apr 2011 12:18:11 +0100 [thread overview]
Message-ID: <1301656691.9447.88.camel@elijah> (raw)
In-Reply-To: <3e95e737bc51c2295926.1301508274@localhost>
On Wed, 2011-03-30 at 19:04 +0100, Olaf Hering wrote:
> # HG changeset patch
> # User Olaf Hering <olaf@aepfle.de>
> # Date 1301424075 -7200
> # Node ID 3e95e737bc51c2295926e4f23389b1cb161d6d7b
> # Parent 8a2ce5e49b2c5f2e013734b5d53eae37572f4101
> xentrace: use tbuf_size for overflow check
>
> The calculated number of per-cpu trace pages is stored in t_info and
> shared with tools like xentrace. Since its an u16 the value may overflow
> because the current check is based on u32.
Hmm -- while this is true, it's possible this may change in the future.
If we ever changed t_info.tbuf_size to be u32, then t_buf.prod/cons
would again be the limiting factor.
Should we perhaps add both checks?
> Using the u16 means each cpu could in theory use up to 256MB as trace
> buffer. However such a large allocation will currently fail on x86 due
> to the MAX_ORDER limit.
FWIW, I don't believe that there's any reason the allocations have to be
contiguous any more. I kept them contiguous to minimize the changes to
the moving parts near a release. But the new system has been pretty
well tested now, so I think looking at non-contiguous allocations may be
worthwhile.
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
>
> diff -r 8a2ce5e49b2c -r 3e95e737bc51 xen/common/trace.c
> --- a/xen/common/trace.c Tue Mar 29 20:37:20 2011 +0200
> +++ b/xen/common/trace.c Tue Mar 29 20:41:15 2011 +0200
> @@ -104,25 +104,26 @@
> * calculate_tbuf_size - check to make sure that the proposed size will fit
> * in the currently sized struct t_info and allows prod and cons to
> * reach double the value without overflow.
> + * tbuf_size is u16, while t_buf prod/cons are u32, so using tbuf_size for
> + * overflow check is good.
> + * The t_info layout is fixed and cant be changed without breaking xentrace.
> * Initialize t_info_pages based on number of trace pages.
> */
> static int calculate_tbuf_size(unsigned int pages)
> {
> - struct t_buf dummy;
> - typeof(dummy.prod) size;
> + struct t_info dummy;
> + typeof(dummy.tbuf_size) max_pages;
> unsigned int t_info_words;
>
> /* force maximum value for an unsigned type */
> - size = -1;
> + max_pages = -1;
>
> - /* max size holds up to n pages */
> - size /= PAGE_SIZE;
> - if ( pages > size )
> + if ( pages > max_pages )
> {
> printk(XENLOG_INFO "xentrace: requested number of %u pages "
> "reduced to %u\n",
> - pages, (unsigned int)size);
> - pages = size;
> + pages, max_pages);
> + pages = max_pages;
> }
>
> t_info_words = num_online_cpus() * pages * sizeof(uint32_t);
next prev parent reply other threads:[~2011-04-01 11:18 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 18:04 [PATCH 0 of 3] xentrace updates Olaf Hering
2011-03-30 18:04 ` [PATCH 1 of 3] xentrace: correct formula to calculate t_info_pages Olaf Hering
2011-04-01 10:32 ` George Dunlap
2011-03-30 18:04 ` [PATCH 2 of 3] xentrace: use tbuf_size for overflow check Olaf Hering
2011-04-01 11:18 ` George Dunlap [this message]
2011-04-05 10:19 ` Olaf Hering
2011-04-07 13:50 ` Olaf Hering
2011-04-18 18:45 ` non-contiguous allocations Olaf Hering
2011-04-26 11:51 ` Jan Beulich
2011-05-06 10:25 ` Olaf Hering
2011-05-06 10:45 ` Jan Beulich
2011-05-06 18:12 ` Olaf Hering
2011-05-06 18:46 ` Keir Fraser
2011-05-07 8:39 ` Olaf Hering
2011-05-07 16:31 ` Keir Fraser
2011-05-09 8:30 ` Jan Beulich
2011-05-09 8:34 ` Keir Fraser
2011-05-09 12:43 ` Olaf Hering
2011-05-09 14:14 ` Keir Fraser
2011-03-30 18:04 ` [PATCH 3 of 3] xentrace: remove unneeded debug printk Olaf Hering
2011-04-01 11:18 ` George Dunlap
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=1301656691.9447.88.camel@elijah \
--to=george.dunlap@citrix.com \
--cc=George.Dunlap@eu.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).