Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp540131pxb; Thu, 30 Sep 2021 11:21:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6OLgOZW0iuKLTmbjo3DDLrCgv1+F1PUjk9g5gW2+q4ocq0YTbG4LDpie7BrcNwciRvLBR X-Received: by 2002:a17:90a:f193:: with SMTP id bv19mr14392950pjb.18.1633026092300; Thu, 30 Sep 2021 11:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633026092; cv=none; d=google.com; s=arc-20160816; b=hLVS9gNvx906EunNWYOv5P63JnlIEvE4SqtDCqYy2PuuS5bzKEHNnpT1TcKfNfCf2p szmcMou4wyDX8zU7uff8Fn5nny2DTicDILR4dwEgrhpHaVC+0JPxx383bEVkf3xhH+li x3hEh/eSebcxKT5kvCti3C2VlkcPmjecNbs4BgkgZPHXCvQzAikcBiSb7Yl7NL2KhwWn VeK6dDPJS46jXfzDYa0IZP1A1/aHkClR8cjPP6melkJHvWugzBsa4K2YxKGQdSeLufpI YyUhkUCwlyPogY/nSYQcrwU1fG8/9jndk+OAa6K08yznTTYjxd5Utr9aZMKasSOjv1TE b2rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=0xvt9u5TsXv8d1IGPLL5CyGLQYAYQ+v7BSk2eo5/jQs=; b=U8KFb41D0wLklOZ4t4wBldtQTKI+Ap/ZObJaTU7rWvgeO7Gw3rBgixe27gCF+h9BJd fyVrWU7CDqWihcOMM17bFw/5UOzxYllrtpMPk0ALVkd5WCR8669PhRsg6QOuch+FEiEr hGUlfbn+mk1mScdo6xEEGO9Tf20MM5aAy6/6ejBgvHi1zfL9nYJ/WW0SheE/kt5Y/Yk1 qkGwoak23Mx+lrFTpJ6/Vn5/gh7/jYwXvcpxbHd7EEh1bJ5BblpWL/rtStzW1OpWN6Gj CiN+eZqNRVZk/XcGBO2IIDeuNxPFGGyKDPvOj8qkTxlcR3rAZ0Iyj6KfcwkAHTRgkzfD 8BoA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h126si4763566pfb.370.2021.09.30.11.21.17; Thu, 30 Sep 2021 11:21:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350686AbhI3Ng7 (ORCPT + 99 others); Thu, 30 Sep 2021 09:36:59 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:36309 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349563AbhI3Ng6 (ORCPT ); Thu, 30 Sep 2021 09:36:58 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4HKvPZ3WwBz9sVL; Thu, 30 Sep 2021 15:35:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LWfDC8gYcJM3; Thu, 30 Sep 2021 15:35:14 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4HKvPZ2RX8z9sVK; Thu, 30 Sep 2021 15:35:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3B8DC8B773; Thu, 30 Sep 2021 15:35:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id ODWiSNY5bC5p; Thu, 30 Sep 2021 15:35:14 +0200 (CEST) Received: from PO20335.IDSI0.si.c-s.fr (unknown [192.168.203.149]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 158B98B763; Thu, 30 Sep 2021 15:35:13 +0200 (CEST) Subject: Re: [PATCH v2 5/7] sched: move CPU field back into thread_info if THREAD_INFO_IN_TASK=y From: Christophe Leroy To: Ard Biesheuvel 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 References: <20210930125813.197418-1-ardb@kernel.org> <20210930125813.197418-6-ardb@kernel.org> <427566ca-80c0-56eb-880b-908bd4a71e9a@csgroup.eu> Message-ID: <2e1f58c0-8b2a-3d72-2261-a43f810e7070@csgroup.eu> Date: Thu, 30 Sep 2021 15:35:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr-FR Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 30/09/2021 à 15:22, Christophe Leroy a écrit : > > > Le 30/09/2021 à 15:12, Ard Biesheuvel a écrit : >> On Thu, 30 Sept 2021 at 15:09, Christophe Leroy >> wrote: >>> >>> >>> >>> Le 30/09/2021 à 14:58, Ard Biesheuvel a écrit : >>>> 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=y, 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-offsets.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, >>>> active_mm)); >>>> -  DEFINE(TSK_CPU,            offsetof(struct task_struct, cpu)); >>>>      BLANK(); >>>>      DEFINE(TSK_TI_CPU,                offsetof(struct task_struct, >>>> thread_info.cpu)); >>>>      DEFINE(TSK_TI_FLAGS,              offsetof(struct task_struct, >>>> thread_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. > > In the old days it was called TI_CPU, was changed by commit f7354ccac844 > ("powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU") after > commit ed1cd6deb013 ("powerpc: Activate CONFIG_THREAD_INFO_IN_TASK") > > I don't have a strong opinion about it but we have: > > $ git grep thread_info arch/powerpc/kernel/asm-offsets.c > arch/powerpc/kernel/asm-offsets.c:#include > arch/powerpc/kernel/asm-offsets.c:      OFFSET(TI_livepatch_sp, > thread_info, livepatch_sp); > arch/powerpc/kernel/asm-offsets.c:      OFFSET(TI_LOCAL_FLAGS, > thread_info, local_flags); > arch/powerpc/kernel/asm-offsets.c: offsetof(struct task_struct, > thread_info)); Forget that. I didn't realise that your change keeps it based on 'task_struct' so it makes sense to keep it named TASK_CPU. > > >> >> >>>>        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/asm-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 >>> >>> ...