[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2] xen-mapcache: use MAP_FIXED flag so the mmap address hint is always honored


  • To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, "qemu-devel@xxxxxxxxxx" <qemu-devel@xxxxxxxxxx>
  • From: Paul Durrant <Paul.Durrant@xxxxxxxxxx>
  • Date: Mon, 18 Mar 2019 15:47:46 +0000
  • Accept-language: en-GB, en-US
  • Cc: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Eduardo Habkost <ehabkost@xxxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Richard Henderson <rth@xxxxxxxxxxx>
  • Delivery-date: Mon, 18 Mar 2019 15:49:52 +0000
  • Ironport-data: A9a23:2QxgMq19ubF5ZmpfvfbDix16xWZ6qk9dZdh5hcR8DSJ1pY1qo89B0l MkJcX/7sacjBaMb25p3pm00xlI4eIscBu4zxpn6qK2rCHCH3bBG8mEM3y8WKhM712fioZ2FL YKcgi56rPTxd6Rx7se7tivqjAFvMQ/7OO9q6SOPd+IDfDduEi1zHFO5xBlZoNTUcUQHLk8Jw vsnsRhHilIL4Ytx8d4pm32eoNfv33GYUpX6T2QvlHGgCekFFzMunOhBKJ/djIzSqWfLnF4vJ DloscVT60H+VKJJKE8Q8X3XbZ7s6rAAIFcV/Z84UCOqzhMj2wSqnX1jHneF/ppIVOugduETF lrFdzIpfGXCiq+ofm9c9PoDv+8VO2FJfzb6jSFGpVw0NOjHuCxrKBTLAQE+XrnaUBVS6vnpf FUwtRiVQS/RX1yNdAwge3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oRyNv4yCFLMRx1KY8aAQcnuYqzgzS/j0WygRVpH/Rc/sGxEGrDLSl4E0WX 5xHwGm4lrpBRVs0e3REPYjo4UYuu+RyFURwTVpA2F9wdwfks3ZzfNPB/Je8fA0vmLrZdpdeG jz616ltIz72SsG9yqrSIlyU/LPcrzZFJNnUpjQcTAGjyNXlDcgAlr4RrugGZQmOmxQZT3OeD PjHOrn5EfobUE9MypRCjG+vdX3l5QO1D9GfNOt8/BJ2Ha1x/mTmTgxqRE3eNiM7VTHsamBME punVNA6U1BQnZinPp/vu+/Ih8wY+hWQC6wDEMIgjlBhV2xRjZGvItTOvF+stW7RpbpIVImNX 7g6/b3EyXkUl8KLT4e6Z6xGLMDXgXZN0WU2+N7F1Jfye8n8I4GDk87pQ2VeTWZC2N9aWpH2O 65CpW5UIoh6/Eb4H4CNvP5GK/RCIL7M1IINQ/ULsuoL/Crj0auyC2tOxDuh8/scGwcWBJWzX ofq7wCLV85BrHPRB07+cx7Le8mm8JZUP1Mk2J/RNe2goO04F97QCHZQpBEpGfYBYRJJ+Eqao ht+T7Okr9WVa3oKK1Gmpd3WDAniu53I+Kcs92kpFyPo8sEXh7ZXAPKs4ligFNFhDDgBCLnSk 2NYRqlc669q96ASz/NiPvpfw==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHU3aGu87VY9TI/c0+y7cr3AfSBy6YRiHjg
  • Thread-topic: [PATCH v2] xen-mapcache: use MAP_FIXED flag so the mmap address hint is always honored

> -----Original Message-----
> From: Roger Pau Monne [mailto:roger.pau@xxxxxxxxxx]
> Sent: 18 March 2019 15:46
> To: qemu-devel@xxxxxxxxxx
> Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>; Stefano Stabellini 
> <sstabellini@xxxxxxxxxx>; Anthony
> Perard <anthony.perard@xxxxxxxxxx>; Paul Durrant <Paul.Durrant@xxxxxxxxxx>; 
> Igor Druzhinin
> <igor.druzhinin@xxxxxxxxxx>; Paolo Bonzini <pbonzini@xxxxxxxxxx>; Richard 
> Henderson <rth@xxxxxxxxxxx>;
> Eduardo Habkost <ehabkost@xxxxxxxxxx>; Michael S. Tsirkin <mst@xxxxxxxxxx>; 
> Marcel Apfelbaum
> <marcel.apfelbaum@xxxxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Subject: [PATCH v2] xen-mapcache: use MAP_FIXED flag so the mmap address hint 
> is always honored
> 
> Or if it's not possible to honor the hinted address an error is returned
> instead. This makes it easier to spot the actual failure, instead of
> failing later on when the caller of xen_remap_bucket realizes the
> mapping has not been created at the requested address.
> 
> Also note that at least on FreeBSD using MAP_FIXED will cause mmap to
> try harder to honor the passed address.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Reviewed-by: Paul Durrant <paul.durrant@xxxxxxxxxx>

> ---
> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> Cc: Anthony Perard <anthony.perard@xxxxxxxxxx>
> Cc: Paul Durrant <paul.durrant@xxxxxxxxxx>
> Cc: Igor Druzhinin <igor.druzhinin@xxxxxxxxxx>
> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> Cc: Richard Henderson <rth@xxxxxxxxxxx>
> Cc: Eduardo Habkost <ehabkost@xxxxxxxxxx>
> Cc: "Michael S. Tsirkin" <mst@xxxxxxxxxx>
> Cc: Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>
> Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
> ---
> Changes since v1:
>  - Use MAP_FIXED for the dummy mmap call also if a specific virtual
>    address is requested.
> ---
>  hw/i386/xen/xen-mapcache.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
> index 349f72d00c..23de5517db 100644
> --- a/hw/i386/xen/xen-mapcache.c
> +++ b/hw/i386/xen/xen-mapcache.c
> @@ -185,8 +185,13 @@ static void xen_remap_bucket(MapCacheEntry *entry,
>      }
> 
>      if (!dummy) {
> +        /*
> +         * If the caller has requested the mapping at a specific address use
> +         * MAP_FIXED to make sure it's honored.
> +         */
>          vaddr_base = xenforeignmemory_map2(xen_fmem, xen_domid, vaddr,
> -                                           PROT_READ | PROT_WRITE, 0,
> +                                           PROT_READ | PROT_WRITE,
> +                                           vaddr ? MAP_FIXED : 0,
>                                             nb_pfn, pfns, err);
>          if (vaddr_base == NULL) {
>              perror("xenforeignmemory_map2");
> @@ -198,7 +203,8 @@ static void xen_remap_bucket(MapCacheEntry *entry,
>           * mapping immediately due to certain circumstances (i.e. on resume 
> now)
>           */
>          vaddr_base = mmap(vaddr, size, PROT_READ | PROT_WRITE,
> -                          MAP_ANON | MAP_SHARED, -1, 0);
> +                          MAP_ANON | MAP_SHARED | (vaddr ? MAP_FIXED : 0),
> +                          -1, 0);
>          if (vaddr_base == MAP_FAILED) {
>              perror("mmap");
>              exit(-1);
> --
> 2.17.2 (Apple Git-113)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.