All of lore.kernel.org
 help / color / mirror / Atom feed
* Why do flush page cache twice when change TT's cache attribute
@ 2012-03-19 15:11 Scott Fang
  2012-03-19 15:13 ` Scott Fang
  2012-03-19 17:22 ` Jerome Glisse
  0 siblings, 2 replies; 6+ messages in thread
From: Scott Fang @ 2012-03-19 15:11 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 821 bytes --]

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.

[-- Attachment #1.2: Type: text/html, Size: 1567 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why do flush page cache twice when change TT's cache attribute
  2012-03-19 15:11 Why do flush page cache twice when change TT's cache attribute Scott Fang
@ 2012-03-19 15:13 ` Scott Fang
  2012-03-19 17:22 ` Jerome Glisse
  1 sibling, 0 replies; 6+ messages in thread
From: Scott Fang @ 2012-03-19 15:13 UTC (permalink / raw)
  To: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 955 bytes --]

typo error. abundant=>redundant

2012/3/19 Scott Fang <donnie.fang@gmail.com>

> 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 redundant flush, or there is some trick to these
> codes?
>
> Thanks for the answer in advance.
>

[-- Attachment #1.2: Type: text/html, Size: 1934 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why do flush page cache twice when change TT's cache attribute
  2012-03-19 15:11 Why do flush page cache twice when change TT's cache attribute Scott Fang
  2012-03-19 15:13 ` Scott Fang
@ 2012-03-19 17:22 ` Jerome Glisse
  2012-03-20  2:15   ` Scott Fang
  1 sibling, 1 reply; 6+ messages in thread
From: Jerome Glisse @ 2012-03-19 17:22 UTC (permalink / raw)
  To: Scott Fang; +Cc: dri-devel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why do flush page cache twice when change TT's cache attribute
  2012-03-19 17:22 ` Jerome Glisse
@ 2012-03-20  2:15   ` Scott Fang
  2012-03-20 15:33     ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Fang @ 2012-03-20  2:15 UTC (permalink / raw)
  To: Jerome Glisse; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1485 bytes --]

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@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
>
>

[-- Attachment #1.2: Type: text/html, Size: 2079 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why do flush page cache twice when change TT's cache attribute
  2012-03-20  2:15   ` Scott Fang
@ 2012-03-20 15:33     ` Konrad Rzeszutek Wilk
  2012-03-21  1:37       ` Scott Fang
  0 siblings, 1 reply; 6+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-03-20 15:33 UTC (permalink / raw)
  To: Scott Fang; +Cc: dri-devel

On Tue, Mar 20, 2012 at 10:15:02AM +0800, Scott Fang wrote:
> 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?

So what are you trying to solve? I mean one way to fix this
is to do:
> 
> 2012/3/20 Jerome Glisse <j.glisse@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);
              goto out;
> > >
> > >     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;
> > >         }
> > >     }
> > 
out:
> > >     ttm->caching_state = c_state;
> > >
> > >     return 0;

Is the problem with calling page change twice making the machine slow?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why do flush page cache twice when change TT's cache attribute
  2012-03-20 15:33     ` Konrad Rzeszutek Wilk
@ 2012-03-21  1:37       ` Scott Fang
  0 siblings, 0 replies; 6+ messages in thread
From: Scott Fang @ 2012-03-21  1:37 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 1719 bytes --]

yes, flush page twice cause system slow in some CPU.
Meanwhile, set_memory_uc/wc doesn't only do flush page cache, but also
change page table attribute, so your solution seems to have some problem.

2012/3/20 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

> On Tue, Mar 20, 2012 at 10:15:02AM +0800, Scott Fang wrote:
> > 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?
>
> So what are you trying to solve? I mean one way to fix this
> is to do:
> >
> > 2012/3/20 Jerome Glisse <j.glisse@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);
>               goto out;
> > > >
> > > >     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;
> > > >         }
> > > >     }
> > >
> out:
> > > >     ttm->caching_state = c_state;
> > > >
> > > >     return 0;
>
> Is the problem with calling page change twice making the machine slow?
>

[-- Attachment #1.2: Type: text/html, Size: 2494 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-03-21  1:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-19 15:11 Why do flush page cache twice when change TT's cache attribute Scott Fang
2012-03-19 15:13 ` Scott Fang
2012-03-19 17:22 ` Jerome Glisse
2012-03-20  2:15   ` Scott Fang
2012-03-20 15:33     ` Konrad Rzeszutek Wilk
2012-03-21  1:37       ` Scott Fang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.