From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DB63FC3DA6E for ; Mon, 8 Jan 2024 17:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AzYM0ecAus/HmYs+NVOrH5ns8wvMfrRTWWbDAAMC6Js=; b=UXBoIE2LcoW5BC 7L3BqGoa5+OPpH1aju2sWGq6cZDG4OaKI7rQCmuN9FQbaTNb77pC50DetjzkWXX/YeSo+4I3mpsqn 4ReAl2a6bFkUAxfptiWQ7qs/uLOg7Sy2Mhw85D5wfreWpOE6see/f0RfdBg3SugFvWf8yYCFhFGv6 N/2i1XaGHXsmSe+oBgimnTVqiDD/BWec8vkj8TFY68y4Sgk005ICPPKNo6DDEEFUd6Tkjvv7S+3E6 UvTgqfyJ4J6619uYRU5rZieW4MkxduFSiVMvYHikUD1VrWUsCW68IIvdyMgYyJ9IUCEfherRQ2Ydu aTQnuGNz45jpXaTRQrxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rMt85-005iLf-2Q; Mon, 08 Jan 2024 17:09:37 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rMt82-005iLE-0F for linux-arm-kernel@lists.infradead.org; Mon, 08 Jan 2024 17:09:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704733770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DEaf+YhhcSSmYZv93sFV02gwVdE3edWxgyCXG4NmWdI=; b=GNA2+g+Lcle+Wh9pF2Ezur8Kn/uBNwBZWpu1j34Vcq3PBLsc57pYzdgqM7x6IrjPvpa3hf ndn4GmiZMAY9d+Mdw3/9jrnPMiZDGUCNhsc9hSi8ZPsx8HzJJOXpLDuYVhcqDLLfSD8bOu sJAfsPjW44Sjj9I5/eJhKX0ny27izOA= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-381-skrlAf1bP0iYfsZy2M-UHA-1; Mon, 08 Jan 2024 12:09:29 -0500 X-MC-Unique: skrlAf1bP0iYfsZy2M-UHA-1 Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-6d9b09d1afaso2535778b3a.3 for ; Mon, 08 Jan 2024 09:09:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704733767; x=1705338567; h=content-transfer-encoding:content-disposition:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DEaf+YhhcSSmYZv93sFV02gwVdE3edWxgyCXG4NmWdI=; b=Jh7cH8nL2D6iIMQIL6fpIds5fN4e5ILo4AydjUhUzKLLjemgEhU5UPSXnYf4wcEXT4 ha1a1kSvUwrEwzeVcLisYOoxBkSqVl8daeS5QF/YIXzzaKNiyq2imaa+ZwByrw2W9WEt eUJcsanCazO7/iEzJH7lNcm0hYV+nKj/kBqJ4RSzCWSe8nhb8LSL6tfIfrdErZVyR2MU v98D2/6ALHsFJbdvZgRwUfFgMGQTWaDUiju7KeXaAfajFYC1SumG5fXPV0R5J+kqx0CP OpxgP5Czu0pozgLOivv3yv3S25rNPlVgK+H9lKcrGayDFXAh0G6nhjgSfACbTQxYSvKH TrqQ== X-Gm-Message-State: AOJu0YyArF7SW7j/AYUeHzp5DATviInXgBQZ7uj062r2/CmgxXRUQqln WAVw6OXFzyHufcyRmNfeVlBcGph3ykG54t41mGNKBk9aKIDysMiCuUnvgpB5sKba5jwXWjIVIfg OT95RVRY/+fXk58LgQhUeMpftthAOmPl3afPcV0WrQj0SsryXJ8w= X-Received: by 2002:a05:6a20:7286:b0:199:d4f5:9c41 with SMTP id o6-20020a056a20728600b00199d4f59c41mr856127pzk.49.1704733767531; Mon, 08 Jan 2024 09:09:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IErO+E71s0wtZ/MsBmj6uqV1ZMA6UTitBqmGrBZDhzYfsqGb4TCxSD/drIP9YHd0TkYrPZ14g== X-Received: by 2002:a05:6a20:7286:b0:199:d4f5:9c41 with SMTP id o6-20020a056a20728600b00199d4f59c41mr856117pzk.49.1704733767231; Mon, 08 Jan 2024 09:09:27 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a803:26a5:3f32:e12b:5335:3c2d]) by smtp.gmail.com with ESMTPSA id t3-20020a62d143000000b006d9a42f25b2sm107553pfl.201.2024.01.08.09.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 09:09:26 -0800 (PST) From: Leonardo Bras To: Arnd Bergmann Cc: Leonardo Bras , 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() Date: Mon, 8 Jan 2024 14:09:18 -0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: <6278e066-a443-4055-9e5c-b13dea5909de@app.fastmail.com> References: <20240105041458.126602-3-leobras@redhat.com> <112ae7d5-61b2-4887-a56f-35ea7c3b1bfa@app.fastmail.com> <6278e066-a443-4055-9e5c-b13dea5909de@app.fastmail.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240108_090934_209318_640FD6CA X-CRM114-Status: GOOD ( 34.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jan 08, 2024 at 05:26:26PM +0100, Arnd Bergmann wrote: > 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) > { > Ok, with the previous defines moved outside !CONFIG_COMPAT, this works as a charm and keeps arch/arm64/kernel/ptrace.o with the same size. I will send a v2 soon. Thanks! Leo > > Arnd > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel