From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB6DEA00BE; Mon, 28 Oct 2019 19:01:04 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3BE941BF4F; Mon, 28 Oct 2019 19:01:03 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by dpdk.org (Postfix) with ESMTP id 8C44C1BF4C for ; Mon, 28 Oct 2019 19:01:01 +0100 (CET) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 5C0E821744 for ; Mon, 28 Oct 2019 18:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572285660; bh=jYHTq2fhIHq1FOGacNdIHCM7MFR7pavyDtJAQBFVzZE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sHQ5BW+4IbC5n3E0yGSonfPNMLwwnaEyifNaFo6GjGnbmAiIscG86OpPWOXR5I7kf Ep5LUXW/3jqk8p75rF6+VTgdRwfsjxidebVeo0ID2shPpfIGVuPOHAkM597TiF1+qK f96abHy/p7boIglCDvJVWbePMCwf684Vnx0io62Y= Received: by mail-wr1-f45.google.com with SMTP id s1so10912143wro.0 for ; Mon, 28 Oct 2019 11:01:00 -0700 (PDT) X-Gm-Message-State: APjAAAWVtta8ahgAGOaGIolLFd9/u4rIsk7Akj0v6Iv9Qf/wEoMay+Ut p5emuEUdEdnAO5QmpQ0EnoqdaATzwDFv96s+GXWFzw== X-Google-Smtp-Source: APXvYqzF/Z3m2iR7JMx3xMDTWkMb5TSAWZEwFovg5TksxxCMUY3r6eSG+zFmZVn16rMZZ9yO4EsPweoUVVftFsNQ3Hs= X-Received: by 2002:a5d:4d0f:: with SMTP id z15mr15475859wrt.195.1572285658852; Mon, 28 Oct 2019 11:00:58 -0700 (PDT) MIME-Version: 1.0 References: <20191025064225.GA22917@1wt.eu> <20191028094253.054fbf9c@hermes.lan> In-Reply-To: <20191028094253.054fbf9c@hermes.lan> From: Andy Lutomirski Date: Mon, 28 Oct 2019 11:00:47 -0700 X-Gmail-Original-Message-ID: Message-ID: To: Stephen Hemminger Cc: Willy Tarreau , Andy Lutomirski , dev@dpdk.org, Thomas Gleixner , Peter Zijlstra , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] Please stop using iopl() in DPDK X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > On Oct 28, 2019, at 10:43 AM, Stephen Hemminger wrote: > > =EF=BB=BFOn 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. If you are getting 10 MPPS with an OUT per packet, I=E2=80=99ll buy you a whole case of beer. I=E2=80=99m suggesting that, on virtio-legacy, you benchmark the performanc= e hit of using a syscall to ring the doorbell. Right now, you're doing an OUT instruction that traps to the hypervisor, probably gets emulated, and goes out to whatever host-side driver is running. The cost of doing that is going to be quite high, especially on older machines. I'm guessing that adding a syscall to the mix won't make much difference. --Andy