Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp484678ybt; Wed, 1 Jul 2020 03:18:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNMMoQHY7rXFs2np1DsDoa0KHnWnlZhExvBwXk35Xre9z3hEt3NpfNrVhKPXGDzTSTE70d X-Received: by 2002:a17:906:1c05:: with SMTP id k5mr21599861ejg.320.1593598723928; Wed, 01 Jul 2020 03:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593598723; cv=none; d=google.com; s=arc-20160816; b=AZ/wrlZsXxjIDvKUJJse8Qo2BWLt6KKHnaQ8m6pjgXj9YuyTHUqbm3WEq6eoTCGLZ+ HL9AiRbVlwXtTll+TqP2o9jemDZ4wxfhTjMJkMn541zXBnWyDMKMOYbJ8koG8YtkpNZT 8yvCdZ87VQ0YpE276qN9DRekVCOemdsCI9YWPzcBoPcEAo7aeqYwQFD6lHQLcoSsg1B0 Y8ZP2Lnxiq2iNiwb6ZkRNaktZf7VMi3cE5AbZp0EvjEnYLyaSV2xOhT+Cp7VEPs0IBa/ +c/+QfILY+TlDCIocZQ+vJrJHXC9C2TvGEZE4BaWhunUUc+C40rvplJaeRvYxJBKVwca Gp3A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=kpaYfe60JXkOzIGnBTFLRWhSJpwNm8yWEF1w/TFYmgU=; b=kfqPMoUqG+9N87QPBElzuAgSI5uVAr2Nrh791jZaBlkVy5jSaHdmr/lYaptuuHWMU8 1OL+sPrWFuT4wDzL1JQ8msmjLsvuVSw5RzbUlQZfq8vaFnQWmjtmpunVkOO+VubkHG6H FwUSbCfrCpt9ttMIp0i/Iz4VJcSAQcxdtiF3tAXKtplPmH1mAscHIE6O2bx2K35+FP4w P98qNhrRBtKHTj1lFk9L8FQOjj7vqrXU9lDzL62ry0tGP41C1vx0mZTYEKDckD82e3df rzpqwVIZxeP8Q5e6omQF+sBvY0LsLd174+nuGIDwuM5R/b0s7Q0pHOKSgwBxe6zyLXnK Yp9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d4si2754696ejb.349.2020.07.01.03.18.19; Wed, 01 Jul 2020 03:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729875AbgGAKR4 (ORCPT + 99 others); Wed, 1 Jul 2020 06:17:56 -0400 Received: from mga05.intel.com ([192.55.52.43]:65263 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729226AbgGAKRy (ORCPT ); Wed, 1 Jul 2020 06:17:54 -0400 IronPort-SDR: UA7j/NGZc672E0pj279sLbEV3EM8ayOjoZr8CDync9Uh8LCi3f0vUmjR1XQMwhWN8ddVrZFHPB WVnJrnxbD/og== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="231405050" X-IronPort-AV: E=Sophos;i="5.75,299,1589266800"; d="scan'208";a="231405050" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2020 03:17:54 -0700 IronPort-SDR: 5MoAoKthMtffAjAf4xbx0GXdGvaC7TB4m9gWvV0bQ0XO+4ddVOvXKSxFN+AdHJEQMv2szwRaNc OGuQIuRAbGYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,299,1589266800"; d="scan'208";a="481542314" Received: from unknown (HELO btopel-mobl.ger.intel.com) ([10.249.43.154]) by fmsmga005.fm.intel.com with ESMTP; 01 Jul 2020 03:17:51 -0700 Subject: Re: [PATCH net] xsk: remove cheap_dma optimization To: Robin Murphy , Christoph Hellwig , Daniel Borkmann Cc: maximmi@mellanox.com, konrad.wilk@oracle.com, jonathan.lemon@gmail.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, netdev@vger.kernel.org, bpf@vger.kernel.org, davem@davemloft.net, magnus.karlsson@intel.com References: <20200626134358.90122-1-bjorn.topel@gmail.com> <20200627070406.GB11854@lst.de> <88d27e1b-dbda-301c-64ba-2391092e3236@intel.com> <878626a2-6663-0d75-6339-7b3608aa4e42@arm.com> From: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Message-ID: Date: Wed, 1 Jul 2020 12:17:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <878626a2-6663-0d75-6339-7b3608aa4e42@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-29 17:41, Robin Murphy wrote: > On 2020-06-28 18:16, Björn Töpel wrote: [...]> >> Somewhat related to the DMA API; It would have performance benefits for >> AF_XDP if the DMA range of the mapped memory was linear, i.e. by IOMMU >> utilization. I've started hacking a thing a little bit, but it would be >> nice if such API was part of the mapping core. >> >> Input: array of pages Output: array of dma addrs (and obviously dev, >> flags and such) >> >> For non-IOMMU len(array of pages) == len(array of dma addrs) >> For best-case IOMMU len(array of dma addrs) == 1 (large linear space) >> >> But that's for later. :-) > > FWIW you will typically get that behaviour from IOMMU-based > implementations of dma_map_sg() right now, although it's not strictly > guaranteed. If you can weather some additional setup cost of calling > sg_alloc_table_from_pages() plus walking the list after mapping to test > whether you did get a contiguous result, you could start taking > advantage of it as some of the dma-buf code in DRM and v4l2 does already > (although those cases actually treat it as a strict dependency rather > than an optimisation). > > I'm inclined to agree that if we're going to see more of these cases, a > new API call that did formally guarantee a DMA-contiguous mapping > (either via IOMMU or bounce buffering) or failure might indeed be handy. > I forgot to reply to this one! My current hack is using the iommu code directly, similar to what vfio-pci does (hopefully not gutting the API this time ;-)). Your approach sound much nicer, and easier. I'll try that out! Thanks a lot for the pointers, and I might be back with more questions. Cheers, Björn > Robin.