From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034075AbcJRXLK (ORCPT ); Tue, 18 Oct 2016 19:11:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58827 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933565AbcJRXKA (ORCPT ); Tue, 18 Oct 2016 19:10:00 -0400 Date: Tue, 18 Oct 2016 16:09:59 -0700 From: Andrew Morton To: David Rientjes Cc: "Kirill A. Shutemov" , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch] mm, thp: avoid unlikely branches for split_huge_pmd Message-Id: <20161018160959.16187f78b58d76c6087e8491@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Oct 2016 16:04:06 -0700 (PDT) David Rientjes wrote: > While doing MADV_DONTNEED on a large area of thp memory, I noticed we > encountered many unlikely() branches in profiles for each backing > hugepage. This is because zap_pmd_range() would call split_huge_pmd(), > which rechecked the conditions that were already validated, but as part of > an unlikely() branch. > > Avoid the unlikely() branch when in a context where pmd is known to be > good for __split_huge_pmd() directly. Before: text data bss dec hex filename 38442 75 48 38565 96a5 mm/memory.o 21755 2369 18464 42588 a65c mm/mempolicy.o 4557 1816 0 6373 18e5 mm/mprotect.o After: 38362 75 48 38485 9655 mm/memory.o 21714 2369 18464 42547 a633 mm/mempolicy.o 4541 1816 0 6357 18d5 mm/mprotect.o So there's a size improvment too. gcc-4.4.4.