From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
Michal Hocko <mhocko@suse.com>,
Matthew Auld <matthew.auld@intel.com>
Subject: Re: [PATCH v2 5/5] drm/i915: Start writeback from the shrinker
Date: Tue, 13 Jun 2017 17:07:04 +0300 [thread overview]
Message-ID: <1497362824.5158.5.camel@linux.intel.com> (raw)
In-Reply-To: <20170609110350.1767-5-chris@chris-wilson.co.uk>
On pe, 2017-06-09 at 12:03 +0100, Chris Wilson wrote:
> When we are called to relieve mempressue via the shrinker, the only way
> we can make progress is either by discarding unwanted pages (those
> objects that userspace has marked MADV_DONTNEED) or by reclaiming the
> dirty objects via swap. As we know that is the only way to make further
> progress, we can initiate the writeback as we invalidate the objects.
> This means the objects we put onto the inactive anon lru list are
> already marked for reclaim+writeback and so will trigger a wait upon the
> writeback inside direct reclaim, greatly improving the success rate of
> direct reclaim on i915 objects.
>
> The corollary is that we may start a slow swap on opportunistic
> mempressure from the likes of the compaction + migration kthreads. This
> is limited by those threads only being allowed to shrink idle pages, but
> also that if we reactivate the page before it is swapped out by gpu
> activity, we only page the cost of repinning the page. The cost is most
> felt when an object is reused after mempressure, which hopefully
> excludes the latency sensitive tasks (as we are just extending the
> impact of swap thrashing to them).
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Michal Hocko <mhocko@suse.com>
<SNIP>
> +static void __start_writeback(struct drm_i915_gem_object *obj)
> +{
<SNIP>
> + /* Force any other users of this object to refault */
> + mapping = obj->base.filp->f_mapping;
> + unmap_mapping_range(mapping, 0, (loff_t)-1, 0);
> +
> + /* Begin writeback on each dirty page */
> + for (i = 0; i < obj->base.size >> PAGE_SHIFT; i++) {
> + struct page *page;
> +
> + page = find_lock_entry(mapping, i);
> + if (!page || radix_tree_exceptional_entry(page))
> + continue;
> +
> + if (!page_mapped(page) && clear_page_dirty_for_io(page)) {
> + int ret;
> +
> + SetPageReclaim(page);
> + ret = mapping->a_ops->writepage(page, &wbc);
> + if (!PageWriteback(page))
> + ClearPageReclaim(page);
> + if (!ret)
> + goto put;
> + }
> + unlock_page(page);
> +put:
> + put_page(page);
> + }
Apart from this part (which should probably be a helper function
outside of i915), the code is:
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-06-13 14:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-09 11:03 [PATCH v2 1/5] drm/i915: Encourage our shrinker more when our shmemfs allocations fails Chris Wilson
2017-06-09 11:03 ` [PATCH v2 2/5] drm/i915: Remove __GFP_NORETRY from our buffer allocator Chris Wilson
2017-06-09 11:07 ` Michal Hocko
2017-06-13 14:01 ` Joonas Lahtinen
2017-06-09 11:03 ` [PATCH v2 3/5] drm/i915: Only restrict noreclaim in the early shrink passes Chris Wilson
2017-06-13 14:02 ` Joonas Lahtinen
2017-06-09 11:03 ` [PATCH v2 4/5] drm/i915: Spin for struct_mutex inside shrinker Chris Wilson
2017-06-13 13:59 ` Joonas Lahtinen
2017-06-09 11:03 ` [PATCH v2 5/5] drm/i915: Start writeback from the shrinker Chris Wilson
2017-06-09 11:17 ` Michal Hocko
2017-06-09 11:51 ` Chris Wilson
2017-06-09 13:35 ` Michal Hocko
2017-06-13 14:07 ` Joonas Lahtinen [this message]
2017-06-14 10:03 ` Chris Wilson
2017-06-09 11:31 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/5] drm/i915: Encourage our shrinker more when our shmemfs allocations fails 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=1497362824.5158.5.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=mhocko@suse.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