Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1063288imm; Wed, 8 Aug 2018 10:05:52 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzakgXKJm6NCMaRAroRb5pFjnjF2f411XWS8W5zLgopZuFC3suDu0bYgVUEIi9Eu+sbUCf4 X-Received: by 2002:a63:4d47:: with SMTP id n7-v6mr3348563pgl.270.1533747952344; Wed, 08 Aug 2018 10:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533747952; cv=none; d=google.com; s=arc-20160816; b=eFIf8P/NFvOklAhLVVDK/L8SJJcqrIQc5ZXXyew8ANNRdS895mxFoljK/xKfA/ZVGs nKNfFDlWqQ5wLV3ZmY7e6Bt6WVckEjgDundxvQpzvnxrBpMg7eh6Id4/R5NTAMvKGsB7 fbA2UAjxoN2SgGeHIqWgEH9oi7pO7iZ+SpL9RSrJzsnqCroj+NQMVJvytaLuLQyfkaIZ mN0oNqnWSmT3qpsNlKqTPdO0Jz+stACvXRBfISrRHyd4Ns9erwPO7hRNtUrzeSVcbjyT w1KtJgYPaGt6mNmaxrJMJE5P8GYDM4lOMEk18ryYfzibr+nvDtbzhQYe97KFcDu+deHv Nerw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=Z0httvTmdvnrjN22PihdUvSvtl2zf3dKEmhCsagSMJk=; b=U1MKEOQWHJtyE6MBmGp8AFGEkUdClN1oRJ8mSz3XusCxNQ3drHAbHBUS22++HUcqxZ LDdrvEZPuM+gSIK67bYylHdWUkXdbcuUz56O99faoGAzqwsh1njxl2DsXLoaK/JxOJpe zI3ZlSb+dcsFbOpH/ZWAZF7146CQi6VPjBUNI4Ozq83C6kRBcg7cVk1OvACLtVHOL+Cn 6NgobGYXAHgsqPOpnEDa2pvPw4aFg2LXD5RD5W1SDbnmn56yDpenDkxzOat0e7iewUVZ bzvHKlM+HK27qFG9jcsX3SKfERY0ZTy7+iwTZgh0zipx4uP+MoA2ygzDIuwd9gZQ7lx3 lwWw== ARC-Authentication-Results: i=1; mx.google.com; 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 i124-v6si5108560pfc.110.2018.08.08.10.05.37; Wed, 08 Aug 2018 10:05:52 -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; 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 S1728060AbeHHTZV (ORCPT + 99 others); Wed, 8 Aug 2018 15:25:21 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:55368 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727337AbeHHTZV (ORCPT ); Wed, 8 Aug 2018 15:25:21 -0400 Received: (qmail 6582 invoked by uid 2102); 8 Aug 2018 13:04:45 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 8 Aug 2018 13:04:45 -0400 Date: Wed, 8 Aug 2018 13:04:45 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Laurent Pinchart cc: Keiichi Watanabe , Tomasz Figa , Linux Kernel Mailing List , Mauro Carvalho Chehab , Linux Media Mailing List , , Douglas Anderson , , Subject: Re: [RFC PATCH v1] media: uvcvideo: Cache URB header data before processing In-Reply-To: <1959555.Z0pJAWgXVZ@avalon> Message-ID: MIME-Version: 1.0 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 On Wed, 8 Aug 2018, 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 DMA > sync around each transfer > > 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. > > > There is no need to wonder. "Frequent DMA mapping/Cached memory" is > > always faster than "No DMA mapping/Uncached memory". > > Is it really, doesn't it depend on the CPU access pattern ? Well, if your access pattern involves transferring data in from the device and then throwing it away without reading it, you might get a different result. :-) But assuming you plan to read the data after transferring it, using uncached memory slows things down so much that the overhead of DMA mapping/unmapping is negligible by comparison. The only exception might be if you were talking about very small amounts of data. I don't know exactly where the crossover occurs, but bear in mind that Matwey's tests required ~50 us for mapping/unmapping and 3000 us for accessing uncached memory. He didn't say how large the transfers were, but that's still a pretty big difference. Alan Stern > > The only issue is that on some platform (such as x86) but not others, > > there is a third option: "No DMA mapping/Cached memory". On platforms > > which support it, this is the fastest option.