From owner-svn-src-head@FreeBSD.ORG Thu Aug 28 18:23:10 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0A2A3C69; Thu, 28 Aug 2014 18:23:10 +0000 (UTC) Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com [IPv6:2a00:1450:4010:c04::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C49C81CA5; Thu, 28 Aug 2014 18:23:08 +0000 (UTC) Received: by mail-lb0-f181.google.com with SMTP id n15so1342501lbi.40 for ; Thu, 28 Aug 2014 11:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=qBRHJnnuXZ+i0xKIlKAZ93XOJzUJ/OG3YDKXbbZFGFU=; b=a4w7wl52BJwPTfjOsck8L2mehCsigGYqPc5fPRY7ZyesOToFjI09nPU/hgYFzmzb+Q rtpQhtrcmMY3bnnxEiHITxR4ktfjAEoptVUUYdKjh3c4nNblsXpHRfHD2ABx2kp0E6Gd 5RNJDk786+Xe72S2JFTDDio4ZyIUTcaEkmAhUYPJ8lDJWtMKZCiblS6ztnfuOPaAbmvI kc862ovTnVeJjK/gp8XQ7neNwo4uJ5Jp5Bp4qqhNTgsizBPGVxAcUdPNCZ/tJ4CiE/xz GjJh24UjPRJr77TId0mkOWWw8Z22Ikqk9+rlAeLFtdIoZckdgfEhMBJzzpFEjQ61bebj mkhg== X-Received: by 10.152.29.129 with SMTP id k1mr6184871lah.81.1409250186596; Thu, 28 Aug 2014 11:23:06 -0700 (PDT) Received: from mavbook.mavhome.dp.ua ([134.249.139.101]) by mx.google.com with ESMTPSA id zt1sm7086334lbc.31.2014.08.28.11.23.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 11:23:05 -0700 (PDT) Sender: Alexander Motin Message-ID: <53FF7386.3050804@FreeBSD.org> Date: Thu, 28 Aug 2014 21:23:02 +0300 From: Alexander Motin User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: =?UTF-8?B?Um9nZXIgUGF1IE1vbm7DqQ==?= , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r269814 - head/sys/dev/xen/blkfront References: <53e8e31e.2179.30c1c657@svn.freebsd.org> In-Reply-To: <53e8e31e.2179.30c1c657@svn.freebsd.org> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2014 18:23:10 -0000 Hi, Roger. It looks to me like this commit does not work as it should. I got problem when I just tried `newfs /dev/ada0 ; mount /dev/ada0 /mnt`. Somehow newfs does not produce valid filesystem. Problem is reliably repeatable and reverting this commit fixes it. I found at least one possible cause there: If original data buffer is unmapped, misaligned and not physically contiguous, then present x86 bus_dmamap_load_bio() implementation will process each physically contiguous segment separately. Due to the misalignment first and last physical segments may have size not multiple to 512 bytes. Since each segment processed separately, they are not joined together, and xbd_queue_cb() is getting segments not multiple to 512 bytes. Attempt to convert them to exact number of sectors in the driver cause data corruption. This is a bug of the busdma code, and until it is fixed I don't see solution other then temporary reverting this commit. On 11.08.2014 18:37, Roger Pau Monné wrote: > Author: royger > Date: Mon Aug 11 15:37:02 2014 > New Revision: 269814 > URL: http://svnweb.freebsd.org/changeset/base/269814 > > Log: > blkfront: add support for unmapped IO > > Using unmapped IO is really beneficial when running inside of a VM, > since it avoids IPIs to other vCPUs in order to invalidate the > mappings. > > This patch adds unmapped IO support to blkfront. The following tests > results have been obtained when running on a Xen host without HAP: > > PVHVM > 3165.84 real 6354.17 user 4483.32 sys > PVHVM with unmapped IO > 2099.46 real 4624.52 user 2967.38 sys > > This is because when running using shadow page tables TLB flushes and > range invalidations are much more expensive, so using unmapped IO > provides a very important performance boost. > > Sponsored by: Citrix Systems R&D > Tested by: robak > MFC after: 1 week > PR: 191173 > > dev/xen/blkfront/blkfront.c: > - Add and announce support for unmapped IO. > > Modified: > head/sys/dev/xen/blkfront/blkfront.c > > Modified: head/sys/dev/xen/blkfront/blkfront.c > ============================================================================== > --- head/sys/dev/xen/blkfront/blkfront.c Mon Aug 11 15:06:07 2014 (r269813) > +++ head/sys/dev/xen/blkfront/blkfront.c Mon Aug 11 15:37:02 2014 (r269814) > @@ -272,8 +272,12 @@ xbd_queue_request(struct xbd_softc *sc, > { > int error; > > - error = bus_dmamap_load(sc->xbd_io_dmat, cm->cm_map, cm->cm_data, > - cm->cm_datalen, xbd_queue_cb, cm, 0); > + if (cm->cm_bp != NULL) > + error = bus_dmamap_load_bio(sc->xbd_io_dmat, cm->cm_map, > + cm->cm_bp, xbd_queue_cb, cm, 0); > + else > + error = bus_dmamap_load(sc->xbd_io_dmat, cm->cm_map, > + cm->cm_data, cm->cm_datalen, xbd_queue_cb, cm, 0); > if (error == EINPROGRESS) { > /* > * Maintain queuing order by freezing the queue. The next > @@ -333,8 +337,6 @@ xbd_bio_command(struct xbd_softc *sc) > } > > cm->cm_bp = bp; > - cm->cm_data = bp->bio_data; > - cm->cm_datalen = bp->bio_bcount; > cm->cm_sector_number = (blkif_sector_t)bp->bio_pblkno; > > switch (bp->bio_cmd) { > @@ -993,7 +995,7 @@ xbd_instance_create(struct xbd_softc *sc > > sc->xbd_disk->d_mediasize = sectors * sector_size; > sc->xbd_disk->d_maxsize = sc->xbd_max_request_size; > - sc->xbd_disk->d_flags = 0; > + sc->xbd_disk->d_flags = DISKFLAG_UNMAPPED_BIO; > if ((sc->xbd_flags & (XBDF_FLUSH|XBDF_BARRIER)) != 0) { > sc->xbd_disk->d_flags |= DISKFLAG_CANFLUSHCACHE; > device_printf(sc->xbd_dev, > -- Alexander Motin