Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp5238712ybx; Sun, 10 Nov 2019 09:24:19 -0800 (PST) X-Google-Smtp-Source: APXvYqz/GGJHMP8FiduWgGOWXIgGNIc79jsTCLOxXkUxKiufVY0E+12WMjISk/Pzf03KfzRfwKpG X-Received: by 2002:a50:c305:: with SMTP id a5mr21449659edb.136.1573406659423; Sun, 10 Nov 2019 09:24:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573406659; cv=none; d=google.com; s=arc-20160816; b=jpozVZRt7ViK6QYAirZBtRucBbXypOuWUTe6tdqBEqFutUtfEyIQUSb/jgU6M8MPym okJ/9jfiGkinPl+TVjookMaFfsddxUVfsA5/AxZq4xX9zd0vxTwC8vkazJrPqL4OaE11 Q++kyaiHPZq1W1/epuuSNXj30pcSvEpGTbIQzReReq+7CDwR03p7bfDNHl4Gu/3deTQv kXLeZqxa13DA49ZcFWY9wI+nj9huworLmpPQdLpjnPvaa3Vt5tVYLMNg+qakR0yzksVq 4byBAuqq7qTmbmiyHmb5/AFNgLrOQSWpGcu923AOoiOd7w0WPGZsvGKvOGrjnQ3wxQnv TNNQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=0R4OFUZi58Id9OiT2d8cG4KxzK+0jeWwqeV4pxS9htk=; b=q3m3KY85zzfcTXuncPiJgskhEixRi/+iEv10yxTOXYKSIP5MmkvdPj0fB0dpThRuxH iIailXIHGSlvK8Zhap0GNRJ7AOmDqf8k5YkqZ4DLiw0dnmod444yhTCvwSxeLYFXPcEv ZzphX8IRYn4Q1CDyRDkNXYfH2Luwhyqe6zIz49ivdI7bYr9zYUCAkFnxpFsb5Kj4cFtN gsczz1KX4onelY0I6DLG7f7LeyEH26GEbqET271hZ4AdUITRHEpHXqRsKoJ7+wqnZe2P KDoMDDnYXBE6PBFLIs05DN24tVK2kt6eM35NQyJOkew4z6+ZPcC5H9Iqq/tJBHxozc3V dRUA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si10119602edj.225.2019.11.10.09.23.56; Sun, 10 Nov 2019 09:24:19 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfKJRVT (ORCPT + 99 others); Sun, 10 Nov 2019 12:21:19 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36252 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbfKJRVS (ORCPT ); Sun, 10 Nov 2019 12:21:18 -0500 Received: by mail-pf1-f193.google.com with SMTP id v19so8820984pfm.3 for ; Sun, 10 Nov 2019 09:21:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0R4OFUZi58Id9OiT2d8cG4KxzK+0jeWwqeV4pxS9htk=; b=CIxmci9cyjMcETGxirOlquAeibP3Cq1xM/a68pATDvLg2fazMpvoWC37TDmGmYuRc7 ySJxorZEwXHM03rwsGamUkCXBO0dlumwaC4D5Sj+8cW0/SWUFD9KKE2l6sZESUD5bjKg oKWWX06xMDCzNp+0i54kCuHOr/vxrHGN3zGS3TY3bnHduO/Wkqu8CA55s7C8/HHImQPO CzJlKXzPMV0/ZGzt31rrYqLAv08i3+hq9viXf491/N6xa8Xc3EUojtF08BIknO5JHKmY qsVwZxjs80QUQ/f/VfmY/249RKziXrdyGSMDuO5F3TaWYeQ9Ww1Wlm9urOsiGX04X8Vp JffA== X-Gm-Message-State: APjAAAW/mbiPU7P6+bT52ffFhHfdDvI9QnQMUfNVkqrvNXz0P8kUdbxT nwYjjdvJxLC/Or9cRWUW0XR53A== X-Received: by 2002:a17:90a:1:: with SMTP id 1mr21340490pja.42.1573406477900; Sun, 10 Nov 2019 09:21:17 -0800 (PST) Received: from ?IPv6:2601:646:c200:1ef2:3602:86ff:fef6:e86b? ([2601:646:c200:1ef2:3602:86ff:fef6:e86b]) by smtp.googlemail.com with ESMTPSA id m68sm11881340pfb.122.2019.11.10.09.21.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Nov 2019 09:21:17 -0800 (PST) Subject: Re: [patch 5/9] x86/ioport: Reduce ioperm impact for sane usage further To: Linus Torvalds , Brian Gerst Cc: Thomas Gleixner , LKML , the arch/x86 maintainers , Stephen Hemminger , Willy Tarreau , Juergen Gross , Sean Christopherson , "H. Peter Anvin" References: <20191106193459.581614484@linutronix.de> <20191106202806.241007755@linutronix.de> From: Andy Lutomirski Message-ID: <8ebcd033-818c-93da-9b86-8cd5e81f9590@kernel.org> Date: Sun, 10 Nov 2019 09:21:15 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/7/19 1:44 PM, Linus Torvalds wrote: > On Thu, Nov 7, 2019 at 1:00 PM Brian Gerst wrote: >> >> There wouldn't have to be a flush on every task switch. > > No. But we'd have to flush on any switch that currently does that memcpy. > > And my point is that a tlb flush (even the single-page case) is likely > more expensive than the memcpy. > >> 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. > > Well, that's exactly my "track the last task" optimization for copying > the thing. > > IOW, it's the same optimization as avoiding the memcpy. > > Which I think is likely very effective, but also makes it fairly > pointless to then try to be clever.. > > So the basic issue remains that playing VM games has almost > universally been slower and more complex than simply not playing VM > games. TLB flushes - even invlpg - tends to be pretty slow. > With my TLB-handling-writing-and-reviewing code on, NAK to any VM games here. Honestly, I almost think we should unconditionally copy the whole 8K for the case where the ioperm() syscall has been used (i.e. not emulating iopl()). The benefit simply does not justify the risk of getting it wrong. I'm okay, but barely, with optimizing the end of the copied range. Optimizing the start of the copied range is pushing it. Playing MMU tricks and getting all the per-task-ioperm and invalidation right is way beyond reasonable. Even the time spent discussing how to optimize a case that has literally one known user that none of us can bring ourselves to care about much seems wasteful.