* Re: [PATCH v2] fix __set_page_dirty_no_writeback() return value
2010-11-11 3:05 [PATCH v2] fix __set_page_dirty_no_writeback() return value Bob Liu
@ 2010-11-11 3:02 ` Andrew Morton
2010-11-11 3:08 ` Bob Liu
2010-11-11 3:26 ` Wu Fengguang
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2010-11-11 3:02 UTC (permalink / raw)
To: Bob Liu; +Cc: fengguang.wu, linux-mm, kenchen
On Thu, 11 Nov 2010 11:05:54 +0800 Bob Liu <lliubbo@gmail.com> wrote:
> __set_page_dirty_no_writeback() should return true if it actually transitioned
> the page from a clean to dirty state although it seems nobody used its return
> value now.
>
> Change from v1:
> * preserving cacheline optimisation as Andrew pointed out
>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
> mm/page-writeback.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index bf85062..ac7018a 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -1157,8 +1157,10 @@ EXPORT_SYMBOL(write_one_page);
> */
> int __set_page_dirty_no_writeback(struct page *page)
> {
> - if (!PageDirty(page))
> + if (!PageDirty(page)) {
> SetPageDirty(page);
> + return 1;
> + }
> return 0;
> }
But that has a race. If someone else sets PG_Dirty between the test
and the set, this function will incorrectly return 1.
Which is why it should use test_and_set if we're going to do this.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] fix __set_page_dirty_no_writeback() return value
@ 2010-11-11 3:05 Bob Liu
2010-11-11 3:02 ` Andrew Morton
2010-11-11 3:26 ` Wu Fengguang
0 siblings, 2 replies; 7+ messages in thread
From: Bob Liu @ 2010-11-11 3:05 UTC (permalink / raw)
To: akpm; +Cc: fengguang.wu, linux-mm, kenchen, Bob Liu
__set_page_dirty_no_writeback() should return true if it actually transitioned
the page from a clean to dirty state although it seems nobody used its return
value now.
Change from v1:
* preserving cacheline optimisation as Andrew pointed out
Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
mm/page-writeback.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index bf85062..ac7018a 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1157,8 +1157,10 @@ EXPORT_SYMBOL(write_one_page);
*/
int __set_page_dirty_no_writeback(struct page *page)
{
- if (!PageDirty(page))
+ if (!PageDirty(page)) {
SetPageDirty(page);
+ return 1;
+ }
return 0;
}
--
1.6.3.3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fix __set_page_dirty_no_writeback() return value
2010-11-11 3:02 ` Andrew Morton
@ 2010-11-11 3:08 ` Bob Liu
0 siblings, 0 replies; 7+ messages in thread
From: Bob Liu @ 2010-11-11 3:08 UTC (permalink / raw)
To: Andrew Morton; +Cc: fengguang.wu, linux-mm, kenchen
On Thu, Nov 11, 2010 at 11:02 AM, Andrew Morton
<akpm@linux-foundation.org> wrote:
> On Thu, 11 Nov 2010 11:05:54 +0800 Bob Liu <lliubbo@gmail.com> wrote:
>
>> __set_page_dirty_no_writeback() should return true if it actually transitioned
>> the page from a clean to dirty state although it seems nobody used its return
>> value now.
>>
>> Change from v1:
>> * preserving cacheline optimisation as Andrew pointed out
>>
>> Signed-off-by: Bob Liu <lliubbo@gmail.com>
>> ---
>> mm/page-writeback.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
>> index bf85062..ac7018a 100644
>> --- a/mm/page-writeback.c
>> +++ b/mm/page-writeback.c
>> @@ -1157,8 +1157,10 @@ EXPORT_SYMBOL(write_one_page);
>> */
>> int __set_page_dirty_no_writeback(struct page *page)
>> {
>> - if (!PageDirty(page))
>> + if (!PageDirty(page)) {
>> SetPageDirty(page);
>> + return 1;
>> + }
>> return 0;
>> }
>
> But that has a race. If someone else sets PG_Dirty between the test
> and the set, this function will incorrectly return 1.
>
> Which is why it should use test_and_set if we're going to do this.
>
Oh, Sorry for that.
I will make a new patch soon.
--
Thanks,
--Bob
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fix __set_page_dirty_no_writeback() return value
2010-11-11 3:05 [PATCH v2] fix __set_page_dirty_no_writeback() return value Bob Liu
2010-11-11 3:02 ` Andrew Morton
@ 2010-11-11 3:26 ` Wu Fengguang
2010-11-11 3:36 ` Bob Liu
1 sibling, 1 reply; 7+ messages in thread
From: Wu Fengguang @ 2010-11-11 3:26 UTC (permalink / raw)
To: Bob Liu; +Cc: akpm, linux-mm, kenchen
On Thu, Nov 11, 2010 at 11:05:54AM +0800, Bob Liu wrote:
> __set_page_dirty_no_writeback() should return true if it actually transitioned
> the page from a clean to dirty state although it seems nobody used its return
> value now.
>
> Change from v1:
> * preserving cacheline optimisation as Andrew pointed out
>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
> mm/page-writeback.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index bf85062..ac7018a 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -1157,8 +1157,10 @@ EXPORT_SYMBOL(write_one_page);
> */
> int __set_page_dirty_no_writeback(struct page *page)
> {
> - if (!PageDirty(page))
> + if (!PageDirty(page)) {
> SetPageDirty(page);
> + return 1;
> + }
> return 0;
> }
It's still racy if not using TestSetPageDirty(). In fact
set_page_dirty() has a default reference implementation:
if (!PageDirty(page)) {
if (!TestSetPageDirty(page))
return 1;
}
return 0;
It seems the return value currently is only tested for doing
balance_dirty_pages_ratelimited(). So not a big problem.
Thanks,
Fengguang
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fix __set_page_dirty_no_writeback() return value
2010-11-11 3:26 ` Wu Fengguang
@ 2010-11-11 3:36 ` Bob Liu
2010-11-11 3:45 ` Wu Fengguang
0 siblings, 1 reply; 7+ messages in thread
From: Bob Liu @ 2010-11-11 3:36 UTC (permalink / raw)
To: Wu Fengguang; +Cc: akpm, linux-mm, kenchen
On Thu, Nov 11, 2010 at 11:26 AM, Wu Fengguang <fengguang.wu@intel.com> wrote:
> On Thu, Nov 11, 2010 at 11:05:54AM +0800, Bob Liu wrote:
>> __set_page_dirty_no_writeback() should return true if it actually transitioned
>> the page from a clean to dirty state although it seems nobody used its return
>> value now.
>>
>> Change from v1:
>> * preserving cacheline optimisation as Andrew pointed out
>>
>> Signed-off-by: Bob Liu <lliubbo@gmail.com>
>> ---
>> mm/page-writeback.c | 4 +++-
>> 1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
>> index bf85062..ac7018a 100644
>> --- a/mm/page-writeback.c
>> +++ b/mm/page-writeback.c
>> @@ -1157,8 +1157,10 @@ EXPORT_SYMBOL(write_one_page);
>> */
>> int __set_page_dirty_no_writeback(struct page *page)
>> {
>> - if (!PageDirty(page))
>> + if (!PageDirty(page)) {
>> SetPageDirty(page);
>> + return 1;
>> + }
>> return 0;
>> }
>
> It's still racy if not using TestSetPageDirty(). In fact
> set_page_dirty() has a default reference implementation:
Yes, Andrew had also pointed out that. And I have send v3 fix this.
Could you ack it?
>
> if (!PageDirty(page)) {
> if (!TestSetPageDirty(page))
> return 1;
return !TestSetPageDirty(page) is more simply?
> }
> return 0;
>
> It seems the return value currently is only tested for doing
> balance_dirty_pages_ratelimited(). So not a big problem.
>
yeah, all those are small changes no matter with any problem:-).
--
Thanks,
--Bob
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fix __set_page_dirty_no_writeback() return value
2010-11-11 3:36 ` Bob Liu
@ 2010-11-11 3:45 ` Wu Fengguang
2010-11-11 7:17 ` Bob Liu
0 siblings, 1 reply; 7+ messages in thread
From: Wu Fengguang @ 2010-11-11 3:45 UTC (permalink / raw)
To: Bob Liu; +Cc: akpm, linux-mm, kenchen
On Thu, Nov 11, 2010 at 11:36:48AM +0800, Bob Liu wrote:
> On Thu, Nov 11, 2010 at 11:26 AM, Wu Fengguang <fengguang.wu@intel.com> wrote:
> > On Thu, Nov 11, 2010 at 11:05:54AM +0800, Bob Liu wrote:
> >> __set_page_dirty_no_writeback() should return true if it actually transitioned
> >> the page from a clean to dirty state although it seems nobody used its return
> >> value now.
> >>
> >> Change from v1:
> >> A A A * preserving cacheline optimisation as Andrew pointed out
> >>
> >> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> >> ---
> >> A mm/page-writeback.c | A A 4 +++-
> >> A 1 files changed, 3 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> >> index bf85062..ac7018a 100644
> >> --- a/mm/page-writeback.c
> >> +++ b/mm/page-writeback.c
> >> @@ -1157,8 +1157,10 @@ EXPORT_SYMBOL(write_one_page);
> >> A */
> >> A int __set_page_dirty_no_writeback(struct page *page)
> >> A {
> >> - A A if (!PageDirty(page))
> >> + A A if (!PageDirty(page)) {
> >> A A A A A A A SetPageDirty(page);
> >> + A A A A A A return 1;
> >> + A A }
> >> A A A return 0;
> >> A }
> >
> > It's still racy if not using TestSetPageDirty(). In fact
> > set_page_dirty() has a default reference implementation:
>
> Yes, Andrew had also pointed out that. And I have send v3 fix this.
> Could you ack it?
Acked-by: Wu Fengguang <fengguang.wu@intel.com>
Thanks!
> >
> > A A A A if (!PageDirty(page)) {
> > A A A A A A A A if (!TestSetPageDirty(page))
> > A A A A A A A A A A A A return 1;
>
> return !TestSetPageDirty(page) is more simply?
Yeah that's fine.
> > A A A A }
> > A A A A return 0;
> >
> > It seems the return value currently is only tested for doing
> > balance_dirty_pages_ratelimited(). So not a big problem.
> >
>
> yeah, all those are small changes no matter with any problem:-).
It's always good to make it correct :) I looked at the users mainly to
answer the question: is it a must fix for 2.6.37 or even 2.6.36.x?
Thanks,
Fengguang
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fix __set_page_dirty_no_writeback() return value
2010-11-11 3:45 ` Wu Fengguang
@ 2010-11-11 7:17 ` Bob Liu
0 siblings, 0 replies; 7+ messages in thread
From: Bob Liu @ 2010-11-11 7:17 UTC (permalink / raw)
To: Wu Fengguang; +Cc: akpm, linux-mm, kenchen
On Thu, Nov 11, 2010 at 11:45 AM, Wu Fengguang <fengguang.wu@intel.com> wrote:
> On Thu, Nov 11, 2010 at 11:36:48AM +0800, Bob Liu wrote:
>> On Thu, Nov 11, 2010 at 11:26 AM, Wu Fengguang <fengguang.wu@intel.com> wrote:
>> > On Thu, Nov 11, 2010 at 11:05:54AM +0800, Bob Liu wrote:
>> >> __set_page_dirty_no_writeback() should return true if it actually transitioned
>> >> the page from a clean to dirty state although it seems nobody used its return
>> >> value now.
>> >>
>> >> Change from v1:
>> >> * preserving cacheline optimisation as Andrew pointed out
>> >>
>> >> Signed-off-by: Bob Liu <lliubbo@gmail.com>
>> >> ---
>> >> mm/page-writeback.c | 4 +++-
>> >> 1 files changed, 3 insertions(+), 1 deletions(-)
>> >>
>> >> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
>> >> index bf85062..ac7018a 100644
>> >> --- a/mm/page-writeback.c
>> >> +++ b/mm/page-writeback.c
>> >> @@ -1157,8 +1157,10 @@ EXPORT_SYMBOL(write_one_page);
>> >> */
>> >> int __set_page_dirty_no_writeback(struct page *page)
>> >> {
>> >> - if (!PageDirty(page))
>> >> + if (!PageDirty(page)) {
>> >> SetPageDirty(page);
>> >> + return 1;
>> >> + }
>> >> return 0;
>> >> }
>> >
>> > It's still racy if not using TestSetPageDirty(). In fact
>> > set_page_dirty() has a default reference implementation:
>>
>> Yes, Andrew had also pointed out that. And I have send v3 fix this.
>> Could you ack it?
>
> Acked-by: Wu Fengguang <fengguang.wu@intel.com>
>
Thanks.
> Thanks!
>
>> >
>> > if (!PageDirty(page)) {
>> > if (!TestSetPageDirty(page))
>> > return 1;
>>
>> return !TestSetPageDirty(page) is more simply?
>
> Yeah that's fine.
>
>> > }
>> > return 0;
>> >
>> > It seems the return value currently is only tested for doing
>> > balance_dirty_pages_ratelimited(). So not a big problem.
>> >
>>
>> yeah, all those are small changes no matter with any problem:-).
>
> It's always good to make it correct :) I looked at the users mainly to
> answer the question: is it a must fix for 2.6.37 or even 2.6.36.x?
>
I have no idea, I think either is okay since it's not related with any bug.
--
Thanks,
--Bob
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-11-11 7:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-11 3:05 [PATCH v2] fix __set_page_dirty_no_writeback() return value Bob Liu
2010-11-11 3:02 ` Andrew Morton
2010-11-11 3:08 ` Bob Liu
2010-11-11 3:26 ` Wu Fengguang
2010-11-11 3:36 ` Bob Liu
2010-11-11 3:45 ` Wu Fengguang
2010-11-11 7:17 ` Bob Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox