Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Dec 2010 20:39:49 +0000 (UTC)
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r216602 - in stable/8/sys: dev/xen/blkfront i386/i386 i386/xen xen/evtchn
Message-ID:  <201012202039.oBKKdnSp083154@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cperciva
Date: Mon Dec 20 20:39:49 2010
New Revision: 216602
URL: http://svn.freebsd.org/changeset/base/216602

Log:
  MFC Xen-related commits r215470, r215472, r215525, r215663, r215813, r215819,
  r215844, r216041, r216241, r216280, r216382, and r216385.
  
  * Make blkfront not advertise a larger maximum I/O size than it can handle
    for unaligned data (r216241)
  * Correctly reserve CPU #0's DPCPU pages (r216041)
  * Make machdep.independent_wallclock do what it claims (r216382)
  * Don't round xen timecounter to the nearest tick (r215663), but decrease
    its frequency to avoid wrapping at ~4.3s (r216385)
  * Remove debugging code which caused a massing slowdown in fork-heavy
    workloads (r215813)
  * Add a missing page table flush before invalidating TLBs in pmap_qremove
    (r215819+215844)
  * In pmap_release, don't unpin pages which weren't pinned (r215525) and don't
    KASSERT page mappings which don't exist (r215470); but do pmap_qremove all
    the relevant pages (r215472)
  * Don't unmask an event channel until after we register the interrupt handler
    for it (r216280)
  
  Approved by:	re (rwatson)

Modified:
  stable/8/sys/dev/xen/blkfront/blkfront.c
  stable/8/sys/i386/i386/machdep.c
  stable/8/sys/i386/xen/clock.c
  stable/8/sys/i386/xen/pmap.c
  stable/8/sys/i386/xen/xen_machdep.c
  stable/8/sys/xen/evtchn/evtchn.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/dev/xen/blkfront/blkfront.c
==============================================================================
--- stable/8/sys/dev/xen/blkfront/blkfront.c	Mon Dec 20 20:25:42 2010	(r216601)
+++ stable/8/sys/dev/xen/blkfront/blkfront.c	Mon Dec 20 20:39:49 2010	(r216602)
@@ -508,7 +508,7 @@ blkfront_initialize(struct xb_softc *sc)
 	sc->ring_pages = 1;
 	sc->max_requests = BLKIF_MAX_RING_REQUESTS(PAGE_SIZE);
 	sc->max_request_segments = BLKIF_MAX_SEGMENTS_PER_HEADER_BLOCK;
-	sc->max_request_size = sc->max_request_segments * PAGE_SIZE;
+	sc->max_request_size = (sc->max_request_segments - 1) * PAGE_SIZE;
 	sc->max_request_blocks = BLKIF_SEGS_TO_BLOCKS(sc->max_request_segments);
 
 	/*

Modified: stable/8/sys/i386/i386/machdep.c
==============================================================================
--- stable/8/sys/i386/i386/machdep.c	Mon Dec 20 20:25:42 2010	(r216601)
+++ stable/8/sys/i386/i386/machdep.c	Mon Dec 20 20:39:49 2010	(r216602)
@@ -2561,6 +2561,8 @@ init386(first)
 		pmap_kenter(pa + KERNBASE, pa);
 	dpcpu_init((void *)(first + KERNBASE), 0);
 	first += DPCPU_SIZE;
+	physfree += DPCPU_SIZE;
+	init_first += DPCPU_SIZE / PAGE_SIZE;
 
 	PCPU_SET(prvspace, pc);
 	PCPU_SET(curthread, &thread0);

Modified: stable/8/sys/i386/xen/clock.c
==============================================================================
--- stable/8/sys/i386/xen/clock.c	Mon Dec 20 20:25:42 2010	(r216601)
+++ stable/8/sys/i386/xen/clock.c	Mon Dec 20 20:39:49 2010	(r216602)
@@ -340,7 +340,8 @@ clkintr(void *arg)
 	 * time base.
 	 */
 	
-	if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) {
+	if (shadow_tv_version != HYPERVISOR_shared_info->wc_version &&
+	    !independent_wallclock) {
 		printf("[XEN] hypervisor wallclock nudged; nudging TOD.\n");
 		update_wallclock();
 		add_uptime_to_wallclock();
@@ -522,7 +523,8 @@ startrtclock()
 	set_cyc2ns_scale(cpu_khz/1000);
 	tsc_freq = cpu_khz * 1000;
 
-        timer_freq = xen_timecounter.tc_frequency = 1000000000LL;
+        timer_freq = 1000000000LL;
+	xen_timecounter.tc_frequency = timer_freq >> 9;
         tc_init(&xen_timecounter);
 
 	rdtscll(alarm);
@@ -829,7 +831,7 @@ xen_get_timecount(struct timecounter *tc
 	
         clk = shadow->system_timestamp + get_nsec_offset(shadow);
 
-	return (uint32_t)((clk / NS_PER_TICK) * NS_PER_TICK);
+	return (uint32_t)(clk >> 9);
 
 }
 

Modified: stable/8/sys/i386/xen/pmap.c
==============================================================================
--- stable/8/sys/i386/xen/pmap.c	Mon Dec 20 20:25:42 2010	(r216601)
+++ stable/8/sys/i386/xen/pmap.c	Mon Dec 20 20:39:49 2010	(r216602)
@@ -1384,6 +1384,7 @@ pmap_qremove(vm_offset_t sva, int count)
 		pmap_kremove(va);
 		va += PAGE_SIZE;
 	}
+	PT_UPDATES_FLUSH();
 	pmap_invalidate_range(kernel_pmap, sva, va);
 	critical_exit();
 	vm_page_unlock_queues();
@@ -1854,15 +1855,24 @@ pmap_release(pmap_t pmap)
 		m = ptdpg[i];
 		ma = xpmap_ptom(VM_PAGE_TO_PHYS(m));
 		/* unpinning L1 and L2 treated the same */
+#if 0
                 xen_pgd_unpin(ma);
+#else
+		if (i == NPGPTD)
+	                xen_pgd_unpin(ma);
+#endif
 #ifdef PAE
-		KASSERT(xpmap_ptom(VM_PAGE_TO_PHYS(m)) == (pmap->pm_pdpt[i] & PG_FRAME),
-		    ("pmap_release: got wrong ptd page"));
+		if (i < NPGPTD)
+			KASSERT(xpmap_ptom(VM_PAGE_TO_PHYS(m)) == (pmap->pm_pdpt[i] & PG_FRAME),
+			    ("pmap_release: got wrong ptd page"));
 #endif
 		m->wire_count--;
 		atomic_subtract_int(&cnt.v_wire_count, 1);
 		vm_page_free(m);
 	}
+#ifdef PAE
+	pmap_qremove((vm_offset_t)pmap->pm_pdpt, 1);
+#endif
 	PMAP_LOCK_DESTROY(pmap);
 }
 

Modified: stable/8/sys/i386/xen/xen_machdep.c
==============================================================================
--- stable/8/sys/i386/xen/xen_machdep.c	Mon Dec 20 20:25:42 2010	(r216601)
+++ stable/8/sys/i386/xen/xen_machdep.c	Mon Dec 20 20:39:49 2010	(r216602)
@@ -482,7 +482,6 @@ xen_pt_pin(vm_paddr_t ma)
 	struct mmuext_op op;
 	op.cmd = MMUEXT_PIN_L1_TABLE;
 	op.arg1.mfn = ma >> PAGE_SHIFT;
-	printk("xen_pt_pin(): mfn=%x\n", op.arg1.mfn);
 	xen_flush_queue();
 	PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
 }

