* Re: [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit [not found] <1345283361-7802-1-git-send-email-linkinjeon@gmail.com> @ 2012-08-19 2:17 ` Fengguang Wu 2012-08-19 10:23 ` Marco Stornelli 2012-08-20 0:09 ` Namjae Jeon 0 siblings, 2 replies; 5+ messages in thread From: Fengguang Wu @ 2012-08-19 2:17 UTC (permalink / raw) To: Namjae Jeon; +Cc: akpm, linux-kernel, linux-fsdevel On Sat, Aug 18, 2012 at 05:49:21AM -0400, Namjae Jeon wrote: > unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty) > > Above function return type is unsigned long, but return value is > kept in "u64 bdi_dirty". > It can return incorrect value by type casting. I don't see how the cast can return wrong value. The u64 is necessary for the intermediate calculations. Thanks, Fengguang > Signed-off-by: Namjae Jeon <linkinjeon@gmail.com> > --- > mm/page-writeback.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index 49133b6..73a7a06 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -546,7 +546,7 @@ static unsigned long hard_dirty_limit(unsigned long thresh) > */ > unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty) > { > - u64 bdi_dirty; > + unsigned long bdi_dirty; > long numerator, denominator; > > /* > -- > 1.7.9.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit 2012-08-19 2:17 ` [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit Fengguang Wu @ 2012-08-19 10:23 ` Marco Stornelli 2012-08-19 10:35 ` Marco Stornelli 2012-08-19 23:49 ` Namjae Jeon 2012-08-20 0:09 ` Namjae Jeon 1 sibling, 2 replies; 5+ messages in thread From: Marco Stornelli @ 2012-08-19 10:23 UTC (permalink / raw) To: Fengguang Wu; +Cc: Namjae Jeon, akpm, linux-kernel, linux-fsdevel Il 19/08/2012 04:17, Fengguang Wu ha scritto: > On Sat, Aug 18, 2012 at 05:49:21AM -0400, Namjae Jeon wrote: >> unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty) >> >> Above function return type is unsigned long, but return value is >> kept in "u64 bdi_dirty". >> It can return incorrect value by type casting. > > I don't see how the cast can return wrong value. > The u64 is necessary for the intermediate calculations. > > Thanks, > Fengguang > We are sure u64 is 8byte long, but unsigned long is 4byte long on 32-bit machine, so if bdi_dirty can assume values bigger than 2^32 there is an implicit truncate of its value, isn't it? Marco ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit 2012-08-19 10:23 ` Marco Stornelli @ 2012-08-19 10:35 ` Marco Stornelli 2012-08-19 23:49 ` Namjae Jeon 1 sibling, 0 replies; 5+ messages in thread From: Marco Stornelli @ 2012-08-19 10:35 UTC (permalink / raw) To: Fengguang Wu; +Cc: Namjae Jeon, akpm, linux-kernel, linux-fsdevel Il 19/08/2012 12:23, Marco Stornelli ha scritto: > Il 19/08/2012 04:17, Fengguang Wu ha scritto: >> On Sat, Aug 18, 2012 at 05:49:21AM -0400, Namjae Jeon wrote: >>> unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned >>> long dirty) >>> >>> Above function return type is unsigned long, but return value is >>> kept in "u64 bdi_dirty". >>> It can return incorrect value by type casting. >> >> I don't see how the cast can return wrong value. >> The u64 is necessary for the intermediate calculations. >> >> Thanks, >> Fengguang >> > > We are sure u64 is 8byte long, but unsigned long is 4byte long on 32-bit > machine, so if bdi_dirty can assume values bigger than 2^32 there is an > implicit truncate of its value, isn't it? > > Marco Sorry but I didn't see the code, it seems not possible so the wrong situation can't happen. Maybe we can simply add a comment, nothing more. Marco ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit 2012-08-19 10:23 ` Marco Stornelli 2012-08-19 10:35 ` Marco Stornelli @ 2012-08-19 23:49 ` Namjae Jeon 1 sibling, 0 replies; 5+ messages in thread From: Namjae Jeon @ 2012-08-19 23:49 UTC (permalink / raw) To: Marco Stornelli; +Cc: Fengguang Wu, akpm, linux-kernel, linux-fsdevel 2012/8/19, Marco Stornelli <marco.stornelli@gmail.com>: > Il 19/08/2012 04:17, Fengguang Wu ha scritto: >> On Sat, Aug 18, 2012 at 05:49:21AM -0400, Namjae Jeon wrote: >>> unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long >>> dirty) >>> >>> Above function return type is unsigned long, but return value is >>> kept in "u64 bdi_dirty". >>> It can return incorrect value by type casting. >> >> I don't see how the cast can return wrong value. >> The u64 is necessary for the intermediate calculations. >> >> Thanks, >> Fengguang >> > > We are sure u64 is 8byte long, but unsigned long is 4byte long on 32-bit > machine, so if bdi_dirty can assume values bigger than 2^32 there is an > implicit truncate of its value, isn't it? Yes, right. Thanks. > > Marco > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit 2012-08-19 2:17 ` [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit Fengguang Wu 2012-08-19 10:23 ` Marco Stornelli @ 2012-08-20 0:09 ` Namjae Jeon 1 sibling, 0 replies; 5+ messages in thread From: Namjae Jeon @ 2012-08-20 0:09 UTC (permalink / raw) To: Fengguang Wu; +Cc: akpm, linux-kernel, linux-fsdevel 2012/8/19, Fengguang Wu <fengguang.wu@intel.com>: > On Sat, Aug 18, 2012 at 05:49:21AM -0400, Namjae Jeon wrote: >> unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long >> dirty) >> >> Above function return type is unsigned long, but return value is >> kept in "u64 bdi_dirty". >> It can return incorrect value by type casting. > > I don't see how the cast can return wrong value. > The u64 is necessary for the intermediate calculations. > > Thanks, > Fengguang Hi Wu. I understand. Thanks for your reply. > >> Signed-off-by: Namjae Jeon <linkinjeon@gmail.com> >> --- >> mm/page-writeback.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/page-writeback.c b/mm/page-writeback.c >> index 49133b6..73a7a06 100644 >> --- a/mm/page-writeback.c >> +++ b/mm/page-writeback.c >> @@ -546,7 +546,7 @@ static unsigned long hard_dirty_limit(unsigned long >> thresh) >> */ >> unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long >> dirty) >> { >> - u64 bdi_dirty; >> + unsigned long bdi_dirty; >> long numerator, denominator; >> >> /* >> -- >> 1.7.9.5 > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-20 0:09 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1345283361-7802-1-git-send-email-linkinjeon@gmail.com> 2012-08-19 2:17 ` [PATCH 2/3] writeback: fix incorrect return value type of bdi_dirty_limit Fengguang Wu 2012-08-19 10:23 ` Marco Stornelli 2012-08-19 10:35 ` Marco Stornelli 2012-08-19 23:49 ` Namjae Jeon 2012-08-20 0:09 ` Namjae Jeon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).