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 1BB78ECAAA1 for ; Tue, 30 Aug 2022 09:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: MIME-Version:References:Message-ID:In-Reply-To:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wWMOth1kdfQQKQX8bFnE3YG6brkHFco8eTJAe1bjzDw=; b=JM+hv4gN3+GlFS8NpjEuKhiYdm cYhqk8U892wp09GSs+VuqdIFumNmMSRBec4YvPvIJ/vedm/ocZm8vkvZbJergUx3jVYKe73tsHTUg cKg71CNn0wBAOc2F+5vY2Sz8Lzk36Ba0NQKT/CvaEGb+tHUVKpZ6qzY3dO4vZJJUgyQNPmRVPDjl+ WNkfJWFcDKSO/TzP9dTvYxeaP6p7yx95b60Y1xrpkc2kBHruFR+ubqxgoGGex5Bxx9yojqGRuLDqQ qNcJA4ZO0Wd85b7AxTgkc2GJyHxam1GqjJIabWK6GfMTPEccLua6RhpkbBO89VbJUPe024HPkJFSe SzVKCxvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oSxWA-00Fcf0-P3; Tue, 30 Aug 2022 09:26:47 +0000 Received: from mga12.intel.com ([192.55.52.136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oSxW5-00FcaK-7V for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2022 09:26:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661851601; x=1693387601; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=unlic4/lYX6T/gxK2b8kUDtNMgSGMfP8eMU0jAigMdY=; b=HlXMBWN2gCEwFj1bOgHSyVqnwbUa4Aj9zy/mvjtQnboG3ySk7jj51ZFO v/9dpxuCkZwC1l0Obm87/seE7eJreHfaCYLcxPePcOtVKnzz7Wz0dKJvl MIDh3lFth/ItPoMMUCgbFTaCFtiMskValS7IDfR3Pxc3sB4ZJxrYhVbYP yKgSFsLFCc8zUnXhW+ZZZp7bMBV4xO6Mie52iyC1RjbpCOgNIxpF8Y+e8 1Kt1/s6+ZaYTUzdj4vZ/UeTq3atPiW8iupopttzaOkmpiXnMaHQGoib1Y 4OWCLUlu9ZsmvyAUZSmna3MYzvbUkV2+o20W0X4o/5OtkB/rTkc2FTmR/ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10454"; a="274877900" X-IronPort-AV: E=Sophos;i="5.93,274,1654585200"; d="scan'208";a="274877900" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 02:26:39 -0700 X-IronPort-AV: E=Sophos;i="5.93,274,1654585200"; d="scan'208";a="672778415" Received: from arnesgom-mobl.ger.corp.intel.com ([10.252.54.235]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 02:26:30 -0700 Date: Tue, 30 Aug 2022 12:26:29 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Greg Kroah-Hartman Subject: Re: [PATCH v2 4/4] serial: Add kserial_rs485 to avoid wasted space due to .padding In-Reply-To: Message-ID: <58d6748-ebd-e637-c1b2-b8e469e6d86d@linux.intel.com> References: <20220830072956.3630-1-ilpo.jarvinen@linux.intel.com> <20220830072956.3630-5-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-1331296277-1661851599=:1864" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220830_022641_581145_F41C563D X-CRM114-Status: GOOD ( 24.72 ) 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: , Cc: Alexandre Belloni , linux-doc@vger.kernel.org, Alexandre Torgue , LKML , Fabio Estevam , linux-stm32@st-md-mailman.stormreply.com, Jonathan Corbet , Jiri Slaby , Russell King , Lino Sanfilippo , NXP Linux Team , linux-serial , Pengutronix Kernel Team , Sascha Hauer , Vladimir Zapolskiy , Andy Shevchenko , linux-arm-kernel@lists.infradead.org, Richard Genoud , Maxime Coquelin , Shawn Guo , Claudiu Beznea Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1331296277-1661851599=:1864 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT On Tue, 30 Aug 2022, Greg Kroah-Hartman wrote: > On Tue, Aug 30, 2022 at 10:29:56AM +0300, Ilpo Järvinen wrote: > > -static int serial_rs485_from_user(struct serial_rs485 *rs485, > > +static int serial_rs485_from_user(struct kserial_rs485 *rs485, > > const struct serial_rs485 __user *rs485_user) > > { > > - if (copy_from_user(rs485, rs485_user, sizeof(*rs485))) > > + struct serial_rs485 rs485_uapi; > > + > > + if (copy_from_user(&rs485_uapi, rs485_user, sizeof(*rs485))) > > return -EFAULT; > > > > + *rs485 = *((struct kserial_rs485 *)&rs485_uapi); > > Ah, you are mapping this on top of the existing structure, so there was > no padding in the original one, why say that? While I'm not exactly sure what you tried to say with this, I'll try to answer regardless. It's the opposite, there's padding in rs485_user, and therefore also in rs485_uapi. Struct serial_rs485 has padding and is part of uapi so it cannot be changed to remove the extra padding. I cannot directly copy_from_user into *rs485 because it lacks the padding. Thus, the immediate rs485_uapi and then assign to rs485. > > +/* > > + * Compile-time asserts for struct kserial_rs485 and struct serial_rs485 equality > > + * (except padding). > > This does not take into account any padding, in fact it's the opposite > as all of this: ?? I said: "(except padding)" which I thought implies that padding is intentionally excluded (it doesn't exist in kserial_rs485). > > + */ > > +static_assert(offsetof(struct kserial_rs485, flags) == > > + offsetof(struct serial_rs485, flags)); > > +static_assert(offsetof(struct kserial_rs485, delay_rts_before_send) == > > + offsetof(struct serial_rs485, delay_rts_before_send)); > > +static_assert(offsetof(struct kserial_rs485, delay_rts_after_send) == > > + offsetof(struct serial_rs485, delay_rts_after_send)); > > +static_assert(offsetof(struct kserial_rs485, addr_recv) == > > + offsetof(struct serial_rs485, addr_recv)); > > +static_assert(offsetof(struct kserial_rs485, addr_dest) == > > + offsetof(struct serial_rs485, addr_dest)); > > +static_assert(sizeof(struct kserial_rs485) <= sizeof(struct serial_rs485)); > > Is there to ensure that the offsets are exactly the same, no padding > involved anywhere. That's because for kernel padding "doesn't matter", it doesn't want it, it would be just wasted space. After this series, padding is used only for uapi, no longer for the in-kernel structs. > So I don't understand the problem you are trying to solve here, struct serial_rs485 has padding that is ~16B long currently. serial_rs485 is currently used for a few things: - Keep track of rs485 state (per port) - Record what rs485 options the port supports (per port) - Record rs485 options a driver supports (per driver with rs485 support) - Exchange rs485 config/state information with userspace Only the last of those requires the padding (because it has been part of uapi since day 1). With kserial_rs485, the padding can eliminated for the first 3 cases. If you feel ~32B per uart_port too little to be useful (and a little more per driver), I can just drop this patch. -- i. --8323329-1331296277-1661851599=:1864 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --8323329-1331296277-1661851599=:1864--