svn commit: r253925 - head/contrib/bmake

2013-08-04 Thread Simon J. Gerraty
Author: sjg
Date: Sun Aug  4 07:10:16 2013
New Revision: 253925
URL: http://svnweb.freebsd.org/changeset/base/253925

Log:
  Move the call to Job_SetPrefix() to Job_Init() so that
  makefiles have had a chance to set .MAKE.JOB.PREFIX

Modified:
  head/contrib/bmake/job.c
  head/contrib/bmake/main.c

Modified: head/contrib/bmake/job.c
==
--- head/contrib/bmake/job.cSun Aug  4 06:36:17 2013(r253924)
+++ head/contrib/bmake/job.cSun Aug  4 07:10:16 2013(r253925)
@@ -2214,6 +2214,7 @@ Job_SetPrefix(void)
 void
 Job_Init(void)
 {
+Job_SetPrefix();
 /* Allocate space for all the job info */
 job_table = bmake_malloc(maxJobs * sizeof *job_table);
 memset(job_table, 0, maxJobs * sizeof *job_table);

Modified: head/contrib/bmake/main.c
==
--- head/contrib/bmake/main.c   Sun Aug  4 06:36:17 2013(r253924)
+++ head/contrib/bmake/main.c   Sun Aug  4 07:10:16 2013(r253925)
@@ -1026,7 +1026,6 @@ main(int argc, char **argv)
snprintf(pn, sizeof(pn), "%s[%d]", progname, makelevel);
progname = bmake_strdup(pn);
}
-   Job_SetPrefix();
 
 #ifdef USE_META
meta_init();
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r253887 - head/sys/dev/filemon

2013-08-04 Thread Jilles Tjoelker
On Sun, Aug 04, 2013 at 12:15:23PM +0900, Hiroki Sato wrote:
> Jilles Tjoelker  wrote
>   in <20130802152204.ga1...@stack.nl>:

> ji> You can simplify the code using the fairly new pget(). This will also
> ji> fix the incorrect errno when the process does not exist (should be
> ji> [ESRCH]).
> ji>
> ji> This change is a step in the right direction but is incomplete. Although
> ji> the check protects currently running processes, I do not see how it
> ji> prevents tracing a process that gets the same PID again after the
> ji> original target process has exited. This not only leaks sensitive
> ji> information but may also prevent tracing by the legitimate owner of the
> ji> process (because only one filemon will write events for a process). This
> ji> could be fixed by setting filemon->pid = -1 in
> ji> filemon_wrapper_sys_exit() and not allowing P_WEXIT and zombies in
> ji> FILEMON_SET_PID (PGET_NOTWEXIT disallows both). An [EBUSY] when there is
> ji> already a filemon monitoring the process may also be useful (or writing
> ji> copies of the events to all attached filemons).

>  Thank you for your comments.  Can you review the attached patch?  If
>  there is no problem, I will commit this and MFC to stable branches.

> Index: sys/dev/filemon/filemon.c
> ===
> --- sys/dev/filemon/filemon.c (revision 253911)
> +++ sys/dev/filemon/filemon.c (working copy)
> @@ -164,13 +164,12 @@
> 
>   /* Set the monitored process ID. */
>   case FILEMON_SET_PID:
> - p = pfind(*((pid_t *)data));
> - if (p == NULL)
> - return (EINVAL);
> - error = p_candebug(curthread, p);
> - if (error == 0)
> + error = pget(*((pid_t *)data), PGET_CANDEBUG | PGET_NOTWEXIT,
> + &p);
> + if (error == 0) {
>   filemon->pid = p->p_pid;
> - PROC_UNLOCK(p);
> + PROC_UNLOCK(p);
> + }
>   break;
> 
>   default:
> Index: sys/dev/filemon/filemon_wrapper.c
> ===
> --- sys/dev/filemon/filemon_wrapper.c (revision 253911)
> +++ sys/dev/filemon/filemon_wrapper.c (working copy)
> @@ -574,6 +574,7 @@
>   (uintmax_t)now.tv_sec, (uintmax_t)now.tv_usec);
> 
>   filemon_output(filemon, filemon->msgbufr, len);
> + filemon->pid = -1;
>   }
> 
>   /* Unlock the found filemon structure. */

This looks OK, but I have not tested it.

I think filemon_ioctl() may need to lock the struct filemon. Replacing
the fp seems particularly unsafe.

I did not fully know about the recursive effect on child processes when
I wrote my earlier mail. Filemon allows tracing setuid programs this
way, which may be a security risk and is not possible with ktrace/truss.
Perhaps it is best to commit this patch, but also add a warning to
filemon(4) that it should not be loaded on systems with untrusted users
or the permissions on /dev/filemon should be restricted (via
/etc/devfs.rules).

