Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp615502pxb; Tue, 14 Sep 2021 05:12:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymosfsZeOyd82nBM1kGaywfPgyravZRhgJVkCfMCOCV3DjAdgzlBRpPk4bfsGFu1S4OVgh X-Received: by 2002:aa7:dd57:: with SMTP id o23mr19083871edw.385.1631621560047; Tue, 14 Sep 2021 05:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631621560; cv=none; d=google.com; s=arc-20160816; b=ujfa5EGrUHbz1XX7oqTUUx/BoDXO33bUQZWJR7oKjGAYxQMftw4muIH97WAPWD5eGQ xtQ5fAskCwkE8avmQrbBRaPp6kHUfLprWMjLpIU+CkDN69RpWo7iT9PFvMEV4l9JsHUd 4dptiVZXw0qJgVdPvb0fV5a3nqmQCpOxe+IDYsUkn51SloYt9oaX/sJlnQHfteJFjYCb ZBfH6WS1Dsu+OIOhlVQcpt1kgJDyfOnvsaEpQEwW7WZi+5w5wTLrDkw+gxJ4rS9S0XhL BopeEU+jXLE8BcZAiRU6QYHCuJAxYasdnvxohmJmap4jGA3DG40gnWTGUBlzAzUqp7WC pqCQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8e3rhgfOBDvrHwI0cWYyK0548YafpSYNw2AZEAxjxCM=; b=e23FEGFxozehczU7ltMttUSYtDeC+n7Ycn5o2zSRdq4wsurFnaWipurj4w2EQBpje3 2GfTd4rRCtcBiY+Ry1OAphIwOopzOhtJr9pzF6q3umFf8DlIQe8On8MXyY8ESd0jxiI8 zdruKRI+kWiii92yJKiWpHtMhSEi29gqFALe1Xw9/fMJP6yemQ41tbURatKL/Pmk1PtJ tRtQruyqpAKYcgSNM31uwrJG8YmpLg7tI/1V2Gd2QElFkvuM70IGTgMUtIKKa3Ek/k3r sOApDMgSbHMgiCBrGrmtoUBnxMl+gcvK0XC6k9VoWgat7GWfYfulBSvhUR1n/m8cFGdu 7A8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q7nvntBS; 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 y16si10906710edl.589.2021.09.14.05.12.15; Tue, 14 Sep 2021 05:12:40 -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=Q7nvntBS; 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 S232437AbhINMME (ORCPT + 99 others); Tue, 14 Sep 2021 08:12:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:41228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232065AbhINMMD (ORCPT ); Tue, 14 Sep 2021 08:12:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DEAA46103B; Tue, 14 Sep 2021 12:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631621446; bh=1NIpBNLdfCZYb9J55l4Q8hL2EpMOVJf4F1ZP4EPic0o=; h=From:To:Cc:Subject:Date:From; b=Q7nvntBS2UPB7WBgtlsRmwoqulQsE1KJvhWDedyZA1BSnxb8yPU0K17QnznuiE3fU mAeLUTwMZ/zeLor7nmbccDG/KPyeNo62+HOjtNdyL6iAZTQ8hEAdpJiS1bX7tvkFcd pGPiYTsDjJggRDkG0PEhPZCBGyPgTAbGOdaQA2i4+t+5dTa6u/NO207XoF6tvowP1b 9aNH1bsh+C4dVWnBEgC8NYYps4JsZcROJhlN5L7ekYMdg5YVNLb5X9hU6YeJP6yazc i1agQJWLHvsIkA7OW0eP1CG1zoVzC6WmTMxPnhjtaVgyONkRu94OZ6YvAsEoZv4THJ bFzLs/LVRpZCw== 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 , Vasily Gorbik , Christian Borntraeger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Kees Cook , Andy Lutomirski , Linus Torvalds , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org Subject: [RFC PATCH 0/8] Move task_struct::cpu back into thread_info Date: Tue, 14 Sep 2021 14:10:28 +0200 Message-Id: <20210914121036.3975026-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit c65eacbe290b ("sched/core: Allow putting thread_info into task_struct") mentions that, along with moving thread_info into task_struct, the cpu field is moved out of the former into the latter, but does not explain why. While collaborating with Keith on adding THREAD_INFO_IN_TASK support to ARM, we noticed that keeping CPU in task_struct is problematic for architectures that define raw_smp_processor_id() in terms of this field, as it requires linux/sched.h to be included, which causes a lot of pain in terms of circular dependencies (or 'header soup', as the original commit refers to it). For examples of how existing architectures work around this, please refer to patches #6 or #7. In the former case, it uses an awful asm-offsets hack to index thread_info/current without using its type definition. The latter approach simply keeps a copy of the task_struct CPU field in thread_info, and keeps it in sync at context switch time. Patch #8 reverts this latter approach for ARM, but this code is still under review so it does not currently apply to mainline. We also discussed introducing yet another Kconfig symbol to indicate that the arch has THREAD_INFO_IN_TASK enabled but still prefers to keep its CPU field in thread_info, but simply keeping it in thread_info in all cases seems to be the cleanest approach here. Cc: Keith Packard Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Christophe Leroy Cc: Paul Mackerras Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Albert Ou Cc: Heiko Carstens Cc: Vasily Gorbik Cc: Christian Borntraeger Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Peter Zijlstra Cc: Kees Cook Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-riscv@lists.infradead.org Cc: linux-s390@vger.kernel.org Ard Biesheuvel (8): arm64: add CPU field to struct thread_info x86: add CPU field to struct thread_info s390: add CPU field to struct thread_info powerpc: add CPU field to struct thread_info sched: move CPU field back into thread_info if THREAD_INFO_IN_TASK=y powerpc: smp: remove hack to obtain offset of task_struct::cpu riscv: rely on core code to keep thread_info::cpu updated ARM: rely on core code to keep thread_info::cpu updated arch/arm/include/asm/switch_to.h | 14 -------------- arch/arm/kernel/smp.c | 3 --- arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/kernel/asm-offsets.c | 2 +- arch/arm64/kernel/head.S | 2 +- arch/powerpc/Makefile | 11 ----------- arch/powerpc/include/asm/smp.h | 17 +---------------- arch/powerpc/include/asm/thread_info.h | 3 +++ arch/powerpc/kernel/asm-offsets.c | 4 +--- arch/powerpc/kernel/smp.c | 2 +- arch/riscv/kernel/asm-offsets.c | 1 - arch/riscv/kernel/entry.S | 5 ----- arch/riscv/kernel/head.S | 1 - arch/s390/include/asm/thread_info.h | 1 + arch/x86/include/asm/thread_info.h | 3 +++ include/linux/sched.h | 6 +----- kernel/sched/sched.h | 4 ---- 17 files changed, 14 insertions(+), 66 deletions(-) -- 2.30.2