From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756630AbdLPDVs (ORCPT ); Fri, 15 Dec 2017 22:21:48 -0500 Received: from mga04.intel.com ([192.55.52.120]:20122 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756038AbdLPDVq (ORCPT ); Fri, 15 Dec 2017 22:21:46 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,408,1508828400"; d="scan'208";a="3239587" Subject: Re: [PATCH v2 01/17] mm/gup: Fixup p*_access_permitted() To: Linus Torvalds , Al Viro References: <20171214205450.GI3326@worktop> <8eedb9a3-0ba2-52df-58f6-3ed869d18ca3@intel.com> <20171215075147.nzpsmb7asyr6etig@hirez.programming.kicks-ass.net> <629d90d9-df33-2c31-e644-0bc356b61f25@intel.com> <20171216024824.GK21978@ZenIV.linux.org.uk> Cc: Dan Williams , Peter Zijlstra , Linux Kernel Mailing List , Thomas Gleixner , the arch/x86 maintainers , Andy Lutomirsky , Borislav Petkov , Greg KH , Kees Cook , Hugh Dickins , Brian Gerst , Josh Poimboeuf , Denys Vlasenko , Boris Ostrovsky , Juergen Gross , David Laight , Eduardo Valentin , "Liguori, Anthony" , Will Deacon , linux-mm , "Kirill A. Shutemov" From: Dave Hansen Message-ID: Date: Fri, 15 Dec 2017 19:21:45 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/15/2017 06:52 PM, Linus Torvalds wrote: > On Fri, Dec 15, 2017 at 6:48 PM, Al Viro wrote: >> Treating protection key bits as "escalate to page fault and let that >> deal with the checks" should be fine > > Well, it's *semantically* fine and I think it's the right model from > that standpoint. It's _close_ to fine. :) Practically, we're going to have two classes of things in the world: 1. Things that are protected with protection keys and have non-zero bits in the pkey PTE bits. 2. Things that are _not_ protected will have zeros in there. But, in the hardware, *everything* has a pkey. 0 is the default, obviously, but the hardware treats it the same as all the other values. So, if we go checking for the "pkey bits being set", and have behavior diverge when they are set, we end up with pkey=0 being even more special compared to the rest. This might be OK, but it's going to be interesting to document and write tests for it. I'm already dreading the manpage updates. > However, since the main use case of protection keys is probably > databases (Dave?) and since those also might be performance-sensitive > about direct-IO doing page table lookups, it might not be great in > practice. Yeah, databases are definitely the heavy-hitters that care about it. But, these PKRU checks are cheap. I forget the actual cycle counts, but I remember thinking that it's pretty darn cheap to read PKRU. In the grand scheme of doing a page table walk and incrementing an atomic, it's surely in the noise for direct I/O to large pages, which is basically guaranteed for the database guys. I did some get_user_pages() torture tests (on small pages IIRC) before I put the code in and could not detect a delta from the code being there or not.