From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Subject: Re: [PATCH v5 11/14] software node: move small properties inline when copying Date: Wed, 16 Oct 2019 10:48:57 +0300 Message-ID: <20191016074857.GN32742@smile.fi.intel.com> References: <20191011230721.206646-1-dmitry.torokhov@gmail.com> <20191011230721.206646-12-dmitry.torokhov@gmail.com> <20191015122028.GI32742@smile.fi.intel.com> <20191015182553.GG105649@dtor-ws> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20191015182553.GG105649@dtor-ws> Sender: linux-kernel-owner@vger.kernel.org To: Dmitry Torokhov Cc: "Rafael J. Wysocki" , Heikki Krogerus , Mika Westerberg , Linus Walleij , Ard Biesheuvel , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org List-Id: platform-driver-x86.vger.kernel.org On Tue, Oct 15, 2019 at 11:25:53AM -0700, Dmitry Torokhov wrote: > On Tue, Oct 15, 2019 at 03:20:28PM +0300, Andy Shevchenko wrote: > > On Fri, Oct 11, 2019 at 04:07:18PM -0700, Dmitry Torokhov wrote: > > > When copying/duplicating set of properties, move smaller properties that > > > were stored separately directly inside property entry structures. We can > > > move: > > > > > > - up to 8 bytes from U8 arrays > > > - up to 4 words > > > - up to 2 double words > > > - one U64 value > > > - one or 2 strings. > > > > Can you show where you extract such values? > > the "value" union's largest member is u64, which is 8 bytes. Strings are > pointers, so on 32-bit arches you can stuff 2 pointers into 8 bytes, > while on 64-bits you have space for only one. > > > > > > + if (!dst->is_inline && dst->length <= sizeof(dst->value)) { > > > + /* We have an opportunity to move the data inline */ > > > + const void *tmp = dst->pointer; > > > + > > > > > + memcpy(&dst->value, tmp, dst->length); > > > > ...because this is strange trick. > > Not sure what is so strange about it. You just take data that is stored > separately and move it into the structure, provided that it is not too > big (i.e. it does not exceed sizeof(value union) size). You store a value as union, but going to read as a member of union? I'm pretty sure it breaks standard rules. -- With Best Regards, Andy Shevchenko