Can I do the optimization like:<br><br>    if (ttm-&gt;caching_state == tt_cached)<br> -        drm_clflush_pages(ttm-&gt;pages, ttm-&gt;num_pages);<br>+        for (i = 0; i &lt; ttm-&gt;num_pages; ++i) <br>+           if (PageHighMem(ttm-&gt;pages[i]))<br>
+                drm_clflush_pages(&amp;ttm-&gt;pages[i], 1);<br><br>only do flush cache when high memory and leave the linear memory flush in function set_memory_uc/wc?<br><br><div class="gmail_quote">2012/3/20 Jerome Glisse <span dir="ltr">&lt;<a href="mailto:j.glisse@gmail.com">j.glisse@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">On Mon, 2012-03-19 at 23:11 +0800, Scott Fang wrote:<br>
&gt; In function ttm_tt_set_caching<br>
&gt; ,,,,,,,<br>
&gt;<br>
&gt;     if (ttm-&gt;caching_state == tt_cached)<br>
&gt;         drm_clflush_pages(ttm-&gt;pages, ttm-&gt;num_pages);<br>
&gt;<br>
&gt;     for (i = 0; i &lt; ttm-&gt;num_pages; ++i) {<br>
&gt;         cur_page = ttm-&gt;pages[i];<br>
&gt;         if (likely(cur_page != NULL)) {<br>
&gt;             ret = ttm_tt_set_page_caching(cur_page,<br>
&gt;                               ttm-&gt;caching_state,<br>
&gt;                               c_state);<br>
&gt;             if (unlikely(ret != 0))<br>
&gt;                 goto out_err;<br>
&gt;         }<br>
&gt;     }<br>
&gt;<br>
&gt;     ttm-&gt;caching_state = c_state;<br>
&gt;<br>
&gt;     return 0;<br>
&gt;<br>
&gt;<br>
&gt; drm_clflush_pages flush cache one time.<br>
&gt; then in the following function<br>
&gt; ttm_tt_set_page_caching-&gt;set_memory_wc-&gt;change_page_attr_set: in this<br>
&gt; function may flush page cache again.<br>
&gt;<br>
&gt; Does the code do some abundant flush, or there is some trick to these<br>
&gt; codes?<br>
&gt;<br>
&gt; Thanks for the answer in advance.<br>
<br>
</div></div>Yes there might be redundant flushing.<br>
<br>
Cheers,<br>
<font color="#888888">Jerome<br>
<br>
</font></blockquote></div><br>