From patchwork Mon Nov 27 21:34:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 10078213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 59214602BD for ; Mon, 27 Nov 2017 21:38:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B7932908B for ; Mon, 27 Nov 2017 21:38:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4065D2908D; Mon, 27 Nov 2017 21:38:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB91B2908B for ; Mon, 27 Nov 2017 21:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753040AbdK0Vgz (ORCPT ); Mon, 27 Nov 2017 16:36:55 -0500 Received: from mga02.intel.com ([134.134.136.20]:55058 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752715AbdK0Vec (ORCPT ); Mon, 27 Nov 2017 16:34:32 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Nov 2017 13:34:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,465,1505804400"; d="scan'208";a="7738194" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.35]) by fmsmga001.fm.intel.com with ESMTP; 27 Nov 2017 13:34:30 -0800 Received: by tassilo.localdomain (Postfix, from userid 1000) id A60D63010AB; Mon, 27 Nov 2017 13:34:29 -0800 (PST) From: Andi Kleen To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, samitolvanen@google.com, alxmtvv@gmail.com, linux-kbuild@vger.kernel.org, yamada.masahiro@socionext.com, akpm@linux-foundation.org, Andi Kleen Subject: [PATCH 16/21] lto: Add __noreorder and mark initcalls __noreorder Date: Mon, 27 Nov 2017 13:34:18 -0800 Message-Id: <20171127213423.27218-17-andi@firstfloor.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171127213423.27218-1-andi@firstfloor.org> References: <20171127213423.27218-1-andi@firstfloor.org> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.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-gcc.h | 5 +++++ include/linux/compiler_types.h | 3 +++ include/linux/init.h | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 2272ded07496..0d562baeb379 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -324,6 +324,11 @@ #define __no_sanitize_address #endif +#if __GNUC__ >= 5 +/* Avoid reordering a top level statement */ +#define __noreorder __attribute__((no_reorder)) +#endif + /* * A trick to suppress uninitialized variable warning without generating any * code diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 6b79a9bba9a7..fe4604603f5e 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -260,6 +260,9 @@ struct ftrace_likely_data { #define __assume_aligned(a, ...) #endif +#ifndef __noreorder +#define __noreorder +#endif /* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type diff --git a/include/linux/init.h b/include/linux/init.h index ea1b31101d9e..abf1980367b7 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -161,7 +161,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; /*