Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1669358ybx; Thu, 7 Nov 2019 15:23:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyoh3sN4RdTyGzhMOniV5oHEmPpiUmtUWJsXVHGUfNXYfoFMBcZW7tV6FY3WEeph8xo8Eel X-Received: by 2002:a17:906:f154:: with SMTP id gw20mr5780048ejb.279.1573169023345; Thu, 07 Nov 2019 15:23:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573169023; cv=none; d=google.com; s=arc-20160816; b=WcyCTfkTIHnpxMYom9vRUMGDLW0zp5yyyXtK5d5UllqQl9sIhMQHrqkhIawfW/vTEZ OksD1B0hY9sQ1L9geZzzqDgy1amf89fz7DXnDlRJYZ4FdOkRiRjNGB5hQsXupqReHcFs 6p8FKjSH0cO8KEaJWYvjITwj5ROscTpILeKOAGvshOZLvpc4u6i+VVW29nPmPJUpa6jp AVp1FOr34/2fTQ+zBMWRspqLaig3YW4qgG9a3M4HWG9sSyYaRH4rOkGutP0mBXTRRJ0W 08eXB+9rl6FdpHrLaVFusGaKUALSV3B3mN46jA/KAa2VMWtTOWDcUuqvxEU1koFYsF4X /M7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:dkim-signature:dkim-filter; bh=uNbQFowrRqXhBohKSrYXwjHjXr0oEl9bBD2nzLbcE5E=; b=v2+dAerumqq5XBPCaVC9Lj0mdXeXHsGFTNV3Gy/+yBYxp4V4S92WKiD85n5vie1FB0 tYwmeT5ZzXX8qzS8ft7suonJk4Xw5lg+nStQa16jx0CHQRKDZ8u4ZV/U6jyVZaVmqoCS 1+5W0uGqI6gIABRSoKck1TCmO5A90iQxoGdED3VqK7QqnScWJSGfMDLeRli3BvYQXooh g27TiWDi0ceo1f1is1kpOiApd5V7XxZEtf6QJoFX1H6ZV2H9M37Jv78wWT/VXeOKusDu Dx1kygSN6sW5khj3AGBc0NcSZpJvPOy9XCbCu9ittnOAZduN8cUbGHST1QrdVFLo/oG1 eB3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@zytor.com header.s=2019091901 header.b=FCWOt1t0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p17si2628139ejb.9.2019.11.07.15.23.20; Thu, 07 Nov 2019 15:23:43 -0800 (PST) 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=fail header.i=@zytor.com header.s=2019091901 header.b=FCWOt1t0; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727909AbfKGXWT (ORCPT + 99 others); Thu, 7 Nov 2019 18:22:19 -0500 Received: from terminus.zytor.com ([198.137.202.136]:38327 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727102AbfKGXWT (ORCPT ); Thu, 7 Nov 2019 18:22:19 -0500 Received: from [IPv6:2601:646:8600:3281:ac8f:6015:6ba:e227] ([IPv6:2601:646:8600:3281:ac8f:6015:6ba:e227]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id xA7NKMfg1367689 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Thu, 7 Nov 2019 15:20:24 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com xA7NKMfg1367689 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019091901; t=1573168824; bh=uNbQFowrRqXhBohKSrYXwjHjXr0oEl9bBD2nzLbcE5E=; h=Date:In-Reply-To:References:Subject:To:CC:From:From; b=FCWOt1t03s3DFteQ7ZNBuBfQ6XW7w3dh85SeSEmvgIlxenCdJLqOSnnAPFkCemjt4 2yWbEWVQb/Hr2UbzJ1SPURxnbdxAgYizRXFP2ERM8cud/scsuuo3wA9+PKG8lbiVxY y37q+eWs9DTcSLFGlbKZYfsOgdZsI44s5W5quuOcFXa5uXAiexAi9N10t2UQUTQtAU oI5hz5XJOSKxPTw9rr+z9VBkKJMNJhD4XFnbtCe0t+5zbYII8rDqt7CJ3F9BY6QOBP ZE9u60ykiPMR7lET3Lj8LfafmW5fcCZz8WMhVIbZbb1+2df7Lv9e+w9K8SBWZNAWVQ L1OpxcGNF2qdA== Date: Thu, 07 Nov 2019 15:20:15 -0800 User-Agent: K-9 Mail for Android In-Reply-To: References: <20191106193459.581614484@linutronix.de> <20191106202806.241007755@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [patch 5/9] x86/ioport: Reduce ioperm impact for sane usage further To: Thomas Gleixner , Brian Gerst CC: Linus Torvalds , LKML , the arch/x86 maintainers , Stephen Hemminger , Willy Tarreau , Juergen Gross , Sean Christopherson From: hpa@zytor.com Message-ID: <8D806995-2FC5-4CE0-89D7-165D461D5242@zytor.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On November 7, 2019 1:32:15 PM PST, Thomas Gleixner = wrote: >On Thu, 7 Nov 2019, Brian Gerst wrote: >> On Thu, Nov 7, 2019 at 2:54 PM Linus Torvalds >> wrote: >> > >> > On Thu, Nov 7, 2019 at 11:24 AM Brian Gerst >wrote: >> > > >> > > Here is a different idea: We already map the TSS virtually in >> > > cpu_entry_area=2E Why not page-align the IO bitmap and remap it to >the >> > > task's bitmap on task switch? That would avoid all copying on >task >> > > switch=2E >> > >> > We map the tss _once_, statically, percpu, without ever changing >it, >> > and then we just (potentially) change a couple of fields in it on >> > process switch=2E >> > >> > Your idea isn't horrible, but it would involve a TLB flush for the >> > page when the io bitmap changes=2E Which is almost certainly more >> > expensive than just copying the bitmap intelligently=2E >> > >> > Particularly since I do think that the copy can basically be done >> > effectively never, assuming there really aren't multiple concurrent >> > users of ioperm() (and iopl)=2E >>=20 >> There wouldn't have to be a flush on every task switch=2E If we make >it >> so that tasks that don't use a bitmap just unmap the pages in the >> cpu_entry_area and set tss=2Eio_bitmap_base to outside the segment >> limit, we would only have to flush when switching from a task using >> the bitmap (because the next task uses a different bitmap or we are >> unmapping it)=2E If the previous task doesn't have a bitmap the pages >> in cpu_entry_area were unmapped and can't be in the TLB, so no flush >> is needed=2E > >Funny=2E I was just debating exactly this with Peter Ziljstra over IRC :) >=20 >> Going a step further, we could track which task is mapped to the >> current cpu like proposed above, and only flush when a different task >> needs the IO bitmap, or when the bitmap is being freed on task exit=2E > >Yes=2E > >But, we really should check what aside of DoSemu is using this still=2E >None >of my machines I checked have a single instance of ioperm()/iopl() >usage=2E > >So the real question is whether it's worth the trouble or if we are >just >better off to copy if there is an actual user and the sequence count of >the >bitmap is different than the one which was active last time=2E > >Thanks, > > tglx I have written suffer using this, because of far better real time performa= nce=2E I just want to punch a hole (just like mmapping an MMIO device=2E) I do agree that let's not optimize for the rare case=2E --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E