Date: Mon, 2 Apr 2012 20:34:16 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r233814 - in stable/9/sys: i386/conf kern sys Message-ID: <201204022034.q32KYGeX015737@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Mon Apr 2 20:34:15 2012 New Revision: 233814 URL: http://svn.freebsd.org/changeset/base/233814 Log: MFC 232700: Add a new sched_clear_name() method to the scheduler interface to clear the cached name used for KTR_SCHED traces when a thread's name changes. This way KTR_SCHED traces (and thus schedgraph) will notice when a thread's name changes, most commonly via execve(). Modified: stable/9/sys/kern/kern_exec.c stable/9/sys/kern/kern_intr.c stable/9/sys/kern/kern_kthread.c stable/9/sys/kern/kern_thr.c stable/9/sys/kern/sched_4bsd.c stable/9/sys/kern/sched_ule.c stable/9/sys/sys/sched.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/i386/conf/XENHVM (props changed) Modified: stable/9/sys/kern/kern_exec.c ============================================================================== --- stable/9/sys/kern/kern_exec.c Mon Apr 2 20:14:51 2012 (r233813) +++ stable/9/sys/kern/kern_exec.c Mon Apr 2 20:34:15 2012 (r233814) @@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$"); #include <sys/pioctl.h> #include <sys/namei.h> #include <sys/resourcevar.h> +#include <sys/sched.h> #include <sys/sdt.h> #include <sys/sf_buf.h> #include <sys/syscallsubr.h> @@ -636,6 +637,9 @@ interpret: else if (vn_commname(binvp, p->p_comm, sizeof(p->p_comm)) != 0) bcopy(fexecv_proc_title, p->p_comm, sizeof(fexecv_proc_title)); bcopy(p->p_comm, td->td_name, sizeof(td->td_name)); +#ifdef KTR + sched_clear_tdname(td); +#endif /* * mark as execed, wakeup the process that vforked (if any) and tell Modified: stable/9/sys/kern/kern_intr.c ============================================================================== --- stable/9/sys/kern/kern_intr.c Mon Apr 2 20:14:51 2012 (r233813) +++ stable/9/sys/kern/kern_intr.c Mon Apr 2 20:34:15 2012 (r233814) @@ -180,6 +180,9 @@ ithread_update(struct intr_thread *ithd) /* Update name and priority. */ strlcpy(td->td_name, ie->ie_fullname, sizeof(td->td_name)); +#ifdef KTR + sched_clear_tdname(td); +#endif thread_lock(td); sched_prio(td, pri); thread_unlock(td); Modified: stable/9/sys/kern/kern_kthread.c ============================================================================== --- stable/9/sys/kern/kern_kthread.c Mon Apr 2 20:14:51 2012 (r233813) +++ stable/9/sys/kern/kern_kthread.c Mon Apr 2 20:34:15 2012 (r233814) @@ -115,6 +115,9 @@ kproc_create(void (*func)(void *), void va_start(ap, fmt); vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap); va_end(ap); +#ifdef KTR + sched_clear_tdname(td); +#endif /* call the processes' main()... */ cpu_set_fork_handler(td, func, arg); @@ -453,6 +456,9 @@ kproc_kthread_add(void (*func)(void *), va_start(ap, fmt); vsnprintf(td->td_name, sizeof(td->td_name), fmt, ap); va_end(ap); +#ifdef KTR + sched_clear_tdname(td); +#endif return (0); } va_start(ap, fmt); Modified: stable/9/sys/kern/kern_thr.c ============================================================================== --- stable/9/sys/kern/kern_thr.c Mon Apr 2 20:14:51 2012 (r233813) +++ stable/9/sys/kern/kern_thr.c Mon Apr 2 20:34:15 2012 (r233814) @@ -547,6 +547,9 @@ sys_thr_set_name(struct thread *td, stru if (ttd == NULL) return (ESRCH); strcpy(ttd->td_name, name); +#ifdef KTR + sched_clear_tdname(ttd); +#endif PROC_UNLOCK(p); return (error); } Modified: stable/9/sys/kern/sched_4bsd.c ============================================================================== --- stable/9/sys/kern/sched_4bsd.c Mon Apr 2 20:14:51 2012 (r233813) +++ stable/9/sys/kern/sched_4bsd.c Mon Apr 2 20:34:15 2012 (r233814) @@ -1613,6 +1613,17 @@ sched_tdname(struct thread *td) #endif } +#ifdef KTR +void +sched_clear_tdname(struct thread *td) +{ + struct td_sched *ts; + + ts = td->td_sched; + ts->ts_name[0] = '\0'; +} +#endif + void sched_affinity(struct thread *td) { Modified: stable/9/sys/kern/sched_ule.c ============================================================================== --- stable/9/sys/kern/sched_ule.c Mon Apr 2 20:14:51 2012 (r233813) +++ stable/9/sys/kern/sched_ule.c Mon Apr 2 20:34:15 2012 (r233814) @@ -2684,6 +2684,17 @@ sched_tdname(struct thread *td) #endif } +#ifdef KTR +void +sched_clear_tdname(struct thread *td) +{ + struct td_sched *ts; + + ts = td->td_sched; + ts->ts_name[0] = '\0'; +} +#endif + #ifdef SMP /* Modified: stable/9/sys/sys/sched.h ============================================================================== --- stable/9/sys/sys/sched.h Mon Apr 2 20:14:51 2012 (r233813) +++ stable/9/sys/sys/sched.h Mon Apr 2 20:34:15 2012 (r233814) @@ -138,6 +138,9 @@ int sched_sizeof_thread(void); * functions. */ char *sched_tdname(struct thread *td); +#ifdef KTR +void sched_clear_tdname(struct thread *td); +#endif static __inline void sched_pin(void)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204022034.q32KYGeX015737>