Modified: stable/8/sys/xen/evtchn/evtchn.c
==============================================================================
--- stable/8/sys/xen/evtchn/evtchn.c	Mon Dec 20 20:25:42 2010	(r216601)
+++ stable/8/sys/xen/evtchn/evtchn.c	Mon Dec 20 20:39:49 2010	(r216602)
@@ -256,7 +256,7 @@ find_unbound_irq(void)
 }
 
 static int
-bind_caller_port_to_irq(unsigned int caller_port)
+bind_caller_port_to_irq(unsigned int caller_port, int * port)
 {
         int irq;
 
@@ -271,7 +271,7 @@ bind_caller_port_to_irq(unsigned int cal
         }
 
         irq_bindcount[irq]++;
-	unmask_evtchn(caller_port);
+	*port = caller_port;
 
  out:
         mtx_unlock_spin(&irq_mapping_update_lock);
@@ -279,7 +279,7 @@ bind_caller_port_to_irq(unsigned int cal
 }
 
 static int
-bind_local_port_to_irq(unsigned int local_port)
+bind_local_port_to_irq(unsigned int local_port, int * port)
 {
         int irq;
 
@@ -298,7 +298,7 @@ bind_local_port_to_irq(unsigned int loca
         evtchn_to_irq[local_port] = irq;
         irq_info[irq] = mk_irq_info(IRQT_LOCAL_PORT, 0, local_port);
         irq_bindcount[irq]++;
-	unmask_evtchn(local_port);
+	*port = local_port;
 
  out:
         mtx_unlock_spin(&irq_mapping_update_lock);
@@ -306,7 +306,7 @@ bind_local_port_to_irq(unsigned int loca
 }
 
 static int
-bind_listening_port_to_irq(unsigned int remote_domain)
+bind_listening_port_to_irq(unsigned int remote_domain, int * port)
 {
         struct evtchn_alloc_unbound alloc_unbound;
         int err;
@@ -317,12 +317,12 @@ bind_listening_port_to_irq(unsigned int 
         err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
                                           &alloc_unbound);
 
-        return err ? : bind_local_port_to_irq(alloc_unbound.port);
+        return err ? : bind_local_port_to_irq(alloc_unbound.port, port);
 }
 
 static int
 bind_interdomain_evtchn_to_irq(unsigned int remote_domain,
-    unsigned int remote_port)
+    unsigned int remote_port, int * port)
 {
         struct evtchn_bind_interdomain bind_interdomain;
         int err;
@@ -333,11 +333,11 @@ bind_interdomain_evtchn_to_irq(unsigned 
         err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
                                           &bind_interdomain);
 
-        return err ? : bind_local_port_to_irq(bind_interdomain.local_port);
+        return err ? : bind_local_port_to_irq(bind_interdomain.local_port, port);
 }
 
 static int 
-bind_virq_to_irq(unsigned int virq, unsigned int cpu)
+bind_virq_to_irq(unsigned int virq, unsigned int cpu, int * port)
 {
 	struct evtchn_bind_virq bind_virq;
 	int evtchn = 0, irq;
@@ -363,7 +363,7 @@ bind_virq_to_irq(unsigned int virq, unsi
 	}
 
 	irq_bindcount[irq]++;
-	unmask_evtchn(evtchn);
+	*port = evtchn;
 out:
 	mtx_unlock_spin(&irq_mapping_update_lock);
 
@@ -371,10 +371,8 @@ out:
 }
 
 
-extern int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu);
-
-int 
-bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
+static int 
+bind_ipi_to_irq(unsigned int ipi, unsigned int cpu, int * port)
 {
 	struct evtchn_bind_ipi bind_ipi;
 	int irq;
@@ -398,7 +396,7 @@ bind_ipi_to_irq(unsigned int ipi, unsign
 		bind_evtchn_to_cpu(evtchn, cpu);
 	}
 	irq_bindcount[irq]++;
-	unmask_evtchn(evtchn);
+	*port = evtchn;
 out:
 	
 	mtx_unlock_spin(&irq_mapping_update_lock);
@@ -449,9 +447,10 @@ bind_caller_port_to_irqhandler(unsigned 
     unsigned long irqflags, unsigned int *irqp)
 {
 	unsigned int irq;
+	int port = -1;
 	int error;
 
-	irq = bind_caller_port_to_irq(caller_port);
+	irq = bind_caller_port_to_irq(caller_port, &port);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
 	error = intr_add_handler(devname, irq, NULL, handler, arg, irqflags,
 	    &xp->xp_pins[irq].xp_cookie);
@@ -460,6 +459,8 @@ bind_caller_port_to_irqhandler(unsigned 
 		unbind_from_irq(irq);
 		return (error);
 	}
+	if (port != -1)
+		unmask_evtchn(port);
 
 	if (irqp)
 		*irqp = irq;
@@ -473,9 +474,10 @@ bind_listening_port_to_irqhandler(unsign
     unsigned long irqflags, unsigned int *irqp)
 {
 	unsigned int irq;
+	int port = -1;
 	int error;
 
-	irq = bind_listening_port_to_irq(remote_domain);
+	irq = bind_listening_port_to_irq(remote_domain, &port);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
 	error = intr_add_handler(devname, irq, NULL, handler, arg, irqflags,
 	    &xp->xp_pins[irq].xp_cookie);
@@ -483,6 +485,8 @@ bind_listening_port_to_irqhandler(unsign
 		unbind_from_irq(irq);
 		return (error);
 	}
+	if (port != -1)
+		unmask_evtchn(port);
 	if (irqp)
 		*irqp = irq;
 	
@@ -496,9 +500,10 @@ bind_interdomain_evtchn_to_irqhandler(un
     unsigned int *irqp)
 {
 	unsigned int irq;
+	int port = -1;
 	int error;
 
-	irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port);
+	irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port, &port);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
 	error = intr_add_handler(devname, irq, NULL, handler, arg,
 	    irqflags, &xp->xp_pins[irq].xp_cookie);
@@ -506,6 +511,8 @@ bind_interdomain_evtchn_to_irqhandler(un
 		unbind_from_irq(irq);
 		return (error);
 	}
+	if (port != -1)
+		unmask_evtchn(port);
 
 	if (irqp)
 		*irqp = irq;
@@ -518,9 +525,10 @@ bind_virq_to_irqhandler(unsigned int vir
     void *arg, unsigned long irqflags, unsigned int *irqp)
 {
 	unsigned int irq;
+	int port = -1;
 	int error;
 
-	irq = bind_virq_to_irq(virq, cpu);
+	irq = bind_virq_to_irq(virq, cpu, &port);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
 	error = intr_add_handler(devname, irq, filter, handler,
 	    arg, irqflags, &xp->xp_pins[irq].xp_cookie);
@@ -528,6 +536,8 @@ bind_virq_to_irqhandler(unsigned int vir
 		unbind_from_irq(irq);
 		return (error);
 	}
+	if (port != -1)
+		unmask_evtchn(port);
 
 	if (irqp)
 		*irqp = irq;
@@ -540,9 +550,10 @@ bind_ipi_to_irqhandler(unsigned int ipi,
     unsigned long irqflags, unsigned int *irqp)
 {
 	unsigned int irq;
+	int port = -1;
 	int error;
 	
-	irq = bind_ipi_to_irq(ipi, cpu);
+	irq = bind_ipi_to_irq(ipi, cpu, &port);
 	intr_register_source(&xp->xp_pins[irq].xp_intsrc);
 	error = intr_add_handler(devname, irq, filter, NULL,
 	    NULL, irqflags, &xp->xp_pins[irq].xp_cookie);
@@ -550,6 +561,8 @@ bind_ipi_to_irqhandler(unsigned int ipi,
 		unbind_from_irq(irq);
 		return (error);
 	}
+	if (port != -1)
+		unmask_evtchn(port);
 
 	if (irqp)
 		*irqp = irq;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012202039.oBKKdnSp083154>