Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751412AbeAPSDL (ORCPT + 1 other); Tue, 16 Jan 2018 13:03:11 -0500 Received: from mga06.intel.com ([134.134.136.31]:28706 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751060AbeAPSDK (ORCPT ); Tue, 16 Jan 2018 13:03:10 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,369,1511856000"; d="scan'208";a="193810120" Subject: Re: [PATCH 07/16] x86/mm: Move two more functions from pgtable_64.h to pgtable.h To: Joerg Roedel , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" References: <1516120619-1159-1-git-send-email-joro@8bytes.org> <1516120619-1159-8-git-send-email-joro@8bytes.org> Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , jroedel@suse.de From: Dave Hansen Message-ID: <727a7eba-41a0-d5bb-df54-8e58b33fde76@intel.com> Date: Tue, 16 Jan 2018 10:03:09 -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: <1516120619-1159-8-git-send-email-joro@8bytes.org> 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 Return-Path: On 01/16/2018 08:36 AM, Joerg Roedel wrote: > +/* > + * Page table pages are page-aligned. The lower half of the top > + * level is used for userspace and the top half for the kernel. > + * > + * Returns true for parts of the PGD that map userspace and > + * false for the parts that map the kernel. > + */ > +static inline bool pgdp_maps_userspace(void *__ptr) > +{ > + unsigned long ptr = (unsigned long)__ptr; > + > + return (((ptr & ~PAGE_MASK) / sizeof(pgd_t)) < KERNEL_PGD_BOUNDARY); > +} One of the reasons to implement it the other way: - return (ptr & ~PAGE_MASK) < (PAGE_SIZE / 2); is that the compiler can do this all quickly. KERNEL_PGD_BOUNDARY depends on PAGE_OFFSET which depends on a variable. IOW, the compiler can't do it. How much worse is the code that this generates?