All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [Intel-gfx] [igt-dev] [PATCH i-g-t] benchmarks/gem_wsim: Tidy manual sizeof VLA calculations
Date: Mon, 3 Jun 2019 13:53:23 +0100	[thread overview]
Message-ID: <10a079f3-6f97-e414-ff34-5470d405ca87@linux.intel.com> (raw)
In-Reply-To: <20190527094611.31948-1-chris@chris-wilson.co.uk>


On 27/05/2019 10:46, Chris Wilson wrote:
> We can use offsetof for the same effect, much tidier with no dummy
> locals.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   benchmarks/gem_wsim.c | 15 ++++++---------
>   1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> index db19925b1..a76fdbfe2 100644
> --- a/benchmarks/gem_wsim.c
> +++ b/benchmarks/gem_wsim.c
> @@ -1443,23 +1443,20 @@ set_ctx_sseu(struct ctx *ctx, uint64_t slice_mask)
>   
>   static size_t sizeof_load_balance(int count)
>   {
> -	struct i915_context_engines_load_balance *ptr;
> -
> -	return sizeof(*ptr) + count * sizeof(ptr->engines[0]);
> +	return offsetof(struct i915_context_engines_load_balance,
> +			engines[count]);
>   }
>   
>   static size_t sizeof_param_engines(int count)
>   {
> -	struct i915_context_param_engines *ptr;
> -
> -	return sizeof(*ptr) + count * sizeof(ptr->engines[0]);
> +	return offsetof(struct i915_context_param_engines,
> +			engines[count]);
>   }
>   
>   static size_t sizeof_engines_bond(int count)
>   {
> -	struct i915_context_engines_bond *ptr;
> -
> -	return sizeof(*ptr) + count * sizeof(ptr->engines[0]);
> +	return offsetof(struct i915_context_engines_bond,
> +			engines[count]);
>   }
>   
>   #define alloca0(sz) ({ size_t sz__ = (sz); memset(alloca(sz__), 0, sz__); })
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] benchmarks/gem_wsim: Tidy manual sizeof VLA calculations
Date: Mon, 3 Jun 2019 13:53:23 +0100	[thread overview]
Message-ID: <10a079f3-6f97-e414-ff34-5470d405ca87@linux.intel.com> (raw)
In-Reply-To: <20190527094611.31948-1-chris@chris-wilson.co.uk>


On 27/05/2019 10:46, Chris Wilson wrote:
> We can use offsetof for the same effect, much tidier with no dummy
> locals.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   benchmarks/gem_wsim.c | 15 ++++++---------
>   1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/benchmarks/gem_wsim.c b/benchmarks/gem_wsim.c
> index db19925b1..a76fdbfe2 100644
> --- a/benchmarks/gem_wsim.c
> +++ b/benchmarks/gem_wsim.c
> @@ -1443,23 +1443,20 @@ set_ctx_sseu(struct ctx *ctx, uint64_t slice_mask)
>   
>   static size_t sizeof_load_balance(int count)
>   {
> -	struct i915_context_engines_load_balance *ptr;
> -
> -	return sizeof(*ptr) + count * sizeof(ptr->engines[0]);
> +	return offsetof(struct i915_context_engines_load_balance,
> +			engines[count]);
>   }
>   
>   static size_t sizeof_param_engines(int count)
>   {
> -	struct i915_context_param_engines *ptr;
> -
> -	return sizeof(*ptr) + count * sizeof(ptr->engines[0]);
> +	return offsetof(struct i915_context_param_engines,
> +			engines[count]);
>   }
>   
>   static size_t sizeof_engines_bond(int count)
>   {
> -	struct i915_context_engines_bond *ptr;
> -
> -	return sizeof(*ptr) + count * sizeof(ptr->engines[0]);
> +	return offsetof(struct i915_context_engines_bond,
> +			engines[count]);
>   }
>   
>   #define alloca0(sz) ({ size_t sz__ = (sz); memset(alloca(sz__), 0, sz__); })
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-06-03 12:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27  9:46 [igt-dev] [PATCH i-g-t] benchmarks/gem_wsim: Tidy manual sizeof VLA calculations Chris Wilson
2019-05-27  9:46 ` Chris Wilson
2019-05-27 11:33 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-05-27 21:24 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-06-03 12:53 ` Tvrtko Ursulin [this message]
2019-06-03 12:53   ` [igt-dev] [PATCH i-g-t] " Tvrtko Ursulin

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=10a079f3-6f97-e414-ff34-5470d405ca87@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.