svn commit: r217439 - stable/8/sbin/hastd
Author: pjd Date: Sat Jan 15 08:18:58 2011 New Revision: 217439 URL: http://svn.freebsd.org/changeset/base/217439 Log: MFC r217307,r217308,r217312: r217307: Install default signal handlers before masking signals we want to handle. It is possible that the parent process ignores some of them and sigtimedwait() will never see them, eventhough they are masked. The most common situation for this to happen is boot process where init(8) ignores SIGHUP before starting to execute /etc/rc. This in turn caused hastd(8) to ignore SIGHUP. Reported by: trasz Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com r217308: Add a note that when custom signal handler is installed for a signal, signal action is restored to default in child after fork(2). In this case there is no need to do anything with dummy SIGCHLD handler, because after fork(2) it will be automatically reverted to SIG_IGN. Obtained from:Wheel Systems Sp. z o.o. http://www.wheelsystems.com r217312: execve(2), not fork(2) resets signal handler to the default value (if it isn't ignored). Correct comment talking about that. Pointed out by: kib Modified: stable/8/sbin/hastd/hastd.c stable/8/sbin/hastd/hooks.c Directory Properties: stable/8/sbin/hastd/ (props changed) Modified: stable/8/sbin/hastd/hastd.c == --- stable/8/sbin/hastd/hastd.c Sat Jan 15 03:06:03 2011(r217438) +++ stable/8/sbin/hastd/hastd.c Sat Jan 15 08:18:58 2011(r217439) @@ -754,10 +754,18 @@ main(int argc, char *argv[]) assert(cfg != NULL); /* +* Restore default actions for interesting signals in case parent +* process (like init(8)) decided to ignore some of them (like SIGHUP). +*/ + PJDLOG_VERIFY(signal(SIGHUP, SIG_DFL) != SIG_ERR); + PJDLOG_VERIFY(signal(SIGINT, SIG_DFL) != SIG_ERR); + PJDLOG_VERIFY(signal(SIGTERM, SIG_DFL) != SIG_ERR); + /* * Because SIGCHLD is ignored by default, setup dummy handler for it, * so we can mask it. */ PJDLOG_VERIFY(signal(SIGCHLD, dummy_sighandler) != SIG_ERR); + PJDLOG_VERIFY(sigemptyset(&mask) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGHUP) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0); Modified: stable/8/sbin/hastd/hooks.c == --- stable/8/sbin/hastd/hooks.c Sat Jan 15 03:06:03 2011(r217438) +++ stable/8/sbin/hastd/hooks.c Sat Jan 15 08:18:58 2011(r217439) @@ -372,6 +372,11 @@ hook_execv(const char *path, va_list ap) descriptors(); PJDLOG_VERIFY(sigemptyset(&mask) == 0); PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); + /* +* Dummy handler set for SIGCHLD in the parent will be restored +* to SIG_IGN on execv(3) below, so there is no need to do +* anything with it. +*/ execv(path, args); pjdlog_errno(LOG_ERR, "Unable to execute %s", path); exit(EX_SOFTWARE); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217440 - stable/8/lib/libc/net
Author: kib Date: Sat Jan 15 08:35:41 2011 New Revision: 217440 URL: http://svn.freebsd.org/changeset/base/217440 Log: MFC r217143: Fix struct FILE * leak on error (in disabled by default hesiod support code). PR: 153756 Modified: stable/8/lib/libc/net/hesiod.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/locale/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) Modified: stable/8/lib/libc/net/hesiod.c == --- stable/8/lib/libc/net/hesiod.c Sat Jan 15 08:18:58 2011 (r217439) +++ stable/8/lib/libc/net/hesiod.c Sat Jan 15 08:35:41 2011 (r217440) @@ -324,6 +324,7 @@ read_config_file(ctx, filename) ? &ctx->lhs : &ctx->rhs; *which = strdup(data); if (!*which) { + fclose(fp); errno = ENOMEM; return -1; } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217441 - stable/8/lib/libc/stdlib
Author: kib Date: Sat Jan 15 08:37:33 2011 New Revision: 217441 URL: http://svn.freebsd.org/changeset/base/217441 Log: MFC r217144: Fix some style(9) issues. Do not use strlcpy() where simple assignment is enough. Modified: stable/8/lib/libc/stdlib/realpath.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/locale/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) Modified: stable/8/lib/libc/stdlib/realpath.c == --- stable/8/lib/libc/stdlib/realpath.c Sat Jan 15 08:35:41 2011 (r217440) +++ stable/8/lib/libc/stdlib/realpath.c Sat Jan 15 08:37:33 2011 (r217441) @@ -54,7 +54,7 @@ realpath(const char * __restrict path, c char *p, *q, *s; size_t left_len, resolved_len; unsigned symlinks; - int serrno, slen, m; + int m, serrno, slen; char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX]; if (path == NULL) { @@ -73,7 +73,6 @@ realpath(const char * __restrict path, c m = 1; } else m = 0; - symlinks = 0; if (path[0] == '/') { resolved[0] = '/'; @@ -86,8 +85,10 @@ realpath(const char * __restrict path, c if (getcwd(resolved, PATH_MAX) == NULL) { if (m) free(resolved); - else - strlcpy(resolved, ".", PATH_MAX); + else { + resolved[0] = '.'; + resolved[1] = '\0'; + } return (NULL); } resolved_len = strlen(resolved); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r217369 - in head/sys: cam/scsi sys
On Fri, Jan 14, 2011 at 10:27 PM, Bruce Evans wrote: > On Fri, 14 Jan 2011, Garrett Cooper wrote: > >> On Fri, Jan 14, 2011 at 6:42 PM, Bruce Evans wrote: >>> >>> On Fri, 14 Jan 2011 m...@freebsd.org wrote: >>> On Thu, Jan 13, 2011 at 10:50 PM, Bruce Evans wrote: > > On Thu, 13 Jan 2011 m...@freebsd.org wrote: > >> There appear to be 330 uses of SYSCTL and QUAD on the same line in >> CURRENT. This seems reasonable to change them to S64, U64 and X64 so >> they correctly reflect the size they operate upon. >> >> What do y'all think? > > Now I suggest delaying this until they can be renamed to a type- > generic > SYSCTL_INT() (would probably need to be spelled differently, SYSCTL_I() > say, even if SYSCTL_INT() was changed at the same time). I'm torn on this one. The compiler knows the type (unless, for SYSCTL_INT, NULL/0 is used, but that is also a compile-time check), but to interpret it requires the use of __builtin_foo which is a gcc extension and not part of standard C. Philosophically, while I like this kind of letting the compiler do the work, if you want C++ you know where to find it. >>> >>> Oops. I think sizeof() and issigned() can be used to determine the type >>> well enough in functions and initialized data (do a fuller type check if >>> the compiler supports it), but I don't know how to do this in static >>> sysctl declarations (since sizeof() can't be used in cpp expressions). >> >> Why not just create some dumb testcases that can be run at build >> time to determine that for you? > > Well, how? You are given SYSCTL_I(&var, ...) and have to convert this > to what is now in SYSCTL_INT(), using only the type of var, in hundreds > or thousands of files. I don't even know how to do this with a test > case for each file, short of parsing all the files. Oops, I do know > how to translate from sizeof(var) to CTLTYPE_INT or CTLTYPE_UINT. > That's just (sizeof(var) == sizeof(int) ? CTLTYPE_INT : ...). The > signness is harder (might need gnu typeof(), but not the recent type > checking attributes). This won't convert from SYSCTL_I() existing > SYSCTL_INT() (the switch on the size would have to be in an ifdef for > that, but sizeof() doesn't work in ifdefs), but it works for generating > CTLTYPE_* internally SYSCTL_I(). The difficulty is converting from a > bare variable `var' to an integer representing the signedness of its > type, without using an unportability like typeof(). With typeof(), this > is: > > /* Only works for arithmetic types: */ > #define isinteger(var) ((typeof(var))0.1 == 0) > #define issigned(var) ((typeof(var))-1 < 0) > ... This is what I meant: $ cat test_warnings.c #include size_t x = (int) -1; int y = 200L; $ gcc -Wconversion -Wstrict-overflow -Wsign-compare -c test_warnings.c test_size_t.c:3: warning: negative integer implicitly converted to unsigned type test_size_t.c:4: warning: overflow in implicit constant conversion $ With the right CFLAGS and a few properly written tests, and a few make rules, you can figure out what's what pretty easily *shrugs*. Thanks, -Garrett ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217442 - stable/8/sys/kern
Author: kib Date: Sat Jan 15 09:25:19 2011 New Revision: 217442 URL: http://svn.freebsd.org/changeset/base/217442 Log: MFC r217150: Collect code to translate between vm_prot_t and p_flags into helper functions. Modified: stable/8/sys/kern/imgact_elf.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/imgact_elf.c == --- stable/8/sys/kern/imgact_elf.c Sat Jan 15 08:37:33 2011 (r217441) +++ stable/8/sys/kern/imgact_elf.c Sat Jan 15 09:25:19 2011 (r217442) @@ -86,6 +86,8 @@ static boolean_t __elfN(freebsd_trans_os static boolean_t kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel); static boolean_t __elfN(check_note)(struct image_params *imgp, Elf_Brandnote *checknote, int32_t *osrel); +static vm_prot_t __elfN(trans_prot)(Elf_Word); +static Elf_Word __elfN(untrans_prot)(vm_prot_t); SYSCTL_NODE(_kern, OID_AUTO, __CONCAT(elf, __ELF_WORD_SIZE), CTLFLAG_RW, 0, ""); @@ -632,14 +634,7 @@ __elfN(load_file)(struct proc *p, const for (i = 0, numsegs = 0; i < hdr->e_phnum; i++) { if (phdr[i].p_type == PT_LOAD && phdr[i].p_memsz != 0) { /* Loadable segment */ - prot = 0; - if (phdr[i].p_flags & PF_X) - prot |= VM_PROT_EXECUTE; - if (phdr[i].p_flags & PF_W) - prot |= VM_PROT_WRITE; - if (phdr[i].p_flags & PF_R) - prot |= VM_PROT_READ; - + prot = __elfN(trans_prot)(phdr[i].p_flags); if ((error = __elfN(load_section)(vmspace, imgp->object, phdr[i].p_offset, (caddr_t)(uintptr_t)phdr[i].p_vaddr + rbase, @@ -780,13 +775,7 @@ __CONCAT(exec_, __elfN(imgact))(struct i case PT_LOAD: /* Loadable segment */ if (phdr[i].p_memsz == 0) break; - prot = 0; - if (phdr[i].p_flags & PF_X) - prot |= VM_PROT_EXECUTE; - if (phdr[i].p_flags & PF_W) - prot |= VM_PROT_WRITE; - if (phdr[i].p_flags & PF_R) - prot |= VM_PROT_READ; + prot = __elfN(trans_prot)(phdr[i].p_flags); #if defined(__ia64__) && __ELF_WORD_SIZE == 32 && defined(IA32_ME_HARDER) /* @@ -1086,13 +1075,7 @@ cb_put_phdr(entry, closure) phdr->p_paddr = 0; phdr->p_filesz = phdr->p_memsz = entry->end - entry->start; phdr->p_align = PAGE_SIZE; - phdr->p_flags = 0; - if (entry->protection & VM_PROT_READ) - phdr->p_flags |= PF_R; - if (entry->protection & VM_PROT_WRITE) - phdr->p_flags |= PF_W; - if (entry->protection & VM_PROT_EXECUTE) - phdr->p_flags |= PF_X; + phdr->p_flags = __elfN(untrans_prot)(entry->protection); phc->offset += phdr->p_filesz; phc->phdr++; @@ -1483,3 +1466,33 @@ static struct execsw __elfN(execsw) = { __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) }; EXEC_SET(__CONCAT(elf, __ELF_WORD_SIZE), __elfN(execsw)); + +static vm_prot_t +__elfN(trans_prot)(Elf_Word flags) +{ + vm_prot_t prot; + + prot = 0; + if (flags & PF_X) + prot |= VM_PROT_EXECUTE; + if (flags & PF_W) + prot |= VM_PROT_WRITE; + if (flags & PF_R) + prot |= VM_PROT_READ; + return (prot); +} + +static Elf_Word +__elfN(untrans_prot)(vm_prot_t prot) +{ + Elf_Word flags; + + flags = 0; + if (prot & VM_PROT_EXECUTE) + flags |= PF_X; + if (prot & VM_PROT_READ) + flags |= PF_R; + if (prot & VM_PROT_WRITE) + flags |= PF_W; + return (flags); +} ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217443 - stable/7/sys/geom
Author: jh Date: Sat Jan 15 09:36:31 2011 New Revision: 217443 URL: http://svn.freebsd.org/changeset/base/217443 Log: MFC r214748: Extend the g_eventlock mutex coverage in one_event() to include setting of the EV_DONE flag and use the mutex to protect against losing wakeups in g_waitfor_event(). Modified: stable/7/sys/geom/geom_event.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/geom/geom_event.c == --- stable/7/sys/geom/geom_event.c Sat Jan 15 09:25:19 2011 (r217442) +++ stable/7/sys/geom/geom_event.c Sat Jan 15 09:36:31 2011 (r217443) @@ -212,11 +212,12 @@ one_event(void) g_topology_assert(); mtx_lock(&g_eventlock); TAILQ_REMOVE(&g_events, ep, events); - mtx_unlock(&g_eventlock); if (ep->flag & EV_WAKEUP) { ep->flag |= EV_DONE; + mtx_unlock(&g_eventlock); wakeup(ep); } else { + mtx_unlock(&g_eventlock); g_free(ep); } g_topology_unlock(); @@ -355,11 +356,14 @@ g_waitfor_event(g_event_t *func, void *a va_end(ap); if (error) return (error); - do - tsleep(ep, PRIBIO, "g_waitfor_event", hz); - while (!(ep->flag & EV_DONE)); + + mtx_lock(&g_eventlock); + while (!(ep->flag & EV_DONE)) + msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", hz); if (ep->flag & EV_CANCELED) error = EAGAIN; + mtx_unlock(&g_eventlock); + g_free(ep); return (error); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217444 - head/sys/cam/ata
Author: mav Date: Sat Jan 15 09:43:25 2011 New Revision: 217444 URL: http://svn.freebsd.org/changeset/base/217444 Log: Some old WD SATA disks report supported and enabled device-initiated interface power management, but return ABORT error on attempt to disable it. Make CAM SATA probe sequence ignore this error, as it is not fatal. Modified: head/sys/cam/ata/ata_xpt.c Modified: head/sys/cam/ata/ata_xpt.c == --- head/sys/cam/ata/ata_xpt.c Sat Jan 15 09:36:31 2011(r217443) +++ head/sys/cam/ata/ata_xpt.c Sat Jan 15 09:43:25 2011(r217444) @@ -727,6 +727,7 @@ probedone(struct cam_periph *periph, uni struct ata_params *ident_buf; probe_softc *softc; struct cam_path *path; + cam_status status; u_int32_t priority; u_int caps; int found = 1; @@ -751,6 +752,7 @@ probedone(struct cam_periph *periph, uni xpt_release_devq(done_ccb->ccb_h.path, /*count*/1, /*run_queue*/TRUE); } + status = done_ccb->ccb_h.status & CAM_STATUS_MASK; if (softc->restart) { softc->faults++; if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == @@ -760,12 +762,24 @@ probedone(struct cam_periph *periph, uni goto done; else softc->restart = 0; - } else + /* Old PIO2 devices may not support mode setting. */ - if (softc->action == PROBE_SETMODE && + } else if (softc->action == PROBE_SETMODE && + status == CAM_ATA_STATUS_ERROR && ata_max_pmode(ident_buf) <= ATA_PIO2 && - (ident_buf->capabilities1 & ATA_SUPPORT_IORDY) == 0) + (ident_buf->capabilities1 & ATA_SUPPORT_IORDY) == 0) { + goto noerror; + + /* +* Some old WD SATA disks report supported and enabled +* device-initiated interface power management, but return +* ABORT on attempt to disable it. +*/ + } else if (softc->action == PROBE_SETPM && + status == CAM_ATA_STATUS_ERROR) { goto noerror; + } + /* * If we get to this point, we got an error status back * from the inquiry and the error status doesn't require ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r217369 - in head/sys: cam/scsi sys
On Sat, 15 Jan 2011, Garrett Cooper wrote: On Fri, Jan 14, 2011 at 10:27 PM, Bruce Evans wrote: On Fri, 14 Jan 2011, Garrett Cooper wrote: On Fri, Jan 14, 2011 at 6:42 PM, Bruce Evans wrote: ... Oops. ?I think sizeof() and issigned() can be used to determine the type well enough in functions and initialized data (do a fuller type check if the compiler supports it), but I don't know how to do this in static sysctl declarations (since sizeof() can't be used in cpp expressions). ? Why not just create some dumb testcases that can be run at build time to determine that for you? Well, how? ?You are given SYSCTL_I(&var, ...) and have to convert this to what is now in SYSCTL_INT(), using only the type of var, in hundreds or thousands of files. ?I don't even know how to do this with a test ... ? ? ? ?/* Only works for arithmetic types: */ ? ? ? ?#define isinteger(var) ?((typeof(var))0.1 == 0) ? ? ? ?#define issigned(var) ? ((typeof(var))-1 < 0) ? ? ? ?... This is what I meant: $ cat test_warnings.c #include size_t x = (int) -1; int y = 200L; $ gcc -Wconversion -Wstrict-overflow -Wsign-compare -c test_warnings.c test_size_t.c:3: warning: negative integer implicitly converted to unsigned type test_size_t.c:4: warning: overflow in implicit constant conversion $ With the right CFLAGS and a few properly written tests, and a few make rules, you can figure out what's what pretty easily *shrugs*. That's a lot more parsing than seems reasonable. Anyway, we already depend on gnu __typeof() being avaible for the much more central API of pcpu. All pcpu accesses on amd64 and i386 use it, except curthread (curthread has been hacked to use a more direct asm for compile-time efficiency). SYSCTL_I() works even better that I first thought. It automatically gives support for all typedefed integral types. No SYSCTL_FOO_T()s with messy MD ifdefs for matching up foo_t with an integral type are needed. Instead there are even messier MI ifdefs in SYSCTL_I() :-). But not so many. There are hundreds of typedefed types of interest, but only 8 different integer types to map to (8/16/32/64 bits signed and unsigned). The complication that int64_t is plain long on 64 bit arches but long long on 32-bit arches still arises. CTLTYPE_QUAD can be associated with int64_t on all arches, but the format for printing these is arch-dependent. (Note that quad_t's cannot be printed using %qd, and %qd is unusable, since %qd is just an alias for %lld, while quad_t is an alias for int64_t and int64_t is plain long on 64-bit arches so its format is %ld on these arches and %lld on others.) Bruce___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r217369 - in head/sys: cam/scsi sys
On Sat, Jan 15, 2011 at 6:55 AM, Bruce Evans wrote: > On Sat, 15 Jan 2011, Garrett Cooper wrote: > >> On Fri, Jan 14, 2011 at 10:27 PM, Bruce Evans >> wrote: >>> >>> On Fri, 14 Jan 2011, Garrett Cooper wrote: >>> On Fri, Jan 14, 2011 at 6:42 PM, Bruce Evans wrote: > > ... > Oops. I think sizeof() and issigned() can be used to determine the > type > well enough in functions and initialized data (do a fuller type check > if > the compiler supports it), but I don't know how to do this in static > sysctl declarations (since sizeof() can't be used in cpp expressions). Why not just create some dumb testcases that can be run at build time to determine that for you? >>> >>> Well, how? You are given SYSCTL_I(&var, ...) and have to convert this >>> to what is now in SYSCTL_INT(), using only the type of var, in hundreds >>> or thousands of files. I don't even know how to do this with a test >>> ... >>> >>> /* Only works for arithmetic types: */ >>> #define isinteger(var) ((typeof(var))0.1 == 0) >>> #define issigned(var) ((typeof(var))-1 < 0) >>> ... >> >> This is what I meant: >> >> $ cat test_warnings.c >> #include >> >> size_t x = (int) -1; >> int y = 200L; >> $ gcc -Wconversion -Wstrict-overflow -Wsign-compare -c test_warnings.c >> test_size_t.c:3: warning: negative integer implicitly converted to >> unsigned type >> test_size_t.c:4: warning: overflow in implicit constant conversion >> $ >> >> With the right CFLAGS and a few properly written tests, and a few >> make rules, you can figure out what's what pretty easily *shrugs*. > > That's a lot more parsing than seems reasonable. > > Anyway, we already depend on gnu __typeof() being avaible for the much > more central API of pcpu. All pcpu accesses on amd64 and i386 use it, > except curthread (curthread has been hacked to use a more direct asm > for compile-time efficiency). > > SYSCTL_I() works even better that I first thought. It automatically > gives support for all typedefed integral types. No SYSCTL_FOO_T()s > with messy MD ifdefs for matching up foo_t with an integral type are > needed. Instead there are even messier MI ifdefs in SYSCTL_I() :-). > But not so many. There are hundreds of typedefed types of interest, > but only 8 different integer types to map to (8/16/32/64 bits signed > and unsigned). The complication that int64_t is plain long on 64 > bit arches but long long on 32-bit arches still arises. CTLTYPE_QUAD > can be associated with int64_t on all arches, but the format for printing > these is arch-dependent. (Note that quad_t's cannot be printed using > %qd, and %qd is unusable, since %qd is just an alias for %lld, while > quad_t is an alias for int64_t and int64_t is plain long on 64-bit > arches so its format is %ld on these arches and %lld on others.) The printing is done entirely in user-space, so it's not too bad. I had figured to upcast everything to [u]intmax_t anyways, and what to cast from would just be [u]int32_t and [u]int64_t depending on reported size. Anything smaller should be copyout(9)'d as a 4 bit quantity. But, there's two factors at play here. The first is sysctl(8) which asks for the size when reading and manages it. The second is sysctl(2) where we have code like SCTL_MASK32 so a long on a 64-bit kernel looks like a long to a 32-bit app. It would be simpler to expose this as an 8-byte quantity on 64-bit kernel, and sysctl(8) will deal with this just fine, but that would break some uses of sysctl(2). However, I *think* it is safe to check the sysctl_req's oldidx/oldlen to see what size the user-space expects and cast a kernel long to int before SYSCTL_OUT. $WORK has gotten busy so I haven't had a chance to work on this much but I'm hopeful that the missus will watch the kids this weekend and allow me to hack. Thanks, matthew ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217445 - stable/8/sys/net
Author: rwatson Date: Sat Jan 15 18:41:42 2011 New Revision: 217445 URL: http://svn.freebsd.org/changeset/base/217445 Log: Merge r204199 from head to stable/8: Export netisr configuration and statistics to userspace via sysctl(9). Sponsored by: Juniper Networks Modified: stable/8/sys/net/netisr.c stable/8/sys/net/netisr.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c == --- stable/8/sys/net/netisr.c Sat Jan 15 09:43:25 2011(r217444) +++ stable/8/sys/net/netisr.c Sat Jan 15 18:41:42 2011(r217445) @@ -1,7 +1,11 @@ /*- * Copyright (c) 2007-2009 Robert N. M. Watson + * Copyright (c) 2010 Juniper Networks, Inc. * All rights reserved. * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -1118,6 +1122,170 @@ netisr_start(void *arg) } SYSINIT(netisr_start, SI_SUB_SMP, SI_ORDER_MIDDLE, netisr_start, NULL); +/* + * Sysctl monitoring for netisr: query a list of registered protocols. + */ +static int +sysctl_netisr_proto(SYSCTL_HANDLER_ARGS) +{ + struct rm_priotracker tracker; + struct sysctl_netisr_proto *snpp, *snp_array; + struct netisr_proto *npp; + u_int counter, proto; + int error; + + if (req->newptr != NULL) + return (EINVAL); + snp_array = malloc(sizeof(*snp_array) * NETISR_MAXPROT, M_TEMP, + M_ZERO | M_WAITOK); + counter = 0; + NETISR_RLOCK(&tracker); + for (proto = 0; proto < NETISR_MAXPROT; proto++) { + npp = &np[proto]; + if (npp->np_name == NULL) + continue; + snpp = &snp_array[counter]; + snpp->snp_version = sizeof(*snpp); + strlcpy(snpp->snp_name, npp->np_name, NETISR_NAMEMAXLEN); + snpp->snp_proto = proto; + snpp->snp_qlimit = npp->np_qlimit; + snpp->snp_policy = npp->np_policy; + if (npp->np_m2flow != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_M2FLOW; + if (npp->np_m2cpuid != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_M2CPUID; + if (npp->np_drainedcpu != NULL) + snpp->snp_flags |= NETISR_SNP_FLAGS_DRAINEDCPU; + counter++; + } + NETISR_RUNLOCK(&tracker); + KASSERT(counter < NETISR_MAXPROT, + ("sysctl_netisr_proto: counter too big (%d)", counter)); + error = SYSCTL_OUT(req, snp_array, sizeof(*snp_array) * counter); + free(snp_array, M_TEMP); + return (error); +} + +SYSCTL_PROC(_net_isr, OID_AUTO, proto, +CTLFLAG_RD|CTLTYPE_STRUCT|CTLFLAG_MPSAFE, 0, 0, sysctl_netisr_proto, +"S,sysctl_netisr_proto", +"Return list of protocols registered with netisr"); + +/* + * Sysctl monitoring for netisr: query a list of workstreams. + */ +static int +sysctl_netisr_workstream(SYSCTL_HANDLER_ARGS) +{ + struct rm_priotracker tracker; + struct sysctl_netisr_workstream *snwsp, *snws_array; + struct netisr_workstream *nwsp; + u_int counter, cpuid; + int error; + + if (req->newptr != NULL) + return (EINVAL); + snws_array = malloc(sizeof(*snws_array) * MAXCPU, M_TEMP, + M_ZERO | M_WAITOK); + counter = 0; + NETISR_RLOCK(&tracker); + for (cpuid = 0; cpuid < MAXCPU; cpuid++) { + if (CPU_ABSENT(cpuid)) + continue; + nwsp = DPCPU_ID_PTR(cpuid, nws); + if (nwsp->nws_intr_event == NULL) + continue; + NWS_LOCK(nwsp); + snwsp = &snws_array[counter]; + snwsp->snws_version = sizeof(*snwsp); + + /* +* For now, we equate workstream IDs and CPU IDs in the +* kernel, but expose them independently to userspace in case +* that assumption changes in the future. +*/ + snwsp->snws_wsid = cpuid; + snwsp->snws_cpu = cpuid; + if (nwsp->nws_intr_event != NULL) + snwsp->snws_flags |= NETISR_SNWS_FLAGS_INTR; + NWS_UNLOCK(nwsp); + counter++; + } + NETISR_RUNLOCK(&tracker); + KASSERT(counter < MAXCPU, + ("sysctl_netisr_workstream: counter too big (%d)", counter)); + error = SYSCTL_OUT(req, snws_array, sizeof(*snws_array) * counter); + free(snws_array, M_TEMP);
svn commit: r217446 - stable/8/usr.bin/netstat
Author: rwatson Date: Sat Jan 15 18:51:45 2011 New Revision: 217446 URL: http://svn.freebsd.org/changeset/base/217446 Log: Merge r204202 from head to stable/8: Teach netstat(1) to print out netisr statistics when given the -Q argument. Currently supports only reporting on live systems via sysctl, kmem support needs to be edded. Sponsored by: Juniper Networks Added: stable/8/usr.bin/netstat/netisr.c - copied unchanged from r204202, head/usr.bin/netstat/netisr.c Modified: stable/8/usr.bin/netstat/Makefile stable/8/usr.bin/netstat/main.c stable/8/usr.bin/netstat/netstat.1 stable/8/usr.bin/netstat/netstat.h Directory Properties: stable/8/usr.bin/netstat/ (props changed) Modified: stable/8/usr.bin/netstat/Makefile == --- stable/8/usr.bin/netstat/Makefile Sat Jan 15 18:41:42 2011 (r217445) +++ stable/8/usr.bin/netstat/Makefile Sat Jan 15 18:51:45 2011 (r217446) @@ -4,7 +4,7 @@ .include PROG= netstat -SRCS= if.c inet.c main.c mbuf.c mroute.c route.c \ +SRCS= if.c inet.c main.c mbuf.c mroute.c netisr.c route.c \ unix.c atalk.c mroute6.c ipsec.c bpf.c pfkey.c sctp.c WARNS?=3 Modified: stable/8/usr.bin/netstat/main.c == --- stable/8/usr.bin/netstat/main.c Sat Jan 15 18:41:42 2011 (r217445) +++ stable/8/usr.bin/netstat/main.c Sat Jan 15 18:51:45 2011 (r217446) @@ -336,6 +336,7 @@ int noutputs = 0; /* how much outputs be intnumeric_addr; /* show addresses numerically */ intnumeric_port; /* show ports numerically */ static int pflag; /* show given protocol */ +intQflag; /* show netisr information */ intrflag; /* show routing tables (or routing stats) */ intsflag; /* show protocol statistics */ inttflag; /* show i/f watchdog timers */ @@ -447,6 +448,9 @@ main(int argc, char *argv[]) } pflag = 1; break; + case 'Q': + Qflag = 1; + break; case 'q': noutputs = atoi(optarg); if (noutputs != 0) @@ -534,6 +538,12 @@ main(int argc, char *argv[]) mbpr(NULL, 0); exit(0); } + if (Qflag) { + if (!live) + usage(); + netisr_stats(); + exit(0); + } #if 0 /* * Keep file descriptors open to avoid overhead @@ -789,7 +799,7 @@ name2protox(const char *name) static void usage(void) { - (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", + (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", "usage: netstat [-AaLnSTWx] [-f protocol_family | -p protocol]\n" " [-M core] [-N system]", " netstat -i | -I interface [-abdhntW] [-f address_family]\n" @@ -804,6 +814,7 @@ usage(void) " netstat -r [-AanW] [-f address_family] [-M core] [-N system]", " netstat -rs [-s] [-M core] [-N system]", " netstat -g [-W] [-f address_family] [-M core] [-N system]", -" netstat -gs [-s] [-f address_family] [-M core] [-N system]"); +" netstat -gs [-s] [-f address_family] [-M core] [-N system]", +" netstat -Q"); exit(1); } Copied: stable/8/usr.bin/netstat/netisr.c (from r204202, head/usr.bin/netstat/netisr.c) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/usr.bin/netstat/netisr.c Sat Jan 15 18:51:45 2011 (r217446, copy of r204202, head/usr.bin/netstat/netisr.c) @@ -0,0 +1,268 @@ +/*- + * Copyright (c) 2010 Juniper Networks, Inc. + * All rights reserved. + * + * This software was developed by Robert N. M. Watson under contract + * to Juniper Networks, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + *
svn commit: r217447 - stable/8/share/man/man9
Author: rwatson Date: Sat Jan 15 18:56:51 2011 New Revision: 217447 URL: http://svn.freebsd.org/changeset/base/217447 Log: Merge r204206 from head to stable/8: Cross-reference netstat(1) from netisr(9) since you can now use it to monitor netisr status. Sponsored by: Juniper Networks Modified: stable/8/share/man/man9/netisr.9 Directory Properties: stable/8/share/man/man9/ (props changed) Modified: stable/8/share/man/man9/netisr.9 == --- stable/8/share/man/man9/netisr.9Sat Jan 15 18:51:45 2011 (r217446) +++ stable/8/share/man/man9/netisr.9Sat Jan 15 18:56:51 2011 (r217447) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 26, 2009 +.Dd February 22, 2010 .Dt NETISR 9 .Os .Sh NAME @@ -66,6 +66,8 @@ The .Nm kernel interface suite allows device drivers (and other packet sources) to direct packets to protocols for directly dispatched or deferred processing. +Protocol registration and work stream statistics may be monitored using +.Xr netstat 1 . .Ss Protocol registration Protocols register and unregister handlers using .Fn netisr_register @@ -209,6 +211,7 @@ IPv6 .It Dv NETISR_NATM ATM .It Dv NETISR_EPAIR +.Xr netstat 1 , .Xr epair 4 .El .Sh AUTHORS ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217448 - stable/8/usr.bin/netstat
Author: rwatson Date: Sat Jan 15 19:00:22 2011 New Revision: 217448 URL: http://svn.freebsd.org/changeset/base/217448 Log: Merge mergeinfo only for r204207 from head to stable/8; the edit itself was apparently merged as part of a separate change: Update date on netstat(1) for -Q. Suggested by: bz Modified: Directory Properties: stable/8/usr.bin/netstat/ (props changed) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217449 - stable/8/sys/net
Author: rwatson Date: Sat Jan 15 19:02:08 2011 New Revision: 217449 URL: http://svn.freebsd.org/changeset/base/217449 Log: Merge r204208 from head to stable/8: Fix constant assignment for netisr protocol information sysctl. Spotted by: bz Modified: stable/8/sys/net/netisr.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.h == --- stable/8/sys/net/netisr.h Sat Jan 15 19:00:22 2011(r217448) +++ stable/8/sys/net/netisr.h Sat Jan 15 19:02:08 2011(r217449) @@ -92,7 +92,7 @@ struct sysctl_netisr_proto { */ #defineNETISR_SNP_FLAGS_M2FLOW 0x0001 /* nh_m2flow */ #defineNETISR_SNP_FLAGS_M2CPUID0x0002 /* nh_m2cpuid */ -#defineNETISR_SNP_FLAGS_DRAINEDCPU 0x0003 /* nh_drainedcpu */ +#defineNETISR_SNP_FLAGS_DRAINEDCPU 0x0004 /* nh_drainedcpu */ /* * Next, a structure per-workstream, with per-protocol data, exported as ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217450 - stable/8/sys/net
Author: rwatson Date: Sat Jan 15 19:05:06 2011 New Revision: 217450 URL: http://svn.freebsd.org/changeset/base/217450 Log: Merge r204303 from head to stable/8: Fix edge cases in several KASSERTs: use <= rather than < when testing that counters have not gone about MAXCPU or NETISR_MAXPROT. These problems caused panics on UP kernels with INVARIANTS when using sysctl -a, but would also have caused problems for 32-core boxes or if the netisr protocol vector was fully populated. Reported by:nwhitehorn, Neel Natu Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c == --- stable/8/sys/net/netisr.c Sat Jan 15 19:02:08 2011(r217449) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:05:06 2011(r217450) @@ -1159,7 +1159,7 @@ sysctl_netisr_proto(SYSCTL_HANDLER_ARGS) counter++; } NETISR_RUNLOCK(&tracker); - KASSERT(counter < NETISR_MAXPROT, + KASSERT(counter <= NETISR_MAXPROT, ("sysctl_netisr_proto: counter too big (%d)", counter)); error = SYSCTL_OUT(req, snp_array, sizeof(*snp_array) * counter); free(snp_array, M_TEMP); @@ -1212,7 +1212,7 @@ sysctl_netisr_workstream(SYSCTL_HANDLER_ counter++; } NETISR_RUNLOCK(&tracker); - KASSERT(counter < MAXCPU, + KASSERT(counter <= MAXCPU, ("sysctl_netisr_workstream: counter too big (%d)", counter)); error = SYSCTL_OUT(req, snws_array, sizeof(*snws_array) * counter); free(snws_array, M_TEMP); @@ -1273,7 +1273,7 @@ sysctl_netisr_work(SYSCTL_HANDLER_ARGS) } NWS_UNLOCK(nwsp); } - KASSERT(counter < MAXCPU * NETISR_MAXPROT, + KASSERT(counter <= MAXCPU * NETISR_MAXPROT, ("sysctl_netisr_work: counter too big (%d)", counter)); NETISR_RUNLOCK(&tracker); error = SYSCTL_OUT(req, snw_array, sizeof(*snw_array) * counter); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217451 - head/sys/powerpc/aim
Author: andreast Date: Sat Jan 15 19:16:05 2011 New Revision: 217451 URL: http://svn.freebsd.org/changeset/base/217451 Log: Remove unused variables. Spotted by a cppcheck (devel/cppcheck, http://sourceforge.net/projects/cppcheck) run. Approved by: nwhitehorn (mentor) Modified: head/sys/powerpc/aim/slb.c Modified: head/sys/powerpc/aim/slb.c == --- head/sys/powerpc/aim/slb.c Sat Jan 15 19:05:06 2011(r217450) +++ head/sys/powerpc/aim/slb.c Sat Jan 15 19:16:05 2011(r217451) @@ -200,9 +200,7 @@ make_intermediate(uint64_t esid, struct uint64_t kernel_va_to_slbv(vm_offset_t va) { - uint64_t esid, slbv; - - esid = (uintptr_t)va >> ADDR_SR_SHFT; + uint64_t slbv; /* Set kernel VSID to deterministic value */ slbv = (KERNEL_VSID((uintptr_t)va >> ADDR_SR_SHFT)) << SLBV_VSID_SHIFT; @@ -485,18 +483,11 @@ slb_uma_real_alloc(uma_zone_t zone, int static vm_offset_t realmax = 0; void *va; vm_page_t m; - int pflags; if (realmax == 0) realmax = platform_real_maxaddr(); *flags = UMA_SLAB_PRIV; - if ((wait & (M_NOWAIT|M_USE_RESERVE)) == M_NOWAIT) - pflags = VM_ALLOC_INTERRUPT | VM_ALLOC_WIRED; - else - pflags = VM_ALLOC_SYSTEM | VM_ALLOC_WIRED; - if (wait & M_ZERO) - pflags |= VM_ALLOC_ZERO; for (;;) { m = vm_phys_alloc_contig(1, 0, realmax, PAGE_SIZE, ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217452 - head/sys/dev/iicbus
Author: andreast Date: Sat Jan 15 19:16:56 2011 New Revision: 217452 URL: http://svn.freebsd.org/changeset/base/217452 Log: Remove unused variable. Spotted by a cppcheck (devel/cppcheck, http://sourceforge.net/projects/cppcheck) run. Approved by: nwhitehorn (mentor) Modified: head/sys/dev/iicbus/max6690.c Modified: head/sys/dev/iicbus/max6690.c == --- head/sys/dev/iicbus/max6690.c Sat Jan 15 19:16:05 2011 (r217451) +++ head/sys/dev/iicbus/max6690.c Sat Jan 15 19:16:56 2011 (r217452) @@ -209,7 +209,6 @@ max6690_attach(device_t dev) static void max6690_start(void *xdev) { - phandle_t child; struct max6690_softc *sc; struct sysctl_oid *oid, *sensroot_oid; struct sysctl_ctx_list *ctx; @@ -222,8 +221,6 @@ max6690_start(void *xdev) sc->sc_nsensors = 0; - child = ofw_bus_get_node(dev); - /* Count the actual number of sensors. */ sc->sc_nsensors = max6690_fill_sensor_prop(dev); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217453 - head/sys/vm
Author: alc Date: Sat Jan 15 19:21:28 2011 New Revision: 217453 URL: http://svn.freebsd.org/changeset/base/217453 Log: For some time now, the kernel and kmem objects have been ordinary OBJT_PHYS objects. Thus, there is no need for handling them specially in vm_fault(). In fact, this special case handling would have led to an assertion failure just before the call to pmap_enter(). Reviewed by: kib@ MFC after:6 weeks Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c == --- head/sys/vm/vm_fault.c Sat Jan 15 19:16:56 2011(r217452) +++ head/sys/vm/vm_fault.c Sat Jan 15 19:21:28 2011(r217453) @@ -383,11 +383,8 @@ RetryFault:; * found the page ). */ vm_page_busy(fs.m); - if (fs.m->valid != VM_PAGE_BITS_ALL && - fs.m->object != kernel_object && fs.m->object != kmem_object) { + if (fs.m->valid != VM_PAGE_BITS_ALL) goto readrest; - } - break; } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217454 - stable/8/lib/libkvm
Author: rwatson Date: Sat Jan 15 19:23:14 2011 New Revision: 217454 URL: http://svn.freebsd.org/changeset/base/217454 Log: Merge r204494, r204511 from head to stable/8: A first cut at teaching libkvm how to deal with dynamic per-CPU storage (DPCPU): A new API, kvm_dpcpu_setcpu(3), selects the active CPU for the purposes of DPCPU. Calls to kvm_nlist(3) will automatically translate DPCPU symbols and return a pointer to the current CPU's version of the data. Consumers needing to read the same symbol on several CPUs will invoke a series of setcpu/nlist calls, one per CPU of interest. This addition makes it possible for tools like netstat(1) to query the values of DPCPU variables during crashdump analysis, and is based on similar code handling virtualized global variables. Sponsored by: Juniper Networks, Inc. Not all programs including kvm.h include the necessary headers to use u_int, so prefer unsigned int. Pointed out by: bz, kib, Mr Tinderbox Modified: stable/8/lib/libkvm/Makefile stable/8/lib/libkvm/kvm.c stable/8/lib/libkvm/kvm.h stable/8/lib/libkvm/kvm_getpcpu.3 stable/8/lib/libkvm/kvm_pcpu.c stable/8/lib/libkvm/kvm_private.h Directory Properties: stable/8/lib/libkvm/ (props changed) Modified: stable/8/lib/libkvm/Makefile == --- stable/8/lib/libkvm/MakefileSat Jan 15 19:21:28 2011 (r217453) +++ stable/8/lib/libkvm/MakefileSat Jan 15 19:23:14 2011 (r217454) @@ -21,6 +21,7 @@ MAN= kvm.3 kvm_getcptime.3 kvm_geterr.3 kvm_read.3 MLINKS+=kvm_getpcpu.3 kvm_getmaxcpu.3 +MLINKS+=kvm_getpcpu.3 kvm_dpcpu_setcpu.3 MLINKS+=kvm_getprocs.3 kvm_getargv.3 kvm_getprocs.3 kvm_getenvv.3 MLINKS+=kvm_open.3 kvm_close.3 kvm_open.3 kvm_openfiles.3 MLINKS+=kvm_read.3 kvm_write.3 Modified: stable/8/lib/libkvm/kvm.c == --- stable/8/lib/libkvm/kvm.c Sat Jan 15 19:21:28 2011(r217453) +++ stable/8/lib/libkvm/kvm.c Sat Jan 15 19:23:14 2011(r217454) @@ -416,6 +416,8 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, struct kld_sym_lookup lookup; int error; char *prefix = "", symname[1024]; /* XXX-BZ symbol name length limit? */ + int tried_vnet, tried_dpcpu; + /* * If we can't use the kld symbol lookup, revert to the * slow library call. @@ -429,6 +431,10 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, error = kvm_fdnlist_prefix(kd, nl, error, VNET_SYMPREFIX, _kvm_vnet_validaddr); + if (error > 0 && _kvm_dpcpu_initialized(kd, initialize)) + error = kvm_fdnlist_prefix(kd, nl, error, + "pcpu_entry_", _kvm_dpcpu_validaddr); + return (error); } @@ -437,6 +443,8 @@ _kvm_nlist(kvm_t *kd, struct nlist *nl, * and look it up with a kldsym(2) syscall. */ nvalid = 0; + tried_vnet = 0; + tried_dpcpu = 0; again: for (p = nl; p->n_name && p->n_name[0]; ++p) { if (p->n_type != N_UNDF) @@ -464,6 +472,10 @@ again: !strcmp(prefix, VNET_SYMPREFIX)) p->n_value = _kvm_vnet_validaddr(kd, lookup.symvalue); + else if (_kvm_dpcpu_initialized(kd, initialize) && + !strcmp(prefix, "pcpu_entry_")) + p->n_value = + _kvm_dpcpu_validaddr(kd, lookup.symvalue); else p->n_value = lookup.symvalue; ++nvalid; @@ -473,14 +485,19 @@ again: /* * Check the number of entries that weren't found. If they exist, -* try again with a prefix for virtualized symbol names. +* try again with a prefix for virtualized or DPCPU symbol names. */ error = ((p - nl) - nvalid); - if (error && _kvm_vnet_initialized(kd, initialize) && - strcmp(prefix, VNET_SYMPREFIX)) { + if (error && _kvm_vnet_initialized(kd, initialize) && !tried_vnet) { + tried_vnet = 1; prefix = VNET_SYMPREFIX; goto again; } + if (error && _kvm_dpcpu_initialized(kd, initialize) && !tried_dpcpu) { + tried_dpcpu = 1; + prefix = "pcpu_entry_"; + goto again; + } /* * Return the number of entries that weren't found. If they exist, Modified: stable/8/lib/libkvm/kvm.h == --- stable/8/lib/libkvm/kvm.h Sat Jan 15 19:21:28 2011(r217453) +++ stable/8/lib/libkvm/kvm.h Sat Jan 15 19:23:14 2011(r217454) @@
svn commit: r217455 - stable/8/sys/net
Author: rwatson Date: Sat Jan 15 19:27:22 2011 New Revision: 217455 URL: http://svn.freebsd.org/changeset/base/217455 Log: Merge r203913 from head to stable/8 (original change by pjd): Mark various sysctls also as tunables. Reviewed by:rwatson Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c == --- stable/8/sys/net/netisr.c Sat Jan 15 19:23:14 2011(r217454) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:27:22 2011(r217455) @@ -160,13 +160,13 @@ SYSCTL_INT(_net_isr, OID_AUTO, direct, C */ static int netisr_maxthreads = -1; /* Max number of threads. */ TUNABLE_INT("net.isr.maxthreads", &netisr_maxthreads); -SYSCTL_INT(_net_isr, OID_AUTO, maxthreads, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, maxthreads, CTLFLAG_RDTUN, &netisr_maxthreads, 0, "Use at most this many CPUs for netisr processing"); static int netisr_bindthreads = 0; /* Bind threads to CPUs. */ TUNABLE_INT("net.isr.bindthreads", &netisr_bindthreads); -SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, bindthreads, CTLFLAG_RDTUN, &netisr_bindthreads, 0, "Bind netisr threads to CPUs."); /* @@ -176,7 +176,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthrea #defineNETISR_DEFAULT_MAXQLIMIT10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; TUNABLE_INT("net.isr.maxqlimit", &netisr_maxqlimit); -SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit, CTLFLAG_RDTUN, &netisr_maxqlimit, 0, "Maximum netisr per-protocol, per-CPU queue depth."); @@ -188,7 +188,7 @@ SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit #defineNETISR_DEFAULT_DEFAULTQLIMIT256 static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; TUNABLE_INT("net.isr.defaultqlimit", &netisr_defaultqlimit); -SYSCTL_INT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RD, +SYSCTL_INT(_net_isr, OID_AUTO, defaultqlimit, CTLFLAG_RDTUN, &netisr_defaultqlimit, 0, "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217456 - stable/8/sys/net
Author: rwatson Date: Sat Jan 15 19:36:47 2011 New Revision: 217456 URL: http://svn.freebsd.org/changeset/base/217456 Log: Merge from head to stable/8: Refine netisr.c comments a bit. Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c == --- stable/8/sys/net/netisr.c Sat Jan 15 19:27:22 2011(r217455) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:36:47 2011(r217456) @@ -36,13 +36,13 @@ __FBSDID("$FreeBSD$"); * dispatched) and asynchronous (deferred dispatch) processing of packets by * registered protocol handlers. Callers pass a protocol identifier and * packet to netisr, along with a direct dispatch hint, and work will either - * be immediately processed with the registered handler, or passed to a - * kernel software interrupt (SWI) thread for deferred dispatch. Callers - * will generally select one or the other based on: + * be immediately processed by the registered handler, or passed to a + * software interrupt (SWI) thread for deferred dispatch. Callers will + * generally select one or the other based on: * - * - Might directly dispatching a netisr handler lead to code reentrance or + * - Whether directly dispatching a netisr handler lead to code reentrance or * lock recursion, such as entering the socket code from the socket code. - * - Might directly dispatching a netisr handler lead to recursive + * - Whether directly dispatching a netisr handler lead to recursive * processing, such as when decapsulating several wrapped layers of tunnel * information (IPSEC within IPSEC within ...). * @@ -58,9 +58,9 @@ __FBSDID("$FreeBSD$"); * more than one flow. * * netisr supports several policy variations, represented by the - * NETISR_POLICY_* constants, allowing protocols to play a varying role in + * NETISR_POLICY_* constants, allowing protocols to play various roles in * identifying flows, assigning work to CPUs, etc. These are described in - * detail in netisr.h. + * netisr.h. */ #include "opt_ddb.h" @@ -105,7 +105,7 @@ __FBSDID("$FreeBSD$"); * * Note: the NETISR_LOCKING define controls whether read locks are acquired * in packet processing paths requiring netisr registration stability. This - * is disabled by default as it can lead to a measurable performance + * is disabled by default as it can lead to measurable performance * degradation even with rmlocks (3%-6% for loopback ping-pong traffic), and * because netisr registration and unregistration is extremely rare at * runtime. If it becomes more common, this decision should be revisited. @@ -170,8 +170,9 @@ SYSCTL_INT(_net_isr, OID_AUTO, bindthrea &netisr_bindthreads, 0, "Bind netisr threads to CPUs."); /* - * Limit per-workstream queues to at most net.isr.maxqlimit, both for initial - * configuration and later modification using netisr_setqlimit(). + * Limit per-workstream mbuf queue limits s to at most net.isr.maxqlimit, + * both for initial configuration and later modification using + * netisr_setqlimit(). */ #defineNETISR_DEFAULT_MAXQLIMIT10240 static u_int netisr_maxqlimit = NETISR_DEFAULT_MAXQLIMIT; @@ -181,9 +182,9 @@ SYSCTL_INT(_net_isr, OID_AUTO, maxqlimit "Maximum netisr per-protocol, per-CPU queue depth."); /* - * The default per-workstream queue limit for protocols that don't initialize - * the nh_qlimit field of their struct netisr_handler. If this is set above - * netisr_maxqlimit, we truncate it to the maximum during boot. + * The default per-workstream mbuf queue limit for protocols that don't + * initialize the nh_qlimit field of their struct netisr_handler. If this is + * set above netisr_maxqlimit, we truncate it to the maximum during boot. */ #defineNETISR_DEFAULT_DEFAULTQLIMIT256 static u_int netisr_defaultqlimit = NETISR_DEFAULT_DEFAULTQLIMIT; @@ -241,12 +242,14 @@ struct netisr_work { }; /* - * Workstreams hold a set of ordered work across each protocol, and are + * Workstreams hold a queue of ordered work across each protocol, and are * described by netisr_workstream. Each workstream is associated with a * worker thread, which in turn is pinned to a CPU. Work associated with a * workstream can be processd in other threads during direct dispatch; * concurrent processing is prevented by the NWS_RUNNING flag, which - * indicates that a thread is already processing the work queue. + * indicates that a thread is already processing the work queue. It is + * important to prevent a directly dispatched packet from "skipping ahead" of + * work already in the workstream queue. */ struct netisr_workstream { struct intr_ev
svn commit: r217457 - stable/8/sys/net
Author: rwatson Date: Sat Jan 15 19:46:36 2011 New Revision: 217457 URL: http://svn.freebsd.org/changeset/base/217457 Log: Merge r204497, r204499 from head to stable/8: Changes to support crashdump analysis of netisr: - Rename the netisr protocol registration array, 'np' to 'netisr_proto', in order to reduce the chances of symbol name collisions. It remains statically defined, but it will be looked up by netstat(1). - Move certain internal structure definitions from netisr.c to netisr_internal.h so that netstat(1) can find them. They remain private, and should not be used for any other purpose (for example, they should not be used by kernel modules, which must instead use the public interfaces in netisr.h). - Store a kernel-compiled version of NETISR_MAXPROT in the global variable netisr_maxprot, and export via a sysctl, so that it is available for use by netstat(1). This is especially important for crashdump interpretation, where the size of the workstream structure is determined by the maximum number of protocols compiled into the kernel. Sponsored by: Juniper Networks Whitespace tweak. Added: stable/8/sys/net/netisr_internal.h - copied unchanged from r204497, head/sys/net/netisr_internal.h Modified: stable/8/sys/net/netisr.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/net/netisr.c == --- stable/8/sys/net/netisr.c Sat Jan 15 19:36:47 2011(r217456) +++ stable/8/sys/net/netisr.c Sat Jan 15 19:46:36 2011(r217457) @@ -87,9 +87,11 @@ __FBSDID("$FreeBSD$"); #include #endif +#define_WANT_NETISR_INTERNAL /* Enable definitions from netisr_internal.h */ #include #include #include +#include #include /*- @@ -99,7 +101,7 @@ __FBSDID("$FreeBSD$"); * * The following data structures and fields are protected by this lock: * - * - The np array, including all fields of struct netisr_proto. + * - The netisr_proto array, including all fields of struct netisr_proto. * - The nws array, including all fields of struct netisr_worker. * - The nws_array array. * @@ -194,79 +196,23 @@ SYSCTL_INT(_net_isr, OID_AUTO, defaultql "Default netisr per-protocol, per-CPU queue limit if not set by protocol"); /* - * Each protocol is described by a struct netisr_proto, which holds all - * global per-protocol information. This data structure is set up by - * netisr_register(), and derived from the public struct netisr_handler. + * Store and export the compile-time constant NETISR_MAXPROT limit on the + * number of protocols that can register with netisr at a time. This is + * required for crashdump analysis, as it sizes netisr_proto[]. */ -struct netisr_proto { - const char *np_name; /* Character string protocol name. */ - netisr_handler_t *np_handler; /* Protocol handler. */ - netisr_m2flow_t *np_m2flow; /* Query flow for untagged packet. */ - netisr_m2cpuid_t *np_m2cpuid; /* Query CPU to process packet on. */ - netisr_drainedcpu_t *np_drainedcpu; /* Callback when drained a queue. */ - u_intnp_qlimit; /* Maximum per-CPU queue depth. */ - u_intnp_policy; /* Work placement policy. */ -}; - -#defineNETISR_MAXPROT 16 /* Compile-time limit. */ +static u_int netisr_maxprot = NETISR_MAXPROT; +SYSCTL_INT(_net_isr, OID_AUTO, maxprot, CTLFLAG_RD, +&netisr_maxprot, 0, +"Compile-time limit on the number of protocols supported by netisr."); /* - * The np array describes all registered protocols, indexed by protocol - * number. + * The netisr_proto array describes all registered protocols, indexed by + * protocol number. See netisr_internal.h for more details. */ -static struct netisr_proto np[NETISR_MAXPROT]; +static struct netisr_proto netisr_proto[NETISR_MAXPROT]; /* - * Protocol-specific work for each workstream is described by struct - * netisr_work. Each work descriptor consists of an mbuf queue and - * statistics. - */ -struct netisr_work { - /* -* Packet queue, linked by m_nextpkt. -*/ - struct mbuf *nw_head; - struct mbuf *nw_tail; - u_intnw_len; - u_intnw_qlimit; - u_intnw_watermark; - - /* -* Statistics -- written unlocked, but mostly from curcpu. -*/ - u_int64_tnw_dispatched; /* Number of direct dispatches. */ - u_int64_tnw_hybrid_dispatched; /* "" hybrid dispatches. */ - u_int64_tnw_qdrops; /* "" drops. */ - u_int64_t
svn commit: r217458 - stable/8/usr.bin/netstat
Author: rwatson Date: Sat Jan 15 19:49:08 2011 New Revision: 217458 URL: http://svn.freebsd.org/changeset/base/217458 Log: Merge r204499, r204515 from head to stable/8: Teach netstat -Q to work with -N and -M by adding libkvm versions of data query routines. This code is necessarily more fragile in the presence of kernel changes than querying the kernel via sysctl (the default), but useful when investigating crashes or live kernel state via firewire. Sponsored by: Juniper Networks Prefer vocabulary of 'Current' and 'Limit' to 'Value' and 'Maximum' in netstat -Q. Sponsored by: Juniper Networks Modified: stable/8/usr.bin/netstat/main.c stable/8/usr.bin/netstat/netisr.c stable/8/usr.bin/netstat/netstat.h Directory Properties: stable/8/usr.bin/netstat/ (props changed) Modified: stable/8/usr.bin/netstat/main.c == --- stable/8/usr.bin/netstat/main.c Sat Jan 15 19:46:36 2011 (r217457) +++ stable/8/usr.bin/netstat/main.c Sat Jan 15 19:49:08 2011 (r217458) @@ -539,9 +539,11 @@ main(int argc, char *argv[]) exit(0); } if (Qflag) { - if (!live) - usage(); - netisr_stats(); + if (!live) { + if (kread(0, NULL, 0) == 0) + netisr_stats(kvmd); + } else + netisr_stats(NULL); exit(0); } #if 0 Modified: stable/8/usr.bin/netstat/netisr.c == --- stable/8/usr.bin/netstat/netisr.c Sat Jan 15 19:46:36 2011 (r217457) +++ stable/8/usr.bin/netstat/netisr.c Sat Jan 15 19:49:08 2011 (r217458) @@ -31,15 +31,22 @@ __FBSDID("$FreeBSD$"); -#include +#include #include +#include +#include + +#define_WANT_NETISR_INTERNAL #include +#include #include +#include #include #include #include +#include #include "netstat.h" @@ -65,6 +72,90 @@ static u_int workstream_array_len; static struct sysctl_netisr_work *work_array; static u_intwork_array_len; +static u_int *nws_array; + +static u_intmaxprot; + +static void +netisr_load_kvm_uint(kvm_t *kd, char *name, u_int *p) +{ + struct nlist nl[] = { + { .n_name = name }, + { .n_name = NULL }, + }; + int ret; + + ret = kvm_nlist(kd, nl); + if (ret < 0) + errx(-1, "%s: kvm_nlist(%s): %s", __func__, name, + kvm_geterr(kd)); + if (ret != 0) + errx(-1, "%s: kvm_nlist(%s): unresolved symbol", __func__, + name); + if (kvm_read(kd, nl[0].n_value, p, sizeof(*p)) != sizeof(*p)) + errx(-1, "%s: kvm_read(%s): %s", __func__, name, + kvm_geterr(kd)); +} + +/* + * Load a nul-terminated string from KVM up to 'limit', guarantee that the + * string in local memory is nul-terminated. + */ +static void +netisr_load_kvm_string(kvm_t *kd, uintptr_t addr, char *dest, u_int limit) +{ + u_int i; + + for (i = 0; i < limit; i++) { + if (kvm_read(kd, addr + i, &dest[i], sizeof(dest[i])) != + sizeof(dest[i])) + err(-1, "%s: kvm_read: %s", __func__, + kvm_geterr(kd)); + if (dest[i] == '\0') + break; + } + dest[limit - 1] = '\0'; +} + +static const char * +netisr_proto2name(u_int proto) +{ + u_int i; + + for (i = 0; i < proto_array_len; i++) { + if (proto_array[i].snp_proto == proto) + return (proto_array[i].snp_name); + } + return ("unknown"); +} + +static int +netisr_protoispresent(u_int proto) +{ + u_int i; + + for (i = 0; i < proto_array_len; i++) { + if (proto_array[i].snp_proto == proto) + return (1); + } + return (0); +} + +static void +netisr_load_kvm_config(kvm_t *kd) +{ + + netisr_load_kvm_uint(kd, "_netisr_bindthreads", &bindthreads); + netisr_load_kvm_uint(kd, "_netisr_maxthreads", &maxthreads); + netisr_load_kvm_uint(kd, "_nws_count", &numthreads); + + netisr_load_kvm_uint(kd, "_netisr_defaultqlimit", &defaultqlimit); + netisr_load_kvm_uint(kd, "_netisr_maxqlimit", &maxqlimit); + + netisr_load_kvm_uint(kd, "_netisr_direct", &direct); + netisr_load_kvm_uint(kd, "_netisr_direct_force", &direct_force); +} + static void netisr_load_sysctl_uint(const char *name, u_int *p) { @@ -78,7 +169,7 @@ netisr_load_sysctl_uint(const char *name } static void -netisr_load_config(void) +netisr_load_sysctl_config(void) { netisr_load_sysctl_uint("net.is
svn commit: r217459 - head/sys/powerpc/include
Author: marcel Date: Sat Jan 15 20:18:08 2011 New Revision: 217459 URL: http://svn.freebsd.org/changeset/base/217459 Log: Don't redefine MODINFOMD_BOOTINFO as MODINFOMD_DTBP. This breaks support for older loaders. Add MODINFOMD_DTBP as a new tag instead. Modified: head/sys/powerpc/include/metadata.h Modified: head/sys/powerpc/include/metadata.h == --- head/sys/powerpc/include/metadata.h Sat Jan 15 19:49:08 2011 (r217458) +++ head/sys/powerpc/include/metadata.h Sat Jan 15 20:18:08 2011 (r217459) @@ -32,6 +32,7 @@ #defineMODINFOMD_ENVP 0x1001 #defineMODINFOMD_HOWTO 0x1002 #defineMODINFOMD_KERNEND 0x1003 -#defineMODINFOMD_DTBP 0x1004 +#defineMODINFOMD_BOOTINFO 0x1004 +#defineMODINFOMD_DTBP 0x1005 #endif /* !_MACHINE_METADATA_H_ */ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217461 - in head: bin/sh tools/regression/bin/sh/builtins
Author: jilles Date: Sat Jan 15 21:09:00 2011 New Revision: 217461 URL: http://svn.freebsd.org/changeset/base/217461 Log: sh: Fix some things about -- in trap: * Make 'trap --' do the same as 'trap' instead of nothing. * Make '--' stop option processing (note that '-' action is not an option). Side effect: The error message for an unknown option is different. Added: head/tools/regression/bin/sh/builtins/trap5.0 (contents, props changed) Modified: head/bin/sh/trap.c Modified: head/bin/sh/trap.c == --- head/bin/sh/trap.c Sat Jan 15 20:37:56 2011(r217460) +++ head/bin/sh/trap.c Sat Jan 15 21:09:00 2011(r217461) @@ -153,8 +153,18 @@ trapcmd(int argc, char **argv) char *action; int signo; int errors = 0; + int i; + + while ((i = nextopt("l")) != '\0') { + switch (i) { + case 'l': + printsignals(); + return (0); + } + } + argv = argptr; - if (argc <= 1) { + if (*argv == NULL) { for (signo = 0 ; signo < sys_nsig ; signo++) { if (signo < NSIG && trap[signo] != NULL) { out1str("trap -- "); @@ -171,19 +181,12 @@ trapcmd(int argc, char **argv) return 0; } action = NULL; - if (*++argv && strcmp(*argv, "--") == 0) - argv++; if (*argv && sigstring_to_signum(*argv) == -1) { - if ((*argv)[0] != '-') { - action = *argv; + if (strcmp(*argv, "-") == 0) argv++; - } else if ((*argv)[1] == '\0') { + else { + action = *argv; argv++; - } else if ((*argv)[1] == 'l' && (*argv)[2] == '\0') { - printsignals(); - return 0; - } else { - error("bad option %s", *argv); } } while (*argv) { Added: head/tools/regression/bin/sh/builtins/trap5.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/trap5.0 Sat Jan 15 21:09:00 2011(r217461) @@ -0,0 +1,19 @@ +# $FreeBSD$ + +set -e +trap - USR1 +initial=$(trap) +trap -- -l USR1 +added=$(trap) +[ -n "$added" ] +trap - USR1 +second=$(trap) +[ "$initial" = "$second" ] +eval "$added" +added2=$(trap) +added3=$(trap --) +[ "$added" = "$added2" ] +[ "$added2" = "$added3" ] +trap -- - USR1 +third=$(trap) +[ "$initial" = "$third" ] ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217463 - head/sys/vm
Author: kib Date: Sat Jan 15 21:56:38 2011 New Revision: 217463 URL: http://svn.freebsd.org/changeset/base/217463 Log: For consistency, use kernel_object instead of &kernel_object_store when initializing the object mutex. Do the same for kmem_object. Discussed with: alc MFC after:1 week Modified: head/sys/vm/vm_object.c Modified: head/sys/vm/vm_object.c == --- head/sys/vm/vm_object.c Sat Jan 15 21:24:39 2011(r217462) +++ head/sys/vm/vm_object.c Sat Jan 15 21:56:38 2011(r217463) @@ -244,7 +244,7 @@ vm_object_init(void) TAILQ_INIT(&vm_object_list); mtx_init(&vm_object_list_mtx, "vm object_list", NULL, MTX_DEF); - VM_OBJECT_LOCK_INIT(&kernel_object_store, "kernel object"); + VM_OBJECT_LOCK_INIT(kernel_object, "kernel object"); _vm_object_allocate(OBJT_PHYS, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS), kernel_object); #if VM_NRESERVLEVEL > 0 @@ -252,7 +252,7 @@ vm_object_init(void) kernel_object->pg_color = (u_short)atop(VM_MIN_KERNEL_ADDRESS); #endif - VM_OBJECT_LOCK_INIT(&kmem_object_store, "kmem object"); + VM_OBJECT_LOCK_INIT(kmem_object, "kmem object"); _vm_object_allocate(OBJT_PHYS, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS), kmem_object); #if VM_NRESERVLEVEL > 0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217464 - head/share/man/man4
Author: marius Date: Sat Jan 15 22:07:08 2011 New Revision: 217464 URL: http://svn.freebsd.org/changeset/base/217464 Log: Add a manual page for rgephy(4) and reference it as appropriate. The motivation for having rgephy.4 is to document the special media option add in r217415. MFC after:3 days Added: head/share/man/man4/rgephy.4 (contents, props changed) Modified: head/share/man/man4/Makefile head/share/man/man4/miibus.4 head/share/man/man4/nfe.4 head/share/man/man4/re.4 Modified: head/share/man/man4/Makefile == --- head/share/man/man4/MakefileSat Jan 15 21:56:38 2011 (r217463) +++ head/share/man/man4/MakefileSat Jan 15 22:07:08 2011 (r217464) @@ -337,6 +337,7 @@ MAN=aac.4 \ random.4 \ rc.4 \ re.4 \ + rgephy.4 \ rl.4 \ rndtest.4 \ route.4 \ Modified: head/share/man/man4/miibus.4 == --- head/share/man/man4/miibus.4Sat Jan 15 21:56:38 2011 (r217463) +++ head/share/man/man4/miibus.4Sat Jan 15 22:07:08 2011 (r217464) @@ -8,7 +8,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 30, 2010 +.Dd January 15, 2011 .Dt MIIBUS 4 .Os .Sh NAME @@ -162,6 +162,7 @@ but as a result are not well behaved new .Xr nve 4 , .Xr pcn 4 , .Xr re 4 , +.Xr rgephy 4 , .Xr rl 4 , .Xr rue 4 , .Xr sf 4 , Modified: head/share/man/man4/nfe.4 == --- head/share/man/man4/nfe.4 Sat Jan 15 21:56:38 2011(r217463) +++ head/share/man/man4/nfe.4 Sat Jan 15 22:07:08 2011(r217464) @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 2, 2008 +.Dd January, 2011 .Dt NFE 4 .Os .Sh NAME @@ -174,6 +174,7 @@ before a change takes effect. .Xr netintro 4 , .Xr pci 4 , .Xr polling 4 , +.Xr rgephy 4 , .Xr sysctl 8 , .Xr ifconfig 8 .Sh HISTORY Modified: head/share/man/man4/re.4 == --- head/share/man/man4/re.4Sat Jan 15 21:56:38 2011(r217463) +++ head/share/man/man4/re.4Sat Jan 15 22:07:08 2011(r217464) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 2, 2010 +.Dd January, 2011 .Dt RE 4 .Os .Sh NAME @@ -213,6 +213,7 @@ the network connection (cable). .Xr netintro 4 , .Xr ng_ether 4 , .Xr polling 4 , +.Xr rgephy 4 , .Xr vlan 4 , .Xr ifconfig 8 .Rs Added: head/share/man/man4/rgephy.4 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/rgephy.4Sat Jan 15 22:07:08 2011 (r217464) @@ -0,0 +1,96 @@ +.\" +.\" Copyright (c) 2011 Marius Strobl +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 15 2011 $ +.Dt RGEPHY 4 +.Os +.Sh NAME +.Nm rgephy +.Nd RealTek RTL8168/8169/8110/8211 series 10/100/1000 Gigabit Ethernet PHY driver +.Sh SYNOPSIS +To compile all available PHY drivers into the kernel, +place the following line in your kernel configuration file: +.Bd -ragged -offset indent +.Cd "device miibus" +.Ed +.Pp +Alternatively, to selectively compile this driver into the kernel, +place the following lines in your kernel configuration file instead: +.Bd -ragged -offset indent +.Cd "device mii" +.Cd "device rgephy" +.Ed +.Sh DESCRIPTION +The +.Nm +driver supports the RealTek RTL8168, RTL8169, RTL8110 and RTL8211 series +integrated 10/100/1000 Gigabit Ethernet PHYs. +.Pp +In order to get a list of
Re: svn commit: r217369 - in head/sys: cam/scsi sys
On Sat, 15 Jan 2011 m...@freebsd.org wrote: On Sat, Jan 15, 2011 at 6:55 AM, Bruce Evans wrote: SYSCTL_I() works even better that I first thought. ?It automatically gives support for all typedefed integral types. ?No SYSCTL_FOO_T()s ... Grrr, my sentence breaks of 2 spaces are being echoed as 1 space and 1 hard \xa0. The printing is done entirely in user-space, so it's not too bad. I had figured to upcast everything to [u]intmax_t anyways, and what to cast from would just be [u]int32_t and [u]int64_t depending on reported size. Anything smaller should be copyout(9)'d as a 4 bit quantity. I think it shouldn't be converted in the kernel. Applications using sysctl already have to deal with fields shorter than int in structs returned by sysctl(). They don't need to deal with integers shorter than int only since sysctl() doesn't support such integers yet. Short integers could still be returned as essentially themselves by packing them into a struct with nothing else. But, there's two factors at play here. The first is sysctl(8) which asks for the size when reading and manages it. The second is sysctl(2) where we have code like SCTL_MASK32 so a long on a 64-bit kernel looks like a long to a 32-bit app. It would be simpler to expose this as an 8-byte quantity on 64-bit kernel, and sysctl(8) will deal with this just fine, but that would break some uses of sysctl(2). What are the uses? I guess they are not-so-hard-coding data types as int and long, etc., and hard-coding them as int32_t and int64_t. Then you get an error when the kernel returns an unexpected length, but unexpected lengths are expected for 32-bit apps on 64-bit kernels. BTW, short writes are still horribly broken. Suppose there is a size mismatch causing an application tries to write 32 bits to a 64-bit kernel variable. Then no error is detected, and the kernel variable ois left with garbage in its top bits. The error detection last worked with 4.4BSD sysctl, and is still documented to work: % [EINVAL] A non-null newp is given and its specified length in % newlen is too large or too small. I think the case where newlen is too large still works. I guess the bug is potentially larger for 32 bit compat applications, but it is rarely seen for those too since only system management applications should be writing to kernel variables and there is no reason to run such applications in 32 bit mode. The bug affects mainly cases where there is a kernel type mismatch, like using sysctl_handle_int() on a 64-bit variable. I forget how short reads were not detected as errors. It still takes the size in the sysctl data to be for 64 bits for this error to be detectable for either read or write. But your recent changes should fix all such type mismatches. However, I *think* it is safe to check the sysctl_req's oldidx/oldlen to see what size the user-space expects and cast a kernel long to int before SYSCTL_OUT. Maybe if the value fits. The application might be probing for a size that works. Then it shouldn't care what size the value is returned in, provided the value fits. Writing is only slightly more delicate. The application must use a size in which the value fits. Then the kernel can expand the size if necessary. It just has to be careful to fill the top bits and not have sign extension bugs. sysctl_handle_i() can probably handle both directions. Lower-level sysctl code should still return an error if there is a size mismatch. If a value doesn't fit, then the application will just have to detect the error and try a larger size (or fail if it doesn't support larger size). An example might be a 32-bit app reading 64-bit kernel pointers. These probably have the high bits set, so they won't fit in 32-bit sizes. But the application can easily read them using 64-bit sizes. Integers and pointers larger than 64 bits would be more interesting, since a compat application might not have any integer data type larger enough to represent them. So I changed my mind about converting in the kernel. Just try to convert to whatever size the application is trying to use. Don't even force >= 32 bit sizes on applications. $WORK has gotten busy so I haven't had a chance to work on this much but I'm hopeful that the missus will watch the kids this weekend and allow me to hack. You seem to have found time :-). Bruce___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r217468 - head/share/man/man4
Author: marius Date: Sun Jan 16 04:14:56 2011 New Revision: 217468 URL: http://svn.freebsd.org/changeset/base/217468 Log: Reference rgephy.4 in man pages of additional MAC drivers also known to come in combination with these PHYs. Submitted by: yongari MFC after:3 days Modified: head/share/man/man4/axe.4 head/share/man/man4/nve.4 head/share/man/man4/sge.4 Modified: head/share/man/man4/axe.4 == --- head/share/man/man4/axe.4 Sun Jan 16 00:45:06 2011(r217467) +++ head/share/man/man4/axe.4 Sun Jan 16 04:14:56 2011(r217468) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 20, 2008 +.Dd January 16, 2011 .Dt AXE 4 .Os .Sh NAME @@ -206,6 +206,7 @@ The driver failed to allocate an mbuf fo .Xr miibus 4 , .Xr netintro 4 , .Xr ng_ether 4 , +.Xr rgephy 4 , .Xr ifconfig 8 .Rs .%T "ASIX AX88172 AX88178 and AX88772 data sheets" Modified: head/share/man/man4/nve.4 == --- head/share/man/man4/nve.4 Sun Jan 16 00:45:06 2011(r217467) +++ head/share/man/man4/nve.4 Sun Jan 16 04:14:56 2011(r217468) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 8, 2007 +.Dd January 16, 2011 .Dt NVE 4 .Os .Sh NAME @@ -120,6 +120,7 @@ the network connection (cable). .Xr miibus 4 , .Xr netintro 4 , .Xr ng_ether 4 , +.Xr rgephy 4 , .Xr ifconfig 8 .Sh HISTORY The Modified: head/share/man/man4/sge.4 == --- head/share/man/man4/sge.4 Sun Jan 16 00:45:06 2011(r217467) +++ head/share/man/man4/sge.4 Sun Jan 16 04:14:56 2011(r217468) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 10, 2010 +.Dd January 16, 2011 .Dt SGE 4 .Os .Sh NAME @@ -105,6 +105,7 @@ SiS191 Fast/Gigabit Ethernet controller .Xr miibus 4 , .Xr netintro 4 , .Xr ng_ether 4 , +.Xr rgephy 4 , .Xr vlan 4 , .Xr ifconfig 8 .Sh HISTORY ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
Re: svn commit: r217369 - in head/sys: cam/scsi sys
On Sat, Jan 15, 2011 at 7:06 PM, Bruce Evans wrote: > On Sat, 15 Jan 2011 m...@freebsd.org wrote: >> On Sat, Jan 15, 2011 at 6:55 AM, Bruce Evans wrote: > >> The printing is done entirely in user-space, so it's not too bad. I >> had figured to upcast everything to [u]intmax_t anyways, and what to >> cast from would just be [u]int32_t and [u]int64_t depending on >> reported size. Anything smaller should be copyout(9)'d as a 4 bit >> quantity. > > I think it shouldn't be converted in the kernel. Applications using > sysctl already have to deal with fields shorter than int in structs > returned by sysctl(). They don't need to deal with integers shorter > than int only since sysctl() doesn't support such integers yet. Short > integers could still be returned as essentially themselves by packing > them into a struct with nothing else. > >> But, there's two factors at play here. The first is sysctl(8) which >> asks for the size when reading and manages it. The second is >> sysctl(2) where we have code like SCTL_MASK32 so a long on a 64-bit >> kernel looks like a long to a 32-bit app. It would be simpler to >> expose this as an 8-byte quantity on 64-bit kernel, and sysctl(8) will >> deal with this just fine, but that would break some uses of sysctl(2). > > What are the uses? I guess they are not-so-hard-coding data types as > int and long, etc., and hard-coding them as int32_t and int64_t. Then > you get an error when the kernel returns an unexpected length, but > unexpected lengths are expected for 32-bit apps on 64-bit kernels. > > BTW, short writes are still horribly broken. Suppose there is a size > mismatch causing an application tries to write 32 bits to a 64-bit > kernel variable. Then no error is detected, and the kernel variable > ois left with garbage in its top bits. The error detection last worked > with 4.4BSD sysctl, and is still documented to work: > > % [EINVAL] A non-null newp is given and its specified length > in > % newlen is too large or too small. > > I think the case where newlen is too large still works. > > I guess the bug is potentially larger for 32 bit compat applications, > but it is rarely seen for those too since only system management > applications should be writing to kernel variables and there is no > reason to run such applications in 32 bit mode. At Isilon all of userland is still 32-bit only. The reason is that for a while we supported 32-bit and 64-bit kernels in the field, and in fact for various reasons on install the 32-bit kernel always came up first and a reboot after install was forced for 64-bit capable hardware. But we needed the same userspace to work on both kernels. >> However, I *think* it is safe to check the sysctl_req's oldidx/oldlen >> to see what size the user-space expects and cast a kernel long to int >> before SYSCTL_OUT. > > Maybe if the value fits. The application might be probing for a size > that works. Then it shouldn't care what size the value is returned in, > provided the value fits. Writing is only slightly more delicate. The > application must use a size in which the value fits. Then the kernel > can expand the size if necessary. It just has to be careful to fill > the top bits and not have sign extension bugs. sysctl_handle_i() can > probably handle both directions. Lower-level sysctl code should still > return an error if there is a size mismatch. Probing for a size that works should be passing in NULL for the old ptr to get a hint, and for scalars the sie doesn't change. It would be a somewhat malformed app that probes for the size anywhere below e.g. 512 bytes or 1 page. > If a value doesn't fit, then the application will just have to detect > the error and try a larger size (or fail if it doesn't support larger > size). An example might be a 32-bit app reading 64-bit kernel pointers. > These probably have the high bits set, so they won't fit in 32-bit sizes. > But the application can easily read them using 64-bit sizes. Integers > and pointers larger than 64 bits would be more interesting, since a > compat application might not have any integer data type larger enough > to represent them. > > So I changed my mind about converting in the kernel. Just try to convert > to whatever size the application is trying to use. Don't even force >= 32 > bit sizes on applications. The proposed code does attempt to convert to whatever the app uses, but it assumes the app is using at least a 32-bit quantity. :-) More on the other thread. Thanks, matthew ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"