From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: "Chris Wilson" <chris@chris-wilson.co.uk>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>
Subject: Re: [PATCH 5/6] drm,i915: Introduce drm_malloc_gfp()
Date: Wed, 6 Apr 2016 10:40:19 +0100 [thread overview]
Message-ID: <5704D983.8070804@linux.intel.com> (raw)
In-Reply-To: <20160405130524.GB28265@nuc-i3427.alporthouse.com>
On 05/04/16 14:05, Chris Wilson wrote:
> On Tue, Apr 05, 2016 at 01:57:36PM +0100, Chris Wilson wrote:
>> I have instances where I want to use drm_malloc_ab() but with a custom
>> gfp mask. And with those, where I want a temporary allocation, I want to
>> try a high-order kmalloc() before using a vmalloc().
>>
>> So refactor my usage into drm_malloc_gfp().
>>
>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: dri-devel@lists.freedesktop.org
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Acked-by: Dave Airlie <airlied@redhat.com>
>
>> +static __inline__ void *drm_malloc_gfp(size_t nmemb, size_t size, gfp_t gfp)
>> +{
>> + if (size != 0 && nmemb > SIZE_MAX / size)
>> + return NULL;
>
> I know Dave G. has some fancy code to detect when the size parameter is
> not constant, but one thing I noticed was that gcc would uninline this
> function and we would lose the constant folding. Is there anything we
> can do to convince gcc to avoid a div here (other than pure macro)?
Don't know, apart from maybe _always_inline if it is not considered too big.
But I wanted to ask, why it is interesting to allow size == 0 ? Why not:
if (size == 0 || nmemb > SIZE_MAX / size)
return NULL;
?
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:[~2016-04-06 9:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 12:57 vmap consolidation Chris Wilson
2016-04-05 12:57 ` [PATCH 1/6] drm/i915/dmabuf: Tighten struct_mutex for unmap_dma_buf Chris Wilson
2016-04-06 8:57 ` Tvrtko Ursulin
2016-04-05 12:57 ` [PATCH 2/6] drm/i915: Consolidate common error handling in intel_pin_and_map_ringbuffer_obj Chris Wilson
2016-04-06 9:02 ` Tvrtko Ursulin
2016-04-05 12:57 ` [PATCH 3/6] drm/i915: Refactor duplicate object vmap functions Chris Wilson
2016-04-06 9:30 ` Tvrtko Ursulin
2016-04-06 9:58 ` Chris Wilson
2016-04-05 12:57 ` [PATCH 4/6] drm/i915/shrinker: Restrict vmap purge to objects with vmaps Chris Wilson
2016-04-05 12:57 ` [PATCH 5/6] drm,i915: Introduce drm_malloc_gfp() Chris Wilson
2016-04-05 13:05 ` Chris Wilson
2016-04-06 9:40 ` Tvrtko Ursulin [this message]
2016-04-06 9:47 ` Chris Wilson
2016-04-05 12:57 ` [PATCH 6/6] drm/i915: Avoid allocating a vmap arena for a single page Chris Wilson
2016-04-05 13:01 ` Chris Wilson
2016-04-05 13:14 ` Matthew Auld
2016-04-06 9:49 ` Tvrtko Ursulin
2016-04-06 10:05 ` Chris Wilson
2016-04-06 11:36 ` Tvrtko Ursulin
2016-04-06 13:52 ` Dave Gordon
2016-04-05 15:57 ` ✗ Fi.CI.BAT: failure for series starting with [1/6] drm/i915/dmabuf: Tighten struct_mutex for unmap_dma_buf 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=5704D983.8070804@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=ville.syrjala@linux.intel.com \
/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