public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Michael H. Nguyen" <michael.h.nguyen@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v5 0/7] Command parser batch buffer copy
Date: Tue, 02 Dec 2014 13:57:32 -0800	[thread overview]
Message-ID: <547E35CC.90900@intel.com> (raw)
In-Reply-To: <20141202111348.GE18921@nuc-i3427.alporthouse.com>



On 12/02/2014 03:13 AM, Chris Wilson wrote:
> On Mon, Dec 01, 2014 at 02:39:51PM -0800, Michael H. Nguyen wrote:
>> Re: madvise on creation
>>
>> Were you referring to this?
>>
>> from http://lists.freedesktop.org/archives/intel-gfx/2014-November/055060.htm
>>
>> 	obj = i915_gem_obj_alloc();
>> 	i915_gem_object_get_pages(obj);
>> 	obj->madv = I915_MADV_DONTNEED;
>>
>> If so, I don't understand . _get is returning obj and it'll be
>> needed so would expect to set 'obj->madv = I915_MADV_WILLNEED' which
>> is the case now.
> 
> madv is only evaluated at get_pages(). Once you have the pages, you keep
> them until the shrinker purges them. Hence you only need to call
> get_pages() once and set obj->madv = DONTNEED afterwards, and then you
> only need to check whether the obj is purged before your next reuse (you
> do not need to touch madv ever again). Whilst the object is active it is
> a low priority target for the shrinker. That greatly simplifies the pool
> code.

I have a feeling this may make the driver less readable imo and could also require a re-write of the series. The current code may call get_pages() more than once and occurs outside of the batch_pool management fncs. Would have to re-write things to stop that.

i915_parse_cmds()
  copy_batch()
    i915_gem_obj_prepare_shmem_read()
      i915_gem_object_get_pages()

After removing the fancy retry loop suggested by Daniel and moving to a single cache list, the implementation looks very simple imo. And, setting 'obj->madv = I915_MADV_WILLNEED;' looks right. Readability wise, you don't have to investigate further to understand the justification for that statement. Here is an RFC snippet...

i915_gem_batch_pool_get(struct i915_gem_batch_pool *pool,    
                        size_t size)
{  
        struct drm_i915_gem_object *obj = NULL;
        struct drm_i915_gem_object *tmp, *next;
   
        WARN_ON(!mutex_is_locked(&pool->dev->struct_mutex));
   
        list_for_each_entry_safe(tmp, next,
                        &pool->cache_list, batch_pool_list) {
   
                if (tmp->active)
                        continue;
          
                if (tmp->madv == __I915_MADV_PURGED) {                      
                        list_del(&tmp->batch_pool_list);                    
                        drm_gem_object_unreference(&tmp->base);             
                        continue;
                }
   
                if (tmp->base.size >= size &&
                    tmp->base.size <= (2 * size)) {
                        obj = tmp;
                        break;
                }
        }

        if (!obj) {
                obj = i915_gem_alloc_object(pool->dev, size);
                if (!obj)
                        return ERR_PTR(-ENOMEM);

                list_add_tail(&obj->batch_pool_list, &pool->cache_list);
        }

        obj->madv = I915_MADV_WILLNEED;

        return obj;
}

Given the spirit of your feedback was to simplify pool_get(), does this RFC do it for you? If not, I kindly request we have a sync up meeting to discuss your 'obj->madv = DONTNEED' suggestion.

Thank you much,
-Mike

> -Chris
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2014-12-02 21:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26 21:53 [PATCH v5 0/7] Command parser batch buffer copy michael.h.nguyen
2014-11-26 21:53 ` [PATCH v5 1/7] drm/i915: Implement a framework for batch buffer pools michael.h.nguyen
2014-12-08 15:19   ` Bloomfield, Jon
2014-12-08 18:29     ` Michael H. Nguyen
2014-11-26 21:53 ` [PATCH v5 2/7] drm/i915: Use batch pools with the command parser michael.h.nguyen
2014-11-26 21:53 ` [PATCH v5 3/7] drm/i915: Add a batch pool debugfs file michael.h.nguyen
2014-11-26 21:53 ` [PATCH v5 4/7] drm/i915: Add batch pool details to i915_gem_objects debugfs michael.h.nguyen
2014-11-26 21:53 ` [PATCH v5 5/7] drm/i915: Use batch length instead of object size in command parser michael.h.nguyen
2014-11-26 21:53 ` [PATCH v5 6/7] drm/i915: Mark shadow batch buffers as purgeable michael.h.nguyen
2014-11-26 21:53 ` [PATCH v5 7/7] drm/i915: Tidy up execbuffer command parsing code michael.h.nguyen
2014-11-27  7:44 ` [PATCH v5 0/7] Command parser batch buffer copy Chris Wilson
2014-12-01 22:39   ` Michael H. Nguyen
2014-12-02  9:45     ` Daniel Vetter
2014-12-02 19:10       ` Michael H. Nguyen
2014-12-03  9:14         ` Daniel Vetter
2014-12-02 11:13     ` Chris Wilson
2014-12-02 12:57       ` Daniel Vetter
2014-12-02 21:57       ` Michael H. Nguyen [this message]
2014-12-03  9:17         ` Daniel Vetter
2014-12-03  9:31           ` Chris Wilson
2014-12-03 14:12             ` Daniel Vetter

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=547E35CC.90900@intel.com \
    --to=michael.h.nguyen@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox