Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1404655ybx; Thu, 7 Nov 2019 11:25:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxG76QrpvoZROT3r3V6q3ojzH5/dVwpXoJYh9lpjryVnrHc7hXmk0qopPcKazx9Bf4h92QH X-Received: by 2002:a17:906:70e:: with SMTP id y14mr4736015ejb.70.1573154726598; Thu, 07 Nov 2019 11:25:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573154726; cv=none; d=google.com; s=arc-20160816; b=07FyM6M3h9sgxssn3FBmZsaIuPsJ3qSdLmSQ+ZyjF4hpsB46UPUxhaT9rxkDSOxFAP GJaPsjGGx9bZ/Pca/oYsnZImESLz8x+2qiG+KDSrUCQEQfW7woFUBFNOrp4B4Io8PQgK dN72D3vJU0AF4dM8GGdSDtenrDQ/Jw02blcwT5PHqNcOzu4IWtMci9qeN/twDhZj/rIK 6Ys0jyFTwSLgooShSlO/BkF3J1G4KvHILCKOWEYdC4kV6vxotM2erFgmneGPfO686Rfo Grl73vl6uIcc1TEyAQDNDI3sc0ha+5l/kX8G7lY5PogYxOt74OYN7o/lGf1T6eavdu4+ qfuA== 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=p1Fne7fVseXN7JpRhlsyrXM5qJoZrsw0VJvMW6KPvZ0=; b=QUM65+Y9fBjqnYjA5tqfHrZaTY8ZAdQ3jtpIrxGOm7sMAyU4ST6uAwrtAkfIzaCy/O vn6Tr2qGEsPbfFtEBsaQKIefgbymGIRmlbaOV8LVK/AEb2rH46TYVpWhwH9hNwR70TsT xwld2Ea8T6W00/V3x9HK0TCjEfdRoY/H4KU/Gf4Ivlx1RlJHXZurROwHcVaDgBS10QdS Xov7Iul01ZpQ+YE8ZtPqbsH9Ps8VJJ8jj96Fl0sdnZb+MuxWJEWQeqxhovvz7STo2llT bcjTTbiRLBJK67L6tlmQ/HWqlo9q/NyznkXvGBs45rrqitFcXBQKIfqzsgilrt5rTGuz NKZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OG5ZE3xD; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ck15si2149368ejb.358.2019.11.07.11.25.03; Thu, 07 Nov 2019 11:25:26 -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=pass header.i=@gmail.com header.s=20161025 header.b=OG5ZE3xD; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbfKGTY0 (ORCPT + 99 others); Thu, 7 Nov 2019 14:24:26 -0500 Received: from mail-io1-f44.google.com ([209.85.166.44]:35170 "EHLO mail-io1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbfKGTYZ (ORCPT ); Thu, 7 Nov 2019 14:24:25 -0500 Received: by mail-io1-f44.google.com with SMTP id x21so3603528iol.2 for ; Thu, 07 Nov 2019 11:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p1Fne7fVseXN7JpRhlsyrXM5qJoZrsw0VJvMW6KPvZ0=; b=OG5ZE3xDyaGK6p52nR8NCMZrSvPRGz4vrjoa65OE7EJ6LCZHun+e0rnpQ4BmxeMKpx JPFQ9IlnZORfl2zhct+nyhnZLiPNGL07lVjGupf/BwcP11vuecq+jmeAnKTjKMaU61Ur d02f64SO2aj9A9JFUNWJTSOCQX5kMxLY+Y9WaL3Jf47jP2pJN4oIssmN5mJtW2ZWS7CH V9ZDUc/xpFTWHwTWiZ6+1MFn8KVN1B6fjEwB8eyhcAk3JOIUB68R/94g5zd14kRm7XCC Fk7CHN8myc/PhmObGmHbaRNkBP9zlw5yePN8Wys4rHTbGZBiXDP+sFV8h3tg+nyjSzG0 fT2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p1Fne7fVseXN7JpRhlsyrXM5qJoZrsw0VJvMW6KPvZ0=; b=MayEdssWDjYzEJif/k4XStBaOclsOL6cZcHZnXKqooqtdposJD9D4ZNQ7nZG/NrrBd v33LhlHxsxzt+qZhzQ+lfl3+86poVVSpgbfQhI+6phN5P88jjDQrdMIJUo4hDOx+C3Wx 34OqlY7nXsQuxJ+7uhPQqKr0/cVUAt5SGirl0iWDg/SRFqLpjyXndqxHRDWBEW7Bq5SQ XAoFF/RISo+DGFSjuc0FN6bAYqAnHDo3vauuNLxdXR4Pjun9LtfLlAOfAXvttIkuuGLx OrrDHZiqmMGOI61FA9PROBezVMyfiYEkBCdYQHi3g+hECeWoBph2XGXTFd1xHhNtThKy PW7g== X-Gm-Message-State: APjAAAWvS2PrIpmmDHE9W59ccFS/CIlm+pAj+e8AP7OAEm+TEmWsvaoj oIkK+H5TvuNsy+bDSmUhjYDHGnczrq7Oc032kA== X-Received: by 2002:a5d:8450:: with SMTP id w16mr4981251ior.11.1573154664973; Thu, 07 Nov 2019 11:24:24 -0800 (PST) MIME-Version: 1.0 References: <20191106193459.581614484@linutronix.de> <20191106202806.241007755@linutronix.de> In-Reply-To: <20191106202806.241007755@linutronix.de> From: Brian Gerst Date: Thu, 7 Nov 2019 14:24:12 -0500 Message-ID: Subject: Re: [patch 5/9] x86/ioport: Reduce ioperm impact for sane usage further To: Thomas Gleixner Cc: LKML , "the arch/x86 maintainers" , Stephen Hemminger , Willy Tarreau , Juergen Gross , Sean Christopherson , Linus Torvalds , "H. Peter Anvin" 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 Wed, Nov 6, 2019 at 4:01 PM Thomas Gleixner wrote: > > Sane ioperm() users only set the few bits in the I/O space which they need to > access. But the update logic of the TSS I/O bitmap copies always from byte > 0 to the last byte in the tasks bitmap which contains a zero permission bit. > > That means that for access only to port 65335 the full 8K bitmap has to be > copied even if all the bytes in the TSS I/O bitmap are already filled with > 0xff. > > Calculate both the position of the first zero bit and the last zero bit to > limit the range which needs to be copied. This does not solve the problem > when the previous tasked had only byte 0 cleared and the next one has only > byte 65535 cleared, but trying to solve that would be too complex and > heavyweight for the context switch path. As the ioperm() usage is very rare > the case which is optimized is the single task/process which uses ioperm(). Here is a different idea: We already map the TSS virtually in cpu_entry_area. 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. -- Brian Gerst