1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>i915_gem_shrink</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Linux DRM Developer's Guide"><link rel="up" href="ch04s03.html#idp1128510940" title="Buffer Object Memory Shrinking"><link rel="prev" href="API-i915-gem-evict-everything.html" title="i915_gem_evict_everything"><link rel="next" href="API-i915-gem-shrink-all.html" title="i915_gem_shrink_all"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">i915_gem_shrink</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-i915-gem-evict-everything.html">Prev</a>&#160;</td><th width="60%" align="center">Buffer Object Memory Shrinking</th><td width="20%" align="right">&#160;<a accesskey="n" href="API-i915-gem-shrink-all.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-i915-gem-shrink"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>i915_gem_shrink &#8212; 
2  Shrink buffer object caches
3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">unsigned long <b class="fsfunc">i915_gem_shrink </b>(</code></td><td>struct drm_i915_private * <var class="pdparam">dev_priv</var>, </td></tr><tr><td>&#160;</td><td>long <var class="pdparam">target</var>, </td></tr><tr><td>&#160;</td><td>unsigned <var class="pdparam">flags</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1"><a name="idp1128517676"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>dev_priv</code></em></span></dt><dd><p>
4     i915 device
5    </p></dd><dt><span class="term"><em class="parameter"><code>target</code></em></span></dt><dd><p>
6     amount of memory to make available, in pages
7    </p></dd><dt><span class="term"><em class="parameter"><code>flags</code></em></span></dt><dd><p>
8     control flags for selecting cache types
9    </p></dd></dl></div></div><div class="refsect1"><a name="idp1128521340"></a><h2>Description</h2><p>
10   This function is the main interface to the shrinker. It will try to release
11   up to <em class="parameter"><code>target</code></em> pages of main memory backing storage from buffer objects.
12   Selection of the specific caches can be done with <em class="parameter"><code>flags</code></em>. This is e.g. useful
13   when purgeable objects should be removed from caches preferentially.
14   </p><p>
15
16   Note that it's not guaranteed that released amount is actually available as
17   free system memory - the pages might still be in-used to due to other reasons
18   (like cpu mmaps) or the mm core has reused them before we could grab them.
19   Therefore code that needs to explicitly shrink buffer objects caches (e.g. to
20   avoid deadlocks in memory reclaim) must fall back to <code class="function">i915_gem_shrink_all</code>.
21   </p><p>
22
23   Also note that any kind of pinning (both per-vma address space pins and
24   backing storage pins at the buffer object level) result in the shrinker code
25   having to skip the object.
26</p></div><div class="refsect1"><a name="idp1128524124"></a><h2>Returns</h2><p>
27   The number of pages of backing storage actually released.
28</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-i915-gem-evict-everything.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch04s03.html#idp1128510940">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="API-i915-gem-shrink-all.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">i915_gem_evict_everything</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span class="phrase">i915_gem_shrink_all</span></td></tr></table></div></body></html>
29