Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp806185rdb; Wed, 1 Nov 2023 03:29:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHL+suYSdYiD8B9//4AKVI9GKyWMaI4X8qNOG2qJUQhP2P2nIMJH7k7z8gbj/eO3SS/yRTQ X-Received: by 2002:a05:6358:ee97:b0:168:ea7d:5a45 with SMTP id il23-20020a056358ee9700b00168ea7d5a45mr17820391rwb.27.1698834570882; Wed, 01 Nov 2023 03:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698834570; cv=none; d=google.com; s=arc-20160816; b=NpkuJlvJeEWVMIIAQvkdVfLtSe+s/d0jk94sTyajOk2E3fDGS6nZHlwbY4D72KNMee t3f4zvhJz3/NZOYCeWsmpnbz8kNWxMHarrIGNbb4Jv8hu759YN1xCUVCF9RkokO0wyM2 J4UwaS0mmgCtL4odsLZP18U1/snCT+vHQJrJmJu9KqcMVbj4sn28/Unka8sdT92YZoMk Qi8kG/lHOdpNSQFOW5xWa/gwZ4gBIfsivQUBBx3ZuDX5pHIr6b4hUzPIzFU83bB7+A4R JUjv3RdXOjY/u3yrGFHCccVu5i5fyTgGXORCqWFX6gHZUSL1aH5qNqlJjEXwJndrcYZS I+aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YqI36cfidBvfcbWCHZIi34My4LBUITxzF3CxYYDCZq0=; fh=Ly4ODSF1SS2EwGJPLibj6pPqMVohsJ612rYGniT+Jng=; b=mIdRQBsHCSJDYV/Yh4Vi6PX/TKbZ0QN4nGtpLvpG8i9HFkT3DT6LJ/wOz22Vk5TeME Ym3dTFVIKo1ETrpp/WS9P37KOY/KKr4z5Ww5HXV/AJ/tgnR45Z0cwZDjzg/biLSpR8Qz T7G1Xoll6wcIC2MGyy7CXcZ1FIXktZoS+8tHaLmv7s/Yzk7cpPROU1yd69M3f4pjuj7I L6GNLYNonn7W6cp+6W5CUK5Z3SJemJnndm0GLHpf5MyCOD2uWdOaqJI1ACIUzGF6l1GX 14hgO86ThoYl4NO7rSE2ZvIGZg0nb7GBwHoDnG7KpN80Ia6MdBCKmEOrVXcr9fzhYj9+ iJHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Zh633f4w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id c35-20020a630d23000000b00565cc12ee24si2708717pgl.874.2023.11.01.03.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 03:29:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Zh633f4w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 766AC804486D; Wed, 1 Nov 2023 03:29:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235094AbjKAK26 (ORCPT + 99 others); Wed, 1 Nov 2023 06:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234963AbjKAK26 (ORCPT ); Wed, 1 Nov 2023 06:28:58 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F3A1E8; Wed, 1 Nov 2023 03:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=YqI36cfidBvfcbWCHZIi34My4LBUITxzF3CxYYDCZq0=; b=Zh633f4wCAI8EWWmxguZFS/+Vs CqlawvSqXSb4Wg9fybZ4tY/5LQoH9sTD/VbVXY6KnTNzy6KOdLqyxwb+Ug9hZ1KJDBsJRCVi8LgpB XLtQVNt9EDS9EuDNgaiAAzm0ZvV0HXl1PoKMb2kNrp48bn28Aj79yntf/pVQCWj/V/JNVZuyUbqeo nmcSnXL1t+aMwwNLMAfwCSYxFLTxgoJhvQviljAvy+TOAHlEcyoNUjZjFGT1Wac91UvR3SG/YsUWP CHKG7DOPxsGqJQwqoZz0fV3/QbYB+evcOuh17Fi4tQq0lxcQWVlmnM3CzjzilQB2ysmVqIRzWaeea UhqTUsjQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qy8Sq-005dgg-19; Wed, 01 Nov 2023 10:28:44 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 093B43002AF; Wed, 1 Nov 2023 11:28:44 +0100 (CET) Date: Wed, 1 Nov 2023 11:28:43 +0100 From: Peter Zijlstra To: Arnd Bergmann Cc: Jiaxun Yang , Linux-Arch , x86@kernel.org, linux-kernel@vger.kernel.org, Baoquan He Subject: Re: Overhead of io{read,write}{8,16,32,64} on x86 Message-ID: <20231101102843.GJ15024@noisy.programming.kicks-ass.net> References: <82076999-9346-473d-8841-1480cd70b527@app.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 01 Nov 2023 03:29:18 -0700 (PDT) On Wed, Nov 01, 2023 at 10:08:42AM +0100, Arnd Bergmann wrote: > On Tue, Oct 31, 2023, at 22:41, Jiaxun Yang wrote: > > Hi all, > > > > I'm trying to improve Kernel's support of devices that have ioports > > mapped into MMIO, that involves converting existing driver which is > > using {in,out}{l,w,b} to use io{read,write}{8,16,32,64}, so they can > > benefit from ioport_map and pci_iomap. > > > > However, the problem is io{read,write}{8,16,32,64} will incur penalty > > on x86 by introducing extra function calls (they are not inlined) and > > having extra condition judgment on MMIO vs PIO. > > > > x86 folks, do you think this kind of overhead is acceptable? I do think > > most of PCI/ISA drivers will need to be converted. > > > > linux-arch folks, do you think it will be better if we introduce a > > variant of io{read,write}{8,16,32,64} that direct to PIO on x86 but > > remains the same functionality on other architectures? > > I think in general there is not much of a problem here since > the inb()/outb() operations themselves are extremely slow already, > in particular the outb() writes are non-posted unlike writeb(). > > My feeling is that converting to ioread/iowrite is generally a win > for any driver that already needs to support both cases (e.g. > serial-8250) since this can unify the two code paths. And here I looked at iowrite8 and find it includes tracing and all sorts, which means it is unsuitable for things like early-serial and the shiny new atomic write functionality of said serial-8250.