-- 
Jilles Tjoelker
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253926 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2013-08-04 Thread Steven Hartland
Author: smh
Date: Sun Aug  4 11:38:08 2013
New Revision: 253926
URL: http://svnweb.freebsd.org/changeset/base/253926

Log:
  zfs_ioc_rename should not leave the value of zc_name passed in via zc altered
  on return.
  
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Aug 
 4 07:10:16 2013(r253925)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sun Aug 
 4 11:38:08 2013(r253926)
@@ -3612,6 +3612,8 @@ zfs_ioc_rename(zfs_cmd_t *zc)
at = strchr(zc->zc_name, '@');
if (at != NULL) {
/* snaps must be in same fs */
+   int error;
+
if (strncmp(zc->zc_name, zc->zc_value, at - zc->zc_name + 1))
return (SET_ERROR(EXDEV));
*at = '\0';
@@ -3620,14 +3622,19 @@ zfs_ioc_rename(zfs_cmd_t *zc)
 #else
if (zc->zc_objset_type == DMU_OST_ZFS && allow_mounted) {
 #endif
-   int error = dmu_objset_find(zc->zc_name,
+   error = dmu_objset_find(zc->zc_name,
recursive_unmount, at + 1,
recursive ? DS_FIND_CHILDREN : 0);
-   if (error != 0)
+   if (error != 0) {
+   *at = '@';
return (error);
+   }
}
-   return (dsl_dataset_rename_snapshot(zc->zc_name,
-   at + 1, strchr(zc->zc_value, '@') + 1, recursive));
+   error = dsl_dataset_rename_snapshot(zc->zc_name,
+   at + 1, strchr(zc->zc_value, '@') + 1, recursive);
+   *at = '@';
+
+   return (error);
} else {
 #ifdef illumos
if (zc->zc_objset_type == DMU_OST_ZVOL)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r253887 - head/sys/dev/filemon

2013-08-04 Thread Simon J. Gerraty
>>  Thank you for your comments.  Can you review the attached patch?  If
>>  there is no problem, I will commit this and MFC to stable branches.

Looks good.
But don't commit it untested ;-)
I can test it for you.

>Perhaps it is best to commit this patch, but also add a warning to
>filemon(4) that it should not be loaded on systems with untrusted users
>or the permissions on /dev/filemon should be restricted (via
>/etc/devfs.rules).

That would largely defeat the purpose.
This driver was written to overcome issues with dtrace:

a/ it needed privs beyond normal user
b/ it could not reliably provide path of binary being exec'd
c/ performace

#b is probably fixable, but the fix could not be relied on to exist 
everywhere.

This driver looks at a very limited set of syscalls, and does not report
anything beyond pathnames read/written/exec'd.
In the NetBSD version I even dropped stat calls as being unnecessary
(for make).

dtrace would meet many of Robert's criteria for a general purpose
functionality but allows far more functionality, and apart from the
issues above, cannot (I'm told) be ported to linux.
A simple driver like this can be.


___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253927 - in head/sys: fs/tmpfs kern

2013-08-04 Thread Attilio Rao
Author: attilio
Date: Sun Aug  4 15:56:19 2013
New Revision: 253927
URL: http://svnweb.freebsd.org/changeset/base/253927

Log:
  Remove unnecessary soft busy of the page before to do vn_rdwr() in
  kern_sendfile() which is unnecessary.
  The page is already wired so it will not be subjected to pagefault.
  The content cannot be effectively protected as it is full of races
  already.
  Multiple accesses to the same indexes are serialized through vn_rdwr().
  
  Sponsored by: EMC / Isilon storage division
  Reviewed by:  alc, jeff
  Tested by:pho

Modified:
  head/sys/fs/tmpfs/tmpfs_vnops.c
  head/sys/kern/uipc_syscalls.c

Modified: head/sys/fs/tmpfs/tmpfs_vnops.c
==
--- head/sys/fs/tmpfs/tmpfs_vnops.c Sun Aug  4 11:38:08 2013
(r253926)
+++ head/sys/fs/tmpfs/tmpfs_vnops.c Sun Aug  4 15:56:19 2013
(r253927)
@@ -448,10 +448,8 @@ tmpfs_nocacheread(vm_object_t tobj, vm_p
VM_OBJECT_WLOCK(tobj);
 
/*
-* The kern_sendfile() code calls vn_rdwr() with the page
-* soft-busied.  Ignore the soft-busy state here. Parallel
-* reads of the page content from disk are prevented by
-* VPO_BUSY.
+* Parallel reads of the page content from disk are prevented
+* by VPO_BUSY.
 *
 * Although the tmpfs vnode lock is held here, it is
 * nonetheless safe to sleep waiting for a free page.  The
@@ -460,7 +458,7 @@ tmpfs_nocacheread(vm_object_t tobj, vm_p
 * type object.
 */
m = vm_page_grab(tobj, idx, VM_ALLOC_NORMAL | VM_ALLOC_RETRY |
-   VM_ALLOC_IGN_SBUSY | VM_ALLOC_NOBUSY);
+   VM_ALLOC_NOBUSY);
if (m->valid != VM_PAGE_BITS_ALL) {
vm_page_busy(m);
if (vm_pager_has_page(tobj, idx, NULL, NULL)) {

Modified: head/sys/kern/uipc_syscalls.c
==
--- head/sys/kern/uipc_syscalls.c   Sun Aug  4 11:38:08 2013
(r253926)
+++ head/sys/kern/uipc_syscalls.c   Sun Aug  4 15:56:19 2013
(r253927)
@@ -2246,11 +2246,6 @@ retry_space:
ssize_t resid;
int readahead = sfreadahead * MAXBSIZE;
 
-   /*
-* Ensure that our page is still around
-* when the I/O completes.
-*/
-   vm_page_io_start(pg);
VM_OBJECT_WUNLOCK(obj);
 
/*
@@ -2264,11 +2259,9 @@ retry_space:
trunc_page(off), UIO_NOCOPY, IO_NODELOCKED |
IO_VMIO | ((readahead / bsize) << 
IO_SEQSHIFT),
td->td_ucred, NOCRED, &resid, td);
-   VM_OBJECT_WLOCK(obj);
-   vm_page_io_finish(pg);
-   if (!error)
-   VM_OBJECT_WUNLOCK(obj);
SFSTAT_INC(sf_iocnt);
+   if (error)
+   VM_OBJECT_WLOCK(obj);
}
if (error) {
vm_page_lock(pg);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253930 - head/cddl/contrib/opensolaris/cmd/zfs

2013-08-04 Thread Robert Millan
Author: rmh
Date: Sun Aug  4 16:25:46 2013
New Revision: 253930
URL: http://svnweb.freebsd.org/changeset/base/253930

Log:
  Fix implicit declaration of warnx().

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSun Aug  4 16:23:09 
2013(r253929)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cSun Aug  4 16:25:46 
2013(r253930)
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r253883 - in head: contrib/bmake contrib/bmake/mk contrib/bmake/unit-tests usr.bin/bmake usr.bin/bmake/unit-tests

2013-08-04 Thread Rui Paulo
On 3 Aug 2013, at 23:27, Simon J. Gerraty  wrote:

> 
> On Sat, 3 Aug 2013 22:11:46 -0700, Rui Paulo writes:
>> On 2 Aug 2013, at 23:01, Simon J. Gerraty  wrote:
>> 
>>> 
>>> On Fri, 2 Aug 2013 22:46:36 -0700, Rui Paulo writes:
 Cool! Can we set this in /etc/make.conf ?
>>> 
>>> I would expect so.
>> 
>> Doesn't seem to make any effect...
> 
> Ah, looks like Job_SetPrefix() is called too early, will fix.
> You can set it on the command line for sure.


Yes, that works.

--
Rui Paulo

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r253925 - head/contrib/bmake

2013-08-04 Thread Rui Paulo
On 4 Aug 2013, at 00:10, Simon J. Gerraty  wrote:

> Author: sjg
> Date: Sun Aug  4 07:10:16 2013
> New Revision: 253925
> URL: http://svnweb.freebsd.org/changeset/base/253925
> 
> Log:
>  Move the call to Job_SetPrefix() to Job_Init() so that
>  makefiles have had a chance to set .MAKE.JOB.PREFIX
> 
> Modified:
>  head/contrib/bmake/job.c
>  head/contrib/bmake/main.c


Thanks!

--
Rui Paulo

___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253936 - head/etc/devd

2013-08-04 Thread Rui Paulo
Author: rpaulo
Date: Sun Aug  4 19:36:46 2013
New Revision: 253936
URL: http://svnweb.freebsd.org/changeset/base/253936

Log:
  Regen for if_rsu.

Modified:
  head/etc/devd/usb.conf

Modified: head/etc/devd/usb.conf
==
--- head/etc/devd/usb.conf  Sun Aug  4 19:17:06 2013(r253935)
+++ head/etc/devd/usb.conf  Sun Aug  4 19:36:46 2013(r253936)
@@ -777,7 +777,7 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x050d";
-   match "product" "(0x8053|0x805c|0x815c|0x825a|0x825b)";
+   match "product" "(0x8053|0x805c|0x815c)";
action "kldload -n if_run";
 };
 
@@ -785,6 +785,30 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x050d";
+   match "product" "0x815f";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x050d";
+   match "product" "(0x825a|0x825b)";
+   action "kldload -n if_run";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x050d";
+   match "product" "0x845a";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x050d";
match "product" "0x905b";
action "kldload -n if_rum";
 };
@@ -800,6 +824,14 @@ nomatch 32 {
 nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
+   match "vendor" "0x050d";
+   match "product" "0x945a";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
match "vendor" "0x0525";
match "product" "(0x1080|0xa4a0)";
action "kldload -n udbp";
@@ -1249,6 +1281,14 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x06f8";
+   match "product" "(0xe031|0xe032)";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x06f8";
match "product" "0xe033";
action "kldload -n if_urtwn";
 };
@@ -1457,6 +1497,14 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x07aa";
+   match "product" "0x0047";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x07aa";
match "product" "0x0056";
action "kldload -n if_urtwn";
 };
@@ -1561,6 +1609,14 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x07d1";
+   match "product" "(0x3300|0x3302|0x3303)";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x07d1";
match "product" "0x3a0c";
action "kldload -n if_uath";
 };
@@ -1657,7 +1713,23 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x083a";
-   match "product" 
"(0x6618|0x7511|0x7512|0x7522|0x8522|0xa512|0xa618|0xa701|0xa702|0xb522|0xc522|0xd522)";
+   match "product" 
"(0x6618|0x7511|0x7512|0x7522|0x8522|0xa512|0xa618|0xa701|0xa702|0xb522)";
+   action "kldload -n if_run";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x083a";
+   match "product" "0xc512";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x083a";
+   match "product" "(0xc522|0xd522)";
action "kldload -n if_run";
 };
 
@@ -2137,7 +2209,39 @@ nomatch 32 {
match "bus" "uhub[0-9]+";
match "mode" "host";
match "vendor" "0x0b05";
-   match "product" 
"(0x1731|0x1732|0x1742|0x1760|0x1761|0x1784|0x1790|0x179d)";
+   match "product" "(0x1731|0x1732|0x1742|0x1760|0x1761|0x1784)";
+   action "kldload -n if_run";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x0b05";
+   match "product" "0x1786";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x0b05";
+   match "product" "0x1790";
+   action "kldload -n if_run";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x0b05";
+   match "product" "0x1791";
+   action "kldload -n if_rsu";
+};
+
+nomatch 32 {
+   match "bus" "uhub[0-9]+";
+   match "mode" "host";
+   match "vendor" "0x0b05";
+   match "product" "0x179d";
action "kldload -n if_run";
 };
 
@@ -2273,7 +2377,23 @@ nomatch 32 {
   

svn commit: r253937 - head/sys/dev/iwn

2013-08-04 Thread Hiren Panchasara
Author: hiren
Date: Sun Aug  4 19:54:47 2013
New Revision: 253937
URL: http://svnweb.freebsd.org/changeset/base/253937

Log:
  Fixing a typo.
  
  Approved by:  sbruno (mentor, implicit)

Modified:
  head/sys/dev/iwn/if_iwn.c

Modified: head/sys/dev/iwn/if_iwn.c
==
--- head/sys/dev/iwn/if_iwn.c   Sun Aug  4 19:36:46 2013(r253936)
+++ head/sys/dev/iwn/if_iwn.c   Sun Aug  4 19:54:47 2013(r253937)
@@ -7489,7 +7489,7 @@ iwn_hw_reset(void *arg0, int pending)
 #defineCOUNTOF(array) (sizeof(array) / sizeof(array[0]))
 
 /*
- * Transate CSR code to string
+ * Translate CSR code to string
  */
 static char *iwn_get_csr_string(int csr)
 {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253938 - head/sys/geom/part

2013-08-04 Thread Marcel Moolenaar
Author: marcel
Date: Sun Aug  4 21:00:22 2013
New Revision: 253938
URL: http://svnweb.freebsd.org/changeset/base/253938

Log:
  Remove inclusion of . We have no business knowing
  anything related to MBR in this file.

Modified:
  head/sys/geom/part/g_part.c
  head/sys/geom/part/g_part_apm.c

Modified: head/sys/geom/part/g_part.c
==
--- head/sys/geom/part/g_part.c Sun Aug  4 19:54:47 2013(r253937)
+++ head/sys/geom/part/g_part.c Sun Aug  4 21:00:22 2013(r253938)
@@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

Modified: head/sys/geom/part/g_part_apm.c
==
--- head/sys/geom/part/g_part_apm.c Sun Aug  4 19:54:47 2013
(r253937)
+++ head/sys/geom/part/g_part_apm.c Sun Aug  4 21:00:22 2013
(r253938)
@@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253939 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs fs/tmpfs kern vm

2013-08-04 Thread Attilio Rao
Author: attilio
Date: Sun Aug  4 21:07:24 2013
New Revision: 253939
URL: http://svnweb.freebsd.org/changeset/base/253939

Log:
  The page hold mechanism is fast but it has couple of fallouts:
  - It does not let pages respect the LRU policy
  - It bloats the active/inactive queues of few pages
  
  Try to avoid it as much as possible with the long-term target to
  completely remove it.
  Use the soft-busy mechanism to protect page content accesses during
  short-term operations (like uiomove_fromphys()).
  
  After this change only vm_fault_quick_hold_pages() is still using the
  hold mechanism for page content access.
  There is an additional complexity there as the quick path cannot
  immediately access the page object to busy the page and the slow path
  cannot however busy more than one page a time (to avoid deadlocks).
  
  Fixing such primitive can bring to complete removal of the page hold
  mechanism.
  
  Sponsored by: EMC / Isilon storage division
  Discussed with:   alc
  Reviewed by:  jeff
  Tested by:pho

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  head/sys/fs/tmpfs/tmpfs_vnops.c
  head/sys/kern/imgact_elf.c
  head/sys/kern/kern_exec.c
  head/sys/kern/sys_process.c
  head/sys/vm/vm_extern.h
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_glue.c
  head/sys/vm/vm_map.h

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sun Aug 
 4 21:00:22 2013(r253938)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sun Aug 
 4 21:07:24 2013(r253939)
@@ -324,7 +324,8 @@ zfs_ioctl(vnode_t *vp, u_long com, intpt
 }
 
 static vm_page_t
-page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t nbytes)
+page_busy(vnode_t *vp, int64_t start, int64_t off, int64_t nbytes,
+boolean_t alloc)
 {
vm_object_t obj;
vm_page_t pp;
@@ -346,6 +347,8 @@ page_busy(vnode_t *vp, int64_t start, in
continue;
}
} else if (pp == NULL) {
+   if (!alloc)
+   break;
pp = vm_page_alloc(obj, OFF_TO_IDX(start),
VM_ALLOC_SYSTEM | VM_ALLOC_IFCACHED |
VM_ALLOC_NOBUSY);
@@ -356,8 +359,10 @@ page_busy(vnode_t *vp, int64_t start, in
 
if (pp != NULL) {
ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL);
-   vm_object_pip_add(obj, 1);
vm_page_io_start(pp);
+   if (!alloc)
+   break;
+   vm_object_pip_add(obj, 1);
pmap_remove_write(pp);
vm_page_clear_dirty(pp, off, nbytes);
}
@@ -367,55 +372,12 @@ page_busy(vnode_t *vp, int64_t start, in
 }
 
 static void
-page_unbusy(vm_page_t pp)
+page_unbusy(vm_page_t pp, boolean_t unalloc)
 {
 
vm_page_io_finish(pp);
-   vm_object_pip_subtract(pp->object, 1);
-}
-
-static vm_page_t
-page_hold(vnode_t *vp, int64_t start)
-{
-   vm_object_t obj;
-   vm_page_t pp;
-
-   obj = vp->v_object;
-   zfs_vmobject_assert_wlocked(obj);
-
-   for (;;) {
-   if ((pp = vm_page_lookup(obj, OFF_TO_IDX(start))) != NULL &&
-   pp->valid) {
-   if ((pp->oflags & VPO_BUSY) != 0) {
-   /*
-* Reference the page before unlocking and
-* sleeping so that the page daemon is less
-* likely to reclaim it.
-*/
-   vm_page_reference(pp);
-   vm_page_sleep(pp, "zfsmwb");
-   continue;
-   }
-
-   ASSERT3U(pp->valid, ==, VM_PAGE_BITS_ALL);
-   vm_page_lock(pp);
-   vm_page_hold(pp);
-   vm_page_unlock(pp);
-
-   } else
-   pp = NULL;
-   break;
-   }
-   return (pp);
-}
-
-static void
-page_unhold(vm_page_t pp)
-{
-
-   vm_page_lock(pp);
-   vm_page_unhold(pp);
-   vm_page_unlock(pp);
+   if (unalloc)
+   vm_object_pip_subtract(pp->object, 1);
 }
 
 static caddr_t
@@ -479,7 +441,8 @@ update_pages(vnode_t *vp, int64_t start,
 
zfs_vmobject_wlock(obj);
vm_page_undirty(pp);
-   } else if ((pp = page_busy(vp, start, off, nbytes)) != NULL) {
+   } else if ((pp = page_busy(vp, start, off, nbytes,
+   TRUE)) != NULL) {
zfs_vmobject_wunlock(obj);
 
va = zfs_map_p

svn commit: r253940 - in head/sys/sparc64: include sparc64

2013-08-04 Thread Attilio Rao
Author: attilio
Date: Sun Aug  4 21:17:05 2013
New Revision: 253940
URL: http://svnweb.freebsd.org/changeset/base/253940

Log:
  Remove unused member.
  
  Sponsored by: EMC / Isilon storage division
  Reviewed by:  alc
  Tested by:pho

Modified:
  head/sys/sparc64/include/pmap.h
  head/sys/sparc64/sparc64/pmap.c

Modified: head/sys/sparc64/include/pmap.h
==
--- head/sys/sparc64/include/pmap.h Sun Aug  4 21:07:24 2013
(r253939)
+++ head/sys/sparc64/include/pmap.h Sun Aug  4 21:17:05 2013
(r253940)
@@ -56,7 +56,6 @@ struct md_page {
struct  pmap *pmap;
uint32_t colors[DCACHE_COLORS];
int32_t color;
-   uint32_t flags;
 };
 
 struct pmap {

Modified: head/sys/sparc64/sparc64/pmap.c
==
--- head/sys/sparc64/sparc64/pmap.c Sun Aug  4 21:07:24 2013
(r253939)
+++ head/sys/sparc64/sparc64/pmap.c Sun Aug  4 21:17:05 2013
(r253940)
@@ -765,7 +765,6 @@ pmap_page_init(vm_page_t m)
 
TAILQ_INIT(&m->md.tte_list);
m->md.color = DCACHE_COLOR(VM_PAGE_TO_PHYS(m));
-   m->md.flags = 0;
m->md.pmap = NULL;
 }
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253949 - in head/sys: amd64/amd64 i386/i386

2013-08-04 Thread Jeff Roberson
Author: jeff
Date: Mon Aug  5 00:28:03 2013
New Revision: 253949
URL: http://svnweb.freebsd.org/changeset/base/253949

Log:
   - Introduce a specific function, pmap_remove_kernel_pde, for removing
 huge pages in the kernel's address space.  This works around several
 asserts from pmap_demote_pde_locked that did not apply and gave false
 warnings.
  
  Discovered by:pho
  Reviewed by:  alc
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/amd64/amd64/pmap.c
  head/sys/i386/i386/pmap.c

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Sun Aug  4 23:45:04 2013(r253948)
+++ head/sys/amd64/amd64/pmap.c Mon Aug  5 00:28:03 2013(r253949)
@@ -2795,6 +2795,44 @@ pmap_demote_pde_locked(pmap_t pmap, pd_e
 }
 
 /*
+ * pmap_remove_kernel_pde: Remove a kernel superpage mapping.
+ */
+static void
+pmap_remove_kernel_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va)
+{
+   pd_entry_t newpde;
+   vm_paddr_t mptepa;
+   vm_page_t mpte;
+
+   PMAP_LOCK_ASSERT(pmap, MA_OWNED);
+   mpte = pmap_lookup_pt_page(pmap, va);
+   if (mpte == NULL)
+   panic("pmap_remove_kernel_pde: Missing pt page.");
+
+   pmap_remove_pt_page(pmap, mpte);
+   mptepa = VM_PAGE_TO_PHYS(mpte);
+   newpde = mptepa | PG_M | PG_A | PG_RW | PG_V;
+
+   /*
+* Initialize the page table page.
+*/
+   pagezero((void *)PHYS_TO_DMAP(mptepa));
+
+   /*
+* Demote the mapping.
+*/
+   if (workaround_erratum383)
+   pmap_update_pde(pmap, va, pde, newpde);
+   else
+   pde_store(pde, newpde);
+
+   /*
+* Invalidate a stale recursive mapping of the page table page.
+*/
+   pmap_invalidate_page(pmap, (vm_offset_t)vtopte(va));
+}
+
+/*
  * pmap_remove_pde: do the things to unmap a superpage in a process
  */
 static int
@@ -2837,8 +2875,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t 
}
}
if (pmap == kernel_pmap) {
-   if (!pmap_demote_pde_locked(pmap, pdq, sva, lockp))
-   panic("pmap_remove_pde: failed demotion");
+   pmap_remove_kernel_pde(pmap, pdq, sva);
} else {
mpte = pmap_lookup_pt_page(pmap, sva);
if (mpte != NULL) {

Modified: head/sys/i386/i386/pmap.c
==
--- head/sys/i386/i386/pmap.c   Sun Aug  4 23:45:04 2013(r253948)
+++ head/sys/i386/i386/pmap.c   Mon Aug  5 00:28:03 2013(r253949)
@@ -2773,6 +2773,44 @@ pmap_demote_pde(pmap_t pmap, pd_entry_t 
 }
 
 /*
+ * Removes a 2- or 4MB page mapping from the kernel pmap.
+ */
+static void
+pmap_remove_kernel_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va)
+{
+   pd_entry_t newpde;
+   vm_paddr_t mptepa;
+   vm_page_t mpte;
+
+   PMAP_LOCK_ASSERT(pmap, MA_OWNED);
+   mpte = pmap_lookup_pt_page(pmap, va);
+   if (mpte == NULL)
+   panic("pmap_remove_kernel_pde: Missing pt page.");
+
+   pmap_remove_pt_page(pmap, mpte);
+   mptepa = VM_PAGE_TO_PHYS(mpte);
+   newpde = mptepa | PG_M | PG_A | PG_RW | PG_V;
+
+   /*
+* Initialize the page table page.
+*/
+   pagezero((void *)&KPTmap[i386_btop(trunc_4mpage(va))]);
+
+   /*
+* Remove the mapping.
+*/
+   if (workaround_erratum383)
+   pmap_update_pde(pmap, va, pde, newpde);
+   else 
+   pmap_kenter_pde(va, newpde);
+
+   /*
+* Invalidate the recursive mapping of the page table page.
+*/
+   pmap_invalidate_page(pmap, (vm_offset_t)vtopte(va));
+}
+
+/*
  * pmap_remove_pde: do the things to unmap a superpage in a process
  */
 static void
@@ -2814,8 +2852,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t 
}
}
if (pmap == kernel_pmap) {
-   if (!pmap_demote_pde(pmap, pdq, sva))
-   panic("pmap_remove_pde: failed demotion");
+   pmap_remove_kernel_pde(pmap, pdq, sva);
} else {
mpte = pmap_lookup_pt_page(pmap, sva);
if (mpte != NULL) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r253950 - head/sys/netinet6

2013-08-04 Thread Hiroki Sato
Author: hrs
Date: Mon Aug  5 00:36:12 2013
New Revision: 253950
URL: http://svnweb.freebsd.org/changeset/base/253950

Log:
  Fix a panic in tmpaddrtimer.

Modified:
  head/sys/netinet6/in6_ifattach.c

Modified: head/sys/netinet6/in6_ifattach.c
==
--- head/sys/netinet6/in6_ifattach.cMon Aug  5 00:28:03 2013
(r253949)
+++ head/sys/netinet6/in6_ifattach.cMon Aug  5 00:36:12 2013
(r253950)
@@ -932,6 +932,8 @@ in6_tmpaddrtimer(void *arg)
 
bzero(nullbuf, sizeof(nullbuf));
TAILQ_FOREACH(ifp, &V_ifnet, if_list) {
+   if (ifp->if_afdata[AF_INET6] == NULL)
+   continue;
ndi = ND_IFINFO(ifp);
if (bcmp(ndi->randomid, nullbuf, sizeof(nullbuf)) != 0) {
/*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r253862 - head/sys/boot/ficl

2013-08-04 Thread Jan Beich
Marcel Moolenaar  writes:

> +static union { 
> + struct dirent dirent;
> + char buf[512];
> +} u;
> +off_t off;
> +int len;
[...]
> +/*
> + * The readdirfd() function is specific to the loader environment.
> + * We do the best we can to make freaddir work, but it's not at
> + * all guaranteed.
> + */
> +off = lseek(fd, 0LL, SEEK_CUR);
> +len = getdents(fd, u.buf, sizeof(u.buf));
> +d = (len != -1) ? &u.dirent : NULL;
> +if (d != NULL)
> + lseek(fd, off + d->d_reclen, SEEK_SET);

How did you test? I can't make the code work on amd64 using
either ficl32 or ficl64.

  # r253862
  ok> s" /bin" 0 fopen
  ok> dup freaddir . type cr
  -1 .
  ok> dup freaddir . type cr
  -1 sleep
  ok> dup freaddir . type cr
  -1 sleep
  ok> dup freaddir . type cr
  -1 sleep
  ok> dup freaddir . type cr
  -1 sleep

  # bin/172542
  ok> s" /bin" 0 fopen
  ok> dup freaddir . type cr
  -1 .
  ok> dup freaddir . type cr
  -1 ..
  ok> dup freaddir . type cr
  -1 sleep
  ok> dup freaddir . type cr
  -1 domainname
  ok> dup freaddir . type cr
  -1 ps
  ok> dup freaddir . type cr
  -1 sync
  ok> dup freaddir . type cr
  -1 red  
  
  # zfsloader (no '.' and '..' - zfs_readdir bug?)
  OK s" /bin" 0 fopen
  OK dup freaddir . type cr
  -1 cat
  OK dup freaddir . type cr
  -1 sh
  OK dup freaddir . type cr
  -1 chflags
  OK dup freaddir . type cr
  -1 chio
  OK dup freaddir . type cr
  -1 sleep
  OK dup freaddir . type cr
  -1 chmod

Here's an example with a loop almost endless.

  # r253862 
  ok> s" /bin" lsdir
  .
  sleep
  sleep
  sleep
  ...

  \ list directory contents
  : lsdir ( dir -- )
0 fopen
begin
  dup
  freaddir
while
  type cr
repeat
fclose
  ;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r253862 - head/sys/boot/ficl

2013-08-04 Thread Marcel Moolenaar

On Aug 4, 2013, at 2:06 PM, Jan Beich  wrote:

> Marcel Moolenaar  writes:
> 
>> +static union { 
>> +struct dirent dirent;
>> +char buf[512];
>> +} u;
>> +off_t off;
>> +int len;
> [...]
>> +/*
>> + * The readdirfd() function is specific to the loader environment.
>> + * We do the best we can to make freaddir work, but it's not at
>> + * all guaranteed.
>> + */
>> +off = lseek(fd, 0LL, SEEK_CUR);
>> +len = getdents(fd, u.buf, sizeof(u.buf));
>> +d = (len != -1) ? &u.dirent : NULL;
>> +if (d != NULL)
>> +lseek(fd, off + d->d_reclen, SEEK_SET);
> 
> How did you test?

On amd64 with UFS. The problem is that using d_reclen to get to
the next dirent is highly non-portable and depends on the FS
used:

fbsdvm64% uname -m
amd64
fbsdvm64% pwd
/usr/src/sys/boot/ficl
fbsdvm64% ./testmain 
ficl Version 3.03
Aug  4 2013 

ok> s" /bin" 0 fopen . cr
3
ok> 3 freaddir . type cr
-1 .
ok> 3 freaddir . type cr
-1 ..
ok> 3 freaddir . type cr
-1 chflags
ok> 3 freaddir . type cr
-1 [
ok> 3 freaddir . type cr
-1 cat
ok> 3 freaddir . type cr
-1 domainname
ok> 3 freaddir . type cr
-1 chio
ok> 3 freaddir . type cr
-1 chmod
ok> 3 freaddir . type cr
-1 cp
ok> 3 freaddir . type cr
-1 csh

It's probably not going to work on any other FS. The
alternative is to just not support freaddir due to lack
of runtime support.

FYI,

-- 
Marcel Moolenaar
mar...@xcllnt.net


___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r253887 - head/sys/dev/filemon

2013-08-04 Thread Hiroki Sato
"Simon J. Gerraty"  wrote
  in <20130804151754.8189758...@chaos.jnpr.net>:

sj> >>  Thank you for your comments.  Can you review the attached patch?  If
sj> >>  there is no problem, I will commit this and MFC to stable branches.
sj>
sj> Looks good.
sj> But don't commit it untested ;-)
sj> I can test it for you.

 Okay, I will wait for the results.

-- Hiroki


pgphKqb9x7cuD.pgp
Description: PGP signature


Re: svn commit: r253862 - head/sys/boot/ficl

2013-08-04 Thread Jan Beich
Marcel Moolenaar  writes:

> On Aug 4, 2013, at 2:06 PM, Jan Beich  wrote:
>
>> Marcel Moolenaar  writes:
>> 
>>> +static union { 
>>> +   struct dirent dirent;
>>> +   char buf[512];
>>> +} u;
>>> +off_t off;
>>> +int len;
>> [...]
>>> +/*
>>> + * The readdirfd() function is specific to the loader environment.
>>> + * We do the best we can to make freaddir work, but it's not at
>>> + * all guaranteed.
>>> + */
>>> +off = lseek(fd, 0LL, SEEK_CUR);
>>> +len = getdents(fd, u.buf, sizeof(u.buf));
>>> +d = (len != -1) ? &u.dirent : NULL;
>>> +if (d != NULL)
>>> +   lseek(fd, off + d->d_reclen, SEEK_SET);
>> 
>> How did you test?
>
> On amd64 with UFS. The problem is that using d_reclen to get to
> the next dirent is highly non-portable and depends on the FS
> used:
>
> fbsdvm64% uname -m
> amd64
> fbsdvm64% pwd
> /usr/src/sys/boot/ficl
> fbsdvm64% ./testmain 
> ficl Version 3.03
> Aug  4 2013 
>
> ok> s" /bin" 0 fopen . cr
> 3
> ok> 3 freaddir . type cr
> -1 .
> ok> 3 freaddir . type cr
> -1 ..
> ok> 3 freaddir . type cr
> -1 chflags
> ok> 3 freaddir . type cr
> -1 [
> ok> 3 freaddir . type cr
> -1 cat
> ok> 3 freaddir . type cr
> -1 domainname
> ok> 3 freaddir . type cr
> -1 chio
> ok> 3 freaddir . type cr
> -1 chmod
> ok> 3 freaddir . type cr
> -1 cp
> ok> 3 freaddir . type cr
> -1 csh

Except there'd be no FICL_FALSE after the last entry. Try running
my lsdir function.

>
> It's probably not going to work on any other FS. The
> alternative is to just not support freaddir due to lack
> of runtime support.

What's the issue with my version in bin/172542 ? It doesn't
use d_reclen but relies on a side-effect of readdir() call.

>>  +static DIR *dir;
>>  +if (lseek(fd, 0, SEEK_CUR) == 0)
>>  +   dir = fdopendir(fd);
>>  +if (dir != NULL)
>>  +   d = readdir(dir);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"