Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1902191ybi; Mon, 1 Jul 2019 02:30:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzq5W2Q0CeTYgA9vVq5JMzdtIN2K5/ku9QcGX24S6+j3AQWMzKvSTzfWwUnsIsWdOzBNkBa X-Received: by 2002:a17:902:2a68:: with SMTP id i95mr28378010plb.167.1561973414471; Mon, 01 Jul 2019 02:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561973414; cv=none; d=google.com; s=arc-20160816; b=Fo5C3I5TfcTTHqnNCyMIzLwyFh5nb4BgLC4NEky694pW1d3pNhYzdHVbzyZStsfF4O q/E4oMwe0ib/KiFPHgWCp2uuzkTjqbpYC5md0HGi9KMEy8EbwnEoUjzzWUJY756ZD31M CbCSxq7JgLmzAXeWXC7AtPyorT2KTP9hE1hyHNloi6oyPSOjgjKaVup0vSxW4tiD6Q7n rByn6FGF0UGJtY0nb8kniWhQPOSQaunBywHPQwUa897lmVTe3njSkZObcQ251k6/gHeV 0zQONPQGnNN0Yg9GfkQ94sxYs9cLZ51dncV9i3lx6r8DfqAKtvoiAjmPdFss1tLLbDAa M8Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KrfXpIQxr/cn2+9rwoAEVrRZR4QKKQe4lr3NtCXDl9w=; b=YupdJ1290jBmyUcNFZI2wPpJQgHvKtGYoX4ah4WMOtMiXVzWOFoyDfNL6PRPcZkqHf T3smefN3yLlIgos1HPKfPAKaLyyut6cAuUsoNXYkVj554AFOiY9m8SQwJ3rFAFX/a35z pQcO5pckahaH3KY3Fja4ihXi76Hr3FrbzN+UUPswYoS7Pe6AXItKtYBvcrz+R54unAsa 3TAeDYBQIXch/w5r6oa/ctwojuOPlXqkRHoSAP25CS1CCJ8RSlsIZZ+SY5i7hlFL7ToE 20xc9Qo2yDpW/9NbT8RZSkwQFfEruccOq5Y22A9Z1SbGqx0ceEEDP+xfrc/uUWL/5dOx 8kGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=smmR1WDj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si9977369pjt.79.2019.07.01.02.29.58; Mon, 01 Jul 2019 02:30:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=smmR1WDj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728431AbfGAJ3k (ORCPT + 99 others); Mon, 1 Jul 2019 05:29:40 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37682 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728366AbfGAJ3k (ORCPT ); Mon, 1 Jul 2019 05:29:40 -0400 Received: by mail-pf1-f193.google.com with SMTP id 19so6290442pfa.4; Mon, 01 Jul 2019 02:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=KrfXpIQxr/cn2+9rwoAEVrRZR4QKKQe4lr3NtCXDl9w=; b=smmR1WDj9hEEUk0Fi/hV9Yntct1psX33m2A/KLnuExax/YWgDzvlGKgOxwdePAWmXA h4aI9Ej6GQpkipSZDJG1obdyHVrOm7BMcih7ah3c36xxIj6FbIwqaoRi5ZYT4WYmRdL3 gD2zvsMTEPggGtdn72k+qQ+McyXFDD4i1AqQxCyrgg5VwbrHe4UWh4uKeowRlMTjDG1k 170+kns5ylrfzHdM4170qVNcyVe61muK5///zIMjo4MZfAa+wiP0b4yHQVXR0oNhExgQ v9m5TPBfx0flrzxVf2S06zMK8D+XnTm23Tt6Njj9QjfbI5XUkI0dhIsHkJ/udYPKemY+ Tp+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=KrfXpIQxr/cn2+9rwoAEVrRZR4QKKQe4lr3NtCXDl9w=; b=nZRZB/XQ5ZpZOcTQ2Pxg/ErfBY2SNK/R86kutWFT7iBrjCEiFSBq1Vy3p//gNZ8rUT 5Y4st9yShiZ+QZ+odr2KH0dVTBu7OOmSR9Y38SI188coVtKGxotHRDAYPVYroU99dwC1 /8eRddVBRTDSxD2p+KzHrcuvKrBO14bwv1pyYnlOdLy+vPugAVd5BoewPVYaexiT1q9q I9cjluH2H2PTazmJEBITV052uJG/S54lR7f/FBgh9jGrM13TlYiLNAbfrJUJFQ7rEUM/ wHZsahIka+D2uXkN303k2V0fPxVVmvPCH2bX6xFXLTs8Cghfhs5EKtXB3klmhxGLsRFk Bhfw== X-Gm-Message-State: APjAAAX9XhjWp2LGETFvcqMOtkg0Mc4e1Zfksy5ZvOrbfVNvejc9mL/Z 5NYrnUdvJkI8y+VCNuelwnEK52gB X-Received: by 2002:a17:90a:206a:: with SMTP id n97mr30227096pjc.10.1561973379791; Mon, 01 Jul 2019 02:29:39 -0700 (PDT) Received: from localhost.localdomain ([163.152.3.133]) by smtp.gmail.com with ESMTPSA id u65sm23209068pjb.1.2019.07.01.02.29.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 01 Jul 2019 02:29:39 -0700 (PDT) Date: Mon, 1 Jul 2019 18:29:34 +0900 From: Suwan Kim To: shuah Cc: stern@rowland.harvard.edu, valentina.manea.m@gmail.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] usbip: Skip DMA mapping and unmapping for urb at vhci Message-ID: <20190701092932.GA3939@localhost.localdomain> References: <20190621174553.28862-1-suwan.kim027@gmail.com> <20190621174553.28862-2-suwan.kim027@gmail.com> <10a4f10a-d271-9331-b847-bdc06f9fc9cf@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <10a4f10a-d271-9331-b847-bdc06f9fc9cf@kernel.org> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 28, 2019 at 06:11:54PM -0600, shuah wrote: > Hi Suwan, > > On 6/21/19 11:45 AM, Suwan Kim wrote: > > vhci doesn’t do dma for remote device. Actually, the real dma > > operation is done by network card driver. So, vhci doesn’t use and > > need dma address of transfer buffer of urb. > > > > When vhci supports SG, it is useful to use native SG list instead > > of mapped SG list because dma mapping fnuction can adjust the > > number of SG list that is urb->num_mapped_sgs. > > > > But hcd provides dma mapping and unmapping function by defualt. > > Typo "defualt" > > > Moreover, it causes unnecessary dma mapping and unmapping which > > will be done again at the NIC driver and it wastes CPU cycles. > > So, implement map_urb_for_dma and unmap_urb_for_dma function for > > vhci in order to skip the dma mapping and unmapping procedure. > > > > How did you verify that unnecessary dma map/unmap are happening? > How many CPU cycles did you manage to reduce with this change? Dma mapping/unmapping is not required for vhci because vhci passes the virtual address of the buffer to the network stack without passing the dma address of the buffer. Network stack receive the virtual address of the buffer from vhci and later, network card driver performs dma mapping for the buffer. So, as far as I know, dma address of the buffer is not used for vhci and virtual address is only used by vhci. I used ftrace to measure a duration of usb_hcd_map_urb_for_dma(). As a result, usb_hcd_map_urb_for_dma() took a duration of about 0.14us out of about 10us which is the duration of usb_hcd_submit_urb(). However, this figure is the dma mapping measurement value for physically contiguous buffers when vhci does not support SG, and if vhci supports SG, more CPU cycles will be consumed for SG dma mapping. I think that the important point is dma mapping/unmapping is unnecessary at vhci. So we can skip dma mapping/unmapping and save the CPU cycles (even if it is small). This is an opportunity to reduce the end-to-end latency of usbip and improve the performance. Regards Suwan Kim