Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp361887pxb; Thu, 30 Sep 2021 07:39:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwORB5Oaq97SxyK+Rpu+UrwKlCNTyxsVjQhoCMH0CChI/bModb9DXE6DsmgxghK+8EFujMm X-Received: by 2002:a50:bb09:: with SMTP id y9mr7439873ede.89.1633012779984; Thu, 30 Sep 2021 07:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633012779; cv=none; d=google.com; s=arc-20160816; b=FcMvsT3VjxJm9MGWpu93ePEUVscNvMY6iugSfhEgEjCAkG/SJPzfkHwT9L/TqxMaBy kbvm7mjQek7kvbGPxggPw30MN0jJyUbeRILnGBCqb0aEDXr8d2qtafseOW7pIliBOcRe zjmDbhTr4siQDxPnXh0WQeXd/mPaf1vf8CS/4M8QigfzxQIK63E9lPGyPbzG7hVWRdZk hOAZe1n+Y1IvRhBSx1HuCeBplBYEtMemb0OCDjblv0/hagrmMqgQgreH1IJjaezPhhkq n0yTeXVS9oDNFAJXuh86/907UPC6MKd75JBu0suiwvvwlcOy2NiqRfEAiBRTwjFUeEWc qpCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w9FO45CJZC2O8SXN739hz6NjHZgvYcPb+XJrMq3zN6g=; b=K0NxU7rohsy79HEAlHRu3YGRgHzeBWdDqUTZdkRmIRMsO4Tr0OqeZzjbZteBJIk7FI 2hoLWXpRinA7UJesPfBV+JPed4wCebkYH64dSBWsh78SR57bt9GpjeugGIdi5zI3i9EE 3hst8QBvIOXWqDCYBBLI2obD6xOlwku4XnoLI+/h9WbFK2LOb0oeAQEa/Iqorq42yVMK RGrEo9kAEh6Lp8JRJlexB6lXBIBp7ryA/A5sBFuvl464cDvVmgWTZ4zPH5aYAWlx3miX pC1zAl+aeMBi3fW64xIO9Ukb2DlPH7Xace/MQKvPP6adNzMq40Ld4dSTPi2OQ9aR5/YW Wcuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TNKTZVi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 5si3498727ejq.512.2021.09.30.07.39.15; Thu, 30 Sep 2021 07:39:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="TNKTZVi/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351247AbhI3NA7 (ORCPT + 99 others); Thu, 30 Sep 2021 09:00:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:56464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351250AbhI3NA4 (ORCPT ); Thu, 30 Sep 2021 09:00:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3EC236124B; Thu, 30 Sep 2021 12:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633006754; bh=pZUE+JFU70DO6lZHw0XYBT4g6IgzpD/xlow05Rh/8z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TNKTZVi/XWnH56oiOYl3wSeIgyXy3F5TQpt46FZBcnf+yISH1Md5cU+tOrkOutPVg MP9hMLo5YYMjOFL5fXMITQClNxHeQWhucmVgQEZjQCuJVZF9k9cb1bEcVzsQ+vE9uc ZvUQ/dC1oQY1TVHwqjda/9YjytHRfZUuj/Vk7tXUoCnQ3mCSTQj+IwxvkslkJDBmr/ m5N9eUuGguj70IOZB9fr70XfM9+23s/dAS1ao1hKG9ip21mQrBNVKlC7KRypKm4Xug ly8sZrZnnVjogD+Ra6x3UNQa/forq0ZXw0olEA0XKtYPPEGuhim9WcypH3gDOEGp5D O67SHTtAwir1A== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Keith Packard , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Christophe Leroy , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Mark Rutland Subject: [PATCH v2 6/7] powerpc: smp: remove hack to obtain offset of task_struct::cpu Date: Thu, 30 Sep 2021 14:58:12 +0200 Message-Id: <20210930125813.197418-7-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210930125813.197418-1-ardb@kernel.org> References: <20210930125813.197418-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of relying on awful hacks to obtain the offset of the cpu field in struct task_struct, move it back into struct thread_info, which does not create the same level of circular dependency hell when trying to include the header file that defines it. Signed-off-by: Ard Biesheuvel Acked-by: Mark Rutland Acked-by: Michael Ellerman --- arch/powerpc/Makefile | 11 ----------- arch/powerpc/include/asm/smp.h | 17 +---------------- arch/powerpc/kernel/asm-offsets.c | 2 -- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index aa6808e70647..54cad1faa5d0 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -446,17 +446,6 @@ else endif endif -ifdef CONFIG_SMP -ifdef CONFIG_PPC32 -prepare: task_cpu_prepare - -PHONY += task_cpu_prepare -task_cpu_prepare: prepare0 - $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TASK_CPU") print $$3;}' include/generated/asm-offsets.h)) - -endif # CONFIG_PPC32 -endif # CONFIG_SMP - PHONY += checkbin # Check toolchain versions: # - gcc-4.6 is the minimum kernel-wide version so nothing required. diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index 7ef1cd8168a0..007332a4a732 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h @@ -87,22 +87,7 @@ int is_cpu_dead(unsigned int cpu); /* 32-bit */ extern int smp_hw_index[]; -/* - * This is particularly ugly: it appears we can't actually get the definition - * of task_struct here, but we need access to the CPU this task is running on. - * Instead of using task_struct we're using _TASK_CPU which is extracted from - * asm-offsets.h by kbuild to get the current processor ID. - * - * This also needs to be safeguarded when building asm-offsets.s because at - * that time _TASK_CPU is not defined yet. It could have been guarded by - * _TASK_CPU itself, but we want the build to fail if _TASK_CPU is missing - * when building something else than asm-offsets.s - */ -#ifdef GENERATING_ASM_OFFSETS -#define raw_smp_processor_id() (0) -#else -#define raw_smp_processor_id() (*(unsigned int *)((void *)current + _TASK_CPU)) -#endif +#define raw_smp_processor_id() (current_thread_info()->cpu) #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()]) static inline int get_hard_smp_processor_id(int cpu) diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c index e37e4546034e..cc05522f50bf 100644 --- a/arch/powerpc/kernel/asm-offsets.c +++ b/arch/powerpc/kernel/asm-offsets.c @@ -9,8 +9,6 @@ * #defines from the assembly-language output. */ -#define GENERATING_ASM_OFFSETS /* asm/smp.h */ - #include #include #include -- 2.30.2