Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3526868ybg; Mon, 28 Oct 2019 14:21:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqykkbAb9VJxqfC2Z+W46AQzo5UA1QBvIm2U6vS5kW6WDRJJIktPZfqsmfvcjsR+Tlrv3vTe X-Received: by 2002:a50:870c:: with SMTP id i12mr15357172edb.16.1572297714588; Mon, 28 Oct 2019 14:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572297714; cv=none; d=google.com; s=arc-20160816; b=u8wwOwye50X9vjG0jNy695QXpR2YE3ZdAYES8P1LasVaTTgFpQkI6UnYNOKHswour5 RJV/OyncfJeGlD2d6/erXBS0PQCWZcTR4ve/5RowsO2ja6k0AxC8Zqqj3HREDN1K+U/d gjfU4qOtrAiM7sg5NeRHf3tGVsnjY35U72xMTr93bkjeV2TplPVdy5DlXUgdeM7EV552 r53VQ7mwhPozdxx7S/mEdwQOMoIZJ3oqq6b+/r+pzUoyt77ATMQ8NMyq0LijQirMDLZT iXH6t+u8ChBrQ8tOSzgdMzKoJWhjaY4u1kwIWID1jzGrMA2YIOuvW8SygzuSGJEQSx0G hXZA== 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=A5W7u7DSJb0LcwKOy/vRW0vYB0Jd8xNfJY0DoVS5j3s=; b=WSyKow/e5jB+LyUfCw/XVS7wAwxwO7nqARKaMTXcdSGA/fltBUDOCAVb8QmcL+9b4n tfP06C6CQmP4PQSlcOlxUenzM8NlCJ3y+1L00Yy4wPj7R0Qfbra1UrjuHsJhy4ceqJhR w7a0o//PVd3qIt7jj7xI4aDW0Ow4nGiU9QrPMNOkPtRKsJISZTcX/0+OXisZUdilJ1zP SIuoqSYuWWUjR9tBcnNXcxrePJdbvjUKyZQk9H2y1aYi9nwGI6/LdELo5NmPH+qoCG9Z hRXWJPh59HUA2OKRbw9oOjrsY+SkIPxoLURLPGU7Jxpdp2QX+WAOZbQMuMdwmxsXEq12 3ALA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=OTIwhWIM; 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 k15si7072997ejz.22.2019.10.28.14.21.31; Mon, 28 Oct 2019 14:21:54 -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=OTIwhWIM; 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 S2403834AbfJ1QnD (ORCPT + 99 others); Mon, 28 Oct 2019 12:43:03 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:45886 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731441AbfJ1QnC (ORCPT ); Mon, 28 Oct 2019 12:43:02 -0400 Received: by mail-pl1-f195.google.com with SMTP id y24so5837445plr.12 for ; Mon, 28 Oct 2019 09:43:02 -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=A5W7u7DSJb0LcwKOy/vRW0vYB0Jd8xNfJY0DoVS5j3s=; b=OTIwhWIMVYSCUPSVUxSOG8qI1iEq/l4wie9FZSeQ/pzkHfU5FBJd4eHTLTh3V0W7tn eS9zbcOAXPW9vtlHlsEcOCuU+eKNRul6YzlJPuidR+Ig8lriDtDTszsm/JRb68e+7IR3 1Q7KArlazBtJibtpRFKzKAH9aJ5lMIc9FV8fGcw4ca+k8MdsIX4SUZr5H0sz3A29Kw3q qScOzIPjEJnGztkYMFMWeUtPlRw/8dNsCcMbE3XY4g6X1kuq29zuJJUOsKxVRxh49jH2 X4gYh51ujEqHA7Hnoq3uNLWteKgTULb3Zom1yaj/hVnzUW6lZy5V3pKxUdZHZkNeB40R Y6Sg== 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=A5W7u7DSJb0LcwKOy/vRW0vYB0Jd8xNfJY0DoVS5j3s=; b=Yjsf4aq7tA94pcpazgh5AivrL/kMq7EXF3PcJHl7We9gIFcqpe9o9KNz7UnEH5xihM HqJIs+suAaqnZwPHBQWFaqkGZINYaKe1viiOqXMxA2/1eCX2bY/Op0t3PcsrW6VHgraQ ZIa1Y/YWzbCmhEHOZPrK1i7hltKCVo3EtNPyc8r/OPRb589cGVFOhvNNxsN89audAtpY LcfDRxwqJonZZ5+NCWqFT5WNZLJa8Xv9iUyqq/hv/8jxG+zxTFUfh6iH8XZtC5T1KmAR 12dYcLEuG+C//6X6vQHLS2SJYtgNXhf5njgL5GgWdfpWS2tABWu1VM9R3PFzJBEV92ew kNyg== X-Gm-Message-State: APjAAAV6qZ0U6W1PvehdbWiTlrr36UDq+OQVUMRyRgIoQMpIGE8PJHOs 76SVlpUHkvrhsSli3QJ6iSO0RA== X-Received: by 2002:a17:902:122:: with SMTP id 31mr20000084plb.257.1572280981838; Mon, 28 Oct 2019 09:43:01 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id s18sm5146575pfc.120.2019.10.28.09.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 09:43:01 -0700 (PDT) Date: Mon, 28 Oct 2019 09:42:53 -0700 From: Stephen Hemminger To: Willy Tarreau Cc: Andy Lutomirski , dev@dpdk.org, Thomas Gleixner , Peter Zijlstra , LKML Subject: Re: [dpdk-dev] Please stop using iopl() in DPDK Message-ID: <20191028094253.054fbf9c@hermes.lan> In-Reply-To: <20191025064225.GA22917@1wt.eu> References: <20191025064225.GA22917@1wt.eu> 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 Fri, 25 Oct 2019 08:42:25 +0200 Willy Tarreau wrote: > 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 DPDK does not want to system calls. It kills performance. With pure user mode access it can reach > 10 Million Packets/sec with a system call per packet that drops to 1 Million Packets/sec. Also, adding new system calls might help in the long term, but users are often kernels that are at least 5 years behind upstream.