Why do flush page cache twice when change TT's cache attribute

Scott Fang donnie.fang at gmail.com
Mon Mar 19 19:15:02 PDT 2012


Can I do the optimization like:

    if (ttm->caching_state == tt_cached)
 -        drm_clflush_pages(ttm->pages, ttm->num_pages);
+        for (i = 0; i < ttm->num_pages; ++i)
+           if (PageHighMem(ttm->pages[i]))
+                drm_clflush_pages(&ttm->pages[i], 1);

only do flush cache when high memory and leave the linear memory flush in
function set_memory_uc/wc?

2012/3/20 Jerome Glisse <j.glisse at gmail.com>

> On Mon, 2012-03-19 at 23:11 +0800, Scott Fang wrote:
> > In function ttm_tt_set_caching
> > ,,,,,,,
> >
> >     if (ttm->caching_state == tt_cached)
> >         drm_clflush_pages(ttm->pages, ttm->num_pages);
> >
> >     for (i = 0; i < ttm->num_pages; ++i) {
> >         cur_page = ttm->pages[i];
> >         if (likely(cur_page != NULL)) {
> >             ret = ttm_tt_set_page_caching(cur_page,
> >                               ttm->caching_state,
> >                               c_state);
> >             if (unlikely(ret != 0))
> >                 goto out_err;
> >         }
> >     }
> >
> >     ttm->caching_state = c_state;
> >
> >     return 0;
> >
> >
> > drm_clflush_pages flush cache one time.
> > then in the following function
> > ttm_tt_set_page_caching->set_memory_wc->change_page_attr_set: in this
> > function may flush page cache again.
> >
> > Does the code do some abundant flush, or there is some trick to these
> > codes?
> >
> > Thanks for the answer in advance.
>
> Yes there might be redundant flushing.
>
> Cheers,
> Jerome
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20120320/69ebebc5/attachment.html>


More information about the dri-devel mailing list