[PATCH] Re: Linux 2.2.16pre3

From: Jarno Paananen (jpaana@s2.org)
Date: Tue May 16 2000 - 19:15:36 EST


Kris Karas <ktk@bigfoot.com> writes:

| Alan Cox wrote:
|
| > 2.2.16pre3
|
| Hmm, the missing 'memset' bug I just reported is a bit subtler than I
| thought;should have investigated before putting foot in mouth. For historical
| and general reliability reasons, my kernel build script forces use of
| gcc-2.7.2.3 on all non-devo kernels. When using egcs, the bug disappears.

This is caused by the line:

                dev->elevator = ELEVATOR_DEFAULTS;

The reason is that ELEVATOR_DEFAULTS is of different size than
dev->elevator, which causes gcc 2.7.2.3 to make a memset to clear
the struct and then set the values. Newer compilers inline this
constant memset and thus don't generate the call.

The reason why ELEVATOR_DEFAULTS and dev->elevator are of different
size is that not all fields are initialized. From
include/linux/blkdev.h:

typedef struct elevator_s
{
        int read_latency;
        int write_latency;
        int max_bomb_segments;
        unsigned int queue_ID;
} elevator_t;

#define ELEVATOR_DEFAULTS \
((elevator_t) { \
        128, /* read_latency */ \
        8192, /* write_latency */ \
        4, /* max_bomb_segments */ \
        })

ie. queue_ID is not initialized.

I thought of two different ways to fix this. The first one would be
to add queue_ID to ELEVATOR_DEFAULTS, although it's also
initialized on the next line in ll_rw_blk.c. With this gcc 2.7.2.3
doesn't generate that memset anymore:

--- include/linux/blkdev.h.old Tue May 16 20:07:54 2000
+++ include/linux/blkdev.h Wed May 17 02:40:30 2000
@@ -51,6 +51,7 @@
         128, /* read_latency */ \
         8192, /* write_latency */ \
         4, /* max_bomb_segments */ \
+ 0 /* queue_ID */ \
         })
 
 extern int blkelv_ioctl(kdev_t, unsigned long, unsigned long);

The other way could also be used because ELEVATOR_DEFAULTS is used
only in this one place and thus could be removed and replaced with
the needed initialization by hand:

--- drivers/block/ll_rw_blk.c.old Wed May 17 02:37:42 2000
+++ drivers/block/ll_rw_blk.c Wed May 17 02:43:33 2000
@@ -997,7 +997,9 @@
                 dev->plug_tq.sync = 0;
                 dev->plug_tq.routine = &unplug_device;
                 dev->plug_tq.data = dev;
- dev->elevator = ELEVATOR_DEFAULTS;
+ dev->elevator.read_latency = 128;
+ dev->elevator.write_latency = 8192;
+ dev->elevator.max_bomb_segments = 4;
                 dev->elevator.queue_ID = queue_ID++;
         }
 

With either one of these 2.2.16pre3 compiled with gcc 2.7.2.3 works
nicely on my machine although it still identifies itself as pre2.

// Jarno

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:11 EST