yes, flush page twice cause system slow in some CPU.<br>Meanwhile, set_memory_uc/wc doesn&#39;t only do flush page cache, but also change page table attribute, so your solution seems to have some problem.<br><br><div class="gmail_quote">
2012/3/20 Konrad Rzeszutek Wilk <span dir="ltr">&lt;<a href="mailto:konrad.wilk@oracle.com">konrad.wilk@oracle.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, Mar 20, 2012 at 10:15:02AM +0800, Scott Fang wrote:<br>
&gt; Can I do the optimization like:<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; +        for (i = 0; i &lt; ttm-&gt;num_pages; ++i)<br>
&gt; +           if (PageHighMem(ttm-&gt;pages[i]))<br>
&gt; +                drm_clflush_pages(&amp;ttm-&gt;pages[i], 1);<br>
&gt;<br>
&gt; only do flush cache when high memory and leave the linear memory flush in<br>
&gt; function set_memory_uc/wc?<br>
<br>
</div>So what are you trying to solve? I mean one way to fix this<br>
is to do:<br>
<div class="im">&gt;<br>
&gt; 2012/3/20 Jerome Glisse &lt;<a href="mailto:j.glisse@gmail.com">j.glisse@gmail.com</a>&gt;<br>
&gt;<br>
&gt; &gt; On Mon, 2012-03-19 at 23:11 +0800, Scott Fang wrote:<br>
&gt; &gt; &gt; In function ttm_tt_set_caching<br>
&gt; &gt; &gt; ,,,,,,,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     if (ttm-&gt;caching_state == tt_cached)<br>
&gt; &gt; &gt;         drm_clflush_pages(ttm-&gt;pages, ttm-&gt;num_pages);<br>
</div>              goto out;<br>
<div class="im">&gt; &gt; &gt;<br>
&gt; &gt; &gt;     for (i = 0; i &lt; ttm-&gt;num_pages; ++i) {<br>
&gt; &gt; &gt;         cur_page = ttm-&gt;pages[i];<br>
&gt; &gt; &gt;         if (likely(cur_page != NULL)) {<br>
&gt; &gt; &gt;             ret = ttm_tt_set_page_caching(cur_page,<br>
&gt; &gt; &gt;                               ttm-&gt;caching_state,<br>
&gt; &gt; &gt;                               c_state);<br>
&gt; &gt; &gt;             if (unlikely(ret != 0))<br>
&gt; &gt; &gt;                 goto out_err;<br>
&gt; &gt; &gt;         }<br>
&gt; &gt; &gt;     }<br>
&gt; &gt;<br>
</div>out:<br>
<div class="im">&gt; &gt; &gt;     ttm-&gt;caching_state = c_state;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;     return 0;<br>
<br>
</div>Is the problem with calling page change twice making the machine slow?<br>
</blockquote></div><br>