linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v6 11/15] software node: move small properties inline when copying
Date: Thu, 7 Nov 2019 16:28:44 -0800	[thread overview]
Message-ID: <20191108002844.GX57214@dtor-ws> (raw)
In-Reply-To: <3310518.lfHdziMng4@kreacher>

On Fri, Nov 08, 2019 at 01:04:31AM +0100, Rafael J. Wysocki wrote:
> On Wednesday, November 6, 2019 12:56:56 AM CET Dmitry Torokhov wrote:
> > Hi Rafael,
> > 
> > On Wed, Nov 06, 2019 at 12:42:02AM +0100, Rafael J. Wysocki wrote:
> > > On Wednesday, October 23, 2019 10:02:29 PM CET 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.
> > > 
> > > Yes, we can do that, but how much of a difference does this really make?
> > 
> > Arguably not much I think, but it was pretty cheap to do.
> > 
> > > 
> > > Also, how can one distinguish between a single-value property and an inline
> > > array which this change?  By looking at the length?
> > 
> > We do not really need to distinguish between the 2. The device
> > properties API is typically wrap single values around arrays (i.e. it is
> > perfectly fine to use scalar API to fetch first element of array and use
> > array API to fetch a scalar). So we have property of certain type with
> > certain number of elements, and it can either be stored inside
> > property_entry structure, or outside of it. They are 2 orthogonal
> > concepts.
> > 
> > > 
> > > > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > > ---
> > > >  drivers/base/swnode.c | 10 ++++++++++
> > > >  1 file changed, 10 insertions(+)
> > > > 
> > > > diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c
> > > > index 18a30fb3cc58..49e1108aa4b7 100644
> > > > --- a/drivers/base/swnode.c
> > > > +++ b/drivers/base/swnode.c
> > > > @@ -280,6 +280,16 @@ static int property_entry_copy_data(struct property_entry *dst,
> > > >  	if (!dst->name)
> > > >  		goto out_free_data;
> > > >  
> > > > +	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);
> > > > +		dst->is_inline = true;
> > > > +
> > > > +		kfree(tmp);
> > > 
> > > This would have been more useful if we had been able to avoid making the
> > > allocation altogether.
> > 
> > OK, I can do that and re-send this patch and the one with the tests.
> 
> But if you do that, IMO it would be prudent to extend the definition of
> struct property_entry like this:
> 
>  struct property_entry {
>  	const char *name;
>  	size_t length;
>  	bool is_array;
>  	enum dev_prop_type type;
>  	union {
>  		union {
>  			const u8 *u8_data;
>  			const u16 *u16_data;
>  			const u32 *u32_data;
>  			const u64 *u64_data;
>  			const char * const *str;
>  		} pointer;
>  		union {
>  			u8 u8_data;
>  			u16 u16_data;
>  			u32 u32_data;
>  			u64 u64_data;
>  			const char *str;
> +			u8 u8_buf[sizeof(u64)];
> +			u16 u16_buf[sizeof(u64)/sizeof(u16)];
> +			u32 u32_buf[sizeof(u64)/sizeof(u32)];
> +			char char_buf[sizeof(u64)];
>  		} value;
>  	};
>  };
> 
> to make it clear that the value field is going to be used as an array in
> some cases.

Sorry, just sent out updated series before receiving your email. I can
cook up new patch cleaning this. I think we can drop scalars and only
have arrays and have initializers use <type>_data[0] to create initial
property entries.

> 
> > In the mean time, can you please consider patches 12-14?
> 
> I cannot find drivers/platform/x86/intel_cht_int33fe_typec.c in the mainline,
> so I cannot apply patch [13/15] now and I'm not sure how useful it would be
> to apply patches [10,12/15] without the other two.

Hmm, drivers/platform/x86/intel_cht_int33fe_typec.c used to be
drivers/platform/x86/intel_cht_int33fe.c I think.

I can either regenerate against your tree instead of -next (but then
there will be merge conflict) or we could postpone #13 and #14 (or #5
and #6 in v7) till after merge window.

Please let me know.

-- 
Dmitry

  reply	other threads:[~2019-11-08  0:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 20:02 [PATCH v6 00/15] software node: add support for reference properties Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 01/15] software node: remove DEV_PROP_MAX Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 02/15] software node: introduce PROPERTY_ENTRY_ARRAY_XXX_LEN() Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 03/15] efi/apple-properties: use PROPERTY_ENTRY_U8_ARRAY_LEN Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 04/15] software node: mark internal macros with double underscores Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 05/15] software node: clean up property_copy_string_array() Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 06/15] software node: get rid of property_set_pointer() Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 07/15] software node: remove property_entry_read_uNN_array functions Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 08/15] software node: unify PROPERTY_ENTRY_XXX macros Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 09/15] software node: simplify property_entry_read_string_array() Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 10/15] software node: rename is_array to is_inline Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 11/15] software node: move small properties inline when copying Dmitry Torokhov
2019-11-05 23:42   ` Rafael J. Wysocki
2019-11-05 23:56     ` Dmitry Torokhov
2019-11-08  0:04       ` Rafael J. Wysocki
2019-11-08  0:28         ` Dmitry Torokhov [this message]
2019-11-08  0:45           ` Rafael J. Wysocki
2019-11-08  0:49             ` Dmitry Torokhov
2019-11-08  1:34               ` Rafael J. Wysocki
2019-11-08  3:45                 ` Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 12/15] software node: implement reference properties Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 13/15] platform/x86: intel_cht_int33fe: use inline " Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 14/15] software node: remove separate handling of references Dmitry Torokhov
2019-10-23 20:02 ` [PATCH v6 15/15] software node: add basic tests for property entries Dmitry Torokhov
2019-10-30 22:43 ` [PATCH v6 00/15] software node: add support for reference properties Dmitry Torokhov
2019-11-05 22:09   ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191108002844.GX57214@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).