Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp306749pxb; Thu, 30 Sep 2021 06:32:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoQ6vQv+UyTpxzdDTzXkGS1MzzNHlDbYFiWe3qmFRSroSuNFF8FXNcNeJwi7ArSxhTfp41 X-Received: by 2002:a17:906:1848:: with SMTP id w8mr2199677eje.485.1633008740884; Thu, 30 Sep 2021 06:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633008740; cv=none; d=google.com; s=arc-20160816; b=L/hrqbxzPGJ9bSvomHLY/HgXVudjcpryv/QBL2VmHsGU0ixbIObgMWhwU1aOEayMFf jHO5czhtNxOE7ZQuTWEUjGi29Et9PBK89zLCK5E41cY9MD/jA5vHRcyWV2x+SaQhaEAN q0WwI739ZA5oNn4Y7biWM2RDMfZx2XILGYs8kbXl4x4IEsSoYmfKZrp9VUwTGMwaGE5O hL4C59s0bF1IC0zgFWaiukRMxISkjU2aDWV+ONfJlPMWyG59aDAXcwKahDHWDLeCaaTk sIp0dSqd+17B2+S0Uv6p6o0wHci1lNlmfxatNaQTHmDNQPj25JbwXaJx8L+7QUMyzTCT ryiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=S+gVy31nNQft212cjgwDe/3IdDCZnEtnklyaHCgUc28=; b=qc5FgmCTmvmrBpXOiXPOskZnm27We2DLgoIagZtycLNR9YCcr0es7nC5FoRGgesFjf N+cIbKXQBwM0c1AiaN+fDvaOHPe5budICSAW9EBR0ZlGtL5coYMGGWeSd8yHxmLsx3EG 9S2aV5HePDEFXRMw8UJOod4zNVcIXvwUqqu1/+27sFVMqGqnJeTBTokbOjMtAESSSI/a cJfuAw+3K95nwkD+jchFTnok5uRl60sC9Bb7BCUTYWxjPyCTOlUlN/EYQHWQh/ppbHcK tnyCQLruAGFdWHMeSjVjNRJZR9lq3NNFN1G9JAUhZMX99h34IX7UJnO7oGOYJhOmAyO1 o+SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MGtqMo5E; 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 y1si3066272edq.420.2021.09.30.06.31.37; Thu, 30 Sep 2021 06:32:20 -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=MGtqMo5E; 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 S1350241AbhI3NOU (ORCPT + 99 others); Thu, 30 Sep 2021 09:14:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:36726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349892AbhI3NOT (ORCPT ); Thu, 30 Sep 2021 09:14:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7256761528 for ; Thu, 30 Sep 2021 13:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633007556; bh=vHSfNPWmgwIIa9+j2tmKGBTEDiaUE/7eNtYnP7G/W4Q=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MGtqMo5E4xGTkHt1jJrxW8YHOcPFO6LUA7iPXBkoNrThnA0ffRV3HacMGjBlXi7AH RNHpE4lexIfAM7aq6K6LgijwPx/6A6p5Y5SrzoY8RO4nc3WV3U9+Do//3GcXknocn1 wS7kEkFjzHqyOuluSTRw5D3ZZgG8uiokciZXS3uctswM3fwsUotYXHTKlp1i512dHM tdtjS4eJw2XqnTU27/hYsF7pp7cV5k8CswjDFvpdYwFaNYFkFJiBOdmwgF5KllrrHI JZ619kzb9PZiCVhV0p3CVsLaR8bB0IjAyylIqYloWAsSpF1ZMCv9JaviPjyRfkrNml tntDlL5n/8AbA== Received: by mail-oi1-f172.google.com with SMTP id s24so7147426oij.8 for ; Thu, 30 Sep 2021 06:12:36 -0700 (PDT) X-Gm-Message-State: AOAM530Fq5hzv4ls2HuodYk0ZwAbKfc41/qlYDdvUt52s4ib4+MdrozP mcpWj1E0jsTfYhO8fq4NVEhE3IBORGvEajSIkMk= X-Received: by 2002:a05:6808:1148:: with SMTP id u8mr2628592oiu.33.1633007555710; Thu, 30 Sep 2021 06:12:35 -0700 (PDT) MIME-Version: 1.0 References: <20210930125813.197418-1-ardb@kernel.org> <20210930125813.197418-6-ardb@kernel.org> <427566ca-80c0-56eb-880b-908bd4a71e9a@csgroup.eu> In-Reply-To: <427566ca-80c0-56eb-880b-908bd4a71e9a@csgroup.eu> From: Ard Biesheuvel Date: Thu, 30 Sep 2021 15:12:24 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 5/7] sched: move CPU field back into thread_info if THREAD_INFO_IN_TASK=y To: Christophe Leroy Cc: Linux Kernel Mailing List , Keith Packard , Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Mark Rutland Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Sept 2021 at 15:09, Christophe Leroy wrote: > > > > Le 30/09/2021 =C3=A0 14:58, Ard Biesheuvel a =C3=A9crit : > > THREAD_INFO_IN_TASK moved the CPU field out of thread_info, but this > > causes some issues on architectures that define raw_smp_processor_id() > > in terms of this field, due to the fact that #include'ing linux/sched.h > > to get at struct task_struct is problematic in terms of circular > > dependencies. > > > > Given that thread_info and task_struct are the same data structure > > anyway when THREAD_INFO_IN_TASK=3Dy, let's move it back so that having > > access to the type definition of struct thread_info is sufficient to > > reference the CPU number of the current task. > > > > Note that this requires THREAD_INFO_IN_TASK's definition of the > > task_thread_info() helper to be updated, as task_cpu() takes a > > pointer-to-const, whereas task_thread_info() (which is used to generate > > lvalues as well), needs a non-const pointer. So make it a macro instead= . > > > > Signed-off-by: Ard Biesheuvel > > Acked-by: Catalin Marinas > > Acked-by: Mark Rutland > > Acked-by: Michael Ellerman > > --- > > arch/arm64/kernel/asm-offsets.c | 1 - > > arch/arm64/kernel/head.S | 2 +- > > arch/powerpc/kernel/asm-offsets.c | 2 +- > > arch/powerpc/kernel/smp.c | 2 +- > > include/linux/sched.h | 13 +------------ > > kernel/sched/sched.h | 4 ---- > > 6 files changed, 4 insertions(+), 20 deletions(-) > > > > diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-of= fsets.c > > index cee9f3e9f906..0bfc048221af 100644 > > --- a/arch/arm64/kernel/asm-offsets.c > > +++ b/arch/arm64/kernel/asm-offsets.c > > @@ -27,7 +27,6 @@ > > int main(void) > > { > > DEFINE(TSK_ACTIVE_MM, offsetof(struct task_struct, acti= ve_mm)); > > - DEFINE(TSK_CPU, offsetof(struct task_struct, cpu)); > > BLANK(); > > DEFINE(TSK_TI_CPU, offsetof(struct task_struct, thre= ad_info.cpu)); > > DEFINE(TSK_TI_FLAGS, offsetof(struct task_struct, thre= ad_info.flags)); > > diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S > > index 17962452e31d..6a98f1a38c29 100644 > > --- a/arch/arm64/kernel/head.S > > +++ b/arch/arm64/kernel/head.S > > @@ -412,7 +412,7 @@ SYM_FUNC_END(__create_page_tables) > > scs_load \tsk > > > > adr_l \tmp1, __per_cpu_offset > > - ldr w\tmp2, [\tsk, #TSK_CPU] > > + ldr w\tmp2, [\tsk, #TSK_TI_CPU] > > Why do you need to change the name ? > > For powerpc64, you leave TASK_CPU. > Because arm64 has a clear idiom here, where TSK_TI_ is used for thread_info fields accessed via a task_struct pointer. Also, it only occurs once in the code. Power does not seem to have this idiom, and TASK_CPU is used in many more places, so I don't think it makes sense to change its name. > > ldr \tmp1, [\tmp1, \tmp2, lsl #3] > > set_this_cpu_offset \tmp1 > > .endm > > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/as= m-offsets.c > > index e563d3222d69..e37e4546034e 100644 > > --- a/arch/powerpc/kernel/asm-offsets.c > > +++ b/arch/powerpc/kernel/asm-offsets.c > > @@ -93,7 +93,7 @@ int main(void) > > #endif /* CONFIG_PPC64 */ > > OFFSET(TASK_STACK, task_struct, stack); > > #ifdef CONFIG_SMP > > - OFFSET(TASK_CPU, task_struct, cpu); > > + OFFSET(TASK_CPU, task_struct, thread_info.cpu); > > #endif > > > > #ifdef CONFIG_LIVEPATCH > > ...