Re: do_div() silently truncates "base" to 32bit

2013-09-04 Thread Randy Dunlap
On 09/04/13 08:32, Anatol Pomozov wrote: > Hi > > On Fri, Aug 30, 2013 at 5:50 PM, Anatol Pomozov > wrote: >> Hi, Joe >> >> On Fri, Aug 30, 2013 at 4:28 PM, Joe Perches wrote: >>> On Fri, 2013-08-30 at 15:48 -0700, Randy Dunlap wrote: On 08/30/13 15:14, Anatol Pomozov wrote: > But anoth

Re: do_div() silently truncates "base" to 32bit

2013-09-04 Thread Anatol Pomozov
Hi On Fri, Aug 30, 2013 at 5:50 PM, Anatol Pomozov wrote: > Hi, Joe > > On Fri, Aug 30, 2013 at 4:28 PM, Joe Perches wrote: >> On Fri, 2013-08-30 at 15:48 -0700, Randy Dunlap wrote: >>> On 08/30/13 15:14, Anatol Pomozov wrote: >>> > But another question still remains: why compiler does not warn

Re: do_div() silently truncates "base" to 32bit

2013-08-30 Thread Anatol Pomozov
Hi, Joe On Fri, Aug 30, 2013 at 4:28 PM, Joe Perches wrote: > On Fri, 2013-08-30 at 15:48 -0700, Randy Dunlap wrote: >> On 08/30/13 15:14, Anatol Pomozov wrote: >> > But another question still remains: why compiler does not warn that >> > size truncation happens? How to prevent bugs like CFQ one

Re: do_div() silently truncates "base" to 32bit

2013-08-30 Thread Joe Perches
On Fri, 2013-08-30 at 15:48 -0700, Randy Dunlap wrote: > On 08/30/13 15:14, Anatol Pomozov wrote: > > But another question still remains: why compiler does not warn that > > size truncation happens? How to prevent bugs like CFQ one in the > > future? Should we add a compile-time assert to do_div()

Re: do_div() silently truncates "base" to 32bit

2013-08-30 Thread Randy Dunlap
On 08/30/13 15:14, Anatol Pomozov wrote: > Hi > > On Fri, Aug 30, 2013 at 2:23 PM, Randy Dunlap wrote: >> On 08/30/13 10:21, Anatol Pomozov wrote: >>> Hi, >>> >>> >>> I was debugging weird "zero divide" problem in CFQ code below >>> >>> >>> static u64 cfqg_prfill_avg_queue_size(struct seq_file *s

Re: do_div() silently truncates "base" to 32bit

2013-08-30 Thread Anatol Pomozov
Hi On Fri, Aug 30, 2013 at 2:23 PM, Randy Dunlap wrote: > On 08/30/13 10:21, Anatol Pomozov wrote: >> Hi, >> >> >> I was debugging weird "zero divide" problem in CFQ code below >> >> >> static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, >> struct blkg_policy_data *pd, int off) >> {

Re: do_div() silently truncates "base" to 32bit

2013-08-30 Thread Randy Dunlap
On 08/30/13 10:21, Anatol Pomozov wrote: > Hi, > > > I was debugging weird "zero divide" problem in CFQ code below > > > static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, > struct blkg_policy_data *pd, int off) > { > struct cfq_group *cfqg = pd_to_cfqg(pd); > u64 samples

do_div() silently truncates "base" to 32bit

2013-08-30 Thread Anatol Pomozov
Hi, I was debugging weird "zero divide" problem in CFQ code below static u64 cfqg_prfill_avg_queue_size(struct seq_file *sf, struct blkg_policy_data *pd, int off) { struct cfq_group *cfqg = pd_to_cfqg(pd); u64 samples = blkg_stat_read(&cfqg->stats.avg_queue_size_samples); u64