svn commit: r282409 - stable/10/lib/libc/gen

2015-05-04 Thread Konstantin Belousov
Author: kib
Date: Mon May  4 08:05:13 2015
New Revision: 282409
URL: https://svnweb.freebsd.org/changeset/base/282409

Log:
  MFC r281763:
  Remove code to support the top of the stack layout for FreeBSD 1.x/2.x
  kernel.

Modified:
  stable/10/lib/libc/gen/setproctitle.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/gen/setproctitle.c
==
--- stable/10/lib/libc/gen/setproctitle.c   Mon May  4 04:45:59 2015
(r282408)
+++ stable/10/lib/libc/gen/setproctitle.c   Mon May  4 08:05:13 2015
(r282409)
@@ -42,9 +42,10 @@ __FBSDID($FreeBSD$);
  * 1: old_ps_strings at the very top of the stack.
  * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack.
  * 3: ps_strings at the very top of the stack.
- * This attempts to support a kernel built in the #2 and #3 era.
- */
-
+ * We only support a kernel providing #3 style ps_strings.
+ *
+ * For historical purposes, a definition of the old ps_strings structure
+ * and location is preserved below:
 struct old_ps_strings {
char*old_ps_argvstr;
int old_ps_nargvstr;
@@ -53,6 +54,7 @@ struct old_ps_strings {
 };
 #defineOLD_PS_STRINGS ((struct old_ps_strings *) \
(USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings)))
+ */
 
 #include stdarg.h
 
@@ -136,41 +138,38 @@ setproctitle(const char *fmt, ...)
ps_strings = (struct ps_strings *)ul_ps_strings;
}
 
