Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4037939ybg; Fri, 25 Oct 2019 12:25:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhdUzAPn5RdF9LfS6QDoHlvjLrmSm715teybaqrTPqQuvjH+Kka/l6RgBaOQrYhh6wf1aX X-Received: by 2002:aa7:cdc6:: with SMTP id h6mr5840804edw.243.1572031527586; Fri, 25 Oct 2019 12:25:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572031527; cv=none; d=google.com; s=arc-20160816; b=Ib7GhyONx0qfM4bf+H8ARUrfBH9Ghga8gfgXEMzV4EGezaPyQY3GrMPiZbKwdxQ9vD t6bqFX9WG8Ih3BIO9p698DO6s2BwQsmFITYQ5nAvHriQ13uyLSbrUEZLmrjV5NXVrYHt Gk/RllX3rKItLMPMf592U8LaDUh9Xo9EnjE1iSdN5fYwHaEE3zc3gUj9IsH5OGzFrbTE A5irCQUhitVxI2dFFL0vfGkzMfZiHI+17xLEKZkJw0Rhy1fxMyT28U+udF7ymKIzz0MI UEnRQA2OIauI98IV1H8cQuOEmQCdjFAu2SFlAWI3+M5HHCC/IpppGBRufa0Ih1FwWaYr FSCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=unfN0QaL2k0Zqdi50djmU2F8I/b9QvAdGXVYUoRcDJE=; b=jK/EBq/FFpQYpHM815PoJWHXcZ6e1MBCr58qcDT7vz3++1jtw/Y7Kx2MHQdGO2iekr kaVZ0bJG3+DXKSqADnPJKcmVI5swPw3iCI49wv8ypsiF1zI15vMbuKRB5SC0LWa4QGk4 u6nmdBCOHAYF1HvMme7V5W+Y0Qertq7q7RlmKeaPyNP7pFKrCrPvhJMoqOIo7IUU8Lfm GfTFen9lZ6Go9PmDJCcPd+UoLxcntM2jGFmz0UnbC1QTYqn24VCwqzcyigBzVR8XnE6/ ovTxsHYW0y4bwVR3kNV8RlqKDLZLLGKWAILAYdSDcF7B7ES+VrOLpUCpEdrNgTpguaIr hRgQ== 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 h49si1966365edh.2.2019.10.25.12.25.04; Fri, 25 Oct 2019 12:25:27 -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 S2405247AbfJYGmk (ORCPT + 99 others); Fri, 25 Oct 2019 02:42:40 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:4549 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405128AbfJYGmk (ORCPT ); Fri, 25 Oct 2019 02:42:40 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id x9P6gPsq023039; Fri, 25 Oct 2019 08:42:25 +0200 Date: Fri, 25 Oct 2019 08:42:25 +0200 From: Willy Tarreau To: Andy Lutomirski Cc: dev@dpdk.org, Thomas Gleixner , Peter Zijlstra , LKML Subject: Re: Please stop using iopl() in DPDK Message-ID: <20191025064225.GA22917@1wt.eu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On Thu, Oct 24, 2019 at 09:45:56PM -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. > > There are at least three ways you could avoid using iopl(). Here they > are in rough order of quality in my opinion: (...) I'm just wondering, why wouldn't we introduce a sys_ioport() syscall to perform I/Os in the kernel without having to play at all with iopl()/ ioperm() ? That would alleviate the need for these large port maps. Applications that use outb/inb() usually don't need extreme speeds. Each time I had to use them, it was to access a watchdog, a sensor, a fan, control a front panel LED, or read/write to NVRAM. Some userland drivers possibly don't need much more, and very likely run with privileges turned on all the time, so replacing their inb()/outb() calls would mostly be a matter of redefining them using a macro to use the syscall instead. I'd see an API more or less like this : int ioport(int op, u16 port, long val, long *ret); would take values such as INB,INW,INL to fill *, OUTB,OUTW,OUL to read from , possibly ORB,ORW,ORL to read, or with , write back and return previous value to , ANDB/W/L, XORB/W/L to do the same with and/xor, and maybe a TEST operation to just validate support at start time and replace ioperm/iopl so that subsequent calls do not need to check for errors. Applications could then replace : ioperm() with ioport(TEST,port,0,0) iopl() with ioport(TEST,0,0,0) outb() with ioport(OUTB,port,val,0) inb() with ({ char val;ioport(INB,port,0,&val);val;}) ... and so on. And then ioperm/iopl can easily be dropped. Maybe I'm overlooking something ? Willy