Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751990AbeAPTfN (ORCPT + 1 other); Tue, 16 Jan 2018 14:35:13 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:44083 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751465AbeAPTfK (ORCPT ); Tue, 16 Jan 2018 14:35:10 -0500 Date: Tue, 16 Jan 2018 20:34:59 +0100 (CET) From: Thomas Gleixner To: Joerg Roedel cc: Dave Hansen , Ingo Molnar , "H . Peter Anvin" , 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 Subject: Re: [PATCH 07/16] x86/mm: Move two more functions from pgtable_64.h to pgtable.h In-Reply-To: <20180116191105.GC28161@8bytes.org> Message-ID: References: <1516120619-1159-1-git-send-email-joro@8bytes.org> <1516120619-1159-8-git-send-email-joro@8bytes.org> <727a7eba-41a0-d5bb-df54-8e58b33fde76@intel.com> <20180116191105.GC28161@8bytes.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, 16 Jan 2018, Joerg Roedel wrote: > On Tue, Jan 16, 2018 at 10:03:09AM -0800, Dave Hansen wrote: > > On 01/16/2018 08:36 AM, Joerg Roedel wrote: > > > + 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? > > I havn't looked at the actual code this generates, but the > (PAGE_SIZE / 2) comparison doesn't work on 32 bit where the address > space is not always evenly split. I'll look into a better way to check > this. It should be trivial enough to do return (ptr & ~PAGE_MASK) < PGD_SPLIT_SIZE); and define it PAGE_SIZE/2 for 64bit and for PAE make it depend on the configured address space split. Thanks, tglx