Re: [announce] 'patchview' script
On Tue, Jul 19, 2005 at 11:51:03AM -0700, randy_dunlap wrote: > > Hi, > > Someone asked me about a tool like this and I didn't know of one, > so I made this little script. > > 'patchview' merges a patch file and a source tree to a set of > temporary modified files. This enables better patch (re)viewing > and more viewable context. (hopefully) > > Are there already other tools that do something similar to this? > (other than SCMs) > > > The patchview script is here: > http://www.xenotime.net/linux/scripts/patchview Hey Randy, The mktemp command fails for me, but patchview keeps on going. [EMAIL PROTECTED] ~/tmp]$ patchview mypatch.patch linux-2.6.13-rc3 mktemp: cannot make temp dir /home/njw/tmp/XX/tmp.xV1xRT: No such file or directory failed mktemp for patch files dir. mkdir: cannot create directory `/fs': Permission denied cp: cannot create regular file `/fs/Kconfig': No such file or directory mkdir: cannot create directory `/fs': Permission denied cp: cannot create regular file `/fs/Makefile': No such file or directory [ ... ] This patch makes mktemp work correctly for me and causes patchview to exit if it happens to fail. Thanks, Nick Wilson --- patchview.orig 2005-07-19 12:50:20.0 -0700 +++ patchview 2005-07-19 13:07:12.0 -0700 @@ -48,7 +48,7 @@ else TMPDIR=/tmp fi -WORKDIR=`mktemp -d -p ${TMPDIR}/XX` || echo "failed mktemp for patch files dir." +WORKDIR=`mktemp -d -p ${TMPDIR} XX` || { echo "failed mktemp for patch files dir."; exit 1; } pfiles=`lsdiff --strip 1 $patchfile` - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [NFS] [PATCH] NFS: fix client hang due to race condition
On Wed, Jul 06, 2005 at 07:11:25PM -0700, Lever, Charles wrote: > > The flags field in struct nfs_inode is protected by the BKL. The > > following two code paths (there may be more, but my test program only > > hits these two) modify the flags without obtaining the lock: > > > > nfs_end_data_update > > nfs_release > > nfs_file_release > > __fput > > fput > > filp_close > > sys_close > > syscall_call > > > > nfs_revalidate_mapping > > nfs_file_write > > do_sync_write > > vfs_write > > sys_write > > syscall_call > > > > Running multiple instances of a simple program [1] that opens, writes > > to, and closes NFS mounted files eventually results in the programs > > hanging on an SMP system (see kernel .config [3]). > > > > I've been testing this with 100 instances of the program: > > $ ./breaknfs 100 & > > > > Usually within 10 minutes, all instances of breaknfs will hang. They > > disappear from the output of 'top' and there is no NFS > > activity between > > the client and server. > > [ sysrq output snipped... ] > > > I've reproduced this bug on 2.6.11.10, 2.6.12-mm2, and 2.6.13-rc2. > > > > With my patch against 2.6.13-rc2 below, I ran 100 instances > > of breaknfs > > with this patch for 14 hours and I was unable to get the > > client to hang. > > i agree this is a problem. > > but instead of using heavyweight synchronization, why not convert the > NFS_INO flags into atomic bitops? i have a patch that does that; would > need to be ported to the latest kernels and tested to see if it > addresses the problem. > > nick, are you interested in trying it out? Sure. Send it my way and I'll see if I can get it updated to the latest kernels and test it out. Nick - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] NFS: fix client hang due to race condition
The flags field in struct nfs_inode is protected by the BKL. The following two code paths (there may be more, but my test program only hits these two) modify the flags without obtaining the lock: nfs_end_data_update nfs_release nfs_file_release __fput fput filp_close sys_close syscall_call nfs_revalidate_mapping nfs_file_write do_sync_write vfs_write sys_write syscall_call Running multiple instances of a simple program [1] that opens, writes to, and closes NFS mounted files eventually results in the programs hanging on an SMP system (see kernel .config [3]). I've been testing this with 100 instances of the program: $ ./breaknfs 100 & Usually within 10 minutes, all instances of breaknfs will hang. They disappear from the output of 'top' and there is no NFS activity between the client and server. /proc/*/wchan shows 22 instances of breaknfs are waiting on nfs_wait_on_inode, and 78 on .text.lock.namei echo t > /proc/sysrq-trigger output [2] shows 22 instances of breaknfs similar to this...: breaknfs S 00100100 5060 5530 5523 5531 5529 (NOTLB) de0d1e24 0086 c01178e0 00100100 de0d1de4 de0d1e14 de0d1dec c0309513 de0d1e0c c0127c7e dfaff020 c140e400 04c3 b37f50b5 003a c140e8c0 de7815b0 de7816d8 dbb5963c dbb59650 de0d Call Trace: [] nfs_wait_on_inode+0x1b1/0x1c0 [] __nfs_revalidate_inode+0x2cc/0x340 [] nfs_file_flush+0x8c/0xc0 [] filp_close+0x56/0x70 [] sys_close+0x69/0x90 [] syscall_call+0x7/0xb ... and 78 similar to this: breaknfs D 0310 5060 5523 5466 5524 (NOTLB) ddcafebc 0082 c0369810 0310 ddcaff58 ddcafe90 db975690 ddcafee0 ddcafe94 c0170a75 ddcaff58 dfaff020 c140e400 0178 b2b3096d 003a c140e8c0 df839550 df839678 dbb59e70 dbb59e78 0286 Call Trace: [] __down+0x83/0xe0 [] __down_failed+0xa/0x10 [] .text.lock.namei+0xaa/0x1e5 [] filp_open+0x2d/0x50 [] sys_open+0x4d/0x80 [] syscall_call+0x7/0xb NFS mount options from /proc/mounts: rw,v3,rsize=32768,wsize=32768,hard,intr,udp,lock,addr=njw I've reproduced this bug on 2.6.11.10, 2.6.12-mm2, and 2.6.13-rc2. With my patch against 2.6.13-rc2 below, I ran 100 instances of breaknfs with this patch for 14 hours and I was unable to get the client to hang. Thanks, Nick Wilson [1] http://developer.osdl.org/njw/nfs-bug/breaknfs.c [2] http://developer.osdl.org/njw/nfs-bug/alt-sysrq-t.txt [3] http://developer.osdl.org/njw/nfs-bug/kernel-config The flags field in struct nfs_inode is protected by the BKL. This patch fixes a couple places where the lock is not obtained before changing the flags. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- inode.c |4 1 files changed, 4 insertions(+) --- linux.orig/fs/nfs/inode.c 2005-07-06 11:08:27.0 -0700 +++ linux/fs/nfs/inode.c2005-07-06 11:20:19.0 -0700 @@ -1118,7 +1118,9 @@ void nfs_revalidate_mapping(struct inode nfs_wb_all(inode); } invalidate_inode_pages2(mapping); + lock_kernel(); nfsi->flags &= ~NFS_INO_INVALID_DATA; + unlock_kernel(); if (S_ISDIR(inode->i_mode)) { memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); /* This ensures we revalidate child dentries */ @@ -1153,10 +1155,12 @@ void nfs_end_data_update(struct inode *i if (!nfs_have_delegation(inode, FMODE_READ)) { /* Mark the attribute cache for revalidation */ + lock_kernel(); nfsi->flags |= NFS_INO_INVALID_ATTR; /* Directories and symlinks: invalidate page cache too */ if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) nfsi->flags |= NFS_INO_INVALID_DATA; + unlock_kernel(); } nfsi->cache_change_attribute ++; atomic_dec(&nfsi->data_updates); _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Use ALIGN to remove duplicate code
On Thu, Apr 07, 2005 at 05:50:42PM -0700, Andrew Morton wrote: > Nick Wilson <[EMAIL PROTECTED]> wrote: > > The first patch adds a generic round_up_pow2() macro to kernel.h. The > > remaining patches modify a few files to make use of the new macro. > > We already have ALIGN() and roundup_pow_of_two(). Andrew, This patch makes use of ALIGN() to remove duplicate round-up code. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- include/linux/a.out.h |2 +- kernel/resource.c |2 +- lib/bitmap.c |3 +-- mm/bootmem.c |6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) Index: linux/include/linux/a.out.h === --- linux.orig/include/linux/a.out.h2005-04-08 10:59:14.0 -0700 +++ linux/include/linux/a.out.h 2005-04-08 11:00:40.0 -0700 @@ -138,7 +138,7 @@ enum machine_type { #endif #endif -#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) +#define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE) #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) Index: linux/kernel/resource.c === --- linux.orig/kernel/resource.c2005-04-08 10:59:36.0 -0700 +++ linux/kernel/resource.c 2005-04-08 11:00:50.0 -0700 @@ -263,7 +263,7 @@ static int find_resource(struct resource new->start = min; if (new->end > max) new->end = max; - new->start = (new->start + align - 1) & ~(align - 1); + new->start = ALIGN(new->start, align); if (alignf) alignf(alignf_data, new, size, align); if (new->start < new->end && new->end - new->start + 1 >= size) { Index: linux/lib/bitmap.c === --- linux.orig/lib/bitmap.c 2005-04-08 10:59:40.0 -0700 +++ linux/lib/bitmap.c 2005-04-08 11:00:59.0 -0700 @@ -289,7 +289,6 @@ EXPORT_SYMBOL(__bitmap_weight); #define CHUNKSZ32 #define nbits_to_hold_value(val) fls(val) -#define roundup_power2(val,modulus)(((val) + (modulus) - 1) & ~((modulus) - 1)) #define unhex(c) (isdigit(c) ? (c - '0') : (toupper(c) - 'A' + 10)) #define BASEDEC 10 /* fancier cpuset lists input in decimal */ @@ -316,7 +315,7 @@ int bitmap_scnprintf(char *buf, unsigned if (chunksz == 0) chunksz = CHUNKSZ; - i = roundup_power2(nmaskbits, CHUNKSZ) - CHUNKSZ; + i = ALIGN(nmaskbits, CHUNKSZ) - CHUNKSZ; for (; i >= 0; i -= CHUNKSZ) { chunkmask = ((1ULL << chunksz) - 1); word = i / BITS_PER_LONG; Index: linux/mm/bootmem.c === --- linux.orig/mm/bootmem.c 2005-04-08 10:59:43.0 -0700 +++ linux/mm/bootmem.c 2005-04-08 11:05:45.0 -0700 @@ -57,7 +57,7 @@ static unsigned long __init init_bootmem pgdat->pgdat_next = pgdat_list; pgdat_list = pgdat; - mapsize = (mapsize + (sizeof(long) - 1UL)) & ~(sizeof(long) - 1UL); + mapsize = ALIGN(mapsize, sizeof(long)); bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT); bdata->node_boot_start = (start << PAGE_SHIFT); bdata->node_low_pfn = end; @@ -178,7 +178,7 @@ __alloc_bootmem_core(struct bootmem_data } else preferred = 0; - preferred = ((preferred + align - 1) & ~(align - 1)) >> PAGE_SHIFT; + preferred = ALIGN(preferred, align) >> PAGE_SHIFT; preferred += offset; areasize = (size+PAGE_SIZE-1)/PAGE_SIZE; incr = align >> PAGE_SHIFT ? : 1; @@ -219,7 +219,7 @@ found: */ if (align < PAGE_SIZE && bdata->last_offset && bdata->last_pos+1 == start) { - offset = (bdata->last_offset+align-1) & ~(align-1); + offset = ALIGN(bdata->last_offset, align); BUG_ON(offset > PAGE_SIZE); remaining_size = PAGE_SIZE-offset; if (size < remaining_size) { _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 6/6] mm/bootmem.c: use generic round_up_pow2() macro
From: Nick Wilson <[EMAIL PROTECTED]> Use the generic round_up_pow2() instead of a custom rounding method. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- bootmem.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) Index: linux/mm/bootmem.c === --- linux.orig/mm/bootmem.c 2005-04-07 15:13:56.0 -0700 +++ linux/mm/bootmem.c 2005-04-07 15:46:41.0 -0700 @@ -57,7 +57,7 @@ static unsigned long __init init_bootmem pgdat->pgdat_next = pgdat_list; pgdat_list = pgdat; - mapsize = (mapsize + (sizeof(long) - 1UL)) & ~(sizeof(long) - 1UL); + mapsize = round_up_pow2(mapsize, sizeof(long)); bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT); bdata->node_boot_start = (start << PAGE_SHIFT); bdata->node_low_pfn = end; @@ -178,7 +178,7 @@ __alloc_bootmem_core(struct bootmem_data } else preferred = 0; - preferred = ((preferred + align - 1) & ~(align - 1)) >> PAGE_SHIFT; + preferred = round_up_pow2(preferred, align) >> PAGE_SHIFT; preferred += offset; areasize = (size+PAGE_SIZE-1)/PAGE_SIZE; incr = align >> PAGE_SHIFT ? : 1; @@ -219,7 +219,7 @@ found: */ if (align < PAGE_SIZE && bdata->last_offset && bdata->last_pos+1 == start) { - offset = (bdata->last_offset+align-1) & ~(align-1); + offset = round_up_pow2(bdata->last_offset, align); BUG_ON(offset > PAGE_SIZE); remaining_size = PAGE_SIZE-offset; if (size < remaining_size) { _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/6] lib/bitmap.c: use generic round_up_pow2() macro
From: Nick Wilson <[EMAIL PROTECTED]> Use the generic round_up_pow2() instead of a custom rounding method. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- bitmap.c |3 +-- 1 files changed, 1 insertion(+), 2 deletions(-) Index: linux/lib/bitmap.c === --- linux.orig/lib/bitmap.c 2005-04-07 15:13:56.0 -0700 +++ linux/lib/bitmap.c 2005-04-07 15:46:15.0 -0700 @@ -289,7 +289,6 @@ EXPORT_SYMBOL(__bitmap_weight); #define CHUNKSZ32 #define nbits_to_hold_value(val) fls(val) -#define roundup_power2(val,modulus)(((val) + (modulus) - 1) & ~((modulus) - 1)) #define unhex(c) (isdigit(c) ? (c - '0') : (toupper(c) - 'A' + 10)) #define BASEDEC 10 /* fancier cpuset lists input in decimal */ @@ -316,7 +315,7 @@ int bitmap_scnprintf(char *buf, unsigned if (chunksz == 0) chunksz = CHUNKSZ; - i = roundup_power2(nmaskbits, CHUNKSZ) - CHUNKSZ; + i = round_up_pow2(nmaskbits, CHUNKSZ) - CHUNKSZ; for (; i >= 0; i -= CHUNKSZ) { chunkmask = ((1ULL << chunksz) - 1); word = i / BITS_PER_LONG; _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/6] kernel/resource.c: use generic round_up_pow2() macro
From: Nick Wilson <[EMAIL PROTECTED]> Use the generic round_up_pow2() instead of a custom rounding method. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- resource.c |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: linux/kernel/resource.c === --- linux.orig/kernel/resource.c2005-04-07 15:13:56.0 -0700 +++ linux/kernel/resource.c 2005-04-07 15:45:57.0 -0700 @@ -263,7 +263,7 @@ static int find_resource(struct resource new->start = min; if (new->end > max) new->end = max; - new->start = (new->start + align - 1) & ~(align - 1); + new->start = round_up_pow2(new->start, align); if (alignf) alignf(alignf_data, new, size, align); if (new->start < new->end && new->end - new->start + 1 >= size) { _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/6] include/linux/a.out.h: use generic round_up_pow2() macro
From: Nick Wilson <[EMAIL PROTECTED]> Use the generic round_up_pow2() instead of a custom rounding method. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- a.out.h |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: linux/include/linux/a.out.h === --- linux.orig/include/linux/a.out.h2005-04-07 15:37:22.0 -0700 +++ linux/include/linux/a.out.h 2005-04-07 15:45:34.0 -0700 @@ -138,7 +138,7 @@ enum machine_type { #endif #endif -#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) +#define _N_SEGMENT_ROUND(x) round_up_pow2(x, SEGMENT_SIZE) #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/6] include/linux/kernel.h: use generic round_up_pow2() macro
From: Nick Wilson <[EMAIL PROTECTED]> Add a generic macro to kernel.h to round up to the next multiple of n. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- kernel.h |5 + 1 files changed, 5 insertions(+) Index: linux/include/linux/kernel.h === --- linux.orig/include/linux/kernel.h 2005-04-07 15:13:56.0 -0700 +++ linux/include/linux/kernel.h2005-04-07 15:47:15.0 -0700 @@ -246,6 +246,11 @@ extern void dump_stack(void); #define max_t(type,x,y) \ ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) +/* + * Round x up to the next multiple of n. + * n must be a power of 2. + */ +#define round_up_pow2(x,n) (((x) + (n) - 1) & ~((n) - 1)) /** * container_of - cast a member of a structure out to the containing structure _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/6] include/linux/kernel.h: use generic round_up_pow2() macro
From: Nick Wilson <[EMAIL PROTECTED]> Use the generic round_up_pow2() instead of a custom rounding method. Signed-off-by: Nick Wilson <[EMAIL PROTECTED]> --- kernel.h |2 +- 1 files changed, 1 insertion(+), 1 deletion(-) Index: linux/include/linux/kernel.h === --- linux.orig/include/linux/kernel.h 2005-04-07 15:44:05.0 -0700 +++ linux/include/linux/kernel.h2005-04-07 15:44:53.0 -0700 @@ -28,7 +28,7 @@ extern const char linux_banner[]; #define STACK_MAGIC0xdeadbeef #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1)) +#define ALIGN round_up_pow2 #defineKERN_EMERG "<0>" /* system is unusable */ #defineKERN_ALERT "<1>" /* action must be taken immediately */ _ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/6] add generic round_up_pow2() macro
Randy.Dunlap wrote: > >+#define ALIGN_DATA_SIZE(size) ((size + PAGE_SIZE - 1) & ~(PAGE_SIZE - > >1)) > > > ISTM that we need a generic round_up() function or macro in kernel.h. > > > > a.out.h, reiserfs_fs.h, and ufs_fs.h all have their own round-up > > macros. > I've found many more places in the kernel that use their own functions for doing this. These patches are the beginning of an attempt to clean these up. The first patch adds a generic round_up_pow2() macro to kernel.h. The remaining patches modify a few files to make use of the new macro. Comments welcome. Thanks, Nick - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/