From patchwork Wed Aug 30 09:22:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9929109 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 7224C60380 for ; Wed, 30 Aug 2017 09:24:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69C6C2837D for ; Wed, 30 Aug 2017 09:24:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E45A28415; Wed, 30 Aug 2017 09:24:21 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9ED5F28419 for ; Wed, 30 Aug 2017 09:24:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=uoFwOtHSfgq+5BZ+M53IwlV76CdCQHWni2MqH3OsSk4=; b=FA7nCL7bi5IitM Vsw3C6GeuRNrnnqVMQIqqLCA1ZtNtU9RsAo937gDGELNoO4erVrxg4eJicD8vEG85annwjcxBPBeS FGr9lJBUXy3q7/Z65KeNWYR+2I1DqYYzimitfhNrPXL+Kqcp7/3iDIr/JIQl/rOvxFxXr7OnAj1TQ PCCiATQQhBy1vEaHV1ywCz779pxX9ZCj1kXHK+NpldvW6hRwMFdeggyFiWKOR8TUaQCBtDPlD+ZwI lDZPNMSmHKEgunck1tC99KTPHyJJu59zXjhfdYwRtTpdAucfyl2eOtg0X6n5qpjOmxGMZXa7XAFcZ ul6nUs2jq2WSJ7XcHlkA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmzDm-0004EE-FK; Wed, 30 Aug 2017 09:23:38 +0000 Received: from mail-sn1nam01on0082.outbound.protection.outlook.com ([104.47.32.82] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmzDh-000491-OE for linux-arm-kernel@lists.infradead.org; Wed, 30 Aug 2017 09:23:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=AQREhlQofFVKBbvsey3TIMdCeq7lw83Ovaw654hI29I=; b=e1c2ylMpz8KWsfFVzRBXykmfKSZOoJF64woDZnfYleAXtjbapmJP/GvPxJ15hRdRT9vE5gn0I3UM0UDeXjSf1aVfDnuc5X/KRUDSD3agN1s2PYTrE4sdtgA1feKULEqFVbQen6WiRcnB8zTLaLCJldEseaa3XrNIaHkci5QJGTg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Received: from localhost (2a01:cb1d:41b:1500:dc7f:bb27:a4cf:e7) by SN1PR07MB1455.namprd07.prod.outlook.com (10.161.223.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1385.9; Wed, 30 Aug 2017 09:23:00 +0000 From: Yury Norov To: Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] arm64: move THREAD_* definitions to separated header Date: Wed, 30 Aug 2017 12:22:49 +0300 Message-Id: <20170830092249.20638-1-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [2a01:cb1d:41b:1500:dc7f:bb27:a4cf:e7] X-ClientProxiedBy: DB6PR02CA0009.eurprd02.prod.outlook.com (10.170.218.150) To SN1PR07MB1455.namprd07.prod.outlook.com (10.161.223.141) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b070baa-7ecc-4f56-d1f6-08d4ef88b5b9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN1PR07MB1455; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB1455; 3:oM1+GIR2ggFK1NPMZOrGVtRhdYmNg8cN5qbOnyMfk8Rc1QsT2logZAGBBFKTal0esqaQFm0BmomvTVxi+J4cmWp3t5B0GvD+xyAONkz9Sg420NBeS8nb9aOuYlNgXHmZQ5YEFS6BtgH/6rxgL+rWQOipOdUODcN7Q5O2W4GMvbCF6lfxpU5k+EF/T6wzxHOpFkq9iu9aG5q92ZNr1TbaRwLfEKouFicAvITdrXlCaHHHBTemEJl4Zy9z6nSl/jWI; 25:GnyK5PGo3PJCbN3Yfru0D33uwahqxulfBwmSc9LQd433LYJ6pft17r6uCXtnFel/z0mK58uXWVnlRXi4IdYUOkavprz6U30eXBsW9GfETX/+xpq9C1/3mvNmej16SPtkUCrVbJ2XqD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b+iZXKkyGOET39ALpVJmCKFBJy7cI0IYdPUuorNAyMMhVTNjHiDlJyTDv64= X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(180628864354917)(22074186197030)(166708455590820); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(93006095)(3002001)(6041248)(20161123562025)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN1PR07MB1455; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN1PR07MB1455; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB1455; 4:ZAXD2bYMvFVT2FqpP2g/By0Iu8JxKqYW/LdKNDYnV4gHzu20LxwwrYWu0BL7tlhl0Xt5vqwpFwrRpuv8Q1o+sidGNoehfcqp87V6+1afgugz9sFmikhxng6aRbq/rvdFR4EBTD4U9XcifVuAnjH4qFrhCO56s7s+lNdWOHFIUoZvwZ+qkOYeXiKZngQCQg3LNw+mUH8yk1UbsZAK8b3nGA1QlFfxe2ql1rX3nyQzHDfePWqxbm28R2EkNhj6WOMyahBJ/SaDWfBDx88AJ7LnowZdf93NtAi9dHuJMuRdPOdUjMyXVt/qCwm47X9gy7TpT/gX8eanQ7jkiTAdyraGRaOr8lSkjf1vvclb36LoRFk0ppEmCwyVlNt4HzSaiRaGMDM64uuyL6I5luiS6mRD2w== X-Forefront-PRVS: 041517DFAB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(106356001)(8676002)(189998001)(6666003)(42882006)(101416001)(33646002)(50986999)(105586002)(76506005)(966005)(575784001)(72206003)(50466002)(23676002)(68736007)(5660300001)(6306002)(97736004)(54906002)(1076002)(6116002)(6486002)(53936002)(36756003)(110136004)(6496005)(81166006)(47776003)(50226002)(81156014)(7736002)(4326008)(305945005)(8936002)(2906002)(478600001)(2870700001)(42186005)(25786009)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB1455; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjFQUjA3TUIxNDU1OzIzOnVGcXQ2ejF2S3RMZHJxRzNLMjcxOTBYMFV3?= =?utf-8?B?STdTZWFmZllJckIwYUl1ODd1ajJaT0VVam5OUzVaNnBuV2x6Rzg2eEpzcUNx?= =?utf-8?B?eGtYdkhUVTJrSUNzeFU0RWZYd3ZyYThHU0tKRUQ3cHlNZ01NZDR4SzR0Uit3?= =?utf-8?B?dFNNOUVRUzN1RkJ6cng0RDlTZFM1NjNpNitjUGZyWDJhSUNQZUtYTWhZNC9x?= =?utf-8?B?d1VqK2t2MUlLNi9aVUFzZGdBZXJwVk9UV0JneUw5TlB2VGdFQzB3NXlUSkFk?= =?utf-8?B?SnBiUFZ6dUg4c1I5dFhLYVJNbHZ5cmlDM293SmxoNXRMK2dzVzRpeW9hYlc4?= =?utf-8?B?QUo2UFlLTnZqTW81cHUrRjBRVElnaUpSUlVGWS84NmdCeFM4OWhhMDJyM0ha?= =?utf-8?B?cGJpMlpCbHJ6NEo0U2pMTkZLL2xGRTBYbVpuaDh3SGhUMWI1aVR6YzJrSzN1?= =?utf-8?B?Nm16eERkNnBSekwrazAyK20wRjBmVmp2SEJOYlloa1FvbEc0RlFGWU1qdzRN?= =?utf-8?B?U2xuMjUyWVZ3cWo0aFJIQkFtZEx1b2dpVDVhQlJYNkVNd0ZjeFAra1hnZ1pt?= =?utf-8?B?RGJ6NVZ4ZHdSdkh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1PR07MB1455; 6:56C2fU7GEDWuIyk9Am02uIzpll/pLrPnJVtIaXbKIWWKS3uBZM2GJ2vCl3RMRoOM2xWDko6GePVFThSWfs10g3xusuCRuZoYZTgBJH6XQQK1t5KYvE1BwfKtRLIpn3Z412SUD5PZuQpsovCM3maFvJ3NKYcswBUYQLoM76TLhD8JPB/mNQB99/aMh9dMZ+JA6x/hB7R7/ByzusIawTyIBnVKI+9fD20Gx2xXKG5A2DuyHgbKGgsFW2arilNlUWlQUBZr+BbrXPdeXpKOEYUoEr9vBG4o68AKKZHXVOVgc1A43KxNcbUx5Ns3M0n54QSV4UtKhMFHGsBh8QOvafsSfA==; 5:s2JgdqTDWbL4tNt8imH4VNh+N/TW/s6iY4sgTYgaXXtCEZX1AieJhJ283e846h7KxOFXoAIIQKxTVAotyNqYXEMK+eHhmlZRSrxnP8G3xHXsQDOEJ0QMP8ndNH9QTcfswPENBIJfxNB78etIZ1rxNw==; 24:p2oeMiqYs4dQzEx9k9EXq/lnPKTJ+DP9Enrb/NIFbIzT16zdWLj/gwys9/BtcIx3xBkB+eZmqZYGL4J+qDqEQs7fMiQlx8XM7n/xxPxn1es=; 7:NJglMrSCuRJ1H5nwT/eqq3Adb0+92Y5WVuOdsNdsvOkxsG2JMw6m5YZl/qDrCj0mXwp2QsCe568qTk08QhmEdHT1AFSZsd6wFcrMWuPGrDniu2Y9IutIapuMuSqI9dpwh0ryydwfK+0iWGv9gHJvObh8/uhcz6QC9fJ49HJr1s73AksjhLO/hQuRkwMpkVMQPidoEGWlH8u2GAsB2UqdimVAtmN6lImvf65mNJcT64Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2017 09:23:00.3745 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB1455 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170830_022334_013644_497B8139 X-CRM114-Status: GOOD ( 17.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Yury Norov , James Morse , Laura Abbott Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Mark, all. In patch 'dbc9344a68e506f19f8 ("arm64: clean up THREAD_* definitions")' you move THREAD_* definitions from arch/arm64/include/asm/thread_info.h to asm/memory.h. After that asm/thread_info.h starts to depend on asm/memory.h. When I try to apply ilp32 series on top of it [1], it causes circular dependencies like this one: In file included from ./arch/arm64/include/asm/memory.h:30:0, from ./arch/arm64/include/asm/thread_info.h:30, from ./include/linux/thread_bits.h:20, from ./include/linux/thread_info.h:13, from ./include/asm-generic/preempt.h:4, from ./arch/arm64/include/generated/asm/preempt.h:1, from ./include/linux/preempt.h:80, from ./include/linux/rcupdate.h:40, from ./include/linux/rculist.h:10, from ./include/linux/pid.h:4, from ./include/linux/sched.h:13, from arch/arm64/kernel/asm-offsets.c:21: ./arch/arm64/include/asm/is_compat.h: In function ‘is_a32_compat_task’: ./arch/arm64/include/asm/is_compat.h:25:9: error: implicit declaration of function ‘test_thread_flag’ [-Werror=implicit-function-declaration] return test_thread_flag(TIF_32BIT); ^~~~~~~~~~~~~~~~ The problem is that asm/memory.h depends on asm/is_compat.h to define TASK_SIZE, which in turn requires asm/thread_info.h. The most obvious solution for it is to create is_compat.c file and make is_*_compat() real functions. The other option is to move THREAD_* definitions to separated macro. I would prefer 2nd one because of following reasons: - TASK_SIZE macro is used many times in kernel, including hot paths; - asm/memory.h is included widely, as well as asm/thread_info.h, and it's better not to make them depend one from another; - THREAD_SIZE etc are not memory-related definitions. In this patch THREAD_* definitions moved to separated asm/thread_size.h header. It's enough to resolve dependency above. If you find this approach useful, I can prepare other patch that moves TASK_* definitions from asm/memory.h to new header to remove the dependency from asm/is_compat.h. Also, arch/arm64/kernel/entry.S and arch/arm64/kernel/hibernate-asm.S #includes list is cleaned. [1] https://github.com/norov/linux/tree/ilp32-next (still in progress) CC: Will Deacon CC: Laura Abbott Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: James Morse Signed-off-by: Yury Norov --- arch/arm64/include/asm/memory.h | 30 +------------------- arch/arm64/include/asm/thread_info.h | 2 +- arch/arm64/include/asm/thread_size.h | 53 ++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/entry.S | 2 +- arch/arm64/kernel/hibernate-asm.S | 1 - 5 files changed, 56 insertions(+), 32 deletions(-) create mode 100644 arch/arm64/include/asm/thread_size.h diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 0c3ee6afda5b..bc7ec1930659 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -21,6 +21,7 @@ #ifndef __ASM_MEMORY_H #define __ASM_MEMORY_H +#include #include #include #include @@ -105,35 +106,6 @@ #define KASAN_SHADOW_SIZE (0) #endif -#define MIN_THREAD_SHIFT 14 - -/* - * VMAP'd stacks are allocated at page granularity, so we must ensure that such - * stacks are a multiple of page size. - */ -#if defined(CONFIG_VMAP_STACK) && (MIN_THREAD_SHIFT < PAGE_SHIFT) -#define THREAD_SHIFT PAGE_SHIFT -#else -#define THREAD_SHIFT MIN_THREAD_SHIFT -#endif - -#if THREAD_SHIFT >= PAGE_SHIFT -#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) -#endif - -#define THREAD_SIZE (UL(1) << THREAD_SHIFT) - -/* - * By aligning VMAP'd stacks to 2 * THREAD_SIZE, we can detect overflow by - * checking sp & (1 << THREAD_SHIFT), which we can do cheaply in the entry - * assembly. - */ -#ifdef CONFIG_VMAP_STACK -#define THREAD_ALIGN (2 * THREAD_SIZE) -#else -#define THREAD_ALIGN THREAD_SIZE -#endif - #define IRQ_STACK_SIZE THREAD_SIZE #define OVERFLOW_STACK_SIZE SZ_4K diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index 5d889c645321..6267ba7bd0e4 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -27,7 +27,7 @@ struct task_struct; -#include +#include #include #include diff --git a/arch/arm64/include/asm/thread_size.h b/arch/arm64/include/asm/thread_size.h new file mode 100644 index 000000000000..dd0b8906f9de --- /dev/null +++ b/arch/arm64/include/asm/thread_size.h @@ -0,0 +1,53 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __ASM_THREAD_SIZE_H +#define __ASM_THREAD_SIZE_H + +#ifdef __KERNEL__ + +#include +#include + +#define MIN_THREAD_SHIFT 14 + +/* + * VMAP'd stacks are allocated at page granularity, so we must ensure that such + * stacks are a multiple of page size. + */ +#if defined(CONFIG_VMAP_STACK) && (MIN_THREAD_SHIFT < PAGE_SHIFT) +#define THREAD_SHIFT PAGE_SHIFT +#else +#define THREAD_SHIFT MIN_THREAD_SHIFT +#endif + +#if THREAD_SHIFT >= PAGE_SHIFT +#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) +#endif + +#define THREAD_SIZE (_AC(1, UL) << THREAD_SHIFT) + +/* + * By aligning VMAP'd stacks to 2 * THREAD_SIZE, we can detect overflow by + * checking sp & (1 << THREAD_SHIFT), which we can do cheaply in the entry + * assembly. + */ +#ifdef CONFIG_VMAP_STACK +#define THREAD_ALIGN (2 * THREAD_SIZE) +#else +#define THREAD_ALIGN THREAD_SIZE +#endif + +#endif /* __KERNEL__ */ +#endif /*__ASM_THREAD_SIZE_H */ diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 84b9f1d235ba..43f8ea210bb3 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/arch/arm64/kernel/hibernate-asm.S b/arch/arm64/kernel/hibernate-asm.S index e56d848b6466..46b91702ea26 100644 --- a/arch/arm64/kernel/hibernate-asm.S +++ b/arch/arm64/kernel/hibernate-asm.S @@ -22,7 +22,6 @@ #include #include #include -#include #include #include