Project

General

Profile

0003-Do-not-use-VM_ALLOC_INTERRUPT.-Add-better-inflate-de.patch

ddegroot, 10/04/2018 06:06 AM

View differences:

sys/dev/virtual/virtio/balloon/virtio_balloon.c
125 125
#define VTBALLOON_LOWMEM_TIMEOUT	hz * 1000
126 126

  
127 127
/* vm_page_alloc flags */
128
#define VTBALLOON_REGULAR_ALLOC		VM_ALLOC_NORMAL | VM_ALLOC_INTERRUPT
129
#define VTBALLOON_LOWMEM_ALLOC		VM_ALLOC_SYSTEM | VM_ALLOC_INTERRUPT
128
#define VTBALLOON_REGULAR_ALLOC		VM_ALLOC_NORMAL
129
#define VTBALLOON_LOWMEM_ALLOC		VM_ALLOC_SYSTEM
130 130

  
131 131
/*
132 132
 * Maximum number of pages we'll request to inflate or deflate
......
135 135
 */
136 136
#define VTBALLOON_PAGES_PER_REQUEST	256
137 137

  
138
//#define VTBALLOON_DEFAULT_DEBUG_LEVEL   VTBALLOON_ERROR
138 139
#define VTBALLOON_DEFAULT_DEBUG_LEVEL   VTBALLOON_INFO | VTBALLOON_ERROR
139 140

  
140 141
/* Must be able to fix all pages frames in one page (segment). */
......
457 458
	}
458 459

  
459 460
	if (i > 0) {
460
		/* Always tell host first before freeing the pages. */
461
		/*
462
		 * Note that if virtio VIRTIO_BALLOON_F_MUST_TELL_HOST
463
		 * feature is true, we *have* to tell host first
464
		 * before freeing the pages.
465
		 */
461 466
		vtballoon_send_page_frames(sc, vq, i);
462 467

  
463 468
		while ((m = TAILQ_FIRST(&free_pages)) != NULL) {
......
544 549
static void
545 550
vtballoon_free_page(struct vtballoon_softc *sc, vm_page_t m)
546 551
{
547
	//vm_page_free(m);							// ? orig fbsd.
548 552
	vm_page_free_toq(m);							// ? Is this a good translation ?
549 553
	//vm_page_free_contig(m, unsigned long size); 				// ?
550 554
	sc->vtballoon_current_npages--;
......
587 591
		}
588 592

  
589 593
		desired = vtballoon_desired_size(sc);
594
		if (desired != sc->vtballoon_desired_npages)
595
			vtballoon_dprintf(sc, VTBALLOON_INFO, "balloon %s %d -> %d (4K pages)\n",
596
				desired < sc->vtballoon_desired_npages ? "deflating" : "inflating",
597
				current, desired);
598

  
590 599
		sc->vtballoon_desired_npages = desired;
591 600

  
592 601
		/*
......
600 609

  
601 610
		if (current > desired)
602 611
			break;
603
		if (current < desired && timeout == 0)
612
		else if (current < desired && timeout == 0)
604 613
			break;
614
		else if (!timeout)
615
			vtballoon_dprintf(sc, VTBALLOON_INFO, "balloon %d (4K pages) reached\n", current);
605 616

  
606
		if (!timeout)
607
			vtballoon_dprintf(sc, VTBALLOON_INFO, "thread woke up, adjust size, desired:%d, current:%d\n", desired, current);
608 617
		zsleep(sc, VTBALLOON_SLZ(sc), 0, "vtbslp", timeout);
609 618
	}
610 619
	VTBALLOON_EXIT_SLZ(sc);
611
-