Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4119556ybg; Fri, 25 Oct 2019 13:38:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBU5NPRrCJcxCzutpS4VLA36uW32JLTlU78/1ZFy9mP5GxJzvfRdKQuR8K5KveUee5Swgm X-Received: by 2002:a17:906:5907:: with SMTP id h7mr5224750ejq.328.1572035893850; Fri, 25 Oct 2019 13:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572035893; cv=none; d=google.com; s=arc-20160816; b=wPEVY+F68HijDe7vNKGRVukIT893MS22FC4MI4ECkZ96of9p6PZnSq+noW3VhbOYQJ 05SbguW/cD9FUULr5fzRwhhAHoIoz449OwwpVv+yykudR+wWhIbryqp9yghjmKiHGUdG TV9FN6ibC2a/UmoATWrd9qXgGeG4FyBWIoAbrL09EmNSSMfsS/hF7vQAnqhS42VP4/IM eB+i+IsD/WQMfFpIESGOfMJxXlR0bCYInxUXskc6EZJDiOjFslMFzsYERghIkIrfza+S GgRvUy/PLtmisR2dS5QqYZU1cKRwXXZqqRNEyjU4sdTuyGUutaEKdDPv4/3NMiPykzCG 0ylw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kL4YlBXSyiHnRZFVmXNg4ahICoUtHH33FKcTtU6ktMQ=; b=kxt++5hFg/rOdfHLKfA1CgNNiRxExSJoEVFjEULQNPdXqjzullSv1yw8YE935FrVLn 2pv22bJCFS4AbNs7H6QUBqYxrJHpT2BX5PqTo1MINA78AjirF0KLSw1NISMnekhn11pF pArsX6LOjv+M7ue710URAIbUhmW5gomqoTrk8zMpV4mSI0/Hhw6ANjyJTrEEsa9Z36gk Zc1CjZmpOh5aBgPzFYVSW9/Etx1qQ+Ll32EJHYc6hSJKwmIVdAa9vg0BdOSdKo8Yclbp Ht+cnoGx6yu1fLnlnU1M1T+MWzWuTy27adddfcypZEHAEikmqmblgVbAaLjU1sBwFZ2o KYZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hkMaQ42B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si1698150eda.433.2019.10.25.13.37.50; Fri, 25 Oct 2019 13:38:13 -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=@kernel.org header.s=default header.b=hkMaQ42B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395003AbfJYOqC (ORCPT + 99 others); Fri, 25 Oct 2019 10:46:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:46594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390195AbfJYOqC (ORCPT ); Fri, 25 Oct 2019 10:46:02 -0400 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B5DA21E6F for ; Fri, 25 Oct 2019 14:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572014761; bh=c0TJ1mKs2s0GUD/wp9Pell6cGrl9NXu0zGJCItAHu+0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hkMaQ42BA+w+biTpZI2C7IZ7RMwTnWX4vcDPoqxZHjjbESTSKSYzawpMytL0ntVGa i9vII2WX5+UXdGA3Il7bt/ALNrsVari4gzY8bHMHwSelBbrDXh+vSMDZSBKaeJefT3 4jurLclJrpH+k2u/5euOwanrgR9VvrrxOWSpfYxo= Received: by mail-wm1-f41.google.com with SMTP id g7so2430915wmk.4 for ; Fri, 25 Oct 2019 07:46:01 -0700 (PDT) X-Gm-Message-State: APjAAAWdxx475QHNYU5YQP0YPIRddVUEGXXNewSPt16E/TXT86CWhE/g oGHqQPbMMLbF/PslQL6+Ey5d1PVW9D+iUbGH8PPcaQ== X-Received: by 2002:a7b:c74a:: with SMTP id w10mr3616761wmk.173.1572014759511; Fri, 25 Oct 2019 07:45:59 -0700 (PDT) MIME-Version: 1.0 References: <20191025064225.GA22917@1wt.eu> In-Reply-To: <20191025064225.GA22917@1wt.eu> From: Andy Lutomirski Date: Fri, 25 Oct 2019 07:45:47 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Please stop using iopl() in DPDK To: Willy Tarreau Cc: Andy Lutomirski , dev@dpdk.org, Thomas Gleixner , Peter Zijlstra , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 24, 2019 at 11:42 PM 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); Hmm. I have some memory of a /dev/ioport or similar, but now I can't find it. It does seem quite reasonable. But, for uses like DPDK, /sys/.../resource0 seems like a *far* better API, since it actually uses the kernel's concept of which io range corresponds to which device instead of hoping that the mappings don't change out from under user code. And it has the added benefit that it's restricted to a single device. --Andy