From owner-freebsd-current Thu Dec 12 16:20:22 2002 Delivered-To: freebsd-current@freebsd.org Received: from green.bikeshed.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 82C0C37B401 for ; Thu, 12 Dec 2002 16:20:18 -0800 (PST) Received: from green.bikeshed.org (876k7r62jki03w31@green.bikeshed.org [10.0.0.1] (may be forged)) by green.bikeshed.org (8.12.6/8.12.6) with ESMTP id gBD0KFOa000831 for ; Thu, 12 Dec 2002 19:20:16 -0500 (EST) (envelope-from green@green.bikeshed.org) Received: from localhost (green@localhost) by green.bikeshed.org (8.12.6/8.12.6/Submit) with ESMTP id gBD0KFWg000827 for ; Thu, 12 Dec 2002 19:20:15 -0500 (EST) Message-Id: <200212130020.gBD0KFWg000827@green.bikeshed.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: current@freeBSD.org Subject: fincore.c strikes again (panic bremfree: bp not locked) From: Brian Fundakowski Feldman Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 12 Dec 2002 19:20:15 -0500 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I don't have any more info since for some reason the kernel wasn't saved when my system dumped core, but yet again fincore.c causes evidence that -CURRENT has regressed again. I can't find the old thread I'm thinking of, but from a slightly different thread, bde knew what was going on. For further reference: #include #include #include #include #include #include #include #include #include /* ** print pages of file in core */ void usage(char *name) { printf("Usage: %s [-ns] files...\n",name); printf("\t-n\t\tDo not print filename\n"); printf("\t-o\t\tOnly print files with at least one page in core\n"); printf("\t-s\t\tDo not print file size in pages\n"); } main(int ac,char **av) { int c; int print_name = 1; int print_sizepages = 1; int only_nonzero = 0; int status = 0; while((c = getopt(ac,av,"nos")) != -1) { switch(c) { case 'n': print_name = 0; break; case 'o': only_nonzero = 1; break; case 's': print_sizepages = 0; break; default: usage(av[0]); exit(1); } } for(; optind < ac ; optind++) { int fd; int pind,pcount; caddr_t addr; struct stat statbuf; size_t len; size_t numpages; char *pvec; if (stat(av[optind],&statbuf)) { perror("stat"); status = 1; continue; } if (!S_ISREG(statbuf.st_mode)) { close(fd); continue; } if ((fd = open(av[optind],O_RDONLY)) < 0) { perror(av[optind]); status = 1; continue; } if (fstat(fd,&statbuf)) { perror("fstat"); close(fd); status = 1; continue; } if (!S_ISREG(statbuf.st_mode)) { close(fd); continue; } len = statbuf.st_size; numpages = len/PAGE_SIZE + ((len % PAGE_SIZE) != 0); if (! (statbuf.st_mode & (S_IFREG|S_IFCHR))) { pcount = 0; } else if (len) { if ((addr = mmap(0,len,PROT_READ,MAP_SHARED,fd,0)) == MAP_FAILED) { fprintf(stderr, "mmap (%s): %s\n", av[optind], strerror(errno)); close(fd); status = 1; continue; } pvec = malloc(numpages); if (mincore(addr,len,pvec)) { perror("mincore"); exit(1); } for(pcount = 0,pind = 0 ; pind < numpages ; pind++) { if (pvec[pind]) pcount++; } free(pvec); if (munmap(addr,len)) { perror("munmap"); exit(1); } } else { pcount = 0; } if (pcount || !only_nonzero) { if (print_name) printf("%s: ",av[optind]); printf("%d",pcount); if (print_sizepages) printf("/%d",numpages); printf("\n"); } close(fd); } exit(status); } -- Brian Fundakowski Feldman \'[ FreeBSD ]''''''''''\ <> green@FreeBSD.org <> bfeldman@tislabs.com \ The Power to Serve! \ Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message