search for: num_pages

Displaying 20 results from an estimated 792 matches for "num_pages".

2008 Aug 18
2
[PATCH] virtio_balloon: fix towards_target when deflating balloon
Both v and vb->num_pages are u32 and unsigned int respectively. If v is less than vb->num_pages (and it is, when deflating the balloon), the result is a very large 32-bit number. Since we're returning a s64, instead of getting the same negative number we desire, we get a very large positive number. This handles t...
2008 Aug 18
2
[PATCH] virtio_balloon: fix towards_target when deflating balloon
Both v and vb->num_pages are u32 and unsigned int respectively. If v is less than vb->num_pages (and it is, when deflating the balloon), the result is a very large 32-bit number. Since we're returning a s64, instead of getting the same negative number we desire, we get a very large positive number. This handles t...
2015 Mar 31
2
[PATCH v2 1/6] virtio_balloon: transitional interface
...clude/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index 4b0488f..71ef93b 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h @@ -38,9 +38,9 @@ struct virtio_balloon_config { /* Number of pages host wants Guest to give up. */ - __le32 num_pages; + __u32 num_pages; /* Number of pages we've actually got in balloon. */ - __le32 actual; + __u32 actual; }; #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */ @@ -51,9 +51,16 @@ struct virtio_balloon_config { #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of...
2015 Mar 31
2
[PATCH v2 1/6] virtio_balloon: transitional interface
...clude/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index 4b0488f..71ef93b 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h @@ -38,9 +38,9 @@ struct virtio_balloon_config { /* Number of pages host wants Guest to give up. */ - __le32 num_pages; + __u32 num_pages; /* Number of pages we've actually got in balloon. */ - __le32 actual; + __u32 actual; }; #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */ @@ -51,9 +51,16 @@ struct virtio_balloon_config { #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of...
2017 Oct 22
1
[PATCH v1 1/3] virtio-balloon: replace the coarse-grained balloon_lock
Wei Wang wrote: > >> @@ -162,20 +160,20 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) > >> msleep(200); > >> break; > >> } > >> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); > >> - vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE; > >> + set_page_pfns(vb, pfns + num_pfns, page); > >> if (!virtio_has_feature(vb->vdev, > >> VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) > >> adjust_managed_page_count(page, -1); > >> } > >> >...
2017 Oct 22
1
[PATCH v1 1/3] virtio-balloon: replace the coarse-grained balloon_lock
Wei Wang wrote: > >> @@ -162,20 +160,20 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) > >> msleep(200); > >> break; > >> } > >> - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); > >> - vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE; > >> + set_page_pfns(vb, pfns + num_pfns, page); > >> if (!virtio_has_feature(vb->vdev, > >> VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) > >> adjust_managed_page_count(page, -1); > >> } > >> >...
2017 Oct 13
2
[PATCH] virtio: avoid possible OOM lockup at virtballoon_oom_notify()
...k(&vb->balloon_lock); > + if (wait) > + mutex_lock(&vb->balloon_lock); > + else if (!mutex_trylock(&vb->balloon_lock)) { > + pr_info("virtio_balloon: Unable to release %lu pages due to lock contention.\n", > + (unsigned long) min(num, (size_t)vb->num_pages)); > + return 0; > + } > /* We can't release more pages than taken */ > num = min(num, (size_t)vb->num_pages); > for (vb->num_pfns = 0; vb->num_pfns < num; > @@ -367,7 +373,7 @@ static int virtballoon_oom_notify(struct notifier_block *self, > return NO...
2017 Oct 13
2
[PATCH] virtio: avoid possible OOM lockup at virtballoon_oom_notify()
...k(&vb->balloon_lock); > + if (wait) > + mutex_lock(&vb->balloon_lock); > + else if (!mutex_trylock(&vb->balloon_lock)) { > + pr_info("virtio_balloon: Unable to release %lu pages due to lock contention.\n", > + (unsigned long) min(num, (size_t)vb->num_pages)); > + return 0; > + } > /* We can't release more pages than taken */ > num = min(num, (size_t)vb->num_pages); > for (vb->num_pfns = 0; vb->num_pfns < num; > @@ -367,7 +373,7 @@ static int virtballoon_oom_notify(struct notifier_block *self, > return NO...
2017 Oct 22
2
[PATCH v1 1/3] virtio-balloon: replace the coarse-grained balloon_lock
...d > fill_balloon to run concurrently and solves the deadlock issue. > > @@ -162,20 +160,20 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) > msleep(200); > break; > } > - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); > - vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE; > + set_page_pfns(vb, pfns + num_pfns, page); > if (!virtio_has_feature(vb->vdev, > VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) > adjust_managed_page_count(page, -1); > } > > - num_allocated_pages = vb->num_pfns; > + mutex_lock...
2017 Oct 22
2
[PATCH v1 1/3] virtio-balloon: replace the coarse-grained balloon_lock
...d > fill_balloon to run concurrently and solves the deadlock issue. > > @@ -162,20 +160,20 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) > msleep(200); > break; > } > - set_page_pfns(vb, vb->pfns + vb->num_pfns, page); > - vb->num_pages += VIRTIO_BALLOON_PAGES_PER_PAGE; > + set_page_pfns(vb, pfns + num_pfns, page); > if (!virtio_has_feature(vb->vdev, > VIRTIO_BALLOON_F_DEFLATE_ON_OOM)) > adjust_managed_page_count(page, -1); > } > > - num_allocated_pages = vb->num_pfns; > + mutex_lock...
2017 Oct 20
0
[PATCH v1 1/3] virtio-balloon: replace the coarse-grained balloon_lock
...rivers/virtio/virtio_balloon.c index f0b3a0b..1ecd15a 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -67,7 +67,7 @@ struct virtio_balloon { wait_queue_head_t acked; /* Number of balloon pages we've told the Host we're not using. */ - unsigned int num_pages; + atomic64_t num_pages; /* * The pages we've told the Host we're not using are enqueued * at vb_dev_info->pages list. @@ -76,12 +76,9 @@ struct virtio_balloon { */ struct balloon_dev_info vb_dev_info; - /* Synchronize access/update to this struct virtio_balloon elements *...
2007 Jul 20
2
[PATCH] Remove -static from Documentation/lguest/Makefile
...dr >= top || addr + size >= top) errx(1, "%s:%i: Invalid address %li", __FILE__, line, addr); return (void *)addr; } @@ -629,24 +630,26 @@ static void handle_input(int fd, struct } } -static struct lguest_device_desc *new_dev_desc(u16 type, u16 features, - u16 num_pages) -{ - static unsigned long top = LGUEST_GUEST_TOP; - struct lguest_device_desc *desc; - - desc = malloc(sizeof(*desc)); - desc->type = type; - desc->num_pages = num_pages; - desc->features = features; - desc->status = 0; - if (num_pages) { - top -= num_pages*getpagesize(); - map_zeroe...
2007 Jul 20
2
[PATCH] Remove -static from Documentation/lguest/Makefile
...dr >= top || addr + size >= top) errx(1, "%s:%i: Invalid address %li", __FILE__, line, addr); return (void *)addr; } @@ -629,24 +630,26 @@ static void handle_input(int fd, struct } } -static struct lguest_device_desc *new_dev_desc(u16 type, u16 features, - u16 num_pages) -{ - static unsigned long top = LGUEST_GUEST_TOP; - struct lguest_device_desc *desc; - - desc = malloc(sizeof(*desc)); - desc->type = type; - desc->num_pages = num_pages; - desc->features = features; - desc->status = 0; - if (num_pages) { - top -= num_pages*getpagesize(); - map_zeroe...
2015 Mar 02
0
[PATCH] VMCI: Guard against overflow in queue pair allocation
...ue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c index 35f19a6..6d5144c 100644 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c @@ -295,12 +295,20 @@ static void *qp_alloc_queue(u64 size, u32 flags) { u64 i; struct vmci_queue *queue; - const size_t num_pages = DIV_ROUND_UP(size, PAGE_SIZE) + 1; - const size_t pas_size = num_pages * sizeof(*queue->kernel_if->u.g.pas); - const size_t vas_size = num_pages * sizeof(*queue->kernel_if->u.g.vas); - const size_t queue_size = - sizeof(*queue) + sizeof(*queue->kernel_if) + - pas_size + vas_size;...
2015 Mar 02
0
[PATCH] VMCI: Guard against overflow in queue pair allocation
...ue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c index 35f19a6..6d5144c 100644 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c @@ -295,12 +295,20 @@ static void *qp_alloc_queue(u64 size, u32 flags) { u64 i; struct vmci_queue *queue; - const size_t num_pages = DIV_ROUND_UP(size, PAGE_SIZE) + 1; - const size_t pas_size = num_pages * sizeof(*queue->kernel_if->u.g.pas); - const size_t vas_size = num_pages * sizeof(*queue->kernel_if->u.g.vas); - const size_t queue_size = - sizeof(*queue) + sizeof(*queue->kernel_if) + - pas_size + vas_size;...
2015 Apr 15
2
[PATCH v3 0/6] virtio_balloon: virtio 1 support
...->stats[idx].val = cpu_to_virtio64(vb->vdev, val); } #define pages_to_bytes(x) ((u64)(x) << PAGE_SHIFT) @@ -283,18 +288,27 @@ static void virtballoon_changed(struct virtio_device *vdev) static inline s64 towards_target(struct virtio_balloon *vb) { - __le32 v; s64 target; + u32 num_pages; - virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages, &v); + virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages, + &num_pages); - target = le32_to_cpu(v); + /* Legacy balloon config space is LE, unlike all other devices. */ + if (!virtio_has_feature(...
2015 Apr 15
2
[PATCH v3 0/6] virtio_balloon: virtio 1 support
...->stats[idx].val = cpu_to_virtio64(vb->vdev, val); } #define pages_to_bytes(x) ((u64)(x) << PAGE_SHIFT) @@ -283,18 +288,27 @@ static void virtballoon_changed(struct virtio_device *vdev) static inline s64 towards_target(struct virtio_balloon *vb) { - __le32 v; s64 target; + u32 num_pages; - virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages, &v); + virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages, + &num_pages); - target = le32_to_cpu(v); + /* Legacy balloon config space is LE, unlike all other devices. */ + if (!virtio_has_feature(...
2015 Apr 01
0
[PATCH v2 1/6] virtio_balloon: transitional interface
...queue_add_outbuf(vq, &sg, 1, vb, GFP_KERNEL); > virtqueue_kick(vq); > } > @@ -283,21 +287,30 @@ static void virtballoon_changed(struct virtio_device *vdev) > > static inline s64 towards_target(struct virtio_balloon *vb) > { > - __le32 v; > s64 target; > + u32 num_pages; > > - virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages, &v); > + virtio_cread(vb->vdev, struct virtio_balloon_config, > + num_pages, &num_pages); > > - target = le32_to_cpu(v); > + /* Legacy balloon config space is LE, unlike all other dev...
2017 Oct 13
0
[PATCH] virtio: avoid possible OOM lockup at virtballoon_oom_notify()
...host actually expects us to. I still don't understand what is wrong with not deflating on OOM. According to https://lists.oasis-open.org/archives/virtio-dev/201504/msg00084.html , If VIRTIO_BALLOON_F_DEFLATE_ON_OOM has been negotiated, the driver MAY use pages from the balloon when \field{num_pages} is less than or equal to the actual number of pages in the balloon if this is required for system stability (e.g. if memory is required by applications running within the guest). it says "MAY" rather than "MUST". I think it is legal to be a no-op. Maybe I don't und...
2020 Aug 05
0
[PATCH v3 29/38] virtio_balloon: use LE config space accesses
...-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 8bc1704ffdf3..31cc97f2f515 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -398,12 +398,9 @@ static inline s64 towards_target(struct virtio_balloon *vb) s64 target; u32 num_pages; - virtio_cread(vb->vdev, struct virtio_balloon_config, num_pages, - &num_pages); - /* Legacy balloon config space is LE, unlike all other devices. */ - if (!virtio_has_feature(vb->vdev, VIRTIO_F_VERSION_1)) - num_pages = le32_to_cpu((__force __le32)num_pages); + virtio_cread_l...