From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/i915: Allow optimized platform checks
Date: Mon, 25 Sep 2017 09:22:33 +0100 [thread overview]
Message-ID: <cc36255f-c990-73b1-ffb0-794d36849846@linux.intel.com> (raw)
In-Reply-To: <e0b36937-d399-4ccb-75ac-9ddd5e8c9c69@linux.intel.com>
On 20/09/2017 10:56, Tvrtko Ursulin wrote:
> On 20/09/2017 10:39, Jani Nikula wrote:
>> On Wed, 20 Sep 2017, Tvrtko Ursulin <tursulin@ursulin.net> wrote:
>>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>>
>>> If we store the platform as a bitmask, and convert the
>>> IS_PLATFORM macro to use it, we allow the compiler to
>>> merge the IS_PLATFORM(a) || IS_PLATFORM(b) || ... checks
>>> into a single conditional.
>>>
>>> Even with the added BUG_ON this saves almost 1k of text:
>>>
>>> text data bss dec hex filename
>>> -1460254 60014 3656 1523924 1740d4
>>> drivers/gpu/drm/i915/i915.ko
>>> +1459260 60026 3656 1522942 173cfe
>>> drivers/gpu/drm/i915/i915.ko
>>>
>>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>> Cc: Jani Nikula <jani.nikula@intel.com>
>>> ---
>>> drivers/gpu/drm/i915/i915_drv.c | 6 ++++++
>>> drivers/gpu/drm/i915/i915_drv.h | 3 ++-
>>> 2 files changed, 8 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_drv.c
>>> b/drivers/gpu/drm/i915/i915_drv.c
>>> index b1f96eb1be16..c3bd4b7cb19b 100644
>>> --- a/drivers/gpu/drm/i915/i915_drv.c
>>> +++ b/drivers/gpu/drm/i915/i915_drv.c
>>> @@ -869,6 +869,12 @@ static int i915_driver_init_early(struct
>>> drm_i915_private *dev_priv,
>>> memcpy(device_info, match_info, sizeof(*device_info));
>>> device_info->device_id = dev_priv->drm.pdev->device;
>>> + BUILD_BUG_ON(sizeof(device_info->platform_mask) * BITS_PER_BYTE <
>>> + (INTEL_MAX_PLATFORMS - 1));
>>> + BUG_ON(device_info->platform == 0 >>> + device_info->platform >= INTEL_MAX_PLATFORMS);
>>> + device_info->platform_mask = BIT(device_info->platform - 1);
>>
>> Please just lose the -1, pretty please?
>>
>>> +
>>> BUG_ON(device_info->gen > sizeof(device_info->gen_mask) *
>>> BITS_PER_BYTE);
>>> device_info->gen_mask = BIT(device_info->gen - 1);
>>> diff --git a/drivers/gpu/drm/i915/i915_drv.h
>>> b/drivers/gpu/drm/i915/i915_drv.h
>>> index 950aa109f8cb..81211f23326a 100644
>>> --- a/drivers/gpu/drm/i915/i915_drv.h
>>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>>> @@ -861,6 +861,7 @@ struct intel_device_info {
>>> u8 ring_mask; /* Rings supported by the HW */
>>> enum intel_platform platform;
>>> + u32 platform_mask;
>>> u32 display_mmio_offset;
>>> @@ -2984,7 +2985,7 @@ intel_info(const struct drm_i915_private
>>> *dev_priv)
>>> #define IS_REVID(p, since, until) \
>>> (INTEL_REVID(p) >= (since) && INTEL_REVID(p) <= (until))
>>> -#define IS_PLATFORM(dev_priv, p) ((dev_priv)->info.platform == (p))
>>> +#define IS_PLATFORM(dev_priv, p) ((dev_priv)->info.platform_mask &
>>> BIT((p) - 1))
>>
>> What would the result be without platform_mask and just:
>>
>> #define IS_PLATFORM(dev_priv, p) (BIT((dev_priv)->info.platform) &
>> BIT(p))
>
> More code I'm afraid. But the problem of 32 platforms limit makes it
> problematic for me. Because I checked, and going to u64 for the
> platform_mask grows the code 100-200 bytes over the starting point. We'd
> keep the single conditional advantage but I don't know, feels like not
> worth it in that case. It could only last for a couple years before we
> would need to go to u64.
On the other hand we could take this, and by the time would need to
grown the mask field, we can a) enjoy the size saving, b) by that time
new platform code will dwarf the 100-200 bytes going to u64 will add,
and c) 100-200 bytes might even turn to a gain again, since new or-ed
IS_platform checks will appear. Thoughts?
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-09-25 8:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 9:26 [PATCH 0/3] Claw back optimised IS_PLATFORM checks Tvrtko Ursulin
2017-09-20 9:26 ` [PATCH 1/3] drm/i915: Add IS_PLATFORM macro Tvrtko Ursulin
2017-09-20 9:34 ` Jani Nikula
2017-09-20 9:27 ` [PATCH 2/3] drm/i915: Compact device info access by a small re-ordering Tvrtko Ursulin
2017-09-20 9:34 ` Jani Nikula
2017-09-20 9:27 ` [PATCH 3/3] drm/i915: Allow optimized platform checks Tvrtko Ursulin
2017-09-20 9:39 ` Jani Nikula
2017-09-20 9:56 ` Tvrtko Ursulin
2017-09-25 8:22 ` Tvrtko Ursulin [this message]
2017-09-20 9:39 ` Tvrtko Ursulin
2017-09-20 9:48 ` ✓ Fi.CI.BAT: success for Claw back optimised IS_PLATFORM checks Patchwork
2017-09-20 10:52 ` ✗ Fi.CI.IGT: failure " Patchwork
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=cc36255f-c990-73b1-ffb0-794d36849846@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=tursulin@ursulin.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