-   /* PS_STRINGS points to zeroed memory on a style #2 kernel */
-   if (ps_strings-ps_argvstr) {
-   /* style #3 */
-   if (oargc == -1) {
-   /* Record our original args */
-   oargc = ps_strings-ps_nargvstr;
-   oargv = ps_strings-ps_argvstr;
-   for (i = len = 0; i  oargc; i++) {
-   /*
-* The program may have scribbled into its
-* argv array, e.g., to remove some arguments.
-* If that has happened, break out before
-* trying to call strlen on a NULL pointer.
-*/
-   if (oargv[i] == NULL) {
-   oargc = i;
-   break;
-   }
-   snprintf(obuf + len, SPT_BUFSIZE - len, %s%s,
-   len ?   : , oargv[i]);
-   if (len)
-   len++;
-   len += strlen(oargv[i]);
-   if (len = SPT_BUFSIZE)
-   break;
+   /*
+* PS_STRINGS points to zeroed memory on a style #2 kernel.
+* Should not happen.
+*/
+   if (ps_strings-ps_argvstr == NULL)
+   return;
+
+   /* style #3 */
+   if (oargc == -1) {
+   /* Record our original args */
+   oargc = ps_strings-ps_nargvstr;
+   oargv = ps_strings-ps_argvstr;
+   for (i = len = 0; i  oargc; i++) {
+   /*
+* The program may have scribbled into its
+* argv array, e.g., to remove some arguments.
+* If that has happened, break out before
+* trying to call strlen on a NULL pointer.
+*/
+   if (oargv[i] == NULL) {
+   oargc = i;
+   break;
}
+   snprintf(obuf + len, SPT_BUFSIZE - len, %s%s,
+   len != 0 ?   : , oargv[i]);
+   if (len != 0)
+   len++;
+   len += strlen(oargv[i]);
+   if (len = SPT_BUFSIZE)
+   break;
}
-   ps_strings-ps_nargvstr = nargc;
-   ps_strings-ps_argvstr = nargvp;
-   } else {
-   /* style #2 - we can only restore our first arg :-( */
-   if (*obuf == '\0')
-   strncpy(obuf, OLD_PS_STRINGS-old_ps_argvstr,
-   SPT_BUFSIZE - 1);
-   OLD_PS_STRINGS-old_ps_nargvstr = 1;
-   OLD_PS_STRINGS-old_ps_argvstr = nargvp[0];
}
+   ps_strings-ps_nargvstr = nargc;
+   ps_strings-ps_argvstr = nargvp;
 }
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to svn-src-stable-10-unsubscr...@freebsd.org


svn commit: r282411 - stable/10/sys/kern

2015-05-04 Thread Konstantin Belousov
Author: kib
Date: Mon May  4 08:16:32 2015
New Revision: 282411
URL: https://svnweb.freebsd.org/changeset/base/282411

Log:
  MFC r282085:
  Partially revert r255986: do not call VOP_FSYNC() when helping
  bufdaemon in getnewbuf(), do use buf_flush().  The difference is that
  bufdaemon uses TRYLOCK to get buffer locks, which allows calls to
  getnewbuf() while another buffer is locked.

Modified:
  stable/10/sys/kern/vfs_bio.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/vfs_bio.c
==
--- stable/10/sys/kern/vfs_bio.cMon May  4 08:13:05 2015
(r282410)
+++ stable/10/sys/kern/vfs_bio.cMon May  4 08:16:32 2015
(r282411)
@@ -113,8 +113,8 @@ static void vfs_setdirty_locked_object(s
 static void vfs_vmio_release(struct buf *bp);
 static int vfs_bio_clcheck(struct vnode *vp, int size,
daddr_t lblkno, daddr_t blkno);
-static int buf_flush(int);
-static int flushbufqueues(int, int);
+static int buf_flush(struct vnode *vp, int);
+static int flushbufqueues(struct vnode *, int, int);
 static void buf_daemon(void);
 static void bremfreel(struct buf *bp);
 static __inline void bd_wakeup(void);
@@ -2065,7 +2065,7 @@ getnewbuf_bufd_help(struct vnode *vp, in
 {
struct thread *td;
char *waitmsg;
-   int cnt, error, flags, norunbuf, wait;
+   int error, fl, flags, norunbuf;
 
mtx_assert(bqclean, MA_OWNED);
 
@@ -2087,8 +2087,6 @@ getnewbuf_bufd_help(struct vnode *vp, in
return;
 
td = curthread;
-   cnt = 0;
-   wait = MNT_NOWAIT;
rw_wlock(nblock);
while ((needsbuffer  flags) != 0) {
if (vp != NULL  vp-v_type != VCHR 
@@ -2102,20 +2100,23 @@ getnewbuf_bufd_help(struct vnode *vp, in
 * cannot be achieved by the buf_daemon, that
 * cannot lock the vnode.
 */
-   if (cnt++  2)
-   wait = MNT_WAIT;
-   ASSERT_VOP_LOCKED(vp, bufd_helper);
-   error = VOP_ISLOCKED(vp) == LK_EXCLUSIVE ? 0 :
-   vn_lock(vp, LK_TRYUPGRADE);
-   if (error == 0) {
-   /* play bufdaemon */
-   norunbuf = curthread_pflags_set(TDP_BUFNEED |
-   TDP_NORUNNINGBUF);
-   VOP_FSYNC(vp, wait, td);
-   atomic_add_long(notbufdflushes, 1);
-   curthread_pflags_restore(norunbuf);
-   }
+   norunbuf = ~(TDP_BUFNEED | TDP_NORUNNINGBUF) |
+   (td-td_pflags  TDP_NORUNNINGBUF);
+
+   /*
+* Play bufdaemon.  The getnewbuf() function
+* may be called while the thread owns lock
+* for another dirty buffer for the same
+* vnode, which makes it impossible to use
+* VOP_FSYNC() there, due to the buffer lock
+* recursion.
+*/
+   td-td_pflags |= TDP_BUFNEED | TDP_NORUNNINGBUF;
+   fl = buf_flush(vp, flushbufqtarget);
+   td-td_pflags = norunbuf;
rw_wlock(nblock);
+   if (fl != 0)
+   continue;
if ((needsbuffer  flags) == 0)
break;
}
@@ -2534,18 +2535,20 @@ static struct kproc_desc buf_kp = {
 SYSINIT(bufdaemon, SI_SUB_KTHREAD_BUF, SI_ORDER_FIRST, kproc_start, buf_kp);
 
 static int
-buf_flush(int target)
+buf_flush(struct vnode *vp, int target)
 {
int flushed;
 
-   flushed = flushbufqueues(target, 0);
+   flushed = flushbufqueues(vp, target, 0);
if (flushed == 0) {
/*
 * Could not find any buffers without rollback
 * dependencies, so just write the first one
 * in the hopes of eventually making progress.
 */
-   flushed = flushbufqueues(target, 1);
+   if (vp != NULL  target  2)
+   target /= 2;
+   flushbufqueues(vp, target, 1);
}
return (flushed);
 }
@@ -2582,7 +2585,7 @@ buf_daemon()
 * the I/O system.
 */
while (numdirtybuffers  lodirty) {
-   if (buf_flush(numdirtybuffers - lodirty) == 0)
+   if (buf_flush(NULL, numdirtybuffers - lodirty) == 0)
break;
kern_yield(PRI_USER);
}
@@ -2637,7 +2640,7 @@ SYSCTL_INT(_vfs, OID_AUTO, flushwithdeps
 0, Number of buffers flushed 

svn commit: r282412 - stable/10/libexec/rtld-elf

2015-05-04 Thread Konstantin Belousov
Author: kib
Date: Mon May  4 08:19:12 2015
New Revision: 282412
URL: https://svnweb.freebsd.org/changeset/base/282412

Log:
  MFC r282109:
  Always do token substitution, do not require -z origin to do it.

Modified:
  stable/10/libexec/rtld-elf/rtld.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/libexec/rtld-elf/rtld.c
==
--- stable/10/libexec/rtld-elf/rtld.c   Mon May  4 08:16:32 2015
(r282411)
+++ stable/10/libexec/rtld-elf/rtld.c   Mon May  4 08:19:12 2015
(r282412)
@@ -146,8 +146,10 @@ static void unlink_object(Obj_Entry *);
 static void unload_object(Obj_Entry *);
 static void unref_dag(Obj_Entry *);
 static void ref_dag(Obj_Entry *);
-static char *origin_subst_one(char *, const char *, const char *, bool);
-static char *origin_subst(char *, const char *);
+static char *origin_subst_one(Obj_Entry *, char *, const char *,
+const char *, bool);
+static char *origin_subst(Obj_Entry *, char *);
+static bool obj_resolve_origin(Obj_Entry *obj);
 static void preinit_main(void);
 static int  rtld_verify_versions(const Objlist *);
 static int  rtld_verify_object_versions(Obj_Entry *);
@@ -779,8 +781,8 @@ basename(const char *name)
 static struct utsname uts;
 
 static char *
-origin_subst_one(char *real, const char *kw, const char *subst,
-bool may_free)
+origin_subst_one(Obj_Entry *obj, char *real, const char *kw,
+const char *subst, bool may_free)
 {
char *p, *p1, *res, *resp;
int subst_len, kw_len, subst_count, old_len, new_len;
@@ -799,9 +801,15 @@ origin_subst_one(char *real, const char 
 
/*
 * If the keyword is not found, just return.
+*
+* Return non-substituted string if resolution failed.  We
+* cannot do anything more reasonable, the failure mode of the
+* caller is unresolved library anyway.
 */
-   if (subst_count == 0)
+   if (subst_count == 0 || (obj != NULL  !obj_resolve_origin(obj)))
return (may_free ? real : xstrdup(real));
+   if (obj != NULL)
+   subst = obj-origin_path;
 
/*
 * There is indeed something to substitute.  Calculate the
@@ -838,20 +846,22 @@ origin_subst_one(char *real, const char 
 }
 
 static char *
-origin_subst(char *real, const char *origin_path)
+origin_subst(Obj_Entry *obj, char *real)
 {
char *res1, *res2, *res3, *res4;
 
+   if (obj == NULL || !trust)
+   return (xstrdup(real));
if (uts.sysname[0] == '\0') {
if (uname(uts) != 0) {
_rtld_error(utsname failed: %d, errno);
return (NULL);
}
}
-   res1 = origin_subst_one(real, $ORIGIN, origin_path, false);
-   res2 = origin_subst_one(res1, $OSNAME, uts.sysname, true);
-   res3 = origin_subst_one(res2, $OSREL, uts.release, true);
-   res4 = origin_subst_one(res3, $PLATFORM, uts.machine, true);
+   res1 = origin_subst_one(obj, real, $ORIGIN, NULL, false);
+   res2 = origin_subst_one(NULL, res1, $OSNAME, uts.sysname, true);
+   res3 = origin_subst_one(NULL, res2, $OSREL, uts.release, true);
+   res4 = origin_subst_one(NULL, res3, $PLATFORM, uts.machine, true);
return (res4);
 }
 
@@ -1115,7 +1125,7 @@ digest_dynamic1(Obj_Entry *obj, int earl
 #endif
 
case DT_FLAGS:
-   if ((dynp-d_un.d_val  DF_ORIGIN)  trust)
+   if (dynp-d_un.d_val  DF_ORIGIN)
obj-z_origin = true;
if (dynp-d_un.d_val  DF_SYMBOLIC)
obj-symbolic = true;
@@ -1147,7 +1157,7 @@ digest_dynamic1(Obj_Entry *obj, int earl
case DT_FLAGS_1:
if (dynp-d_un.d_val  DF_1_NOOPEN)
obj-z_noopen = true;
-   if ((dynp-d_un.d_val  DF_1_ORIGIN)  trust)
+   if (dynp-d_un.d_val  DF_1_ORIGIN)
obj-z_origin = true;
if (dynp-d_un.d_val  DF_1_GLOBAL)
obj-z_global = true;
@@ -1198,30 +1208,33 @@ digest_dynamic1(Obj_Entry *obj, int earl
 }
 }
 
+static bool
+obj_resolve_origin(Obj_Entry *obj)
+{
+
+   if (obj-origin_path != NULL)
+   return (true);
+   obj-origin_path = xmalloc(PATH_MAX);
+   return (rtld_dirname_abs(obj-path, obj-origin_path) != -1);
+}
+
 static void
 digest_dynamic2(Obj_Entry *obj, const Elf_Dyn *dyn_rpath,
 const Elf_Dyn *dyn_soname, const Elf_Dyn *dyn_runpath)
 {
 
-if (obj-z_origin  obj-origin_path == NULL) {
-   obj-origin_path = xmalloc(PATH_MAX);
-   if (rtld_dirname_abs(obj-path, obj-origin_path) == -1)
-   rtld_die();
-}
-
-if (dyn_runpath != NULL) {
-   obj-runpath = (char *)obj-strtab + dyn_runpath-d_un.d_val;
-   if (obj-z_origin)
-   obj-runpath = origin_subst(obj-runpath, obj-origin_path);
-}
-else if (dyn_rpath != NULL) {
-   obj-rpath = (char 

svn commit: r282427 - stable/10/sys/net

2015-05-04 Thread Alexander Motin
Author: mav
Date: Mon May  4 19:33:51 2015
New Revision: 282427
URL: https://svnweb.freebsd.org/changeset/base/282427

Log:
  MFC r281765:
  Activate write-only optimization if bpf device opened with O_WRONLY.
  
  dhclient opens bpf as write-only to send packets. It never reads received
  packets from that descriptor, but processing them in kernel takes time.
  Especially much time takes packet timestamping on systems with expensive
  timecounter, such as bhyve guest, where network speed dropped in half.
  
  Sponsored by: iXsystems, Inc.

Modified:
  stable/10/sys/net/bpf.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/bpf.c
==
--- stable/10/sys/net/bpf.c Mon May  4 18:49:25 2015(r282426)
+++ stable/10/sys/net/bpf.c Mon May  4 19:33:51 2015(r282427)
@@ -600,7 +600,7 @@ bpf_attachd(struct bpf_d *d, struct bpf_
 * Save sysctl value to protect from sysctl change
 * between reads
 */
-   op_w = V_bpf_optimize_writers;
+   op_w = V_bpf_optimize_writers || d-bd_writer;
 
if (d-bd_bif != NULL)
bpf_detachd_locked(d);
@@ -802,6 +802,8 @@ bpfopen(struct cdev *dev, int flags, int
 * particular buffer method.
 */
bpf_buffer_init(d);
+   if ((flags  FREAD) == 0)
+   d-bd_writer = 2;
d-bd_hbuf_in_use = 0;
d-bd_bufmode = BPF_BUFMODE_BUFFER;
d-bd_sig = SIGIO;
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to svn-src-stable-10-unsubscr...@freebsd.org


svn commit: r282444 - stable/10/share/man/man9

2015-05-04 Thread Mark Johnston
Author: markj
Date: Tue May  5 03:13:02 2015
New Revision: 282444
URL: https://svnweb.freebsd.org/changeset/base/282444

Log:
  MFC 281701:
  SDT(9): add a section on SDT providers, mentioning the sdt provider.
  Add examples demonstrating how one can list available providers and the
  DTrace probes provided by a provider.

Modified:
  stable/10/share/man/man9/SDT.9
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man9/SDT.9
==
--- stable/10/share/man/man9/SDT.9  Tue May  5 03:08:49 2015
(r282443)
+++ stable/10/share/man/man9/SDT.9  Tue May  5 03:13:02 2015
(r282444)
@@ -24,7 +24,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd March 8, 2015
+.Dd April 18, 2015
 .Dt SDT 9
 .Os
 .Sh NAME
@@ -194,7 +194,37 @@ macros are used to create
 trace points.
 They are meant to be added to executable code and can be used to instrument the
 code in which they are called.
+.Sh PROVIDERS
+A number of kernel DTrace providers are available.
+In general, these providers define stable interfaces and should be treated as
+such: existing D scripts may be broken if a probe is renamed or its arguments
+are modified.
+However, it is often useful to define ad-hoc
+.Nm
+probes for debugging a subsystem or driver.
+Similarly, a developer may wish to provide a group of
+.Nm
+probes without committing to their future stability.
+Such probes should be added to the
+.Ql sdt
+provider instead of defining a new provider.
 .Sh EXAMPLES
+The DTrace providers available on the current system can be listed with
+.Bd -literal -offset indent
+dtrace -l | sed 1d | awk '{print $2}' | sort -u
+.Ed
+.Pp
+A detailed list of the probes offered by a given provider can be obtained by
+specifying the provider using the
+.Fl P
+flag.
+For example, to view the probes and argument types for the
+.Ql sched
+provider, run
+.Bd -literal -offset indent
+dtrace -lv -P sched
+.Ed
+.Pp
 The following probe definition will create a DTrace probe called
 .Ql icmp:::receive-unreachable ,
 which would hypothetically be triggered when the kernel receives an ICMP packet
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to svn-src-stable-10-unsubscr...@freebsd.org


svn commit: r282445 - stable/10/sys/netinet6

2015-05-04 Thread Mark Johnston
Author: markj
Date: Tue May  5 03:17:32 2015
New Revision: 282445
URL: https://svnweb.freebsd.org/changeset/base/282445

Log:
  MFC r281483:
  Fix a possible refcount leak in regen_tmpaddr().

Modified:
  stable/10/sys/netinet6/nd6.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet6/nd6.c
==
--- stable/10/sys/netinet6/nd6.cTue May  5 03:13:02 2015
(r282444)
+++ stable/10/sys/netinet6/nd6.cTue May  5 03:17:32 2015
(r282445)
@@ -757,11 +757,10 @@ regen_tmpaddr(struct in6_ifaddr *ia6)
 * address with the prefix.
 */
if (!IFA6_IS_DEPRECATED(it6))
-   public_ifa6 = it6;
-
-   if (public_ifa6 != NULL)
-   ifa_ref(public_ifa6-ia_ifa);
+   public_ifa6 = it6;
}
+   if (public_ifa6 != NULL)
+   ifa_ref(public_ifa6-ia_ifa);
IF_ADDR_RUNLOCK(ifp);
 
if (public_ifa6 != NULL) {
___
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to svn-src-stable-10-unsubscr...@freebsd.org