Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1350583imm; Wed, 8 Aug 2018 15:36:22 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzZ56HZeLFAd1xKtKhngOrbQ14lSNLfXHiweU0lA6e9l2SsGpHp7HiN06eZ1E52ZhpAtmm4 X-Received: by 2002:a65:4b87:: with SMTP id t7-v6mr4094717pgq.391.1533767782255; Wed, 08 Aug 2018 15:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533767782; cv=none; d=google.com; s=arc-20160816; b=M2Iu8J2BXQ9P25hX5fOaZFkVIOLYEMuINFVV/wZvZmAGLgpqDaNYBR8arlDjl2yrTQ egBymzSgCJpy9mlsH+6kqWm2UOg9Aheu6pfhUzEO5rVSBX2sHynNrD4aw8dkIFkhjTll Z9vfkX18QnZdD1xANC5nqa006yUjqv9kNyLBqzjmbbaThU3EGGoDSq4+44yqWwtW3mof hjvjuP+X+Sez7gExCnOeoMQ80hgEVS9eNwqorNo48pu0OCwDTsLf/HoRnYF5MPhmUnUJ GCLqiWUSePIOBrgcgJWFKMriEQiHSsA/QDfsCU/6CmI7dVqd7pSqpVIw1b6Li2ngqYjf aO7w== 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:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=w2YhtwvYeJht2hMA1cf7ft0s7QxFnBVNv6FcGFR8STQ=; b=rZ9u/J2t05uWHakYmsGERrjukB3JYnJXcXaLAcfAitWQqzmGOpBtuJGZziXg/XmK5k QLFrYgAP00PV5kt+2k0oX6QPIAT7eLajbOc8LpUHVLqadGcGGCWiz2YMnPxwyG8RRfdV k6CZL2TpdUdiHJdxhoM1kfZhBtC/V3/bhjs/RR5ngTZFfsrmGwaUkraSwu7LyJvbxvsg a7QzPMh75snfd0Q/mmCTj9VU2T2w0ov4nXBhKygd9ryitT0x7kCXy/F09742W8JuAiyN hq5OaXV542vaxZhTc6Ob0kAdE2G1xpRTcq5ZhHHYkhU+c1VfTGYtq2aDAwesv53KQm/Q 5t4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=ZGyOhnqp; 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 t11-v6si4200070plq.265.2018.08.08.15.36.07; Wed, 08 Aug 2018 15:36:22 -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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=ZGyOhnqp; 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 S1731951AbeHIA4Q (ORCPT + 99 others); Wed, 8 Aug 2018 20:56:16 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:38744 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731015AbeHIA4Q (ORCPT ); Wed, 8 Aug 2018 20:56:16 -0400 Received: from avalon.localnet (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 04156CD; Thu, 9 Aug 2018 00:34:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1533767669; bh=yEx6SGQXUyn9MtkHrbQ3o3uCSfc8SmY1TF1gDAeME1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZGyOhnqpMODasvyi2yucSrHvMcG3QTypdRCwEnZd91C8pAxSIgCZdmXcLvjScGc5I bd/Mld0P09iG2ybDf/tnPQyomnqWClJZLRZxC/GsOvLcHQFItzXZnXnjvzDDNoiR8u c3McqYtisqe8ZoSrp53j9DOI9juvdWEpdC4TsZ0Y= From: Laurent Pinchart To: Ezequiel Garcia 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 Subject: Re: [RFC PATCH v1] media: uvcvideo: Cache URB header data before processing Date: Thu, 09 Aug 2018 01:35:13 +0300 Message-ID: <2864865.ZqDiYThxxv@avalon> Organization: Ideas on Board Oy In-Reply-To: References: <1959555.Z0pJAWgXVZ@avalon> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ezequiel, On Wednesday, 8 August 2018 19:29:56 EEST Ezequiel Garcia wrote: > On 8 August 2018 at 13:22, Laurent Pinchart wrote: > > 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 > > DMA 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. I agree with you, drivers shouldn't care. > > 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 I hadn't caught up with the pwc e-mail thread, I now have, and I'm happy to see that everything is now properly understood. Thanks again Matwey for your work. -- Regards, Laurent Pinchart