From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756511AbdKNUaE (ORCPT ); Tue, 14 Nov 2017 15:30:04 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:39031 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756021AbdKNU3z (ORCPT ); Tue, 14 Nov 2017 15:29:55 -0500 Date: Tue, 14 Nov 2017 21:29:41 +0100 (CET) From: Thomas Gleixner To: "Kirill A. Shutemov" cc: "Kirill A. Shutemov" , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Nicholas Piggin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 1/2] x86/mm: Do not allow non-MAP_FIXED mapping across DEFAULT_MAP_WINDOW border In-Reply-To: <20171114192113.t7pq5p2n5emmiw2n@node.shutemov.name> Message-ID: References: <20171114134322.40321-1-kirill.shutemov@linux.intel.com> <20171114192113.t7pq5p2n5emmiw2n@node.shutemov.name> 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 On Tue, 14 Nov 2017, Kirill A. Shutemov wrote: > On Tue, Nov 14, 2017 at 05:01:50PM +0100, Thomas Gleixner wrote: > > +bool mmap_address_hint_valid(unsigned long addr, unsigned long len) > > +{ > > + if (TASK_SIZE - len < addr) > > + return false; > > +#if CONFIG_PGTABLE_LEVELS >= 5 > > + return (addr > DEFAULT_MAP_WINDOW) == (addr + len > DEFAULT_MAP_WINDOW); > > Is it micro optimization? I don't feel it necessary. It's not that hot > codepath to care about few cycles. (And one more place to care about for > boot-time switching.) > > If you think it's needed, maybe IS_ENABLED() instead? You're right. It's can be unconditional, For page table levels < 5 its just redundant as its covered by the TASK_SIZE check already. Thanks, tglx