number of elements or bytes for kfifo_in etc
Hi, Stefani,
In new kfifo implementation in 2.6.36-rc1, description of the third parameter is:
"@n: number of elements to be added"
But if my understanding is correct, the actual implementation is:
"@n: number of bytes to be added"
That is sizeof(*fifo->type) is not considered.
I think we should change either the implementation or the description.
Best Regards,
Huang Ying
Am Mittwoch, den 18.08.2010, 13:29 +0800 schrieb Huang Ying:
Quoted 11 lines
Hi, Stefani,
In new kfifo implementation in 2.6.36-rc1, description of the third parameter is:
"@n: number of elements to be added"
But if my understanding is correct, the actual implementation is:
"@n: number of bytes to be added"
Number of bytes is wrong, this is only valid for byte stream fifo's where an element is a byte.
Have a look at samples/kfifo/inttype-example.c where an element is a int type.
Hi, Stefani,
Quoted 10 lines · Stefani Seibold
Am Mittwoch, den 18.08.2010, 13:29 +0800 schrieb Huang Ying:
Quoted 9 lines
Hi, Stefani,
In new kfifo implementation in 2.6.36-rc1, description of the third parameter is:
"@n: number of elements to be added"
But if my understanding is correct, the actual implementation is:
Quoted 8 lines
Quoted 2 lines
"@n: number of bytes to be added"
Number of bytes is wrong, this is only valid for byte stream fifo's where an element is a byte.
Have a look at
samples/kfifo/inttype-example.cwhere an element is a int type.
Yes. You are right. I misunderstood your code. Sorry for bothering.
Best Regards,
Huang Ying
Quoted 16 lines · Huang Ying
Hi, Stefani,
Quoted 13 lines · Stefani Seibold
Am Mittwoch, den 18.08.2010, 13:29 +0800 schrieb Huang Ying:
Quoted 11 lines
Hi, Stefani,
In new kfifo implementation in 2.6.36-rc1, description of the third parameter is:
"@n: number of elements to be added"
But if my understanding is correct, the actual implementation is:
"@n: number of bytes to be added"
Quoted 7 lines
Quoted 5 lines
Number of bytes is wrong, this is only valid for byte stream fifo's where an element is a byte.
Have a look at
samples/kfifo/inttype-example.cwhere an element is a int type.Yes. You are right. I misunderstood your code. Sorry for bothering.
And I found __kfifo->esize is used in __kfifo_in/out etc to convert between elements and bytes. Maybe we can pull the conversion code to corresponding macro, because where esize is constant and may be optimized to bit shifting or nothing. What do you think about that?
Best Regards,
Huang Ying
Am Donnerstag, den 19.08.2010, 09:15 +0800 schrieb Huang Ying:
Quoted 23 lines · Huang Ying
Quoted 22 lines
Hi, Stefani,
Quoted 18 lines · Stefani Seibold
Am Mittwoch, den 18.08.2010, 13:29 +0800 schrieb Huang Ying:
Quoted 11 lines
Hi, Stefani,
In new kfifo implementation in 2.6.36-rc1, description of the third parameter is:
"@n: number of elements to be added"
But if my understanding is correct, the actual implementation is:
"@n: number of bytes to be added"
Number of bytes is wrong, this is only valid for byte stream fifo's where an element is a byte.
Have a look at
samples/kfifo/inttype-example.cwhere an element is a int type.
Quoted 7 lines
Quoted 1 line
Yes. You are right. I misunderstood your code. Sorry for bothering.
And I found
__kfifo->esizeis used in __kfifo_in/out etc to convert between elements and bytes. Maybe we can pull the conversion code to corresponding macro, because where esize is constant and may be optimized to bit shifting or nothing. What do you think about that?
esize isn't constant, especially from the point of view inside __kfifo_in and so on. The is ony good reason not to pass the size of the element using sizeof(*fifo->type) as a parameter, it will generate more code. Storing the size of the element in the kfifo structure is the better decision.
But if you found a better way and can prove it under any circumstance with a list of measurement results u will get an ack!
- Stefani