All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Xen Development Mailing List <xen-devel@lists.xensource.com>
Subject: Re: Re: pv_ops & gntdev?
Date: Wed, 04 Mar 2009 09:18:53 +0100	[thread overview]
Message-ID: <49AE396D.2090503@redhat.com> (raw)
In-Reply-To: <49ADB656.7080404@goop.org>

Jeremy Fitzhardinge wrote:
> Do you have a test program?

Qemu with xen support, including userspace backends for disk & nic which
use gntdev.

Grab it here:
http://git.et.redhat.com/?p=qemu-kraxel.git;a=shortlog;h=refs/heads/xenbits.v0

usage:
qemu -M xenpv -xen-create -uuid $(uuidgen) \
  -kernel <bzImage> -initrd <initrd> \
  -drive media=disk,if=xen,file=<diskimage> \
  -net nic,model=xen,macaddr=<addr> \
  -serial <yourconsolehere>

> Comments below.  There's quite a bit of whitespace damage and formatting
> strangeness (NULL == tests, for example).  I've checked in a couple of
> followup patches to address some of the comments below, but not all.

Ok, I'll grab a fresh checkout and go over it.

>> +        up_write(&priv->sem);
>> +                kfree(add);
>>   
> Leaks ->grants, ->map_ops, ->unmap_ops?

Yep.

>> +    u64 mpte;
>>   
> pteval_t or pte_t

Well, gnttab_set_map_op() wants u64 there, thats why I did it that way.

>> +    BUG_ON(pgnr >= map->count);
>> +    mpte  = (u64)pfn_to_mfn(page_to_pfn(token)) << PAGE_SHIFT;
>> +    mpte |= (unsigned long)pte & ~PAGE_MASK;
>>   
> (!) You're casting pte_t * to unsigned long, masking off the lower bits
> then oring them into your pte.  That doesn't look like it will mean very
> much...  I guess this explains your not-unmapping bug.
> 
> This should probably be using mfn_pte() anyway:
> 
>     mfn = pfn_to_mfn(page_to_pfn(token));
>     pgprot = __pgprot(pte->pte & PTE_FLAGS_MASK);
>     mpte = mfn_pte(mfn, pgprot);

Looks better indeed.  Unclean stuff carried over from 2.6.18 ...

>> +        BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
>> +                     map->map_ops, map->count));
>>   
> WARN_ON() is better here, because we can probably limp on if it fails.

Agree.

>> +static long gntdev_ioctl(struct file *flip,
>> +             unsigned int cmd, unsigned long arg)
>> +{
>> +        struct gntdev_priv *priv = flip->private_data;
>> +        void __user *ptr = (void __user *)arg;
>> +
>> +    switch (cmd) {
>> +    case IOCTL_GNTDEV_MAP_GRANT_REF:
>>   
> ioctl switches should be split into separate functions.

All of them or just the larger ones?

>> +    vma->vm_flags |= VM_RESERVED;
>> +    vma->vm_flags |= VM_DONTCOPY;
>> +    vma->vm_flags |= VM_DONTEXPAND;
>>   
> VM_IO?

Dunno, maybe.  2.6.18 used VM_RESERVED, thats why I sticked to that.
According to mm.h there isn't a big difference between VM_IO and
VM_RESERVED anyway ...

>> +        priv->mm = get_task_mm(current);
>>
>Is this to cope with the /dev/gnttab fd being inherited by/passed to
>some other process, even if the mappings don't follow it?

Well, sort of.  Main intention is that I want to keep track of the mm I
registered the mmu notifier for.  But, yes, it is also used to cope with
fd's inherited / passed on.  It will not work (mmap -> EINVAL), but at
least the driver shouldn't trip over it.

cheers,
  Gerd

  reply	other threads:[~2009-03-04  8:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-24 18:45 pv_ops & gntdev? Gerd Hoffmann
2009-02-24 21:18 ` Jeremy Fitzhardinge
2009-02-24 22:12   ` Gerd Hoffmann
2009-02-25 10:05     ` Gerd Hoffmann
2009-02-25 17:51       ` Jeremy Fitzhardinge
2009-02-25 18:37         ` Gerd Hoffmann
2009-02-25 20:06           ` Jeremy Fitzhardinge
2009-02-25 21:19             ` Gerd Hoffmann
2009-02-25 21:35               ` Jeremy Fitzhardinge
2009-02-25 21:43                 ` Gerd Hoffmann
2009-02-25 21:48                   ` Jeremy Fitzhardinge
2009-02-25 22:11                     ` Gerd Hoffmann
2009-02-25 22:28                       ` Jeremy Fitzhardinge
2009-02-25 22:42                         ` Gerd Hoffmann
2009-02-25 22:59                           ` Jeremy Fitzhardinge
2009-03-02 22:53                             ` Gerd Hoffmann
2009-03-03  1:05                               ` Jeremy Fitzhardinge
2009-03-03 22:59                               ` Jeremy Fitzhardinge
2009-03-04  8:18                                 ` Gerd Hoffmann [this message]
2009-03-04 14:52                                   ` Gerd Hoffmann
2009-03-04 15:16                                     ` Jeremy Fitzhardinge
2009-03-04 15:32                                       ` Gerd Hoffmann
2009-02-25 18:56         ` Gerd Hoffmann
2009-02-25 20:10           ` Jeremy Fitzhardinge
2009-02-25 21:45             ` Gerd Hoffmann
2009-02-25 22:16             ` Gerd Hoffmann
2009-02-25 22:30               ` Jeremy Fitzhardinge

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=49AE396D.2090503@redhat.com \
    --to=kraxel@redhat.com \
    --cc=jeremy@goop.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.