Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1028160imm; Wed, 8 Aug 2018 09:31:38 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzJOQ0ApmJF8nsyth5paL9IMY2Zh2tPSyM2z6ZMBgTtpHtlJWEaNa9t3mbsoFQcQJSkkGR0 X-Received: by 2002:a65:6292:: with SMTP id f18-v6mr3227027pgv.85.1533745898915; Wed, 08 Aug 2018 09:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533745898; cv=none; d=google.com; s=arc-20160816; b=uNkmURimTgAwr7QEDImAZmPs4i3SDQcti0lMeP1YwxtQdfY2ktu99u+ohOzOQ/5ASl AsmwlcoNO2LgfDY/OH7kvLDt4CxabyGybQNRQIJdpKWZgphJOKVZh8RRDSKcWtNS2dY+ 1XLewHRP/TJPuWAmizwjtfKP7mGJDALmGxrvqCtwb8eWIg6ZAQtajwJYGtRjtOb8HCd+ rbwizf4b1Gu5UPDzjYi6kbRc8GiXy33EvCjHZFjjiAnWAQwwAI+9GRrgmLGaY12CkNZ5 lB2RjbpIL+bSf3gQ3rBssMoYR5HgwrokbyhoNU2bBdBXng26BQGhpx9OEiPsyXQ1uXwl iL/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=f9m4EzFrK4o7iKi+yVMqTnAXeSoP5rWcrhp2zGMzxHQ=; b=L1XTzyN8aFNrATE9ZvFTFES8v2GIMrei42z10WzvaJcEb70PhHWxRQWVl1NXnptCfw 03Kh79L2cgtVKsdm9vI2xh6iujZG+5Pk5/i0Z5ktu9QyCEgxr8+EVsyOV8qoKcnGAGjA iMdcwo7DRL/Qb++ixI/cGiCjPMHHV124amnS2EoV87u/2blk9StKEgVSJNdGYhZcmjbW mFCiPYmdPAWopFFy7ii4ppMDy1MufqmKEatcusFeiUpfpxYEFi07LWlvy6yTG5wfpahS fkPI7YLdHhl/74cLLqn7tU7r6afaMGBLY+mU/9Eiw7yBqPm8Kv9QqXAu5HGhXhKi1Zh1 wsgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=NPpiU691; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k130-v6si4823096pfc.282.2018.08.08.09.31.24; Wed, 08 Aug 2018 09:31:38 -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=@vanguardiasur-com-ar.20150623.gappssmtp.com header.s=20150623 header.b=NPpiU691; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbeHHSuY (ORCPT + 99 others); Wed, 8 Aug 2018 14:50:24 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:38832 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbeHHSuX (ORCPT ); Wed, 8 Aug 2018 14:50:23 -0400 Received: by mail-pl0-f66.google.com with SMTP id u11-v6so1261816plq.5 for ; Wed, 08 Aug 2018 09:29:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=f9m4EzFrK4o7iKi+yVMqTnAXeSoP5rWcrhp2zGMzxHQ=; b=NPpiU691Vs6iBhcToq3ZnpjTAgzXLr3y4Jn7nvjQbAJ0aDfjm1hM6cbywXGTbxdTY8 Aqeqah9pWX3kYfjBnjKbBIsNuye49REYFpX1o7F4hGUn4xdixiGknYV6Q+F/P94aKFyO 33ERTcGXZIf7VU5jWP4nIy8gPnptqWElgW66mlgjJXCcf8aRkPt1YNLRdwzg1fgj8zxY MXH1i0aW4q5bK4O6vy7xAmdhNeUPrPd8XnqGgTCqOcc7xTxtmSFb4kQsyLjA1mT/VJfe nfTbsF/VRzuPH3r+1KbO627ZN5/SQUlH7ULcexJlDpmpXmJtfIGsb/JE8FmlZdeLwRSJ LlkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=f9m4EzFrK4o7iKi+yVMqTnAXeSoP5rWcrhp2zGMzxHQ=; b=Mojcnc3TE6Qe2k84xwfMEUr++pTVrEx4aKAIxA3kvHOxiCHvbsx1dUhzCFlzCTx88G AYzik/Xenk77J5FVSmTisTOs1oQzc7OC6ofc6/sDKijagB4KGcmqpJDyHyU8AzaWQU33 0+WXELKzL7nUmaYArAYI9Xj+xjvlzdhzmDSk//thO4m8S3H0GUjZdLtEQ5g106/euXHs 28m/t71K8zl7j0oJbTl5T2BjjK6Al9Bm7fgkK9AbnYKP/aYoujQUNw/WgAIpvTSavQbz Q3iW3DkcZ88PTWHJNotWaG0B41WN1zwlrnQT6uXCNRdjTCAOXxHK0X6EYdO9dCX9qsPY oQ/A== X-Gm-Message-State: AOUpUlF/4IXqUoNsybSzM7iTBSxtSANguPufyDFhfguqjPpu2SgIhvaK kJTaghVxtq0MsFv/ZCNjWER3h7kS6eMexowe1CDIZQ== X-Received: by 2002:a17:902:8482:: with SMTP id c2-v6mr3275801plo.45.1533745796807; Wed, 08 Aug 2018 09:29:56 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:5d02:0:0:0:0 with HTTP; Wed, 8 Aug 2018 09:29:56 -0700 (PDT) In-Reply-To: <1959555.Z0pJAWgXVZ@avalon> References: <1959555.Z0pJAWgXVZ@avalon> From: Ezequiel Garcia Date: Wed, 8 Aug 2018 13:29:56 -0300 Message-ID: Subject: Re: [RFC PATCH v1] media: uvcvideo: Cache URB header data before processing To: Laurent Pinchart Cc: Alan Stern , Keiichi Watanabe , Tomasz Figa , Linux Kernel Mailing List , Mauro Carvalho Chehab , Linux Media Mailing List , kieran.bingham@ideasonboard.com, Douglas Anderson , Ezequiel Garcia , matwey@sai.msu.ru Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8 August 2018 at 13:22, Laurent Pinchart wrote: > Hello, > > On Wednesday, 8 August 2018 17:20:21 EEST Alan Stern wrote: >> On Wed, 8 Aug 2018, Keiichi Watanabe wrote: >> > Hi Laurent, Kieran, Tomasz, >> > >> > Thank you for reviews and suggestions. >> > I want to do additional measurements for improving the performance. >> > >> > Let me clarify my understanding: >> > Currently, if the platform doesn't support coherent-DMA (e.g. ARM), >> > urb_buffer is allocated by usb_alloc_coherent with >> > URB_NO_TRANSFER_DMA_MAP flag instead of using kmalloc. >> >> Not exactly. You are mixing up allocation with mapping. The speed of >> the allocation doesn't matter; all that matters is whether the memory >> is cached and when it gets mapped/unmapped. >> >> > This is because we want to avoid frequent DMA mappings, which are >> > generally expensive. However, memories allocated in this way are not >> > cached. >> > >> > So, we wonder if using usb_alloc_coherent is really fast. >> > In other words, we want to know which is better: >> > "No DMA mapping/Uncached memory" v.s. "Frequent DMA mapping/Cached >> > memory". > > The second option should also be split in two: > > - cached memory with DMA mapping/unmapping around each transfer > - cached memory with DMA mapping/unmapping at allocation/free time, and D= MA > sync around each transfer > I agree with this, the second one should be better. I still wonder if there is anyway we can create a helper for this, as I am under the impression most USB video4linux drivers will want to implement the same. > The second option should in theory lead to at least slightly better > performances, but tests with the pwc driver have reported contradictory > results. I'd like to know whether that's also the case with the uvcvideo > driver, and if so, why. > I believe that is no longer the case. Matwey measured again and the results are what we expected: a single mapping, and sync in the interrupt handler is a little bit faster. See https://lkml.org/lkml/2018/8/4/44 2) dma_unmap and dma_map in the handler: 2A) dma_unmap_single call: 28.8 +- 1.5 usec 2B) memcpy and the rest: 58 +- 6 usec 2C) dma_map_single call: 22 +- 2 usec Total: 110 +- 7 usec 3) dma_sync_single_for_cpu 3A) dma_sync_single_for_cpu call: 29.4 +- 1.7 usec 3B) memcpy and the rest: 59 +- 6 usec 3C) noop (trace events overhead): 5 +- 2 usec Total: 93 +- 7 usec --=20 Ezequiel Garc=C3=ADa, VanguardiaSur www.vanguardiasur.com.ar