From patchwork Wed Apr 8 13:17:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 6179621 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F8B7BF4A6 for ; Wed, 8 Apr 2015 13:20:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5703020328 for ; Wed, 8 Apr 2015 13:20:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D7F120376 for ; Wed, 8 Apr 2015 13:20:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753354AbbDHNUN (ORCPT ); Wed, 8 Apr 2015 09:20:13 -0400 Received: from one.firstfloor.org ([193.170.194.197]:38632 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753089AbbDHNUM (ORCPT ); Wed, 8 Apr 2015 09:20:12 -0400 Received: from basil.firstfloor.org (184-100-226-11.ptld.qwest.net [184.100.226.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id 3ABC686775; Wed, 8 Apr 2015 15:20:11 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 8EC71A0C58; Wed, 8 Apr 2015 06:17:50 -0700 (PDT) From: Andi Kleen To: mmarek@suse.cz Cc: akpm@linux-foundation.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH] lto: Add __noreorder and mark initcalls __noreorder Date: Wed, 8 Apr 2015 06:17:38 -0700 Message-Id: <1428499058-8322-1-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 2.3.3 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andi Kleen gcc 5 has a new no_reorder attribute that prevents top level reordering only for that symbol. Kernels don't like any reordering of initcalls between files, as several initcalls depend on each other. LTO previously needed to use -fno-toplevel-reordering to prevent boot failures. Add a __noreorder wrapper for the no_reorder attribute and use it for initcalls. Signed-off-by: Andi Kleen --- include/linux/compiler-gcc5.h | 3 +++ include/linux/compiler.h | 4 ++++ include/linux/init.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/compiler-gcc5.h b/include/linux/compiler-gcc5.h index efee493..9004c00 100644 --- a/include/linux/compiler-gcc5.h +++ b/include/linux/compiler-gcc5.h @@ -42,6 +42,9 @@ /* Mark a function definition as prohibited from being cloned. */ #define __noclone __attribute__((__noclone__)) +/* Avoid reordering a top level statement */ +#define __noreorder __attribute__((no_reorder)) + /* * Tell the optimizer that something else uses this function or variable. */ diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 1b45e4a..ac639a1 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -334,6 +334,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s #define noinline #endif +#ifndef __noreorder +#define __noreorder /* unimplemented */ +#endif + /* * Rather then using noinline to prevent stack consumption, use * noinline_for_stack instead. For documentation reasons. diff --git a/include/linux/init.h b/include/linux/init.h index 2df8e8d..a0a1244 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -191,7 +191,7 @@ extern bool initcall_debug; */ #define __define_initcall(fn, id) \ - static initcall_t __initcall_##fn##id __used \ + static initcall_t __initcall_##fn##id __used __noreorder \ __attribute__((__section__(".initcall" #id ".init"))) = fn; \ LTO_REFERENCE_INITCALL(__initcall_##fn##id)