memory allocation in sg_io()
Hi,
could you explain to me why this code can get away with allocating the sense buffer on the stack?
static int sg_io(struct file *file, struct request_queue *q,
struct gendisk *bd_disk, struct sg_io_hdr *hdr)
{
unsigned long start_time;
int writing = 0, ret = 0, has_write_perm = 0;
struct request *rq;
char sense[SCSI_SENSE_BUFFERSIZE];
Regards
OliverQuoted 15 lines · Oliver Neukum
Hi,
could you explain to me why this code can get away with allocating the sense buffer on the stack?
static int sg_io(struct file *file, struct
request_queue*q,
struct gendisk*bd_disk, structsg_io_hdr*hdr){ unsigned long start_time; int writing = 0, ret = 0, has_write_perm = 0; struct request *rq; char sense[SCSI_SENSE_BUFFERSIZE]; Regards Oliver
Quoted 1 line
-
where? what? do you mean in scsi_ioctl.c?
why not it's a synchronous call?
Do you mean 96 bytes is too big?
Do you mean DMA alignment and cache coherency? I'm working on that for scsi devices.
Boaz
Quoted 14 lines · Boaz Harrosh
Quoted 13 lines · Oliver Neukum
Hi,
could you explain to me why this code can get away with allocating the sense buffer on the stack?
static int sg_io(struct file *file, struct
request_queue*q,
struct gendisk*bd_disk, structsg_io_hdr*hdr){ unsigned long start_time; int writing = 0, ret = 0, has_write_perm = 0; struct request *rq; char sense[SCSI_SENSE_BUFFERSIZE];
Quoted 8 lines
Quoted 3 lines
Regards
Oliver
-where? what? do you mean in
scsi_ioctl.c?
why not it's a synchronous call?
Do you mean 96 bytes is too big?
Do you mean DMA alignment and cache coherency? I'm working on that for scsi devices.
I'm guessing aligment - so the answer is that 'it cannot get away with it'.
Signature · 1 line
Jens Axboe
Quoted 18 lines · Jens Axboe
Quoted 17 lines · Boaz Harrosh
Quoted 16 lines · Oliver Neukum
Hi,
could you explain to me why this code can get away with allocating the sense buffer on the stack?
static int sg_io(struct file *file, struct
request_queue*q,
struct gendisk*bd_disk, structsg_io_hdr*hdr){ unsigned long start_time; int writing = 0, ret = 0, has_write_perm = 0; struct request *rq; char sense[SCSI_SENSE_BUFFERSIZE]; Regards Oliver-
Quoted 9 lines
Quoted 5 lines
where? what? do you mean in
scsi_ioctl.c?
why not it's a synchronous call?
Do you mean 96 bytes is too big?
Do you mean DMA alignment and cache coherency? I'm working on that for scsi devices.I'm guessing aligment - so the answer is that 'it cannot get away with it'.
I'm working on something for scsi.
Other block devices I don't know.
Boaz
Am Donnerstag, 10. Januar 2008 14:05:25 schrieb Boaz Harrosh:
Quoted 14 lines · Oliver Neukum
Quoted 13 lines
Hi,
could you explain to me why this code can get away with allocating the sense buffer on the stack?
static int sg_io(struct file *file, struct
request_queue*q,
struct gendisk*bd_disk, structsg_io_hdr*hdr){ unsigned long start_time; int writing = 0, ret = 0, has_write_perm = 0; struct request *rq; char sense[SCSI_SENSE_BUFFERSIZE];
Quoted 8 lines
Quoted 3 lines
Regards
Oliver
-where? what? do you mean in
scsi_ioctl.c?
why not it's a synchronous call?
Do you mean 96 bytes is too big?
Do you mean DMA alignment and cache coherency? I'm working on that for scsi devices.
Yes, you are doing DMA on the stack.
Regards
Oliver
Quoted 18 lines · Oliver Neukum
Am Donnerstag, 10. Januar 2008 14:05:25 schrieb Boaz Harrosh:
Quoted 17 lines · Oliver Neukum
Quoted 16 lines
Hi,
could you explain to me why this code can get away with allocating the sense buffer on the stack?
static int sg_io(struct file *file, struct
request_queue*q,
struct gendisk*bd_disk, structsg_io_hdr*hdr){ unsigned long start_time; int writing = 0, ret = 0, has_write_perm = 0; struct request *rq; char sense[SCSI_SENSE_BUFFERSIZE]; Regards Oliver-
Quoted 7 lines
Quoted 5 lines
where? what? do you mean in
scsi_ioctl.c?
why not it's a synchronous call?
Do you mean 96 bytes is too big?
Do you mean DMA alignment and cache coherency? I'm working on that for scsi devices.Yes, you are doing DMA on the stack.
There are many offenders like that, just take a peek in cdrom.c for instance.
Signature · 1 line
Jens Axboe
Quoted 15 lines · Oliver Neukum
Am Donnerstag, 10. Januar 2008 14:05:25 schrieb Boaz Harrosh:
Quoted 6 lines · Oliver Neukum
Quoted 5 lines
Hi,
could you explain to me why this code can get away with allocating the sense buffer on the stack?
Quoted 7 lines
Quoted 7 lines
static int sg_io(struct file *file, struct
request_queue*q,
struct gendisk*bd_disk, structsg_io_hdr*hdr){ unsigned long start_time; int writing = 0, ret = 0, has_write_perm = 0; struct request *rq; char sense[SCSI_SENSE_BUFFERSIZE];
Quoted 1 line
Yes, you are doing DMA on the stack.
Nobody does DMA to rq->sense. ub does a memcpy to it. cciss does a memcpy to it. scsi_lib assigns its own buffer to req->sense, ignoring the one passed down.
That's how this code gets away with it.
Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine "Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."