Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1730927rdb; Mon, 8 Jan 2024 08:27:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyJUVko0od2WdVcrZ9m2VPYaEwSmOPkcxJBWiBX3ufdGCU64Nt/WDRNhPZd3tTYGMZTAQP X-Received: by 2002:a05:6358:63a7:b0:175:969a:68b with SMTP id k39-20020a05635863a700b00175969a068bmr1118408rwh.61.1704731231539; Mon, 08 Jan 2024 08:27:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704731231; cv=none; d=google.com; s=arc-20160816; b=DxdZXF+LnWdu2rwZLOBwP1n/r9Rn1n2TVo85/X+qkvnubKixdm/YJoh3B0w5Pcd9Ak HfKBZgZIEiU7hlqekhzaPLUffFXvEqYKBVklFFiJ4ZGXF5jujf2OBZz3LAUEr3qHvFJB x1eI3K9MrPCngTIhCl0j2JMYIkZ8ttg3ROF7IbwsLYI8uKKaokO2wjjeL7VGuKY6cFA+ s32IL6zV77yEWEnGhJDQ7WJ7I07+hNyHpTqqaZEGzxGAh+AhqOVjAoYwRkK2jMPOYJbD lOvnwCKpx9Gjr1S6o4Pmd4Sy9ODnPFS0Mkx1PEkonjGRhKJhebpp521O204w1h0FxIR3 ZvXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=eeIzoqxrLXo1KH8BIqbi+bTf8TyIf0sMlfYqbdxX6QQ=; fh=inTkz90tjyaFgiJBX2nR8rdeR+iU5LIUx6dUh76TTrY=; b=BRCDjfD8/NffKzgEWdwvy8YZIFTNYryNqUOdTasePfBIy5+fpvPXbk5+dBJOOT+LS/ PdM/gzcKxzUaGxox5YCi55Tp5WvXpyleCuD8Qh5xW8ZJjBFGQX+Q2OX6GrJY4ryeuKfj ynYIEoGLLs77l+mTZe0kZMhfPiNc2GjpGGE8x/eK5UOZcZLKBy/mC1IfsnTFdajDq235 8tvPdIZzXy9Edc0P5x31yke/Oubgrtg417vraWjZBmXh2ENmCnYWO0SOYrgVplEfZ5eB oazosasqtqJVeYiQFaX626Doo5Hs2vnJ/K+LlQ5WH70h1odmyJX437D66codGkhFVI/a 5AsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=eLMqCnP2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=53g7yn4e; spf=pass (google.com: domain of linux-kernel+bounces-19839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19839-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i63-20020a639d42000000b005cec8bccdc0si77580pgd.54.2024.01.08.08.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 08:27:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=eLMqCnP2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=53g7yn4e; spf=pass (google.com: domain of linux-kernel+bounces-19839-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19839-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 562E9B222FC for ; Mon, 8 Jan 2024 16:27:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22DDA537E2; Mon, 8 Jan 2024 16:26:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="eLMqCnP2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="53g7yn4e" X-Original-To: linux-kernel@vger.kernel.org Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3D0552F86 for ; Mon, 8 Jan 2024 16:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id EFC6F5C031A; Mon, 8 Jan 2024 11:26:46 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Mon, 08 Jan 2024 11:26:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1704731206; x=1704817606; bh=eeIzoqxrLX o1KH8BIqbi+bTf8TyIf0sMlfYqbdxX6QQ=; b=eLMqCnP2BUFKyAsVgX1rOKjFDV S4KTs1mPwq7THeA/it05hV74OvJykOS2Ujskkn0Ts3NirCjUIMXkMf/QJuTlBydQ 0z229j2CYF1edy8Yeumj0noQqTYJ88fNAGEldPqeIoGHkkvQKveP9cRRJLGlvN0a eHy4mtyZd4Y3eLNnJaBbvJsOkRmvxyg6litoOungLvIA2FAS6dmSU57eD76piW9T 8iqwB1s0yESSTg3haVNSrMl8PHf11QxXj2yvl4/r7j0yIGHupOOLfD/Seg60TRnH e2P3DUnVLIn7OQv3lMnGvjE+h3A7thi5s5hzs3hyAqN7jR3mrCIKeAt+yJBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1704731206; x=1704817606; bh=eeIzoqxrLXo1KH8BIqbi+bTf8TyI f0sMlfYqbdxX6QQ=; b=53g7yn4eUzL7WZbr/n2CLy6X06nxW3hQkQOhlf5MdIMV PZadsxw2um0gDWTEJeWqjsj/C5IEt3WJCRRA6UcO9Sj42CVQuijH3WOYr9TuDlqy t2QwiHJZS6tNsenQQXvOmkWh9Ieayb6HjwNawg0inUWZZzDn/DIfCHbrUwxIPE7U kQnFV3kox04ZKdUj2BBN6LcAjp6cUspt1G43MZxG+1TAQc64lsdyCIylRaPgi45b uPrTART495RqYGjpnY6JT1aHRGhwA1ChAq9ZnuynUnjIQeEiQdwfKSwiieeY3lCz b9g/YE8YJRV99Wa5GwwN8xp0ygDOFccLJq0fDNL7Kg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdehjedgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 5C0BFB6008F; Mon, 8 Jan 2024 11:26:46 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1364-ga51d5fd3b7-fm-20231219.001-ga51d5fd3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <6278e066-a443-4055-9e5c-b13dea5909de@app.fastmail.com> In-Reply-To: References: <20240105041458.126602-3-leobras@redhat.com> <112ae7d5-61b2-4887-a56f-35ea7c3b1bfa@app.fastmail.com> Date: Mon, 08 Jan 2024 17:26:26 +0100 From: "Arnd Bergmann" To: "Leonardo Bras" Cc: "Mark Rutland" , "Oleg Nesterov" , "Catalin Marinas" , "Will Deacon" , "Mark Brown" , "Steven Rostedt" , "Guo Hui" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/1] arm64: remove unnecessary ifdefs around is_compat_task() Content-Type: text/plain On Mon, Jan 8, 2024, at 17:04, Leonardo Bras wrote: > On Mon, Jan 08, 2024 at 12:07:48PM -0300, Leonardo Bras wrote: >> On Fri, Jan 05, 2024 at 03:38:05PM +0100, Arnd Bergmann wrote: >> > >> > I suspect it's enough to remove all of the other >> > "#ifdef CONFIG_COMPAT" checks in this file and rely on >> > dead code elimination to remove the rest, but there might >> > be additional problems if some extern declarations are >> > hidden in an #ifdef as well. > > I could remove all CONFIG_COMPAT ifdefs from this file, and for compiling > it required a few extra defines (in other files) to be moved outside of > their #ifdef CONFIG_COMPAT. Those being: > > #define VFP_STATE_SIZE ((32 * 8) + 4) > #define VFP_FPSCR_STAT_MASK 0xf800009f > #define VFP_FPSCR_CTRL_MASK 0x07f79f00 > > #define COMPAT_ELF_NGREG 18 > typedef unsigned int compat_elf_greg_t; > typedef compat_elf_greg_t compat_elf_gregset_t[COMPAT_ELF_NGREG]; > > > OTOH, the size of the final arch/arm64/kernel/ptrace.o went from 44768 to > 56328 bytes, which I understand to be undesired. Right, unfortunately it seems that compat_arch_ptrace() is globally visible and consequently not dropped by the compiler in dead code elimination. > A different (and simpler) solution is to have an empty struct in case of > !CONFIG_COMPAT, that will be optimized out in compile-time: > > diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c > index 9f8781f1fdfda..d2f275d8a3e6e 100644 > --- a/arch/arm64/kernel/ptrace.c > +++ b/arch/arm64/kernel/ptrace.c > @@ -2107,6 +2107,9 @@ long compat_arch_ptrace(struct task_struct > *child, compat_long_t request, > > return ret; > } > +#else > +static const struct user_regset_view user_aarch32_view = {}; > +static const struct user_regset_view user_aarch32_ptrace_view = {}; > #endif /* CONFIG_COMPAT */ > > const struct user_regset_view *task_user_regset_view(struct task_struct *task) > > With this the patch will build successfully and arch/arm64/kernel/ptrace.o > will be able to keep it's original size. > > Arnd, is that ok? I don't see it being worth it if you add extra unused lines in order to remove one more #ifdef. I would either leave the task_user_regset_view() function unchanged here, or (if this works) move the #ifdef down a few lines so the existing user_regset_view structures can be shared: @@ -1595,7 +1595,6 @@ static const struct user_regset_view user_aarch64_view = { .regsets = aarch64_regsets, .n = ARRAY_SIZE(aarch64_regsets) }; -#ifdef CONFIG_COMPAT enum compat_regset { REGSET_COMPAT_GPR, REGSET_COMPAT_VFP, @@ -1852,6 +1851,7 @@ static const struct user_regset_view user_aarch32_ptrace_view = { .regsets = aarch32_ptrace_regsets, .n = ARRAY_SIZE(aarch32_ptrace_regsets) }; +#ifdef CONFIG_COMPAT static int compat_ptrace_read_user(struct task_struct *tsk, compat_ulong_t off, compat_ulong_t __user *ret) { Arnd