public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: David Evensky <evensky@dancer.ca.sandia.gov>
To: Pekka Enberg <penberg@kernel.org>
Cc: Sasha Levin <levinsasha928@gmail.com>, kvm@vger.kernel.org
Subject: Re: [PATCH] kvm tools: adds a PCI device that exports a host shared segment as a PCI BAR in the guest
Date: Wed, 24 Aug 2011 23:11:58 -0700	[thread overview]
Message-ID: <20110825061158.GD24996@dancer.ca.sandia.gov> (raw)
In-Reply-To: <CAOJsxLHwnWu0Dto6reWxed6ozwd4U4fH8rQ=xUzpj8N7cm+oAA@mail.gmail.com>

On Thu, Aug 25, 2011 at 09:02:56AM +0300, Pekka Enberg wrote:
> On Thu, Aug 25, 2011 at 1:25 AM, David Evensky <evensky@sandia.gov> wrote:
> > + ? ? ? if (*next == '\0')
> > + ? ? ? ? ? ? ? p = next;
> > + ? ? ? else
> > + ? ? ? ? ? ? ? p = next + 1;
> > + ? ? ? /* parse out size */
> > + ? ? ? base = 10;
> > + ? ? ? if (strcasestr(p, "0x"))
> > + ? ? ? ? ? ? ? base = 16;
> > + ? ? ? size = strtoll(p, &next, base);
> > + ? ? ? if (next == p && size == 0) {
> > + ? ? ? ? ? ? ? pr_info("shmem: no size specified, using default.");
> > + ? ? ? ? ? ? ? size = default_size;
> > + ? ? ? }
> > + ? ? ? /* look for [KMGkmg][Bb]* ?uses base 2. */
> > + ? ? ? int skip_B = 0;
> > + ? ? ? if (strspn(next, "KMGkmg")) { ? /* might have a prefix */
> > + ? ? ? ? ? ? ? if (*(next + 1) == 'B' || *(next + 1) == 'b')
> > + ? ? ? ? ? ? ? ? ? ? ? skip_B = 1;
> > + ? ? ? ? ? ? ? switch (*next) {
> > + ? ? ? ? ? ? ? case 'K':
> > + ? ? ? ? ? ? ? case 'k':
> > + ? ? ? ? ? ? ? ? ? ? ? size = size << KB_SHIFT;
> > + ? ? ? ? ? ? ? ? ? ? ? break;
> > + ? ? ? ? ? ? ? case 'M':
> > + ? ? ? ? ? ? ? case 'm':
> > + ? ? ? ? ? ? ? ? ? ? ? size = size << MB_SHIFT;
> > + ? ? ? ? ? ? ? ? ? ? ? break;
> > + ? ? ? ? ? ? ? case 'G':
> > + ? ? ? ? ? ? ? case 'g':
> > + ? ? ? ? ? ? ? ? ? ? ? size = size << GB_SHIFT;
> > + ? ? ? ? ? ? ? ? ? ? ? break;
> > + ? ? ? ? ? ? ? default:
> > + ? ? ? ? ? ? ? ? ? ? ? die("shmem: bug in detecting size prefix.");
> > + ? ? ? ? ? ? ? ? ? ? ? break;
> > + ? ? ? ? ? ? ? }
> 
> There's some nice code in perf to parse sizes like this. We could just
> steal that.

That sounds good to me.

> > +inline void fill_mem(void *buf, size_t buf_size, char *fill, size_t fill_len)
> > +{
> > + ? ? ? size_t i;
> > +
> > + ? ? ? if (fill_len == 1) {
> > + ? ? ? ? ? ? ? memset(buf, fill[0], buf_size);
> > + ? ? ? } else {
> > + ? ? ? ? ? ? ? if (buf_size > fill_len) {
> > + ? ? ? ? ? ? ? ? ? ? ? for (i = 0; i < buf_size - fill_len; i += fill_len)
> > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? memcpy(((char *)buf) + i, fill, fill_len);
> > + ? ? ? ? ? ? ? ? ? ? ? memcpy(buf + i, fill, buf_size - i);
> > + ? ? ? ? ? ? ? } else {
> > + ? ? ? ? ? ? ? ? ? ? ? memcpy(buf, fill, buf_size);
> > + ? ? ? ? ? ? ? }
> > + ? ? ? }
> > +}
> 
> Can we do a memset_pattern4() type of interface instead? I think it's
> mostly pointless to try to support arbitrary-length 'fill'.

Yeah, I can see how the arbitrary fill thing might be too cute. It
certainly isn't necessary.

  reply	other threads:[~2011-08-25  6:12 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-24 22:25 [PATCH] kvm tools: adds a PCI device that exports a host shared segment as a PCI BAR in the guest David Evensky
2011-08-25  3:27 ` Alexander Graf
2011-08-25  4:49   ` David Evensky
2011-08-25  4:52     ` Alexander Graf
2011-08-25  5:11       ` Pekka Enberg
     [not found]         ` <A16CB574-D2F7-440B-BD26-12EB4DEAD917@suse.de>
2011-08-25  5:37           ` Pekka Enberg
2011-08-25  5:38             ` Alexander Graf
2011-08-25  5:06     ` Pekka Enberg
2011-08-25  5:49       ` David Evensky
2011-08-25 10:31       ` Stefan Hajnoczi
2011-08-25 10:37         ` Pekka Enberg
2011-08-25 10:59           ` Stefan Hajnoczi
2011-08-25 11:15             ` Pekka Enberg
2011-08-25 11:30               ` Avi Kivity
2011-08-25 11:38                 ` Pekka Enberg
2011-08-25 11:51                   ` Avi Kivity
2011-08-25 12:01                     ` Pekka Enberg
2011-08-25 11:51                 ` Sasha Levin
2011-08-25 11:25             ` Sasha Levin
2011-08-25 15:08               ` David Evensky
2011-08-25 22:08                 ` Eric Northup
2011-08-25 22:27                   ` David Evensky
2011-08-26  6:33                 ` Sasha Levin
2011-08-26 15:05                   ` David Evensky
     [not found]               ` <30669_1314285268_p7PFESZN013126_20110825150806.GF24996@dancer.ca.sandia.gov>
2011-08-25 21:00                 ` David Evensky
2011-08-25 21:11                   ` Avi Kivity
2011-08-25 22:03                     ` David Evensky
2011-08-28  7:34                       ` Avi Kivity
2011-08-29  4:55                         ` David Evensky
2011-08-25  5:41 ` Avi Kivity
2011-08-25  6:01   ` David Evensky
2011-08-25  6:02 ` Pekka Enberg
2011-08-25  6:11   ` David Evensky [this message]
     [not found] ` <CAFO3S41WOutTEmMGAeor6w=OZ_cax_AHB7Wo24jfUioynv3DFg@mail.gmail.com>
     [not found]   ` <4E55E378.4060904@kernel.org>
2011-08-25  6:30     ` Asias He
2011-08-25  7:02       ` Pekka Enberg
2011-08-25  7:20         ` Asias He
2011-08-25  7:24           ` Pekka Enberg
2011-08-25 21:35 ` Anthony Liguori
2011-08-25 21:50   ` David Evensky
2011-08-26  6:11   ` Sasha Levin

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=20110825061158.GD24996@dancer.ca.sandia.gov \
    --to=evensky@dancer.ca.sandia.gov \
    --cc=kvm@vger.kernel.org \
    --cc=levinsasha928@gmail.com \
    --cc=penberg@kernel.org \
    /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