Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4125277ybg; Fri, 25 Oct 2019 13:43:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYWLZSTENfBNZyUWYcGAyIGX08Db+o3TEuHc9AWwrzS3qwj5LqqwXpoA8QYPc35FakItp1 X-Received: by 2002:a50:870c:: with SMTP id i12mr2236edb.16.1572036237407; Fri, 25 Oct 2019 13:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572036237; cv=none; d=google.com; s=arc-20160816; b=ix7ams6YAD3GVmdCjqcogDuAudwC8SFGF67wb0txhGkCWjYIitFsYS89E+MTUbSSMv +RcpOVDZ/svjhZ2JMFYlgs52CoC3a8WOGj/loo/L7+GCwEWpZH5OxRre+i8STixrSyxJ rI5tb24V/V3+cO2xC6e7X2EAzZfA87wu9gjrBFjI4o8J2L+yGfhYqNbE83btWXya78B+ Jm/bNSMx9Fkik/6YLa/A8sa68G8dOLo5nzHHTEIEiNgrPpvOOTlomddpQP3fQFN+/9Tz 5QZGPf7YgaeY5mine/ZaMqH/w0GqK0/lMLdOAn9Hm37CDmBPEVOqtZyrEqK6qq4ouVzD /onA== 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:message-id:subject:cc:to:from:date :dkim-signature; bh=DbUUYSktrWx+Mr7+/XFosbA8omgMeae0KrcIpIaZY+4=; b=zmZWt5oir0SVl8gANFO88dcrhbnqS0SNGK5oC5VmJ6ki38+5kV8ZBBxTm2XvwWExWr C1dsfMsn/1C69NoH6eNVeNktLFVzG+88mhBWKMNtjrFBEBmeesSz76lZlRUpGfLGR8iM R/QWDqPIisM9VZktabsMDlsrFLmsU7eW0uXu9+mO5B9HXPwyZB786CINCTweP202wFaV m8KmtwZJ8kK7lodGJtZGYSe/8eaBR3IpStHyO3z9yH49eBlE9Xqbdo+wucOtFuhdE4vH 4VLnxwUonJc7Nevg5ictMk28yc0U02AMhpaia1MvXNsWGwrUKOEsygPxioBaoVLJYqe8 ieyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=g0+LbZNv; 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 cf22si1965700ejb.290.2019.10.25.13.43.34; Fri, 25 Oct 2019 13:43:57 -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=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=g0+LbZNv; 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 S2505287AbfJYQNP (ORCPT + 99 others); Fri, 25 Oct 2019 12:13:15 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:45214 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503806AbfJYQNP (ORCPT ); Fri, 25 Oct 2019 12:13:15 -0400 Received: by mail-pf1-f195.google.com with SMTP id c7so695446pfo.12 for ; Fri, 25 Oct 2019 09:13:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DbUUYSktrWx+Mr7+/XFosbA8omgMeae0KrcIpIaZY+4=; b=g0+LbZNvC0/oQnA0E65voBPgI5E6LKImNIIY7vUgQIElbTP/N/BrP2eccHFrkwmFmY s/iRUc4IV33YfRn/jX8Dy5Rq/NFKpFf4+d+q8dsh1+mEWOqN1FDBuMLWAS/i7aiQDsTm rjZgYLDqNmvlES6m6SYlAsPse7N2DqlyyNu11QSUp8oEHIxqBkd52aZQWm93ynBV3QBI VCthI6AJ3X/avwK3KIFyPQAxihrQ2sHp2eIyAT+Q3Xy0iCAz40Kk5xkOkrJWkVcFD2wn MvWrFjUXMSAKazqGJ9Szf/+biteH0kYub08b0Xot8NmyY7SnoyQ4Z6XqA8WCb+zcBNyS Pmhw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=DbUUYSktrWx+Mr7+/XFosbA8omgMeae0KrcIpIaZY+4=; b=dtrkBmHQGbEcuN65dp0pFY74ao3mL8UE9WeuBkkGCM+n5zvc7rDmCP368xy5+d5/Qd Imzxb18vLgB8/nIP5ptzFcYZYbJiTNJGk74aorKXBb2/T8BtNzR9MyYSN9/xJ7ZZyOcu 8R/SDQpbU2J/NFiEaj+tDm+t2jUDV+qESeEiBMkrvrqXY/7vDG7yHCfzOiOkUBpdBdTD NORZvK3oux5D3uA2jrbiUrod9RFvkSRUkTaTO22MLWhpA+e786xfxYXzXkimmnWTkGQR m9wELWvSPT80AiC8IrOgAF8a3htp10i7vCUh+ey6urA2p53VCOoSwPPIX/Zr4tCi4BJu JTRg== X-Gm-Message-State: APjAAAVTGvDgc0h8tQguG31VkFCVEUS7Qbhga1LAttyzhGTswaaJI4Db +cSeK5L0AxW/zraQj0SUzt0CUg== X-Received: by 2002:a63:4c1c:: with SMTP id z28mr5276599pga.167.1572019994202; Fri, 25 Oct 2019 09:13:14 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h14sm3024927pfo.15.2019.10.25.09.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2019 09:13:13 -0700 (PDT) Date: Fri, 25 Oct 2019 09:13:10 -0700 From: Stephen Hemminger To: Andy Lutomirski Cc: dev@dpdk.org, Thomas Gleixner , Peter Zijlstra , LKML Subject: Re: [dpdk-dev] Please stop using iopl() in DPDK Message-ID: <20191025091310.05770edc@hermes.lan> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Oct 2019 21:45:56 -0700 Andy Lutomirski wrote: > Hi all- > > Supporting iopl() in the Linux kernel is becoming a maintainability > problem. As far as I know, DPDK is the only major modern user of > iopl(). > > After doing some research, DPDK uses direct io port access for only a > single purpose: accessing legacy virtio configuration structures. > These structures are mapped in IO space in BAR 0 on legacy virtio > devices. Yes. Legacy virtio seems to have been designed without consideration of how to use it in userspace. Xen, Vmware and Hyper-V all use memory as a doorbell mechanism which is easier to use from userspace. > There are at least three ways you could avoid using iopl(). Here they > are in rough order of quality in my opinion: > > 1. Change pci_uio_ioport_read() and pci_uio_ioport_write() to use > read() and write() on resource0 in sysfs. The cost of entering the kernel for a doorbell mechanism is too expensive and would kill performance. > 2. Use the alternative access mechanism in the virtio legacy spec: > there is a way to access all of these structures via configuration > space. There is no way to use memory doorbell on older versions of virtio. Users want to run DPDK on old stuff like RHEL6 and even older kernel forks. There are even use cases where virtio is used for a non-Linux host; such as GCP. > 3. Use ioperm() instead of iopl(). Ioperm has the wrong thread semantics. All DPDK applications have multiple threads and the initialization logic needs to work even if the thread is started later; threads can also be started by the user application. Iopl applies to whole process so this is not an issue. > > > We are considering changes to the kernel that will potentially harm > the performance of any program that uses iopl(3) -- in particular, > context switches will become more expensive, and the scheduler might > need to explicitly penalize such programs to ensure fairness. Using > ioperm() already hurts performance, and the proposed changes to iopl() > will make it even worse. Alternatively, the kernel could drop iopl() > support entirely. I will certainly make a change to allow > distributions to remove iopl() support entirely from their kernels, > and I expect that distributions will do this. > > Please fix DPDK. Please fix virtio.