Skip to contentSkip to conversation

blkback statistic counters are signed values

blkback Zoltan Kiss 3 participants 5 messages Mar 4, 2013 – Mar 6, 2013

lore
Share & tools
lore
#0 lore raw

Hi,

One of our colleagues spotted a problem in xentop. Sometimes the VBD_WSECT value suddenly becomes unreasonably high, and it turned out xentop reads /sys/bus/xen-backend/devices/vbd-(domid)-(devID)/statistics/wr_sect into an unsigned long long. That value is exposed by blkback, and among other stat counters, it's a signed integer:

drivers/block/xen-blkback/common.h
struct xen_blkif {
...

	int			st_rd_req;
	int			st_wr_req;
	int			st_oo_req;
	int			st_f_req;
	int			st_ds_req;
	int			st_rd_sect;
	int			st_wr_sect;

I don't think these values should be negative ever, but when they overflow (which happens eventually), they do, and this leads to bad conversion in xentop. I think the best solution would be to change the above mentioned values to unsigned long long as well. Any comments on that?

Regards,

Zoltan Kiss

#1 lore raw
Quoted 21 lines · Zoltan Kiss

Hi,

One of our colleagues spotted a problem in xentop. Sometimes the VBD_WSECT value suddenly becomes unreasonably high, and it turned out xentop reads /sys/bus/xen-backend/devices/vbd-(domid)-(devID)/statistics/wr_sect into an unsigned long long. That value is exposed by blkback, and among other stat counters, it's a signed integer:

drivers/block/xen-blkback/common.h
struct xen_blkif {
...

	int			st_rd_req;
	int			st_wr_req;
	int			st_oo_req;
	int			st_f_req;
	int			st_ds_req;
	int			st_rd_sect;
	int			st_wr_sect;
Quoted 5 lines

I don't think these values should be negative ever, but when they overflow (which happens eventually), they do, and this leads to bad conversion in xentop.
I think the best solution would be to change the above mentioned values to unsigned long long as well. Any comments on that?

Seems like the right approach. Could you send a patch please?

Thought that won't solve the problem when we overflow an 'unsigned long long'.

Quoted 10 lines

Regards,

Zoltan Kiss

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw

Hi,

Quoted 1 line · Konrad Rzeszutek Wilk

Seems like the right approach. Could you send a patch please?

I just sent it to you and [email protected]:

http://lkml.indiana.edu/hypermail/linux/kernel/1303.0/02306.html

Quoted 1 line

Thought that won't solve the problem when we overflow an 'unsigned long long'.

Well, I think it's good enough if the users of these values pay attention, and poll these sysfs entries often enough to detect that there was an overflow.

Regards,

Zoltan Kiss

#3 lore raw
Quoted 6 lines · Zoltan Kiss

Hi,

Quoted 1 line · Konrad Rzeszutek Wilk

Seems like the right approach. Could you send a patch please?

I just sent it to you and [email protected]:

Quoted 7 lines

http://lkml.indiana.edu/hypermail/linux/kernel/1303.0/02306.html

Quoted 2 lines

Thought that won't solve the problem when we overflow an 'unsigned long long'.

Well, I think it's good enough if the users of these values pay attention, and poll these sysfs entries often enough to detect that there was an overflow.

Unless my maths is wrong it will take millions of years for these sector count statistics to overflow.

David

#4 lore raw
Quoted 9 lines · David Vrabel
Quoted 8 lines · Zoltan Kiss

Hi,

Quoted 1 line · Konrad Rzeszutek Wilk

Seems like the right approach. Could you send a patch please?

I just sent it to you and [email protected]:

http://lkml.indiana.edu/hypermail/linux/kernel/1303.0/02306.html

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thought that won't solve the problem when we overflow an 'unsigned long long'.

Well, I think it's good enough if the users of these values pay attention, and poll these sysfs entries often enough to detect that there was an overflow.

Unless my maths is wrong it will take millions of years for these sector count statistics to overflow.

OK, so you are saying like Bill Gates, that this ought to be enough :-)

I will take that as an Acked-by :-)

Quoted 2 lines

David