From owner-svn-src-user@FreeBSD.ORG Sun Oct 31 01:44:41 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 18D50106566C; Sun, 31 Oct 2010 01:44:40 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AA64E8FC15; Sun, 31 Oct 2010 01:44:40 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9V1ieQ0037059; Sun, 31 Oct 2010 01:44:40 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V1ieN1037057; Sun, 31 Oct 2010 01:44:40 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201010310144.o9V1ieN1037057@svn.freebsd.org> From: Doug Barton Date: Sun, 31 Oct 2010 01:44:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214580 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 01:44:41 -0000 Author: dougb Date: Sun Oct 31 01:44:40 2010 New Revision: 214580 URL: http://svn.freebsd.org/changeset/base/214580 Log: Don't call update_build_l() (which also updates PM_NEEDS_UPDATE) in multiport() or update_port(), instead always call it from the main routine, which occurs after the user has made a decision about any +IGNOREME files that might be present. (Also simplifies a bit.) Related to the above, in multiport() if the child returns and the port in question is not in PM_NEEDS_UPDATE (usually/[only?] because there is an +IGNOREME and they chose not to proceed) then add the port to PM_MULTI_BUILT and decrement $num_ports so that it will be ignored in the build phase. In post_first_pass() return if PM_NEEDS_UPDATE is empty. This is a micro-op in the common case, but allows us to give the right message to the user in the -a case where the only port that needs updating has an +IGNOREME file, and the user chose not to proceed. For -a add some whitespace around the "all ports are up to date" Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Oct 31 00:51:22 2010 (r214579) +++ user/dougb/portmaster/portmaster Sun Oct 31 01:44:40 2010 (r214580) @@ -2148,10 +2148,7 @@ update_port () { dep_of_deps=$(( $dep_of_deps + 1 )) - if [ -n "$PM_FIRST_PASS" ]; then - num_of_deps=$(( $num_of_deps + 1 )) - update_build_l $1 - fi + [ -n "$PM_FIRST_PASS" ] && num_of_deps=$(( $num_of_deps + 1 )) deps=" (${dep_of_deps}/${num_of_deps})" @@ -2464,6 +2461,7 @@ post_first_pass () { fi PM_NEEDS_UPDATE=${PM_NEEDS_UPDATE# } + [ -z "$PM_NEEDS_UPDATE" ] && return action=build if [ "$PM_PACKAGES" = only ]; then @@ -2587,7 +2585,13 @@ multiport () { init_term_printf "$port ${numports}/${numports}" ($0 $ARGS $port) || fail "Update for $port failed" . $IPC_SAVE - update_build_l $port + + case "$PM_NEEDS_UPDATE" in + *\ ${origin}\ *) continue ;; + # Handle +IGNOREME in child + *) PM_MULTI_BUILT="${PM_MULTI_BUILT}${port}:" + numports=$(( $numports - 1 )) ;; + esac done check_fetch_only @@ -2807,7 +2811,7 @@ all_first_pass () { check_fetch_only if [ -n "$NO_DEP_UPDATES" ]; then - echo "===>>> All ports are up to date" + echo '' ; echo "===>>> All ports are up to date" ; echo '' safe_exit fi @@ -2969,10 +2973,11 @@ else PM_DEPTH="${PM_DEPTH}>> ${upg_port:-$portdir} " fi -if [ -n "$PM_FIRST_PASS" -a "$$" -eq "$PM_PARENT_PID" ]; then +if [ -n "$PM_FIRST_PASS" ]; then if [ -n "$upg_port" ]; then update_build_l $upg_port - [ -n "$UPDATE_REQ_BYS" -a -n "$RESTART" ] && check_for_updates $upg_port + [ -n "$UPDATE_REQ_BYS" -a -n "$RESTART" -a "$$" -eq "$PM_PARENT_PID" ] && + check_for_updates $upg_port else update_build_l $portdir fi From owner-svn-src-user@FreeBSD.ORG Sun Oct 31 01:57:14 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06794106564A; Sun, 31 Oct 2010 01:57:14 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E9A5D8FC08; Sun, 31 Oct 2010 01:57:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9V1vDbZ037801; Sun, 31 Oct 2010 01:57:13 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V1vDDp037799; Sun, 31 Oct 2010 01:57:13 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201010310157.o9V1vDDp037799@svn.freebsd.org> From: Doug Barton Date: Sun, 31 Oct 2010 01:57:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214581 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 01:57:14 -0000 Author: dougb Date: Sun Oct 31 01:57:13 2010 New Revision: 214581 URL: http://svn.freebsd.org/changeset/base/214581 Log: We only need the "you can restart" text if -n PM_NEEDS_UPDATE Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Oct 31 01:44:40 2010 (r214580) +++ user/dougb/portmaster/portmaster Sun Oct 31 01:57:13 2010 (r214581) @@ -211,7 +211,7 @@ parent_exit () { echo '' fi - if [ -n "$1" ]; then + if [ -n "$1" -a -n "$PM_NEEDS_UPDATE" ]; then echo '' echo "===>>> You can restart from the point of failure with this command line:" echo " ${0##*/} $PM_NEEDS_UPDATE" From owner-svn-src-user@FreeBSD.ORG Sun Oct 31 02:15:24 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51D2A106566B; Sun, 31 Oct 2010 02:15:24 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 40A0E8FC1A; Sun, 31 Oct 2010 02:15:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9V2FOdS038651; Sun, 31 Oct 2010 02:15:24 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V2FOAv038648; Sun, 31 Oct 2010 02:15:24 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201010310215.o9V2FOAv038648@svn.freebsd.org> From: Doug Barton Date: Sun, 31 Oct 2010 02:15:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214582 - in user/dougb/portmaster: . files X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 02:15:24 -0000 Author: dougb Date: Sun Oct 31 02:15:23 2010 New Revision: 214582 URL: http://svn.freebsd.org/changeset/base/214582 Log: Clarify the problem described in the PR: The -e option can only deal with one port at a time so update the docs to reflect that more clearly, and update the code to use the various return values of find_glob_dirs() to make it more clear if the user specifies a pattern that matches more than one. PR: ports/151824 Submitted by: Ben Grimm Modified: user/dougb/portmaster/files/portmaster.8 user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/files/portmaster.8 ============================================================================== --- user/dougb/portmaster/files/portmaster.8 Sun Oct 31 01:57:13 2010 (r214581) +++ user/dougb/portmaster/files/portmaster.8 Sun Oct 31 02:15:23 2010 (r214582) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 8, 2010 +.Dd October 30, 2010 .Dt PORTMASTER 8 .Os .Sh NAME @@ -107,7 +107,7 @@ and/or multiple globs from /var/db/pkg .Fl [l|L] .Nm .Op Fl b [D|d] -.Fl e Ar name/glob of port directory in /var/db/pkg +.Fl e Ar name/glob of a single port directory in /var/db/pkg .Nm .Op Fl b [D|d] .Fl s @@ -468,8 +468,8 @@ requirements. list all installed ports by category .It Fl L list all installed ports by category, and search for updates -.It Fl e Ar name/glob of port directory in /var/db/pkg -expunge port using +.It Fl e Ar name/glob of a single port directory in /var/db/pkg +expunge a port using .Xr pkg_delete 1 , and optionally remove all distfiles. Calls Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Oct 31 01:57:13 2010 (r214581) +++ user/dougb/portmaster/portmaster Sun Oct 31 02:15:23 2010 (r214582) @@ -291,7 +291,7 @@ usage () { echo '' echo "${0##*/} -[l|L]" echo '' - echo "${0##*/} [-b D|d] -e " + echo "${0##*/} [-b D|d] -e " echo "${0##*/} [-b D|d] -s" echo '' echo "${0##*/} [--force-config|-G] [-aftv] -F" @@ -365,7 +365,7 @@ usage () { echo '-l list installed ports by category' echo '-L list installed ports by category, and search for updates' echo '' - echo '-e expunge a port via pkg_delete, and remove its distfiles' + echo '-e expunge a single port via pkg_delete, and remove its distfiles' echo '-s clean out stale ports that used to be depended on' echo '' echo '[--force-config|-G] [-aftv] -F fetch distfiles only' @@ -1907,12 +1907,14 @@ fi if [ -n "$EXPUNGE" ]; then if [ ! -d "$pdb/$EXPUNGE" ]; then - if find_glob_dirs $EXPUNGE; then - EXPUNGE=${glob_dirs#$pdb/} - unset glob_dirs - else - fail "No such directory/port: $pdb/$EXPUNGE" - fi + find_glob_dirs $EXPUNGE + case $? in + 1) fail "No such directory/port: $pdb/$EXPUNGE" ;; + 2) echo "===>>> $EXPUNGE matched multiple ports" + fail "The -e option works with only one port at a time" ;; + 0) EXPUNGE=${glob_dirs#$pdb/} + unset glob_dirs ;; + esac fi origin=`origin_from_pdb $EXPUNGE` From owner-svn-src-user@FreeBSD.ORG Sun Oct 31 07:09:59 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 047FB1065674; Sun, 31 Oct 2010 07:09:59 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE5A18FC14; Sun, 31 Oct 2010 07:09:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9V79wAn053716; Sun, 31 Oct 2010 07:09:58 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9V79wC5053714; Sun, 31 Oct 2010 07:09:58 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201010310709.o9V79wC5053714@svn.freebsd.org> From: Doug Barton Date: Sun, 31 Oct 2010 07:09:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214587 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Oct 2010 07:09:59 -0000 Author: dougb Date: Sun Oct 31 07:09:58 2010 New Revision: 214587 URL: http://svn.freebsd.org/changeset/base/214587 Log: In safe_exit() strip the prepended space from $PM_NEEDS_UPDATE before testing it with -n. Further reduce the amount of pointless stuff we do for -F, and clarify some user output to show we're fetching, not reinstalling. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Sun Oct 31 04:45:53 2010 (r214586) +++ user/dougb/portmaster/portmaster Sun Oct 31 07:09:58 2010 (r214587) @@ -211,6 +211,7 @@ parent_exit () { echo '' fi + PM_NEEDS_UPDATE=${PM_NEEDS_UPDATE# } if [ -n "$1" -a -n "$PM_NEEDS_UPDATE" ]; then echo '' echo "===>>> You can restart from the point of failure with this command line:" @@ -2144,7 +2145,11 @@ update_port () { else case "$1" in */*) echo "===>>> Launching child to install ${1#$pd/}" ;; - *) echo "===>>> Launching child to reinstall $1" ;; + *) if [ -z "$FETCH_ONLY" ]; then + echo "===>>> Launching child to reinstall $1" + else + echo "===>>> Launching child to check distfiles for $1" + fi ;; esac fi @@ -2680,7 +2685,7 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S if [ -n "$LOCALBASE" ]; then LOCALBASE_COMPAT="$LOCALBASE/lib/compat/pkg" - else + elif [ -z "$FETCH_ONLY" ]; then PLB=`pm_make_b -f/usr/share/mk/bsd.port.mk -V LOCALBASE 2>/dev/null` if [ -n "$PLB" ]; then LOCALBASE_COMPAT="$PLB/lib/compat/pkg" @@ -2724,9 +2729,12 @@ if [ "$$" -eq "$PM_PARENT_PID" -a -z "$S fi fi - PM_FIRST_PASS=pm_first_pass ; PM_NEEDS_UPDATE=' ' - NO_DEP_UPDATES=no_dep_updates ; build_l='' - export PM_FIRST_PASS PM_NEEDS_UPDATE NO_DEP_UPDATES build_l + PM_FIRST_PASS=pm_first_pass ; export PM_FIRST_PASS + + if [ -z "$FETCH_ONLY" ]; then + PM_NEEDS_UPDATE=' ' ; NO_DEP_UPDATES=no_dep_updates ; build_l='' + export PM_NEEDS_UPDATE NO_DEP_UPDATES build_l + fi if [ -n "$PM_BUILD_ONLY_LIST" ]; then run_dl_g='' ; build_only_dl_g='' ; rundep_list='' @@ -2975,7 +2983,7 @@ else PM_DEPTH="${PM_DEPTH}>> ${upg_port:-$portdir} " fi -if [ -n "$PM_FIRST_PASS" ]; then +if [ -n "$PM_FIRST_PASS" -a -z "$FETCH_ONLY" ]; then if [ -n "$upg_port" ]; then update_build_l $upg_port [ -n "$UPDATE_REQ_BYS" -a -n "$RESTART" -a "$$" -eq "$PM_PARENT_PID" ] && From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 06:11:05 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 050CD106566B; Tue, 2 Nov 2010 06:11:05 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CDFDD8FC0A; Tue, 2 Nov 2010 06:11:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA26B4G8023178; Tue, 2 Nov 2010 06:11:04 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA26B47S023177; Tue, 2 Nov 2010 06:11:04 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020611.oA26B47S023177@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 06:11:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214656 - user/davidxu X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 06:11:05 -0000 Author: davidxu Date: Tue Nov 2 06:11:04 2010 New Revision: 214656 URL: http://svn.freebsd.org/changeset/base/214656 Log: create dir for me. Added: user/davidxu/ From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 06:13:21 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 85A51106566C; Tue, 2 Nov 2010 06:13:21 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5A9A18FC13; Tue, 2 Nov 2010 06:13:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA26DLWw023287; Tue, 2 Nov 2010 06:13:21 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA26DLhk023286; Tue, 2 Nov 2010 06:13:21 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020613.oA26DLhk023286@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 06:13:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214657 - user/davidxu/libthr X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 06:13:21 -0000 Author: davidxu Date: Tue Nov 2 06:13:21 2010 New Revision: 214657 URL: http://svn.freebsd.org/changeset/base/214657 Log: libthr work. Added: - copied from r214656, head/ Directory Properties: user/davidxu/libthr/ (props changed) From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 06:47:18 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F8CE1065670; Tue, 2 Nov 2010 06:47:18 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CA278FC14; Tue, 2 Nov 2010 06:47:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA26lIgP024659; Tue, 2 Nov 2010 06:47:18 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA26lIJA024650; Tue, 2 Nov 2010 06:47:18 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020647.oA26lIJA024650@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 06:47:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214658 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 06:47:18 -0000 Author: davidxu Date: Tue Nov 2 06:47:18 2010 New Revision: 214658 URL: http://svn.freebsd.org/changeset/base/214658 Log: Implement userland sleep queue. The queue is used to eliminate extra context switches and system calls in condition variable use. The problem is pthread_cond_broadcast can cause thread scheduler's thundering hurd, and because a thread calls pthread_cond_signal or pthread_cond_broadcast with mutex locked, resumed thread tries to lock the mutex and is block again, this is extra context switch. The change tries to move sleeping threads from condition variable's wait queue to mutex wait queue, only when the mutex is unlocked, a sleeping thread is woken up, in ideal case, only one system call is needed. Modified: user/davidxu/libthr/lib/libthr/thread/Makefile.inc user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/lib/libthr/thread/thr_init.c user/davidxu/libthr/lib/libthr/thread/thr_kern.c user/davidxu/libthr/lib/libthr/thread/thr_list.c user/davidxu/libthr/lib/libthr/thread/thr_mutex.c user/davidxu/libthr/lib/libthr/thread/thr_private.h user/davidxu/libthr/lib/libthr/thread/thr_umtx.c user/davidxu/libthr/lib/libthr/thread/thr_umtx.h Modified: user/davidxu/libthr/lib/libthr/thread/Makefile.inc ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/Makefile.inc Tue Nov 2 06:13:21 2010 (r214657) +++ user/davidxu/libthr/lib/libthr/thread/Makefile.inc Tue Nov 2 06:47:18 2010 (r214658) @@ -45,6 +45,7 @@ SRCS+= \ thr_setschedparam.c \ thr_sig.c \ thr_single_np.c \ + thr_sleepq.c \ thr_spec.c \ thr_spinlock.c \ thr_stack.c \ Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Tue Nov 2 06:13:21 2010 (r214657) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Tue Nov 2 06:47:18 2010 (r214658) @@ -45,7 +45,10 @@ int __pthread_cond_timedwait(pthread_con static int cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); static int cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, int cancel); -static int cond_signal_common(pthread_cond_t *cond, int broadcast); +static int cond_signal_common(pthread_cond_t *cond); +static int cond_broadcast_common(pthread_cond_t *cond); + +#define CV_PSHARED(cv) (((cv)->c_kerncv.c_flags & USYNC_PROCESS_SHARED) != 0) /* * Double underscore versions are cancellation points. Single underscore @@ -74,13 +77,12 @@ cond_init(pthread_cond_t *cond, const pt * Initialise the condition variable structure: */ if (cond_attr == NULL || *cond_attr == NULL) { - pcond->c_pshared = 0; pcond->c_clockid = CLOCK_REALTIME; } else { - pcond->c_pshared = (*cond_attr)->c_pshared; + if ((*cond_attr)->c_pshared) + pcond->c_kerncv.c_flags |= USYNC_PROCESS_SHARED; pcond->c_clockid = (*cond_attr)->c_clockid; } - _thr_umutex_init(&pcond->c_lock); *cond = pcond; } /* Return the completion status: */ @@ -128,7 +130,6 @@ _pthread_cond_init(pthread_cond_t *cond, int _pthread_cond_destroy(pthread_cond_t *cond) { - struct pthread *curthread = _get_curthread(); struct pthread_cond *cv; int rval = 0; @@ -138,10 +139,10 @@ _pthread_cond_destroy(pthread_cond_t *co rval = EINVAL; else { cv = *cond; - THR_UMUTEX_LOCK(curthread, &cv->c_lock); + if (cv->c_mutex != NULL) + return (EBUSY); + _thr_ucond_broadcast(&cv->c_kerncv); *cond = THR_COND_DESTROYED; - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); - /* * Free the memory allocated for the condition * variable structure: @@ -155,54 +156,36 @@ struct cond_cancel_info { pthread_mutex_t *mutex; pthread_cond_t *cond; - int count; + int recurse; }; static void cond_cancel_handler(void *arg) { - struct pthread *curthread = _get_curthread(); struct cond_cancel_info *info = (struct cond_cancel_info *)arg; - pthread_cond_t cv; - - if (info->cond != NULL) { - cv = *(info->cond); - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); - } - _mutex_cv_lock(info->mutex, info->count); + + _mutex_cv_lock(info->mutex, info->recurse, 1); } /* - * Cancellation behaivor: - * Thread may be canceled at start, if thread is canceled, it means it - * did not get a wakeup from pthread_cond_signal(), otherwise, it is - * not canceled. - * Thread cancellation never cause wakeup from pthread_cond_signal() - * to be lost. + * Wait on kernel based condition variable. */ static int -cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, +cond_wait_kernel(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, int cancel) { struct pthread *curthread = _get_curthread(); struct timespec ts, ts2, *tsp; + struct pthread_mutex *m; struct cond_cancel_info info; pthread_cond_t cv; - int ret; - - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - CHECK_AND_INIT_COND + int error, error2; cv = *cond; - THR_UMUTEX_LOCK(curthread, &cv->c_lock); - ret = _mutex_cv_unlock(mutex, &info.count); - if (__predict_false(ret != 0)) { - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); - return (ret); - } + m = *mutex; + error = _mutex_cv_detach(mutex, &info.recurse); + if (__predict_false(error != 0)) + return (error); info.mutex = mutex; info.cond = cond; @@ -217,17 +200,129 @@ cond_wait_common(pthread_cond_t *cond, p if (cancel) { THR_CLEANUP_PUSH(curthread, cond_cancel_handler, &info); _thr_cancel_enter2(curthread, 0); - ret = _thr_ucond_wait(&cv->c_kerncv, &cv->c_lock, tsp, 1); + error = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 1); info.cond = NULL; - _thr_cancel_leave(curthread, (ret != 0)); + _thr_cancel_leave(curthread, (error != 0)); THR_CLEANUP_POP(curthread, 0); } else { - ret = _thr_ucond_wait(&cv->c_kerncv, &cv->c_lock, tsp, 0); + error = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); + } + if (error == EINTR) + error = 0; + error2 = _mutex_cv_lock(mutex, info.recurse, 1); + return (error || error2); +} + +/* + * Cancellation behaivor: + * Thread may be canceled at start, if thread is canceled, it means it + * did not get a wakeup from pthread_cond_signal(), otherwise, it is + * not canceled. + * Thread cancellation never cause wakeup from pthread_cond_signal() + * to be lost. + */ +static int +cond_wait_queue(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime, int cancel) +{ + struct pthread *curthread = _get_curthread(); + struct pthread_mutex *m; + struct sleepqueue *sq; + pthread_cond_t cv; + int recurse; + int error; + + cv = *cond; + /* + * Enqueue thread before unlocking mutex, so we can avoid + * sleep lock in pthread_cond_signal whenever possible. + */ + if ((error = _mutex_owned(curthread, mutex)) != 0) + return (error); + sq = _sleepq_lock(cv, CV); + if (cv->c_mutex != NULL && cv->c_mutex != mutex) { + _sleepq_unlock(sq); + return (EINVAL); + } + cv->c_mutex = mutex; + _sleepq_add(sq, curthread); + _thr_clear_wake(curthread); + _sleepq_unlock(sq); + (void)_mutex_cv_unlock(mutex, &recurse); + m = *mutex; + for (;;) { + if (cancel) { + _thr_cancel_enter2(curthread, 0); + error = _thr_sleep(curthread, abstime, cv->c_clockid); + _thr_cancel_leave(curthread, 0); + } else { + error = _thr_sleep(curthread, abstime, cv->c_clockid); + } + _thr_clear_wake(curthread); + + sq = _sleepq_lock(cv, CV); + if (curthread->wchan == NULL) { + /* + * This must be signaled by mutex unlocking, + * they remove us from mutex queue. + */ + _sleepq_unlock(sq); + error = 0; + break; + } if (curthread->wchan == m) { + _sleepq_unlock(sq); + /* + * This must be signaled by cond_signal and there + * is no owner for the mutex. + */ + sq = _sleepq_lock(m, MX); + if (curthread->wchan == m) + _sleepq_remove(sq, curthread); + _sleepq_unlock(sq); + error = 0; + break; + } if (abstime != NULL && error == ETIMEDOUT) { + _sleepq_remove(sq, curthread); + if (_sleepq_empty(sq)) + cv->c_mutex = NULL; + _sleepq_unlock(sq); + break; + } else if (SHOULD_CANCEL(curthread)) { + _sleepq_remove(sq, curthread); + if (_sleepq_empty(sq)) + cv->c_mutex = NULL; + _sleepq_unlock(sq); + (void)_mutex_cv_lock(mutex, recurse, 0); + _pthread_exit(PTHREAD_CANCELED); + } + _sleepq_unlock(sq); + } + _mutex_cv_lock(mutex, recurse, 0); + return (error); +} + +static int +cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime, int cancel) +{ + pthread_cond_t cv; + struct pthread_mutex *m; + + /* + * If the condition variable is statically initialized, + * perform the dynamic initialization: + */ + CHECK_AND_INIT_COND + if ((m = *mutex) == NULL || m < THR_MUTEX_DESTROYED) + return (EINVAL); + if (IS_SIMPLE_MUTEX(m)) { + if (!CV_PSHARED(cv)) + return cond_wait_queue(cond, mutex, abstime, cancel); + else + return (EINVAL); + } else { + return cond_wait_kernel(cond, mutex, abstime, cancel); } - if (ret == EINTR) - ret = 0; - _mutex_cv_lock(mutex, info.count); - return (ret); } int @@ -269,11 +364,14 @@ __pthread_cond_timedwait(pthread_cond_t } static int -cond_signal_common(pthread_cond_t *cond, int broadcast) +cond_signal_common(pthread_cond_t *cond) { - struct pthread *curthread = _get_curthread(); - pthread_cond_t cv; - int ret = 0; + pthread_mutex_t *mutex; + struct pthread_mutex *m; + struct pthread *td; + struct pthread_cond *cv; + struct sleepqueue *cv_sq, *mx_sq; + unsigned *waddr = NULL; /* * If the condition variable is statically initialized, perform dynamic @@ -281,25 +379,118 @@ cond_signal_common(pthread_cond_t *cond, */ CHECK_AND_INIT_COND - THR_UMUTEX_LOCK(curthread, &cv->c_lock); - if (!broadcast) - ret = _thr_ucond_signal(&cv->c_kerncv); - else - ret = _thr_ucond_broadcast(&cv->c_kerncv); - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); - return (ret); + _thr_ucond_signal(&cv->c_kerncv); + + if (CV_PSHARED(cv)) + return (0); + + /* There is no waiter. */ + if (cv->c_mutex == NULL) + return (0); + + cv_sq = _sleepq_lock(cv, CV); + if (_sleepq_empty(cv_sq)) { + _sleepq_unlock(cv_sq); + return (0); + } + /* + * Check if we owned the temporarily binding mutex, + * if owned, we can migrate thread to mutex wait + * queue without waking up thread. + */ + if ((mutex = cv->c_mutex) != NULL) + m = *mutex; + else { + _sleepq_unlock(cv_sq); + PANIC("mutex == NULL"); + } + + td = _sleepq_first(cv_sq); + if (m->m_owner == NULL) + waddr = WAKE_ADDR(td); + _sleepq_remove(cv_sq, td); + mx_sq = _sleepq_lock(m, MX); + _sleepq_add(mx_sq, td); + _mutex_set_contested(m); + _sleepq_unlock(mx_sq); + if (_sleepq_empty(cv_sq)) + cv->c_mutex = NULL; + _sleepq_unlock(cv_sq); + if (waddr != NULL) { + _thr_set_wake(waddr); + _thr_umtx_wake(waddr, INT_MAX, 0); + } + return (0); +} + +static int +cond_broadcast_common(pthread_cond_t *cond) +{ + pthread_mutex_t *mutex; + struct pthread_mutex *m; + struct pthread *td; + struct pthread_cond *cv; + struct sleepqueue *cv_sq, *mx_sq; + unsigned *waddr = NULL; + + /* + * If the condition variable is statically initialized, perform dynamic + * initialization. + */ + CHECK_AND_INIT_COND + + _thr_ucond_broadcast(&cv->c_kerncv); + + if (CV_PSHARED(cv)) + return (0); + + /* There is no waiter. */ + if (cv->c_mutex == NULL) + return (0); + + cv_sq = _sleepq_lock(cv, CV); + if (_sleepq_empty(cv_sq)) { + _sleepq_unlock(cv_sq); + return (0); + } + /* + * Check if we owned the temporarily binding mutex, + * if owned, we can migrate thread to mutex wait + * queue without waking up thread. + */ + if ((mutex = cv->c_mutex) != NULL) + m = *mutex; + else { + _sleepq_unlock(cv_sq); + PANIC("mutex == NULL"); + } + + td = _sleepq_first(cv_sq); + if (m->m_owner == NULL) + waddr = WAKE_ADDR(td); + mx_sq = _sleepq_lock(m, MX); + _sleepq_concat(mx_sq, cv_sq); + _mutex_set_contested(m); + _sleepq_unlock(mx_sq); + cv->c_mutex = NULL; + _sleepq_unlock(cv_sq); + if (waddr != NULL) { + _thr_set_wake(waddr); + _thr_umtx_wake(waddr, INT_MAX, 0); + } + return (0); } int _pthread_cond_signal(pthread_cond_t * cond) { - return (cond_signal_common(cond, 0)); + return (cond_signal_common(cond)); } int _pthread_cond_broadcast(pthread_cond_t * cond) { - return (cond_signal_common(cond, 1)); + return (cond_broadcast_common(cond)); } Modified: user/davidxu/libthr/lib/libthr/thread/thr_init.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_init.c Tue Nov 2 06:13:21 2010 (r214657) +++ user/davidxu/libthr/lib/libthr/thread/thr_init.c Tue Nov 2 06:47:18 2010 (r214658) @@ -444,6 +444,7 @@ init_private(void) _thr_once_init(); _thr_spinlock_init(); _thr_list_init(); + _sleepq_init(); /* * Avoid reinitializing some things if they don't need to be, Modified: user/davidxu/libthr/lib/libthr/thread/thr_kern.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_kern.c Tue Nov 2 06:13:21 2010 (r214657) +++ user/davidxu/libthr/lib/libthr/thread/thr_kern.c Tue Nov 2 06:47:18 2010 (r214658) @@ -31,6 +31,7 @@ #include #include #include +#include #include "thr_private.h" @@ -41,6 +42,53 @@ #define DBG_MSG(x...) #endif +static struct umutex addr_lock; +static struct wake_addr *wake_addr_head; +static struct wake_addr default_wake_addr; + +struct wake_addr * +_thr_alloc_wake_addr(void) +{ + struct pthread *curthread; + struct wake_addr *p; + + if (_thr_initial == NULL) { + return &default_wake_addr; + } + + curthread = _get_curthread(); + + THR_UMUTEX_LOCK(curthread, &addr_lock); + if (wake_addr_head == NULL) { + unsigned i; + unsigned pagesize = getpagesize(); + struct wake_addr *pp = (struct wake_addr *)mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); + for (i = 1; i < pagesize/sizeof(struct wake_addr); ++i) + pp[i].link = &pp[i+1]; + pp[i-1].link = NULL; + wake_addr_head = &pp[1]; + p = &pp[0]; + } else { + p = wake_addr_head; + wake_addr_head = p->link; + } + THR_UMUTEX_UNLOCK(curthread, &addr_lock); + return (p); +} + +void +_thr_release_wake_addr(struct wake_addr *wa) +{ + struct pthread *curthread = _get_curthread(); + + if (wa == &default_wake_addr) + return; + THR_UMUTEX_LOCK(curthread, &addr_lock); + wa->link = wake_addr_head; + wake_addr_head = wa; + THR_UMUTEX_UNLOCK(curthread, &addr_lock); +} + /* * This is called when the first thread (other than the initial * thread) is created. @@ -130,3 +178,29 @@ _thr_setscheduler(lwpid_t lwpid, int pol _schedparam_to_rtp(policy, param, &rtp); return (rtprio_thread(RTP_SET, lwpid, &rtp)); } + +/* Sleep on thread wakeup address */ +int +_thr_sleep(struct pthread *curthread, const struct timespec *abstime, int clockid) +{ + struct timespec *tsp, ts, ts2; + int error; + + if (abstime != NULL) { + if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || + abstime->tv_nsec >= 1000000000) { + return (EINVAL); + } + clock_gettime(clockid, &ts); + TIMESPEC_SUB(&ts2, abstime, &ts); + if (ts2.tv_sec < 0 || ts2.tv_nsec <= 0) + return (ETIMEDOUT); + tsp = &ts2; + } else { + tsp = NULL; + } + + error = _thr_umtx_wait_uint(&curthread->wake_addr->value, + 0, tsp, 0); + return (error); +} Modified: user/davidxu/libthr/lib/libthr/thread/thr_list.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_list.c Tue Nov 2 06:13:21 2010 (r214657) +++ user/davidxu/libthr/lib/libthr/thread/thr_list.c Tue Nov 2 06:47:18 2010 (r214658) @@ -165,6 +165,8 @@ _thr_alloc(struct pthread *curthread) if (tcb != NULL) { memset(thread, 0, sizeof(*thread)); thread->tcb = tcb; + thread->wake_addr = _thr_alloc_wake_addr(); + thread->sleepqueue = _sleepq_alloc(); } else { thr_destroy(curthread, thread); atomic_fetchadd_int(&total_threads, -1); @@ -193,6 +195,8 @@ _thr_free(struct pthread *curthread, str thread->tcb = NULL; if ((curthread == NULL) || (free_thread_count >= MAX_CACHED_THREADS)) { thr_destroy(curthread, thread); + _thr_release_wake_addr(thread->wake_addr); + _sleepq_free(thread->sleepqueue); atomic_fetchadd_int(&total_threads, -1); } else { /* Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 06:13:21 2010 (r214657) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 06:47:18 2010 (r214658) @@ -45,6 +45,10 @@ #include "thr_private.h" +#ifndef UMUTEX_TIDMASK +#define UMUTEX_TIDMASK (~UMUTEX_CONTESTED) +#endif + #if defined(_PTHREADS_INVARIANTS) #define MUTEX_INIT_LINK(m) do { \ (m)->m_qe.tqe_prev = NULL; \ @@ -55,8 +59,8 @@ PANIC("mutex is not on list"); \ } while (0) #define MUTEX_ASSERT_NOT_OWNED(m) do { \ - if (__predict_false((m)->m_qe.tqe_prev != NULL || \ - (m)->m_qe.tqe_next != NULL)) \ + if (__predict_false((m)->m_qe.tqe_prev != NULL ||\ + (m)->m_qe.tqe_next != NULL)) \ PANIC("mutex is on list"); \ } while (0) #else @@ -93,8 +97,6 @@ static int mutex_self_trylock(pthread_mu static int mutex_self_lock(pthread_mutex_t, const struct timespec *abstime); static int mutex_unlock_common(pthread_mutex_t *); -static int mutex_lock_sleep(struct pthread *, pthread_mutex_t, - const struct timespec *); __weak_reference(__pthread_mutex_init, pthread_mutex_init); __strong_reference(__pthread_mutex_init, _pthread_mutex_init); @@ -147,7 +149,7 @@ mutex_init(pthread_mutex_t *mutex, pmutex->m_type = attr->m_type; pmutex->m_owner = NULL; - pmutex->m_count = 0; + pmutex->m_recurse = 0; pmutex->m_refcount = 0; pmutex->m_spinloops = 0; pmutex->m_yieldloops = 0; @@ -173,7 +175,6 @@ mutex_init(pthread_mutex_t *mutex, _thr_spinloops ? _thr_spinloops: MUTEX_ADAPTIVE_SPINS; pmutex->m_yieldloops = _thr_yieldloops; } - *mutex = pmutex; return (0); } @@ -181,19 +182,19 @@ mutex_init(pthread_mutex_t *mutex, static int init_static(struct pthread *thread, pthread_mutex_t *mutex) { - int ret; + int error; THR_LOCK_ACQUIRE(thread, &_mutex_static_lock); if (*mutex == THR_MUTEX_INITIALIZER) - ret = mutex_init(mutex, &_pthread_mutexattr_default, calloc); + error = mutex_init(mutex, &_pthread_mutexattr_default, calloc); else if (*mutex == THR_ADAPTIVE_MUTEX_INITIALIZER) - ret = mutex_init(mutex, &_pthread_mutexattr_adaptive_default, calloc); + error = mutex_init(mutex, &_pthread_mutexattr_adaptive_default, calloc); else - ret = 0; + error = 0; THR_LOCK_RELEASE(thread, &_mutex_static_lock); - return (ret); + return (error); } static void @@ -225,12 +226,12 @@ _pthread_mutex_init_calloc_cb(pthread_mu .m_protocol = PTHREAD_PRIO_NONE, .m_ceiling = 0 }; - int ret; + int error; - ret = mutex_init(mutex, &attr, calloc_cb); - if (ret == 0) + error = mutex_init(mutex, &attr, calloc_cb); + if (error == 0) (*mutex)->m_private = 1; - return (ret); + return (error); } void @@ -247,9 +248,9 @@ _mutex_fork(struct pthread *curthread) * process shared mutex is not supported, so I * am not worried. */ - - TAILQ_FOREACH(m, &curthread->mutexq, m_qe) + TAILQ_FOREACH(m, &curthread->mutexq, m_qe) { m->m_lock.m_owner = TID(curthread); + } TAILQ_FOREACH(m, &curthread->pp_mutexq, m_qe) m->m_lock.m_owner = TID(curthread) | UMUTEX_CONTESTED; } @@ -284,20 +285,32 @@ _pthread_mutex_destroy(pthread_mutex_t * (m)->m_owner = curthread; \ /* Add to the list of owned mutexes: */ \ MUTEX_ASSERT_NOT_OWNED((m)); \ - if (((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0) \ + if (__predict_true(((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) \ TAILQ_INSERT_TAIL(&curthread->mutexq, (m), m_qe);\ else \ TAILQ_INSERT_TAIL(&curthread->pp_mutexq, (m), m_qe);\ } while (0) +#define DEQUEUE_MUTEX(curthread, m) \ + (m)->m_owner = NULL; \ + /* Remove the mutex from the threads queue. */ \ + MUTEX_ASSERT_IS_OWNED(m); \ + if (__predict_true(((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) \ + TAILQ_REMOVE(&curthread->mutexq, (m), m_qe); \ + else { \ + TAILQ_REMOVE(&curthread->pp_mutexq, (m), m_qe); \ + set_inherited_priority(curthread, (m)); \ + } \ + MUTEX_INIT_LINK(m); + #define CHECK_AND_INIT_MUTEX \ if (__predict_false((m = *mutex) <= THR_MUTEX_DESTROYED)) { \ if (m == THR_MUTEX_DESTROYED) \ return (EINVAL); \ - int ret; \ - ret = init_static(_get_curthread(), mutex); \ - if (ret) \ - return (ret); \ + int error; \ + error = init_static(_get_curthread(), mutex); \ + if (error) \ + return (error); \ m = *mutex; \ } @@ -307,20 +320,20 @@ mutex_trylock_common(pthread_mutex_t *mu struct pthread *curthread = _get_curthread(); struct pthread_mutex *m = *mutex; uint32_t id; - int ret; - + int error; + id = TID(curthread); if (m->m_private) THR_CRITICAL_ENTER(curthread); - ret = _thr_umutex_trylock(&m->m_lock, id); - if (__predict_true(ret == 0)) { + error = _thr_umutex_trylock(&m->m_lock, id); + if (__predict_true(error == 0)) { ENQUEUE_MUTEX(curthread, m); } else if (m->m_owner == curthread) { - ret = mutex_self_trylock(m); + error = mutex_self_trylock(m); } /* else {} */ - if (ret && m->m_private) + if (error != 0 && m->m_private) THR_CRITICAL_LEAVE(curthread); - return (ret); + return (error); } int @@ -333,92 +346,149 @@ __pthread_mutex_trylock(pthread_mutex_t return (mutex_trylock_common(mutex)); } +/* Lock user-mode queue based mutex. */ static int -mutex_lock_sleep(struct pthread *curthread, struct pthread_mutex *m, +mutex_lock_queued(struct pthread_mutex *m, const struct timespec *abstime) { - uint32_t id, owner; - int count; - int ret; - - if (m->m_owner == curthread) - return mutex_self_lock(m, abstime); + struct pthread *curthread = _get_curthread(); + struct sleepqueue *sq; + uint32_t owner, tid; + int error = 0; + int spin; + + spin = m->m_spinloops; + tid = TID(curthread); + for (;;) { + if (!_thr_is_smp) + goto sleep; - id = TID(curthread); - /* - * For adaptive mutexes, spin for a bit in the expectation - * that if the application requests this mutex type then - * the lock is likely to be released quickly and it is - * faster than entering the kernel - */ - if (__predict_false( - (m->m_lock.m_flags & - (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) != 0)) - goto sleep_in_kernel; - - if (!_thr_is_smp) - goto yield_loop; - - count = m->m_spinloops; - while (count--) { - owner = m->m_lock.m_owner; - if ((owner & ~UMUTEX_CONTESTED) == 0) { - if (atomic_cmpset_acq_32(&m->m_lock.m_owner, owner, id|owner)) { - ret = 0; - goto done; + while (spin-- > 0) { + /* + * For adaptive mutexes, spin for a bit in the expectation + * that if the application requests this mutex type then + * the lock is likely to be released quickly and it is + * faster than entering the kernel + */ + owner = m->m_lockword; + if ((owner & UMUTEX_TIDMASK) == 0) { + if (atomic_cmpset_acq_32(&m->m_lockword, owner, owner|tid)) { + ENQUEUE_MUTEX(curthread, m); + error = 0; + goto out; + } } + CPU_SPINWAIT; } - CPU_SPINWAIT; - } +sleep: + _thr_clear_wake(curthread); -yield_loop: - count = m->m_yieldloops; - while (count--) { - _sched_yield(); - owner = m->m_lock.m_owner; - if ((owner & ~UMUTEX_CONTESTED) == 0) { - if (atomic_cmpset_acq_32(&m->m_lock.m_owner, owner, id|owner)) { - ret = 0; - goto done; + sq = _sleepq_lock(m, MX); + if (curthread->wchan == NULL) + _sleepq_add(sq, curthread); + _sleepq_unlock(sq); + owner = m->m_lockword; + /* Set contested bit. */ + while ((owner & UMUTEX_TIDMASK) != 0 && (owner & UMUTEX_CONTESTED) == 0) { + if (atomic_cmpset_acq_32(&m->m_lockword, + owner, owner|UMUTEX_CONTESTED)) + break; + owner = m->m_lockword; + } + if ((owner & UMUTEX_TIDMASK) != 0) { + error = _thr_sleep(curthread, abstime, CLOCK_REALTIME); + if (error != EINTR) { + if (curthread->wchan != NULL) { + sq = _sleepq_lock(m, MX); + if (curthread->wchan != NULL) + _sleepq_remove(sq, curthread); + _sleepq_unlock(sq); + } + } else + error = 0; + owner = m->m_lockword; + } + if ((owner & UMUTEX_TIDMASK) == 0) { + if (atomic_cmpset_acq_32(&m->m_lockword, owner, owner|tid)) { + ENQUEUE_MUTEX(curthread, m); + error = 0; + break; } } + if (error != 0) + break; + spin = m->m_spinloops; } +out: + if (curthread->wchan != NULL) { + sq = _sleepq_lock(m, MX); + if (curthread->wchan != NULL) + _sleepq_remove(sq, curthread); + _sleepq_unlock(sq); + } + return (error); +} -sleep_in_kernel: +/* Enter kernel and lock mutex */ +static int +mutex_lock_kernel(struct pthread_mutex *m, + const struct timespec *abstime) +{ + struct pthread *curthread = _get_curthread(); + uint32_t id; + int error; + + id = TID(curthread); if (abstime == NULL) { - ret = __thr_umutex_lock(&m->m_lock, id); - } else if (__predict_false( - abstime->tv_nsec < 0 || - abstime->tv_nsec >= 1000000000)) { - ret = EINVAL; + error = __thr_umutex_lock(&m->m_lock, id); } else { - ret = __thr_umutex_timedlock(&m->m_lock, id, abstime); + error = __thr_umutex_timedlock(&m->m_lock, id, abstime); } -done: - if (ret == 0) + if (error == 0) ENQUEUE_MUTEX(curthread, m); - - return (ret); + return (error); } static inline int -mutex_lock_common(struct pthread_mutex *m, - const struct timespec *abstime) +_mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime) { - struct pthread *curthread = _get_curthread(); - int ret; + struct pthread *curthread = _get_curthread(); + int error; - if (m->m_private) - THR_CRITICAL_ENTER(curthread); if (_thr_umutex_trylock2(&m->m_lock, TID(curthread)) == 0) { ENQUEUE_MUTEX(curthread, m); - ret = 0; + error = 0; + } else if (m->m_owner == curthread) { + error = mutex_self_lock(m, abstime); } else { - ret = mutex_lock_sleep(curthread, m, abstime); + if (__predict_false(abstime != NULL && + (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || + abstime->tv_nsec >= 1000000000))) + error = EINVAL; + else if (__predict_true(IS_SIMPLE_MUTEX(m))) + error = mutex_lock_queued(m, abstime); + else + error = mutex_lock_kernel(m, abstime); } - if (ret && m->m_private) - THR_CRITICAL_LEAVE(curthread); - return (ret); + return (error); +} + +static inline int +mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime) +{ + int error; + + if (!m->m_private) { + error = _mutex_lock_common(m, abstime); + } else { + struct pthread *curthread = _get_curthread(); + + THR_CRITICAL_ENTER(curthread); + error = _mutex_lock_common(m, abstime); + if (error != 0) + THR_CRITICAL_LEAVE(curthread); + } + return (error); } int @@ -451,54 +521,39 @@ _pthread_mutex_unlock(pthread_mutex_t *m return (mutex_unlock_common(m)); } -int -_mutex_cv_lock(pthread_mutex_t *mutex, int count) -{ - struct pthread_mutex *m; - int ret; - - m = *mutex; - ret = mutex_lock_common(m, NULL); - if (ret == 0) { - m->m_refcount--; - m->m_count += count; - } - return (ret); -} - static int mutex_self_trylock(struct pthread_mutex *m) { - int ret; + int error; switch (m->m_type) { case PTHREAD_MUTEX_ERRORCHECK: case PTHREAD_MUTEX_NORMAL: - ret = EBUSY; + error = EBUSY; break; case PTHREAD_MUTEX_RECURSIVE: /* Increment the lock count: */ - if (m->m_count + 1 > 0) { - m->m_count++; - ret = 0; + if (m->m_recurse + 1 > 0) { + m->m_recurse++; + error = 0; } else - ret = EAGAIN; + error = EAGAIN; break; default: /* Trap invalid mutex types; */ - ret = EINVAL; + error = EINVAL; } - return (ret); + return (error); } static int mutex_self_lock(struct pthread_mutex *m, const struct timespec *abstime) { struct timespec ts1, ts2; - int ret; + int error; switch (m->m_type) { case PTHREAD_MUTEX_ERRORCHECK: @@ -506,19 +561,19 @@ mutex_self_lock(struct pthread_mutex *m, if (abstime) { if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { - ret = EINVAL; + error = EINVAL; } else { clock_gettime(CLOCK_REALTIME, &ts1); TIMESPEC_SUB(&ts2, abstime, &ts1); __sys_nanosleep(&ts2, NULL); - ret = ETIMEDOUT; + error = ETIMEDOUT; } } else { /* * POSIX specifies that mutexes should return * EDEADLK if a recursive lock is detected. */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 06:58:01 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99C08106566C; Tue, 2 Nov 2010 06:58:01 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 87A1F8FC08; Tue, 2 Nov 2010 06:58:01 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA26w1UC025066; Tue, 2 Nov 2010 06:58:01 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA26w1Aq025063; Tue, 2 Nov 2010 06:58:01 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020658.oA26w1Aq025063@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 06:58:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214659 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 06:58:01 -0000 Author: davidxu Date: Tue Nov 2 06:58:01 2010 New Revision: 214659 URL: http://svn.freebsd.org/changeset/base/214659 Log: For simple mutex, we don't use thread id as owner data, instead use some contants. This eliminates the need to link the mutex into thread's private list, saves some cycles. The m_owner is pointer of curthread, which is always duplicated in child process after fork(), so for atfork handler in child process which wants to unlock the mutex, it will success rather than return EPERM. Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c user/davidxu/libthr/lib/libthr/thread/thr_private.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 06:47:18 2010 (r214658) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 06:58:01 2010 (r214659) @@ -156,7 +156,7 @@ mutex_init(pthread_mutex_t *mutex, MUTEX_INIT_LINK(pmutex); switch(attr->m_protocol) { case PTHREAD_PRIO_NONE: - pmutex->m_lock.m_owner = UMUTEX_UNOWNED; + pmutex->m_lock.m_owner = 0; pmutex->m_lock.m_flags = 0; break; case PTHREAD_PRIO_INHERIT: @@ -314,23 +314,51 @@ _pthread_mutex_destroy(pthread_mutex_t * m = *mutex; \ } +static inline int +set_lockword(struct pthread_mutex *m) +{ + uint32_t old; + + if (atomic_cmpset_acq_32(&m->m_lockword, 0, MTX_LOCKED)) + return (0); + old = m->m_lockword; + while ((old & MTX_LOCKED) == 0) { + if (atomic_cmpset_acq_32(&m->m_lockword, old, old|MTX_LOCKED)) + return (0); + } + return (EBUSY); +} + static int mutex_trylock_common(pthread_mutex_t *mutex) { struct pthread *curthread = _get_curthread(); struct pthread_mutex *m = *mutex; - uint32_t id; int error; - id = TID(curthread); if (m->m_private) THR_CRITICAL_ENTER(curthread); - error = _thr_umutex_trylock(&m->m_lock, id); - if (__predict_true(error == 0)) { - ENQUEUE_MUTEX(curthread, m); - } else if (m->m_owner == curthread) { - error = mutex_self_trylock(m); - } /* else {} */ + if (IS_SIMPLE_MUTEX(m)) { + if (set_lockword(m) == 0) { + m->m_owner = curthread; + return (0); + } + + if (m->m_owner == curthread) + error = mutex_self_trylock(m); + else + error = EBUSY; + } else { + uint32_t id; + + id = TID(curthread); + error = _thr_umutex_trylock(&m->m_lock, id); + if (__predict_true(error == 0)) { + ENQUEUE_MUTEX(curthread, m); + } else if (m->m_owner == curthread) { + error = mutex_self_trylock(m); + } /* else {} */ + } if (error != 0 && m->m_private) THR_CRITICAL_LEAVE(curthread); return (error); @@ -353,16 +381,22 @@ mutex_lock_queued(struct pthread_mutex * { struct pthread *curthread = _get_curthread(); struct sleepqueue *sq; - uint32_t owner, tid; + uint32_t old; int error = 0; int spin; + if (m->m_owner == curthread) + return mutex_self_lock(m, abstime); + + if (__predict_false(abstime != NULL && + (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || + abstime->tv_nsec >= 1000000000))) + return (EINVAL); + spin = m->m_spinloops; - tid = TID(curthread); for (;;) { if (!_thr_is_smp) goto sleep; - while (spin-- > 0) { /* * For adaptive mutexes, spin for a bit in the expectation @@ -370,10 +404,10 @@ mutex_lock_queued(struct pthread_mutex * * the lock is likely to be released quickly and it is * faster than entering the kernel */ - owner = m->m_lockword; - if ((owner & UMUTEX_TIDMASK) == 0) { - if (atomic_cmpset_acq_32(&m->m_lockword, owner, owner|tid)) { - ENQUEUE_MUTEX(curthread, m); + old = m->m_lockword; + if ((old & MTX_LOCKED) == 0) { + if (set_lockword(m) == 0) { + m->m_owner = curthread; error = 0; goto out; } @@ -387,15 +421,15 @@ sleep: if (curthread->wchan == NULL) _sleepq_add(sq, curthread); _sleepq_unlock(sq); - owner = m->m_lockword; + old = m->m_lockword; /* Set contested bit. */ - while ((owner & UMUTEX_TIDMASK) != 0 && (owner & UMUTEX_CONTESTED) == 0) { + while ((old & MTX_LOCKED) != 0 && (old & MTX_CONTESTED) == 0) { if (atomic_cmpset_acq_32(&m->m_lockword, - owner, owner|UMUTEX_CONTESTED)) + old, old|MTX_CONTESTED)) break; - owner = m->m_lockword; + old = m->m_lockword; } - if ((owner & UMUTEX_TIDMASK) != 0) { + if ((old & MTX_LOCKED) != 0) { error = _thr_sleep(curthread, abstime, CLOCK_REALTIME); if (error != EINTR) { if (curthread->wchan != NULL) { @@ -406,14 +440,12 @@ sleep: } } else error = 0; - owner = m->m_lockword; + old = m->m_lockword; } - if ((owner & UMUTEX_TIDMASK) == 0) { - if (atomic_cmpset_acq_32(&m->m_lockword, owner, owner|tid)) { - ENQUEUE_MUTEX(curthread, m); - error = 0; - break; - } + if (set_lockword(m) == 0) { + m->m_owner = curthread; + error = 0; + break; } if (error != 0) break; @@ -438,6 +470,14 @@ mutex_lock_kernel(struct pthread_mutex * uint32_t id; int error; + if (m->m_owner == curthread) + return mutex_self_lock(m, abstime); + + if (__predict_false(abstime != NULL && + (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || + abstime->tv_nsec >= 1000000000))) + return (EINVAL); + id = TID(curthread); if (abstime == NULL) { error = __thr_umutex_lock(&m->m_lock, id); @@ -453,24 +493,20 @@ static inline int _mutex_lock_common(struct pthread_mutex *m, const struct timespec *abstime) { struct pthread *curthread = _get_curthread(); - int error; - if (_thr_umutex_trylock2(&m->m_lock, TID(curthread)) == 0) { - ENQUEUE_MUTEX(curthread, m); - error = 0; - } else if (m->m_owner == curthread) { - error = mutex_self_lock(m, abstime); + if (IS_SIMPLE_MUTEX(m)) { + if (set_lockword(m) == 0) { + m->m_owner = curthread; + return (0); + } + return mutex_lock_queued(m, abstime); } else { - if (__predict_false(abstime != NULL && - (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || - abstime->tv_nsec >= 1000000000))) - error = EINVAL; - else if (__predict_true(IS_SIMPLE_MUTEX(m))) - error = mutex_lock_queued(m, abstime); - else - error = mutex_lock_kernel(m, abstime); + if (_thr_umutex_trylock2(&m->m_lock, TID(curthread)) == 0) { + ENQUEUE_MUTEX(curthread, m); + return (0); + } + return mutex_lock_kernel(m, abstime); } - return (error); } static inline int @@ -621,21 +657,21 @@ mutex_unlock_queued(struct pthread *curt { struct pthread *td; unsigned int *wake_addr = NULL; - uint32_t tid = TID(curthread); struct sleepqueue *sq; int32_t newval; - if (!atomic_cmpset_rel_32(&m->m_lock.m_owner, tid, UMUTEX_UNOWNED)) { + m->m_owner = NULL; + if (!atomic_cmpset_rel_32(&m->m_lock.m_owner, MTX_LOCKED, 0)) { sq = _sleepq_lock(m, MX); if ((td = _sleepq_first(sq)) != NULL) { _sleepq_remove(sq, td); if (_sleepq_empty(sq)) - newval = UMUTEX_UNOWNED; + newval = 0; else - newval = UMUTEX_CONTESTED; + newval = MTX_CONTESTED; wake_addr = WAKE_ADDR(td); } else { - newval = UMUTEX_UNOWNED; + newval = 0; wake_addr = NULL; } atomic_store_rel_32(&m->m_lockword, newval); @@ -679,11 +715,12 @@ _mutex_unlock_common(struct pthread *cur m->m_recurse--; return (0); } - DEQUEUE_MUTEX(curthread, m); if (__predict_true(IS_SIMPLE_MUTEX(m))) mutex_unlock_queued(curthread, m); - else + else { + DEQUEUE_MUTEX(curthread, m); _thr_umutex_unlock(&m->m_lock, tid); + } return (0); } Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Tue Nov 2 06:47:18 2010 (r214658) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Tue Nov 2 06:58:01 2010 (r214659) @@ -145,6 +145,9 @@ struct sleepqueue { #define MX 0 #define CV 1 +#define MTX_LOCKED 0x01 +#define MTX_CONTESTED 0x02 + struct pthread_mutex { /* * Lock for accesses to this structure. @@ -885,7 +888,7 @@ _sleepq_first(struct sleepqueue *sq) static inline void _mutex_set_contested(struct pthread_mutex *m) { - atomic_set_32(&m->m_lock.m_owner, UMUTEX_CONTESTED); + atomic_set_32(&m->m_lock.m_owner, MTX_CONTESTED); } __END_DECLS From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 07:46:32 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09CCE106564A; Tue, 2 Nov 2010 07:46:32 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC8998FC0A; Tue, 2 Nov 2010 07:46:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA27kV9T026853; Tue, 2 Nov 2010 07:46:31 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA27kVZL026851; Tue, 2 Nov 2010 07:46:31 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020746.oA27kVZL026851@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 07:46:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214660 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 07:46:32 -0000 Author: davidxu Date: Tue Nov 2 07:46:31 2010 New Revision: 214660 URL: http://svn.freebsd.org/changeset/base/214660 Log: Add missing function. Modified: user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_umtx.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Tue Nov 2 06:58:01 2010 (r214659) +++ user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Tue Nov 2 07:46:31 2010 (r214660) @@ -297,6 +297,19 @@ _thr_rwl_unlock(struct urwlock *rwlock) PANIC("unlock error"); } +int +__thr_umtx_lock(volatile umtx_t *mtx) +{ + int v; + + do { + v = *mtx; + if (v == 2 || atomic_cmpset_acq_int(mtx, 1, 2)) + _thr_umtx_wait_uint(mtx, 2, NULL, 0); + } while (!atomic_cmpset_acq_int(mtx, 0, 2)); + return (0); +} + #define LOOPS 500 int From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 07:49:21 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D1945106566C; Tue, 2 Nov 2010 07:49:21 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BEE5F8FC12; Tue, 2 Nov 2010 07:49:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA27nL89026993; Tue, 2 Nov 2010 07:49:21 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA27nLlV026989; Tue, 2 Nov 2010 07:49:21 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020749.oA27nLlV026989@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 07:49:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214661 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 07:49:21 -0000 Author: davidxu Date: Tue Nov 2 07:49:21 2010 New Revision: 214661 URL: http://svn.freebsd.org/changeset/base/214661 Log: Remove link field in pthread_mutex, because it can not be used in process-shared mutex, otherwise, another process can corrupt your mutex link list when you owned it. Instead, allocate mutex link entry from heap, keep it private. Modified: user/davidxu/libthr/lib/libthr/thread/thr_kern.c user/davidxu/libthr/lib/libthr/thread/thr_mutex.c user/davidxu/libthr/lib/libthr/thread/thr_private.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_kern.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_kern.c Tue Nov 2 07:46:31 2010 (r214660) +++ user/davidxu/libthr/lib/libthr/thread/thr_kern.c Tue Nov 2 07:49:21 2010 (r214661) @@ -45,6 +45,8 @@ static struct umutex addr_lock; static struct wake_addr *wake_addr_head; static struct wake_addr default_wake_addr; +static struct umutex mutex_link_lock; +static struct mutex_queue mutex_link_freeq; struct wake_addr * _thr_alloc_wake_addr(void) @@ -89,6 +91,44 @@ _thr_release_wake_addr(struct wake_addr THR_UMUTEX_UNLOCK(curthread, &addr_lock); } +void +_thr_mutex_link_init(void) +{ + TAILQ_INIT(&mutex_link_freeq); + _thr_umutex_init(&mutex_link_lock); +} + +struct mutex_link * +_thr_mutex_link_alloc(void) +{ + struct pthread *curthread = _get_curthread(); + struct mutex_link *p; + + THR_LOCK_ACQUIRE(curthread, &mutex_link_lock); + p = TAILQ_FIRST(&mutex_link_freeq); + if (p == NULL) { + unsigned i; + unsigned pagesize = getpagesize(); + struct mutex_link *pp = (struct mutex_link *)mmap(NULL, getpagesize(), + PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); + for (i = 1; i < pagesize/sizeof(struct mutex_link); ++i) + TAILQ_INSERT_TAIL(&mutex_link_freeq, &pp[i], qe); + p = &pp[0]; + } + THR_LOCK_RELEASE(curthread, &mutex_link_lock); + return (p); +} + +void +_thr_mutex_link_free(struct mutex_link *p) +{ + struct pthread *curthread = _get_curthread(); + + THR_LOCK_ACQUIRE(curthread, &mutex_link_lock); + TAILQ_INSERT_TAIL(&mutex_link_freeq, p, qe); + THR_LOCK_RELEASE(curthread, &mutex_link_lock); +} + /* * This is called when the first thread (other than the initial * thread) is created. Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 07:46:31 2010 (r214660) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 07:49:21 2010 (r214661) @@ -49,26 +49,6 @@ #define UMUTEX_TIDMASK (~UMUTEX_CONTESTED) #endif -#if defined(_PTHREADS_INVARIANTS) -#define MUTEX_INIT_LINK(m) do { \ - (m)->m_qe.tqe_prev = NULL; \ - (m)->m_qe.tqe_next = NULL; \ -} while (0) -#define MUTEX_ASSERT_IS_OWNED(m) do { \ - if (__predict_false((m)->m_qe.tqe_prev == NULL))\ - PANIC("mutex is not on list"); \ -} while (0) -#define MUTEX_ASSERT_NOT_OWNED(m) do { \ - if (__predict_false((m)->m_qe.tqe_prev != NULL ||\ - (m)->m_qe.tqe_next != NULL)) \ - PANIC("mutex is on list"); \ -} while (0) -#else -#define MUTEX_INIT_LINK(m) -#define MUTEX_ASSERT_IS_OWNED(m) -#define MUTEX_ASSERT_NOT_OWNED(m) -#endif - /* * For adaptive mutexes, how many times to spin doing trylock2 * before entering the kernel to block @@ -153,7 +133,6 @@ mutex_init(pthread_mutex_t *mutex, pmutex->m_refcount = 0; pmutex->m_spinloops = 0; pmutex->m_yieldloops = 0; - MUTEX_INIT_LINK(pmutex); switch(attr->m_protocol) { case PTHREAD_PRIO_NONE: pmutex->m_lock.m_owner = 0; @@ -200,15 +179,53 @@ init_static(struct pthread *thread, pthr static void set_inherited_priority(struct pthread *curthread, struct pthread_mutex *m) { - struct pthread_mutex *m2; + struct mutex_link *ml2; - m2 = TAILQ_LAST(&curthread->pp_mutexq, mutex_queue); - if (m2 != NULL) - m->m_lock.m_ceilings[1] = m2->m_lock.m_ceilings[0]; + ml2 = TAILQ_LAST(&curthread->pp_mutexq, mutex_queue); + if (ml2 != NULL) + m->m_lock.m_ceilings[1] = ml2->mutexp->m_lock.m_ceilings[0]; else m->m_lock.m_ceilings[1] = -1; } +static void +enqueue_mutex(struct pthread *curthread, struct pthread_mutex *m) +{ + m->m_owner = curthread; + struct mutex_link *ml = _thr_mutex_link_alloc(); + ml->mutexp = m; + if (((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0) + TAILQ_INSERT_TAIL(&curthread->mutexq, ml, qe); + else + TAILQ_INSERT_TAIL(&curthread->pp_mutexq, ml, qe); +} + +static void +dequeue_mutex(struct pthread *curthread, struct pthread_mutex *m) +{ + struct mutex_link *ml; + + if ((((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) { + TAILQ_FOREACH(ml, &curthread->mutexq, qe) { + if (ml->mutexp == m) { + TAILQ_REMOVE(&curthread->mutexq, ml, qe); + _thr_mutex_link_free(ml); + break; + } + } + } else { + TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) { + if (ml->mutexp == m) { + TAILQ_REMOVE(&curthread->mutexq, ml, qe); + set_inherited_priority(curthread, m); + _thr_mutex_link_free(ml); + break; + } + } + } + m->m_owner = NULL; +} + int __pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutex_attr) @@ -237,7 +254,7 @@ _pthread_mutex_init_calloc_cb(pthread_mu void _mutex_fork(struct pthread *curthread) { - struct pthread_mutex *m; + struct mutex_link *ml; /* * Fix mutex ownership for child process. @@ -248,11 +265,10 @@ _mutex_fork(struct pthread *curthread) * process shared mutex is not supported, so I * am not worried. */ - TAILQ_FOREACH(m, &curthread->mutexq, m_qe) { - m->m_lock.m_owner = TID(curthread); - } - TAILQ_FOREACH(m, &curthread->pp_mutexq, m_qe) - m->m_lock.m_owner = TID(curthread) | UMUTEX_CONTESTED; + TAILQ_FOREACH(ml, &curthread->mutexq, qe) + ml->mutexp->m_lock.m_owner = TID(curthread); + TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) + ml->mutexp->m_lock.m_owner = TID(curthread) | UMUTEX_CONTESTED; } int @@ -271,7 +287,6 @@ _pthread_mutex_destroy(pthread_mutex_t * ret = EBUSY; } else { *mutex = THR_MUTEX_DESTROYED; - MUTEX_ASSERT_NOT_OWNED(m); free(m); ret = 0; } @@ -280,29 +295,6 @@ _pthread_mutex_destroy(pthread_mutex_t * return (ret); } -#define ENQUEUE_MUTEX(curthread, m) \ - do { \ - (m)->m_owner = curthread; \ - /* Add to the list of owned mutexes: */ \ - MUTEX_ASSERT_NOT_OWNED((m)); \ - if (__predict_true(((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) \ - TAILQ_INSERT_TAIL(&curthread->mutexq, (m), m_qe);\ - else \ - TAILQ_INSERT_TAIL(&curthread->pp_mutexq, (m), m_qe);\ - } while (0) - -#define DEQUEUE_MUTEX(curthread, m) \ - (m)->m_owner = NULL; \ - /* Remove the mutex from the threads queue. */ \ - MUTEX_ASSERT_IS_OWNED(m); \ - if (__predict_true(((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) \ - TAILQ_REMOVE(&curthread->mutexq, (m), m_qe); \ - else { \ - TAILQ_REMOVE(&curthread->pp_mutexq, (m), m_qe); \ - set_inherited_priority(curthread, (m)); \ - } \ - MUTEX_INIT_LINK(m); - #define CHECK_AND_INIT_MUTEX \ if (__predict_false((m = *mutex) <= THR_MUTEX_DESTROYED)) { \ if (m == THR_MUTEX_DESTROYED) \ @@ -354,7 +346,7 @@ mutex_trylock_common(pthread_mutex_t *mu id = TID(curthread); error = _thr_umutex_trylock(&m->m_lock, id); if (__predict_true(error == 0)) { - ENQUEUE_MUTEX(curthread, m); + enqueue_mutex(curthread, m); } else if (m->m_owner == curthread) { error = mutex_self_trylock(m); } /* else {} */ @@ -485,7 +477,7 @@ mutex_lock_kernel(struct pthread_mutex * error = __thr_umutex_timedlock(&m->m_lock, id, abstime); } if (error == 0) - ENQUEUE_MUTEX(curthread, m); + enqueue_mutex(curthread, m); return (error); } @@ -502,7 +494,7 @@ _mutex_lock_common(struct pthread_mutex return mutex_lock_queued(m, abstime); } else { if (_thr_umutex_trylock2(&m->m_lock, TID(curthread)) == 0) { - ENQUEUE_MUTEX(curthread, m); + enqueue_mutex(curthread, m); return (0); } return mutex_lock_kernel(m, abstime); @@ -718,7 +710,7 @@ _mutex_unlock_common(struct pthread *cur if (__predict_true(IS_SIMPLE_MUTEX(m))) mutex_unlock_queued(curthread, m); else { - DEQUEUE_MUTEX(curthread, m); + dequeue_mutex(curthread, m); _thr_umutex_unlock(&m->m_lock, tid); } return (0); @@ -800,7 +792,7 @@ _mutex_cv_detach(pthread_mutex_t *mutex, *recurse = m->m_recurse; m->m_recurse = 0; m->m_refcount++; - DEQUEUE_MUTEX(curthread, m); + dequeue_mutex(curthread, m); return (0); } @@ -828,7 +820,8 @@ _pthread_mutex_setprioceiling(pthread_mu int ceiling, int *old_ceiling) { struct pthread *curthread = _get_curthread(); - struct pthread_mutex *m, *m1, *m2; + struct mutex_link *ml, *ml1, *ml2; + struct pthread_mutex *m; int ret; m = *mutex; @@ -839,21 +832,25 @@ _pthread_mutex_setprioceiling(pthread_mu ret = __thr_umutex_set_ceiling(&m->m_lock, ceiling, old_ceiling); if (ret != 0) return (ret); - if (m->m_owner == curthread) { - MUTEX_ASSERT_IS_OWNED(m); - m1 = TAILQ_PREV(m, mutex_queue, m_qe); - m2 = TAILQ_NEXT(m, m_qe); - if ((m1 != NULL && m1->m_lock.m_ceilings[0] > (u_int)ceiling) || - (m2 != NULL && m2->m_lock.m_ceilings[0] < (u_int)ceiling)) { - TAILQ_REMOVE(&curthread->pp_mutexq, m, m_qe); - TAILQ_FOREACH(m2, &curthread->pp_mutexq, m_qe) { - if (m2->m_lock.m_ceilings[0] > (u_int)ceiling) { - TAILQ_INSERT_BEFORE(m2, m, m_qe); + TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) { + if (ml->mutexp == m) + break; + } + if (ml == NULL) /* howto ? */ + return (0); + ml1 = TAILQ_PREV(ml, mutex_queue, qe); + ml2 = TAILQ_NEXT(ml, qe); + if ((ml1 != NULL && ml1->mutexp->m_lock.m_ceilings[0] > (u_int)ceiling) || + (ml2 != NULL && ml2->mutexp->m_lock.m_ceilings[0] < (u_int)ceiling)) { + TAILQ_REMOVE(&curthread->pp_mutexq, ml, qe); + TAILQ_FOREACH(ml2, &curthread->pp_mutexq, qe) { + if (ml2->mutexp->m_lock.m_ceilings[0] > (u_int)ceiling) { + TAILQ_INSERT_BEFORE(ml2, ml, qe); return (0); } } - TAILQ_INSERT_TAIL(&curthread->pp_mutexq, m, m_qe); + TAILQ_INSERT_TAIL(&curthread->pp_mutexq, ml, qe); } } return (0); Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Tue Nov 2 07:46:31 2010 (r214660) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Tue Nov 2 07:49:21 2010 (r214661) @@ -77,7 +77,13 @@ typedef TAILQ_HEAD(pthreadlist, pthread) pthreadlist; typedef TAILQ_HEAD(atfork_head, pthread_atfork) atfork_head; -TAILQ_HEAD(mutex_queue, pthread_mutex); + +struct mutex_link { + TAILQ_ENTRY(mutex_link) qe; + struct pthread_mutex *mutexp; +}; + +TAILQ_HEAD(mutex_queue, mutex_link); /* Signal to do cancellation */ #define SIGCANCEL 32 @@ -161,10 +167,6 @@ struct pthread_mutex { int m_spinloops; int m_yieldloops; int m_private; - /* - * Link for all mutexes a thread currently owns. - */ - TAILQ_ENTRY(pthread_mutex) m_qe; }; @@ -845,6 +847,9 @@ void _thr_sigact_unload(struct dl_phdr_i struct wake_addr *_thr_alloc_wake_addr(void); void _thr_release_wake_addr(struct wake_addr *); int _thr_sleep(struct pthread *, const struct timespec *, int); +void _thr_mutex_link_init(void); +struct mutex_link *_thr_mutex_link_alloc(void); +void _thr_mutex_link_free(struct mutex_link *); void _sleepq_init(void); struct sleepqueue * _sleepq_alloc(void); From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 08:08:37 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5548106566C; Tue, 2 Nov 2010 08:08:37 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A31048FC0C; Tue, 2 Nov 2010 08:08:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA288bT8028085; Tue, 2 Nov 2010 08:08:37 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA288bin028083; Tue, 2 Nov 2010 08:08:37 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020808.oA288bin028083@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 08:08:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214663 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 08:08:37 -0000 Author: davidxu Date: Tue Nov 2 08:08:37 2010 New Revision: 214663 URL: http://svn.freebsd.org/changeset/base/214663 Log: Add sleep queue file. Added: user/davidxu/libthr/lib/libthr/thread/thr_sleepq.c (contents, props changed) Added: user/davidxu/libthr/lib/libthr/thread/thr_sleepq.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/davidxu/libthr/lib/libthr/thread/thr_sleepq.c Tue Nov 2 08:08:37 2010 (r214663) @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2005 David Xu + * Copyright (C) 2003 Daniel M. Eischen + * 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 unmodified, 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 ``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 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$ + */ + +#include +#include "thr_private.h" + +#define HASHSHIFT 9 +#define HASHSIZE (1 << HASHSHIFT) +#define SC_HASH(wchan, type) ((unsigned) \ + ((((uintptr_t)(wchan) >> 3) \ + ^ ((uintptr_t)(wchan) >> (HASHSHIFT + 3))) \ + & (HASHSIZE - 1)) + (((type) == MX)? 0 : HASHSIZE)) +#define SC_LOOKUP(wc, type) &sc_table[SC_HASH(wc, type)] + +struct sleepqueue_chain { + LIST_HEAD(, sleepqueue) sc_queues; + LIST_HEAD(, sleepqueue) sc_freeq; +// struct umutex sc_lock; + umtx_t sc_lock; + int sc_type; + struct sleepqueue sc_spare; +}; + +static struct sleepqueue_chain sc_table[HASHSIZE * 2]; + +void +_sleepq_init(void) +{ + int i; + struct sleepqueue *sq; + + for (i = 0; i < 2 * HASHSIZE; ++i) { + LIST_INIT(&sc_table[i].sc_queues); + LIST_INIT(&sc_table[i].sc_freeq); + //_thr_umutex_init(&sc_table[i].sc_lock); + sc_table[i].sc_lock = 0; + sc_table[i].sc_type = i < HASHSIZE ? MX : CV; + sq = &sc_table[i].sc_spare; + TAILQ_INIT(&sq->sq_blocked); + LIST_INSERT_HEAD(&sc_table[i].sc_freeq, sq, sq_hash); + } +} + +struct sleepqueue * +_sleepq_alloc(void) +{ + struct sleepqueue *sq; + + sq = calloc(1, sizeof(struct sleepqueue)); + TAILQ_INIT(&sq->sq_blocked); + return (sq); +} + +void +_sleepq_free(struct sleepqueue *sq) +{ + if ((char *)sq < (char *)sc_table || + (char *)sq >= (char *)&sc_table[HASHSIZE * 2]) + free(sq); +} + +struct sleepqueue * +_sleepq_lock(void *wchan, int type) +{ + struct pthread *curthread = _get_curthread(); + struct sleepqueue_chain *sc; + struct sleepqueue *sq; + + sc = SC_LOOKUP(wchan, type); +// THR_LOCK_ACQUIRE_SPIN(_get_curthread(), &sc->sc_lock); + THR_CRITICAL_ENTER(curthread); + _thr_umtx_lock_spin(&sc->sc_lock); + LIST_FOREACH(sq, &sc->sc_queues, sq_hash) + if (sq->sq_wchan == wchan) + return (sq); + /* + * If not found, pick a free queue header, note that + * if a thread locked the chain successfully, + * there must have a free sleepqueue, because + * we initialized the chain with one extra sleepqueue. + */ + sq = LIST_FIRST(&sc->sc_freeq); + LIST_REMOVE(sq, sq_hash); + LIST_INSERT_HEAD(&sc->sc_queues, sq, sq_hash); + sq->sq_wchan = wchan; + sq->sq_type = type; + return (sq); +} + +void +_sleepq_unlock(struct sleepqueue *sq) +{ + struct pthread *curthread = _get_curthread(); + struct sleepqueue_chain *sc; + + sc = SC_LOOKUP(sq->sq_wchan, sq->sq_type); + if (TAILQ_EMPTY(&sq->sq_blocked)) { + LIST_REMOVE(sq, sq_hash); + LIST_INSERT_HEAD(&sc->sc_freeq, sq, sq_hash); + } + //THR_LOCK_RELEASE(_get_curthread(), &sc->sc_lock); + _thr_umtx_unlock(&sc->sc_lock); + THR_CRITICAL_LEAVE(curthread); +} + +void +_sleepq_add(struct sleepqueue *sq, struct pthread *td) +{ + struct sleepqueue_chain *sc; + + sc = SC_LOOKUP(sq->sq_wchan, sq->sq_type); + LIST_INSERT_HEAD(&sc->sc_freeq, td->sleepqueue, sq_hash); + td->sleepqueue = NULL; + td->wchan = sq->sq_wchan; + TAILQ_INSERT_TAIL(&sq->sq_blocked, td, wle); +} + +void +_sleepq_remove(struct sleepqueue *sq, struct pthread *td) +{ + struct sleepqueue_chain *sc; + + sc = SC_LOOKUP(sq->sq_wchan, sq->sq_type); + THR_ASSERT((td->wchan == sq->sq_wchan), "wchan is not equal"); + TAILQ_REMOVE(&sq->sq_blocked, td, wle); + td->wchan = NULL; + td->sleepqueue = LIST_FIRST(&sc->sc_freeq); + LIST_REMOVE(td->sleepqueue, sq_hash); +} + +void +_sleepq_concat(struct sleepqueue *sq_dst, struct sleepqueue *sq_src) +{ + struct sleepqueue_chain *sc_dst, *sc_src; + struct sleepqueue *sq_tmp; + struct pthread *td; + + sc_dst = SC_LOOKUP(sq_dst->sq_wchan, sq_dst->sq_type); + sc_src = SC_LOOKUP(sq_src->sq_wchan, sq_src->sq_type); + TAILQ_FOREACH(td, &sq_src->sq_blocked, wle) { + td->wchan = sq_dst->sq_wchan; + /* + * We should move same number of free sleepqueues to + * new channel. + */ + sq_tmp = LIST_FIRST(&sc_src->sc_freeq); + LIST_REMOVE(sq_tmp, sq_hash); + LIST_INSERT_HEAD(&sc_dst->sc_freeq, sq_tmp, sq_hash); + } + TAILQ_CONCAT(&sq_dst->sq_blocked, &sq_src->sq_blocked, wle); +} From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 09:16:41 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC5FB106566B; Tue, 2 Nov 2010 09:16:41 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9AC9C8FC16; Tue, 2 Nov 2010 09:16:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA29Gf27032467; Tue, 2 Nov 2010 09:16:41 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA29GfHH032465; Tue, 2 Nov 2010 09:16:41 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011020916.oA29GfHH032465@svn.freebsd.org> From: David Xu Date: Tue, 2 Nov 2010 09:16:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214670 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 09:16:41 -0000 Author: davidxu Date: Tue Nov 2 09:16:41 2010 New Revision: 214670 URL: http://svn.freebsd.org/changeset/base/214670 Log: Refetch lockword before retrying. Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 09:15:27 2010 (r214669) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Tue Nov 2 09:16:41 2010 (r214670) @@ -317,6 +317,7 @@ set_lockword(struct pthread_mutex *m) while ((old & MTX_LOCKED) == 0) { if (atomic_cmpset_acq_32(&m->m_lockword, old, old|MTX_LOCKED)) return (0); + old = m->m_lockword; } return (EBUSY); } From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 13:47:14 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 252731065694; Tue, 2 Nov 2010 13:47:14 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1434C8FC25; Tue, 2 Nov 2010 13:47:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA2DlDGB051268; Tue, 2 Nov 2010 13:47:13 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2DlDrc051265; Tue, 2 Nov 2010 13:47:13 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201011021347.oA2DlDrc051265@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Tue, 2 Nov 2010 13:47:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214677 - user/ae/usr.sbin/sade X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 13:47:14 -0000 Author: ae Date: Tue Nov 2 13:47:13 2010 New Revision: 214677 URL: http://svn.freebsd.org/changeset/base/214677 Log: Add frontend to tunefs dialog. Modified: user/ae/usr.sbin/sade/ufsed.c Modified: user/ae/usr.sbin/sade/ufsed.c ============================================================================== --- user/ae/usr.sbin/sade/ufsed.c Tue Nov 2 13:04:25 2010 (r214676) +++ user/ae/usr.sbin/sade/ufsed.c Tue Nov 2 13:47:13 2010 (r214677) @@ -258,6 +258,113 @@ ufslist_reread(struct ufslist *fslist) return (error); } +static int +tunefs_keyhndl(int key) +{ + switch (key) { + case ' ': + case KEY_UP: + case KEY_DOWN: + case KEY_LEFT: + case KEY_RIGHT: + return (key); + } + return (0); +} + +static void +ufsed_tunefs(history_t hist, struct ufsinfo *pfs) +{ + struct custom_dlg dlg; + struct dlg_item *item; + DLG_BUTTON *btnOk, *btnCancel, *btnCustom; + DLG_EDIT *eLabel; + WINDOW *win; + uint32_t flags; + int q, h, w, ret, i; + char *title_buf; + struct { + DLG_CHECKBOX *item; + uint32_t flag; + const char *label; + const char *arg; + } checkbox[] = { + { NULL, FS_DOSOFTDEP, "Soft Updates", "-n" }, + { NULL, FS_SUJ, "SU journaling", "-j" }, + { NULL, FS_ACLS, "POSIX.1e ACL", "-a" }, + { NULL, FS_MULTILABEL, "MAC multilabel", "-l" }, + { NULL, FS_GJOURNAL, "GEOM journaling", "-J" }, + { NULL, FS_NFS4ACLS, "NFSv4 ALC", "-N" } + }; + + win = savescr(); + dlg_init(&dlg); + asprintf(&title_buf, "Change a file system parameters for \"%s\":", + pfs->partname); + dlg_add_label(&dlg, 1, 2, 55, 2, title_buf); + eLabel = dlg_add_edit(&dlg, 3, 2, 24, "Volume Label:", + MAXVOLLEN, pfs->volname); + for (i = 0; i < sizeof(checkbox) / sizeof(checkbox[0]); i++) + checkbox[i].item = dlg_add_checkbox(&dlg, + (i < 1) ? 7: 2 + i, (i < 1) ? 2: 30, 24, 1, + (checkbox[i].flag & pfs->flags) != 0, + checkbox[i].label); + btnOk = dlg_add_button(&dlg, 9, 14, " Ok "); + btnCancel = dlg_add_button(&dlg, 9, 26, "Cancel"); + btnCustom = dlg_add_button(&dlg, 9, 38, "Custom"); + use_helpline("Press F1 for help"); + dlg_autosize(&dlg, &w, &h); + dlg_open_dialog(&dlg, w + 1, h + 1, "Change File System"); + q = 0; + do { + ret = dlg_proc(&dlg, tunefs_keyhndl); + if (ret == DE_ESC) { + q = 1; + break; + } + item = dlg_focus_get(&dlg); + switch (ret) { + case DE_CR: + if (item == btnCancel) + q = 1; + else if (item == btnOk) + q = 2; + else if (item == btnCustom) + q = 3; + else + dlg_focus_next(&dlg); + break; + case KEY_UP: + case KEY_LEFT: + dlg_focus_prev(&dlg); + break; + case KEY_DOWN: + case KEY_RIGHT: + dlg_focus_next(&dlg); + break; + case ' ': + if (item->type == CHECKBOX) + dlg_checkbox_toggle(&dlg, item); + }; + } while (q == 0); + + flags = 0; + for (i = 0; i < sizeof(checkbox) / sizeof(checkbox[0]); i++) { + if (dlg_checkbox_checked(&dlg, checkbox[i].item)) + flags |= checkbox[i].flag; + else + flags &= ~checkbox[i].flag; + } + if (flags != pfs->flags) { + /* something changed */ + } + restorescr(win); + dlg_close_dialog(&dlg); + dlg_free(&dlg); + free(title_buf); +} + + #define FSED_MENU_TOP 4 #define FSED_BOTTOM_HEIGHT 7 #define LABEL(l) ((l) ? (l): "-") @@ -345,8 +452,9 @@ resize: tmps = "unknown"; } mvprintw(FSED_MENU_TOP, 30, "%-20s%s", "File System:", tmps); - if (selected->magic == FS_UFS1_MAGIC || - selected->magic == FS_UFS2_MAGIC) { +#define IS_UFS(pfs) \ + ((pfs)->magic == FS_UFS1_MAGIC || (pfs)->magic == FS_UFS2_MAGIC) + if (IS_UFS(selected)) { mvprintw(FSED_MENU_TOP + 1, 30, "%-20s%s", "last mountpoint:", LABEL(selected->fsmnt)); @@ -386,8 +494,13 @@ resize: key = toupper(getch()); switch (key) { - case '\r': - case '\n': + case 'M': + if (!IS_UFS(selected)) { + msg = "Can not modify 'unknown' file system. " + "First create an UFS file system."; + break; + } + ufsed_tunefs(hist, selected); break; case KEY_ESC: case 'Q': From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 19:33:45 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C23621065670; Tue, 2 Nov 2010 19:33:45 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B1B5C8FC0C; Tue, 2 Nov 2010 19:33:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA2JXjpt079145; Tue, 2 Nov 2010 19:33:45 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2JXjRk079143; Tue, 2 Nov 2010 19:33:45 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201011021933.oA2JXjRk079143@svn.freebsd.org> From: Doug Barton Date: Tue, 2 Nov 2010 19:33:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214683 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 19:33:45 -0000 Author: dougb Date: Tue Nov 2 19:33:45 2010 New Revision: 214683 URL: http://svn.freebsd.org/changeset/base/214683 Log: For -a change to using PM_NEEDS_UPDATE for keeping track of things that have already been updated as dependencies of other ports that needed updating. In order to do the above effectively we need to preserve the (moderately hackish) space prepended to the list. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Tue Nov 2 18:34:31 2010 (r214682) +++ user/dougb/portmaster/portmaster Tue Nov 2 19:33:45 2010 (r214683) @@ -242,7 +242,7 @@ safe_exit () { pnu_temp="${pnu_temp}${i} " done - PM_NEEDS_UPDATE="$pnu_temp" + PM_NEEDS_UPDATE=" ${pnu_temp}" else # Do these here so +IGNOREME can modify them echo "num_of_deps='$num_of_deps'" >> $IPC_SAVE @@ -2467,8 +2467,8 @@ post_first_pass () { term_printf fi - PM_NEEDS_UPDATE=${PM_NEEDS_UPDATE# } - [ -z "$PM_NEEDS_UPDATE" ] && return + # Only when -a or multi and user said no to update +IGNOREME(s) + [ "$PM_NEEDS_UPDATE" = ' ' ] && return action=build if [ "$PM_PACKAGES" = only ]; then @@ -2834,7 +2834,12 @@ all_first_pass () { unset roots trunks branches leaves - for origin in $PM_NEEDS_UPDATE; do update_port $origin; done + for origin in $PM_NEEDS_UPDATE; do + case "$PM_NEEDS_UPDATE" in + *\ $origin\ *) update_port $origin ;; + '') continue ;; # Already updated as a dependency + esac + done echo "===>>> Update check of installed ports complete" ; echo '' safe_exit From owner-svn-src-user@FreeBSD.ORG Tue Nov 2 22:06:23 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4608106566C; Tue, 2 Nov 2010 22:06:23 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8715A8FC14; Tue, 2 Nov 2010 22:06:23 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA2M6NO7092152; Tue, 2 Nov 2010 22:06:23 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA2M6NAm092150; Tue, 2 Nov 2010 22:06:23 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201011022206.oA2M6NAm092150@svn.freebsd.org> From: Doug Barton Date: Tue, 2 Nov 2010 22:06:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214689 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2010 22:06:23 -0000 Author: dougb Date: Tue Nov 2 22:06:23 2010 New Revision: 214689 URL: http://svn.freebsd.org/changeset/base/214689 Log: Since we're going to depend on PM_NEEDS_UPDATE to tell us what ports we can skip with -a anyway, use the same mechanism to handle multiport(). This allows me to get rid of yet another list, PM_MULTI_BUILT. While I'm here, tune up all the examples of case "$PM_NEEDS_UPDATE" to have a consistent style. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Tue Nov 2 21:01:18 2010 (r214688) +++ user/dougb/portmaster/portmaster Tue Nov 2 22:06:23 2010 (r214689) @@ -253,7 +253,6 @@ safe_exit () { echo "dep_of_deps='$dep_of_deps'" >> $IPC_SAVE echo "PM_NEEDS_UPDATE='$PM_NEEDS_UPDATE'" >> $IPC_SAVE [ -z "$NO_BACKUP" -a -z "$BACKUP" ] && echo "NB_DELETE='$NB_DELETE'" >> $IPC_SAVE - [ -n "$PM_MULTI_BUILT" ] && echo "PM_MULTI_BUILT='$PM_MULTI_BUILT'" >> $IPC_SAVE if [ -n "$INTERACTIVE_UPDATE" ]; then echo "INTERACTIVE_YES='$INTERACTIVE_YES'" >> $IPC_SAVE echo "INTERACTIVE_NO='$INTERACTIVE_NO'" >> $IPC_SAVE @@ -2525,8 +2524,7 @@ init_term_printf () { multiport () { # Global - PM_MULTI_PORTS=':' ; PM_MULTI_BUILT=':' - export PM_MULTI_PORTS PM_MULTI_BUILT + PM_MULTI_PORTS=':' ; export PM_MULTI_PORTS local port worklist_temp worklist portlist numports origin num @@ -2586,7 +2584,7 @@ multiport () { *) origin=`origin_from_pdb $port` ;; esac - case "$PM_NEEDS_UPDATE" in *\ ${origin}\ *) continue ;; esac + case "$PM_NEEDS_UPDATE" in *\ $origin\ *) continue ;; esac numports=$(( $numports + 1 )) init_term_printf "$port ${numports}/${numports}" @@ -2594,10 +2592,9 @@ multiport () { . $IPC_SAVE case "$PM_NEEDS_UPDATE" in - *\ ${origin}\ *) continue ;; + *\ $origin\ *) continue ;; # Handle +IGNOREME in child - *) PM_MULTI_BUILT="${PM_MULTI_BUILT}${port}:" - numports=$(( $numports - 1 )) ;; + *) numports=$(( $numports - 1 )) ;; esac done @@ -2608,10 +2605,11 @@ multiport () { export PM_BUILDING=pmbuildingmultiport num=0 for port in $worklist; do - case "$PM_MULTI_BUILT" in *:${port}:*) continue ;; esac - case "$port" in - */*) ;; # Ok to proceed + */*) case "$PM_NEEDS_UPDATE" in + *\ $port\ *) ;; # Ok to proceed + *) continue ;; # Already updated as a dependency + esac ;; *) # If an installed version does not exist at this # point it probably got updated as a dependency if [ ! -d "$pdb/$port" ]; then @@ -2837,7 +2835,7 @@ all_first_pass () { for origin in $PM_NEEDS_UPDATE; do case "$PM_NEEDS_UPDATE" in *\ $origin\ *) update_port $origin ;; - '') continue ;; # Already updated as a dependency + *) continue ;; # Already updated as a dependency esac done @@ -3661,8 +3659,6 @@ if [ "$$" -ne "$PM_PARENT_PID" -o -n "$U echo "===>>> $ilist succeeded" ; echo '' fi -[ -n "$PM_MULTI_BUILT" ] && PM_MULTI_BUILT="${PM_MULTI_BUILT}${new_port}:${portdir}:" - INSTALLED_LIST="${INSTALLED_LIST}\t${ilist}\n" [ -e "$pdb/$new_port/+DISPLAY" ] && DISPLAY_LIST="${DISPLAY_LIST}$new_port " CUR_DEPS="${CUR_DEPS}${new_port}:${portdir}:" From owner-svn-src-user@FreeBSD.ORG Wed Nov 3 10:34:21 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B709106566C; Wed, 3 Nov 2010 10:34:21 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8A4088FC18; Wed, 3 Nov 2010 10:34:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA3AYLGM017889; Wed, 3 Nov 2010 10:34:21 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3AYLgJ017886; Wed, 3 Nov 2010 10:34:21 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201011031034.oA3AYLgJ017886@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 3 Nov 2010 10:34:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214733 - user/ae/usr.sbin/sade X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 10:34:21 -0000 Author: ae Date: Wed Nov 3 10:34:21 2010 New Revision: 214733 URL: http://svn.freebsd.org/changeset/base/214733 Log: Remove stale declarations. Fix a typo [1]. Add check for correctness of volume label. Construct tunefs command-line based on info given from dialog. Allow long messages for dmenu_open_errormsg. Noticed by: netchild [1] Modified: user/ae/usr.sbin/sade/menus.c user/ae/usr.sbin/sade/ufsed.c Modified: user/ae/usr.sbin/sade/menus.c ============================================================================== --- user/ae/usr.sbin/sade/menus.c Wed Nov 3 10:24:57 2010 (r214732) +++ user/ae/usr.sbin/sade/menus.c Wed Nov 3 10:34:21 2010 (r214733) @@ -135,12 +135,8 @@ restorescr(WINDOW *win) void dmenu_open_errormsg(char *msg) { - char buf[80]; - int width; WINDOW *win = savescr(); - snprintf(buf, sizeof(buf), "An error occured: %s", msg); - width = (strlen(buf) + 5) % 70; - dialog_msgbox("Error", buf, 5, width, 1); + dialog_mesgbox("Error", msg, -1, -1); restorescr(win); } Modified: user/ae/usr.sbin/sade/ufsed.c ============================================================================== --- user/ae/usr.sbin/sade/ufsed.c Wed Nov 3 10:24:57 2010 (r214732) +++ user/ae/usr.sbin/sade/ufsed.c Wed Nov 3 10:34:21 2010 (r214733) @@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$"); #include "customdlg.h" #include "mntopts.h" +#define CMDLEN_MAX 256 +#define PATH_TUNEFS "/sbin/tunefs" static char *ask_recreate_msg = "WARNING: Selected partition already contains a file system!\n\n" @@ -225,16 +227,6 @@ set_statusline(char *msg) } } -enum hist_cmd_type { - NEWFS, TUNEFS -}; - -struct hist_cmd_entry { - enum hist_cmd_type type; - struct de_fs *pfs; - char *args; -}; - static int ufsed_history_rollback(void *pentry) { @@ -250,12 +242,9 @@ ufsed_history_play(void *pentry) static int ufslist_reread(struct ufslist *fslist) { - int error; ufslist_free(fslist); - error = ufslist_get(fslist); - - return (error); + return (ufslist_get(fslist)); } static int @@ -277,12 +266,12 @@ ufsed_tunefs(history_t hist, struct ufsi { struct custom_dlg dlg; struct dlg_item *item; - DLG_BUTTON *btnOk, *btnCancel, *btnCustom; + DLG_BUTTON *btnOk, *btnCancel, *btnAdvanced; DLG_EDIT *eLabel; WINDOW *win; uint32_t flags; int q, h, w, ret, i; - char *title_buf; + char buf[CMDLEN_MAX], *s; struct { DLG_CHECKBOX *item; uint32_t flag; @@ -294,14 +283,14 @@ ufsed_tunefs(history_t hist, struct ufsi { NULL, FS_ACLS, "POSIX.1e ACL", "-a" }, { NULL, FS_MULTILABEL, "MAC multilabel", "-l" }, { NULL, FS_GJOURNAL, "GEOM journaling", "-J" }, - { NULL, FS_NFS4ACLS, "NFSv4 ALC", "-N" } + { NULL, FS_NFS4ACLS, "NFSv4 ACL", "-N" } }; win = savescr(); dlg_init(&dlg); - asprintf(&title_buf, "Change a file system parameters for \"%s\":", - pfs->partname); - dlg_add_label(&dlg, 1, 2, 55, 2, title_buf); + snprintf(buf, sizeof(buf), + "Change a file system parameters for \"%s\":", pfs->partname); + dlg_add_label(&dlg, 1, 2, 55, 2, buf); eLabel = dlg_add_edit(&dlg, 3, 2, 24, "Volume Label:", MAXVOLLEN, pfs->volname); for (i = 0; i < sizeof(checkbox) / sizeof(checkbox[0]); i++) @@ -311,10 +300,11 @@ ufsed_tunefs(history_t hist, struct ufsi checkbox[i].label); btnOk = dlg_add_button(&dlg, 9, 14, " Ok "); btnCancel = dlg_add_button(&dlg, 9, 26, "Cancel"); - btnCustom = dlg_add_button(&dlg, 9, 38, "Custom"); + btnAdvanced = dlg_add_button(&dlg, 9, 38, "Advanced"); use_helpline("Press F1 for help"); dlg_autosize(&dlg, &w, &h); dlg_open_dialog(&dlg, w + 1, h + 1, "Change File System"); +again: q = 0; do { ret = dlg_proc(&dlg, tunefs_keyhndl); @@ -329,7 +319,7 @@ ufsed_tunefs(history_t hist, struct ufsi q = 1; else if (item == btnOk) q = 2; - else if (item == btnCustom) + else if (item == btnAdvanced) q = 3; else dlg_focus_next(&dlg); @@ -348,20 +338,49 @@ ufsed_tunefs(history_t hist, struct ufsi }; } while (q == 0); - flags = 0; + if (q != 2) + goto done; + + flags = ret = 0; + s = dlg_edit_get_value(&dlg, eLabel); + if (s != NULL && *s != '\0') { /* volname has been specified */ + i = 0; + while (isalnum(s[i++])); + if (s[i] != '\0') { + dmenu_open_errormsg("Invalid character in volume " + "label. Only alphanumerics characters are " + "allowed."); + goto again; + } + /* check for volname changes */ + if (pfs->volname == NULL || + strncmp(pfs->volname, s, MAXVOLLEN) != 0) + ret = 1; + } else if (pfs->volname != NULL) /* we want to reset volume label */ + ret = 1; for (i = 0; i < sizeof(checkbox) / sizeof(checkbox[0]); i++) { if (dlg_checkbox_checked(&dlg, checkbox[i].item)) flags |= checkbox[i].flag; else flags &= ~checkbox[i].flag; } - if (flags != pfs->flags) { - /* something changed */ + if (flags != pfs->flags || ret != 0) { /* something changed */ + snprintf(buf, sizeof(buf), "%s -L \"%s\"", PATH_TUNEFS, + (s != NULL && *s != '\0') ? s: ""); + for (i = 0; i < sizeof(checkbox) / sizeof(checkbox[0]); i++) { + snprintf(buf, sizeof(buf), "%s %s %s", buf, + checkbox[i].arg, + dlg_checkbox_checked(&dlg, checkbox[i].item) ? + "enable": "disable"); + } + snprintf(buf, sizeof(buf), "%s %s%s", buf, _PATH_DEV, + pfs->partname); + /* add command to history */ } +done: restorescr(win); dlg_close_dialog(&dlg); dlg_free(&dlg); - free(title_buf); } From owner-svn-src-user@FreeBSD.ORG Wed Nov 3 12:12:29 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A15A1065672; Wed, 3 Nov 2010 12:12:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 499748FC14; Wed, 3 Nov 2010 12:12:29 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA3CCTxc020270; Wed, 3 Nov 2010 12:12:29 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3CCTN0020268; Wed, 3 Nov 2010 12:12:29 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201011031212.oA3CCTN0020268@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 3 Nov 2010 12:12:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214737 - user/ae/usr.sbin/sade X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 12:12:29 -0000 Author: ae Date: Wed Nov 3 12:12:29 2010 New Revision: 214737 URL: http://svn.freebsd.org/changeset/base/214737 Log: Add simple commit/undo support. Modified: user/ae/usr.sbin/sade/ufsed.c Modified: user/ae/usr.sbin/sade/ufsed.c ============================================================================== --- user/ae/usr.sbin/sade/ufsed.c Wed Nov 3 10:46:39 2010 (r214736) +++ user/ae/usr.sbin/sade/ufsed.c Wed Nov 3 12:12:29 2010 (r214737) @@ -230,12 +230,17 @@ set_statusline(char *msg) static int ufsed_history_rollback(void *pentry) { + + free(pentry); return (0); } static int ufsed_history_play(void *pentry) { + + /* system(pentry); */ + free(pentry); return (0); } @@ -248,8 +253,21 @@ ufslist_reread(struct ufslist *fslist) } static int +ufsed_history_add(history_t hist, const char *cmd) +{ + char *entry; + + entry = strdup(cmd); + if (entry == NULL) + return (ENOMEM); + + return (history_add_entry(hist, entry)); +} + +static int tunefs_keyhndl(int key) { + switch (key) { case ' ': case KEY_UP: @@ -366,7 +384,7 @@ again: } if (flags != pfs->flags || ret != 0) { /* something changed */ snprintf(buf, sizeof(buf), "%s -L \"%s\"", PATH_TUNEFS, - (s != NULL && *s != '\0') ? s: ""); + (s != NULL) ? s: ""); for (i = 0; i < sizeof(checkbox) / sizeof(checkbox[0]); i++) { snprintf(buf, sizeof(buf), "%s %s %s", buf, checkbox[i].arg, @@ -376,6 +394,17 @@ again: snprintf(buf, sizeof(buf), "%s %s%s", buf, _PATH_DEV, pfs->partname); /* add command to history */ + ret = ufsed_history_add(hist, buf); + if (ret) + dmenu_open_errormsg("Operation failed."); + else { /* do fake changes to update current view */ + pfs->flags = flags; + free(pfs->volname); + if (s != NULL && *s != '\0') + pfs->volname = strndup(s, MAXVOLLEN); + else + pfs->volname = NULL; + } } done: restorescr(win); From owner-svn-src-user@FreeBSD.ORG Wed Nov 3 15:22:10 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0D931106564A; Wed, 3 Nov 2010 15:22:10 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC6E08FC1B; Wed, 3 Nov 2010 15:22:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA3FM92p024715; Wed, 3 Nov 2010 15:22:09 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3FM9b6024680; Wed, 3 Nov 2010 15:22:09 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201011031522.oA3FM9b6024680@svn.freebsd.org> From: Nathan Whitehorn Date: Wed, 3 Nov 2010 15:22:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214740 - in user/nwhitehorn/ps3: amd64/acpica amd64/amd64 amd64/include arm/arm boot/ofw/common boot/ofw/libofw boot/sparc64/loader cddl/contrib/opensolaris/uts/common/fs/zfs conf dev/... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 15:22:10 -0000 Author: nwhitehorn Date: Wed Nov 3 15:22:09 2010 New Revision: 214740 URL: http://svn.freebsd.org/changeset/base/214740 Log: IFC @ r214739 Added: user/nwhitehorn/ps3/dev/agp/agp_apple.c - copied unchanged from r214739, head/sys/dev/agp/agp_apple.c user/nwhitehorn/ps3/x86/include/ - copied from r214739, head/sys/x86/include/ user/nwhitehorn/ps3/x86/x86/dump_machdep.c - copied unchanged from r214739, head/sys/x86/x86/dump_machdep.c user/nwhitehorn/ps3/x86/x86/mptable.c - copied unchanged from r214739, head/sys/x86/x86/mptable.c user/nwhitehorn/ps3/x86/x86/mptable_pci.c - copied unchanged from r214739, head/sys/x86/x86/mptable_pci.c user/nwhitehorn/ps3/x86/x86/nexus.c - copied unchanged from r214739, head/sys/x86/x86/nexus.c Deleted: user/nwhitehorn/ps3/amd64/amd64/dump_machdep.c user/nwhitehorn/ps3/amd64/amd64/mptable.c user/nwhitehorn/ps3/amd64/amd64/mptable_pci.c user/nwhitehorn/ps3/amd64/amd64/nexus.c user/nwhitehorn/ps3/amd64/include/apicreg.h user/nwhitehorn/ps3/amd64/include/mca.h user/nwhitehorn/ps3/i386/i386/dump_machdep.c user/nwhitehorn/ps3/i386/i386/mptable.c user/nwhitehorn/ps3/i386/i386/mptable_pci.c user/nwhitehorn/ps3/i386/i386/nexus.c user/nwhitehorn/ps3/i386/include/apicreg.h user/nwhitehorn/ps3/i386/include/mca.h user/nwhitehorn/ps3/pc98/include/apicreg.h user/nwhitehorn/ps3/pc98/include/mca.h Modified: user/nwhitehorn/ps3/amd64/acpica/acpi_wakeup.c user/nwhitehorn/ps3/amd64/acpica/madt.c user/nwhitehorn/ps3/amd64/amd64/amd64_mem.c user/nwhitehorn/ps3/amd64/amd64/apic_vector.S user/nwhitehorn/ps3/amd64/amd64/genassym.c user/nwhitehorn/ps3/amd64/amd64/intr_machdep.c user/nwhitehorn/ps3/amd64/amd64/machdep.c user/nwhitehorn/ps3/amd64/amd64/mp_machdep.c user/nwhitehorn/ps3/amd64/amd64/mp_watchdog.c user/nwhitehorn/ps3/amd64/amd64/pmap.c user/nwhitehorn/ps3/amd64/amd64/trap.c user/nwhitehorn/ps3/amd64/include/pmap.h user/nwhitehorn/ps3/arm/arm/elf_trampoline.c user/nwhitehorn/ps3/boot/ofw/common/main.c user/nwhitehorn/ps3/boot/ofw/libofw/ofw_memory.c user/nwhitehorn/ps3/boot/ofw/libofw/ofw_net.c user/nwhitehorn/ps3/boot/ofw/libofw/openfirm.c user/nwhitehorn/ps3/boot/sparc64/loader/main.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c user/nwhitehorn/ps3/conf/files user/nwhitehorn/ps3/conf/files.amd64 user/nwhitehorn/ps3/conf/files.i386 user/nwhitehorn/ps3/conf/files.pc98 user/nwhitehorn/ps3/conf/files.powerpc user/nwhitehorn/ps3/conf/kern.post.mk user/nwhitehorn/ps3/conf/kmod.mk user/nwhitehorn/ps3/conf/options.amd64 user/nwhitehorn/ps3/conf/options.powerpc user/nwhitehorn/ps3/dev/acpica/acpi.c user/nwhitehorn/ps3/dev/agp/agp.c user/nwhitehorn/ps3/dev/alc/if_alc.c user/nwhitehorn/ps3/dev/ata/chipsets/ata-intel.c user/nwhitehorn/ps3/dev/bge/if_bge.c user/nwhitehorn/ps3/dev/bge/if_bgereg.h user/nwhitehorn/ps3/dev/e1000/e1000_82571.c user/nwhitehorn/ps3/dev/e1000/if_em.c user/nwhitehorn/ps3/dev/e1000/if_em.h user/nwhitehorn/ps3/dev/e1000/if_lem.c user/nwhitehorn/ps3/dev/e1000/if_lem.h user/nwhitehorn/ps3/dev/mii/brgphy.c user/nwhitehorn/ps3/dev/mii/e1000phy.c user/nwhitehorn/ps3/dev/mii/mii_physubr.c user/nwhitehorn/ps3/dev/mii/miidevs user/nwhitehorn/ps3/dev/mii/miivar.h user/nwhitehorn/ps3/dev/usb/usb_device.c user/nwhitehorn/ps3/dev/usb/usb_hub.c user/nwhitehorn/ps3/dev/usb/usbdevs user/nwhitehorn/ps3/dev/usb/usbdi.h user/nwhitehorn/ps3/dev/xen/blkback/blkback.c user/nwhitehorn/ps3/fs/nfs/nfsclstate.h user/nwhitehorn/ps3/fs/nfsclient/nfs_clnode.c user/nwhitehorn/ps3/fs/nfsclient/nfs_clstate.c user/nwhitehorn/ps3/fs/nfsclient/nfs_clvnops.c user/nwhitehorn/ps3/geom/part/g_part.c user/nwhitehorn/ps3/geom/part/g_part.h user/nwhitehorn/ps3/geom/part/g_part_gpt.c user/nwhitehorn/ps3/geom/part/g_part_if.m user/nwhitehorn/ps3/i386/acpica/acpi_wakeup.c user/nwhitehorn/ps3/i386/acpica/madt.c user/nwhitehorn/ps3/i386/i386/apic_vector.s user/nwhitehorn/ps3/i386/i386/genassym.c user/nwhitehorn/ps3/i386/i386/intr_machdep.c user/nwhitehorn/ps3/i386/i386/machdep.c user/nwhitehorn/ps3/i386/i386/mp_machdep.c user/nwhitehorn/ps3/i386/i386/mp_watchdog.c user/nwhitehorn/ps3/i386/i386/mpboot.s user/nwhitehorn/ps3/i386/i386/trap.c user/nwhitehorn/ps3/i386/xen/mp_machdep.c user/nwhitehorn/ps3/i386/xen/mptable.c user/nwhitehorn/ps3/kern/init_main.c user/nwhitehorn/ps3/kern/kern_clock.c user/nwhitehorn/ps3/kern/kern_cpuset.c user/nwhitehorn/ps3/kern/kern_timeout.c user/nwhitehorn/ps3/kern/sched_ule.c user/nwhitehorn/ps3/kern/subr_acl_nfs4.c user/nwhitehorn/ps3/kern/vfs_cache.c user/nwhitehorn/ps3/mips/cavium/octeon_ebt3000_cf.c user/nwhitehorn/ps3/modules/Makefile user/nwhitehorn/ps3/modules/agp/Makefile user/nwhitehorn/ps3/net/bpf.h user/nwhitehorn/ps3/netinet/if_ether.c user/nwhitehorn/ps3/netipsec/ipsec.c user/nwhitehorn/ps3/netipsec/ipsec_input.c user/nwhitehorn/ps3/nfsclient/nfs_vfsops.c user/nwhitehorn/ps3/pc98/include/bus.h user/nwhitehorn/ps3/pc98/pc98/busiosubr.c user/nwhitehorn/ps3/pc98/pc98/machdep.c user/nwhitehorn/ps3/powerpc/aim/copyinout.c user/nwhitehorn/ps3/powerpc/aim/mmu_oea.c user/nwhitehorn/ps3/powerpc/aim/mmu_oea64.c user/nwhitehorn/ps3/powerpc/aim/slb.c user/nwhitehorn/ps3/powerpc/aim/swtch32.S user/nwhitehorn/ps3/powerpc/aim/swtch64.S user/nwhitehorn/ps3/powerpc/aim/trap.c user/nwhitehorn/ps3/powerpc/aim/trap_subr32.S user/nwhitehorn/ps3/powerpc/aim/trap_subr64.S user/nwhitehorn/ps3/powerpc/aim/vm_machdep.c user/nwhitehorn/ps3/powerpc/conf/GENERIC user/nwhitehorn/ps3/powerpc/conf/GENERIC64 user/nwhitehorn/ps3/powerpc/conf/NOTES user/nwhitehorn/ps3/powerpc/include/pcb.h user/nwhitehorn/ps3/powerpc/include/slb.h user/nwhitehorn/ps3/powerpc/include/sr.h user/nwhitehorn/ps3/powerpc/powermac/cpcht.c user/nwhitehorn/ps3/powerpc/powerpc/exec_machdep.c user/nwhitehorn/ps3/powerpc/powerpc/genassym.c user/nwhitehorn/ps3/sparc64/sparc64/pmap.c user/nwhitehorn/ps3/sparc64/sparc64/tick.c user/nwhitehorn/ps3/ufs/ufs/ufs_dirhash.c user/nwhitehorn/ps3/vm/vm_phys.c user/nwhitehorn/ps3/vm/vm_reserv.c user/nwhitehorn/ps3/x86/x86/io_apic.c user/nwhitehorn/ps3/x86/x86/local_apic.c user/nwhitehorn/ps3/x86/x86/mca.c user/nwhitehorn/ps3/x86/x86/msi.c Directory Properties: user/nwhitehorn/ps3/ (props changed) user/nwhitehorn/ps3/amd64/include/xen/ (props changed) user/nwhitehorn/ps3/boot/powerpc/ps3/ (props changed) user/nwhitehorn/ps3/cddl/contrib/opensolaris/ (props changed) user/nwhitehorn/ps3/contrib/dev/acpica/ (props changed) user/nwhitehorn/ps3/contrib/pf/ (props changed) user/nwhitehorn/ps3/contrib/x86emu/ (props changed) user/nwhitehorn/ps3/dev/xen/xenpci/ (props changed) user/nwhitehorn/ps3/powerpc/ps3/ (props changed) Modified: user/nwhitehorn/ps3/amd64/acpica/acpi_wakeup.c ============================================================================== --- user/nwhitehorn/ps3/amd64/acpica/acpi_wakeup.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/acpica/acpi_wakeup.c Wed Nov 3 15:22:09 2010 (r214740) @@ -41,13 +41,13 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include #include #ifdef SMP -#include +#include #include #include #endif Modified: user/nwhitehorn/ps3/amd64/acpica/madt.c ============================================================================== --- user/nwhitehorn/ps3/amd64/acpica/madt.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/acpica/madt.c Wed Nov 3 15:22:09 2010 (r214740) @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include Modified: user/nwhitehorn/ps3/amd64/amd64/amd64_mem.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/amd64_mem.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/amd64_mem.c Wed Nov 3 15:22:09 2010 (r214740) @@ -35,6 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include + #include #include #include @@ -527,9 +531,9 @@ static int amd64_mrset(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg) { struct mem_range_desc *targ; - int error = 0; + int error, i; - switch(*arg) { + switch (*arg) { case MEMRANGE_SET_UPDATE: /* * Make sure that what's being asked for is even @@ -568,6 +572,21 @@ amd64_mrset(struct mem_range_softc *sc, return (EOPNOTSUPP); } + /* + * Ensure that the direct map region does not contain any mappings + * that span MTRRs of different types. However, the fixed MTRRs can + * be ignored, because a large page mapping the first 1 MB of physical + * memory is a special case that the processor handles. The entire + * TLB will be invalidated by amd64_mrstore(), so pmap_demote_DMAP() + * needn't do it. + */ + i = (sc->mr_cap & MR686_FIXMTRR) ? MTRR_N64K + MTRR_N16K + MTRR_N4K : 0; + mrd = sc->mr_desc + i; + for (; i < sc->mr_ndesc; i++, mrd++) { + if (mrd->mr_flags & MDF_ACTIVE) + pmap_demote_DMAP(mrd->mr_base, mrd->mr_len, FALSE); + } + /* Update the hardware. */ amd64_mrstore(sc); @@ -657,6 +676,21 @@ amd64_mrinit(struct mem_range_softc *sc) if (mrd->mr_flags & MDF_ACTIVE) mrd->mr_flags |= MDF_FIRMWARE; } + + /* + * Ensure that the direct map region does not contain any mappings + * that span MTRRs of different types. However, the fixed MTRRs can + * be ignored, because a large page mapping the first 1 MB of physical + * memory is a special case that the processor handles. Invalidate + * any old TLB entries that might hold inconsistent memory type + * information. + */ + i = (sc->mr_cap & MR686_FIXMTRR) ? MTRR_N64K + MTRR_N16K + MTRR_N4K : 0; + mrd = sc->mr_desc + i; + for (; i < sc->mr_ndesc; i++, mrd++) { + if (mrd->mr_flags & MDF_ACTIVE) + pmap_demote_DMAP(mrd->mr_base, mrd->mr_len, TRUE); + } } /* Modified: user/nwhitehorn/ps3/amd64/amd64/apic_vector.S ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/apic_vector.S Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/apic_vector.S Wed Nov 3 15:22:09 2010 (r214740) @@ -39,7 +39,7 @@ #include "opt_smp.h" #include -#include +#include #include "assym.s" Modified: user/nwhitehorn/ps3/amd64/amd64/genassym.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/genassym.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/genassym.c Wed Nov 3 15:22:09 2010 (r214740) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include Modified: user/nwhitehorn/ps3/amd64/amd64/intr_machdep.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/intr_machdep.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/intr_machdep.c Wed Nov 3 15:22:09 2010 (r214740) @@ -458,7 +458,7 @@ intr_next_cpu(void) /* Leave all interrupts on the BSP during boot. */ if (!assign_cpu) - return (cpu_apic_ids[0]); + return (PCPU_GET(apic_id)); mtx_lock_spin(&icu_lock); apic_id = cpu_apic_ids[current_cpu]; Modified: user/nwhitehorn/ps3/amd64/amd64/machdep.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/machdep.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/machdep.c Wed Nov 3 15:22:09 2010 (r214740) @@ -112,7 +112,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include Modified: user/nwhitehorn/ps3/amd64/amd64/mp_machdep.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/mp_machdep.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/mp_machdep.c Wed Nov 3 15:22:09 2010 (r214740) @@ -57,11 +57,11 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include #include -#include +#include #include #include #include Modified: user/nwhitehorn/ps3/amd64/amd64/mp_watchdog.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/mp_watchdog.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/mp_watchdog.c Wed Nov 3 15:22:09 2010 (r214740) @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include Modified: user/nwhitehorn/ps3/amd64/amd64/pmap.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/pmap.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/pmap.c Wed Nov 3 15:22:09 2010 (r214740) @@ -462,7 +462,7 @@ create_pagetables(vm_paddr_t *firstaddr) if (ndmpdp < 4) /* Minimum 4GB of dirmap */ ndmpdp = 4; DMPDPphys = allocpages(firstaddr, NDMPML4E); - if (TRUE || (amd_feature & AMDID_PAGE1GB) == 0) + if ((amd_feature & AMDID_PAGE1GB) == 0) DMPDphys = allocpages(firstaddr, ndmpdp); dmaplimit = (vm_paddr_t)ndmpdp << PDPSHIFT; @@ -494,11 +494,16 @@ create_pagetables(vm_paddr_t *firstaddr) ((pdp_entry_t *)KPDPphys)[i + KPDPI] |= PG_RW | PG_V | PG_U; } - /* Now set up the direct map space using either 2MB or 1GB pages */ - /* Preset PG_M and PG_A because demotion expects it */ - if (TRUE || (amd_feature & AMDID_PAGE1GB) == 0) { + /* + * Now, set up the direct map region using either 2MB or 1GB pages. + * Later, if pmap_mapdev{_attr}() uses the direct map for non-write- + * back memory, pmap_change_attr() will demote any 2MB or 1GB page + * mappings that are partially used. + */ + if ((amd_feature & AMDID_PAGE1GB) == 0) { for (i = 0; i < NPDEPG * ndmpdp; i++) { ((pd_entry_t *)DMPDphys)[i] = (vm_paddr_t)i << PDRSHIFT; + /* Preset PG_M and PG_A because demotion expects it. */ ((pd_entry_t *)DMPDphys)[i] |= PG_RW | PG_V | PG_PS | PG_G | PG_M | PG_A; } @@ -512,6 +517,7 @@ create_pagetables(vm_paddr_t *firstaddr) for (i = 0; i < ndmpdp; i++) { ((pdp_entry_t *)DMPDPphys)[i] = (vm_paddr_t)i << PDPSHIFT; + /* Preset PG_M and PG_A because demotion expects it. */ ((pdp_entry_t *)DMPDPphys)[i] |= PG_RW | PG_V | PG_PS | PG_G | PG_M | PG_A; } @@ -4948,6 +4954,54 @@ pmap_change_attr_locked(vm_offset_t va, } /* + * Demotes any mapping within the direct map region that covers more than the + * specified range of physical addresses. This range's size must be a power + * of two and its starting address must be a multiple of its size. Since the + * demotion does not change any attributes of the mapping, a TLB invalidation + * is not mandatory. The caller may, however, request a TLB invalidation. + */ +void +pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate) +{ + pdp_entry_t *pdpe; + pd_entry_t *pde; + vm_offset_t va; + boolean_t changed; + + if (len == 0) + return; + KASSERT(powerof2(len), ("pmap_demote_DMAP: len is not a power of 2")); + KASSERT((base & (len - 1)) == 0, + ("pmap_demote_DMAP: base is not a multiple of len")); + if (len < NBPDP && base < dmaplimit) { + va = PHYS_TO_DMAP(base); + changed = FALSE; + PMAP_LOCK(kernel_pmap); + pdpe = pmap_pdpe(kernel_pmap, va); + if ((*pdpe & PG_V) == 0) + panic("pmap_demote_DMAP: invalid PDPE"); + if ((*pdpe & PG_PS) != 0) { + if (!pmap_demote_pdpe(kernel_pmap, pdpe, va)) + panic("pmap_demote_DMAP: PDPE failed"); + changed = TRUE; + } + if (len < NBPDR) { + pde = pmap_pdpe_to_pde(pdpe, va); + if ((*pde & PG_V) == 0) + panic("pmap_demote_DMAP: invalid PDE"); + if ((*pde & PG_PS) != 0) { + if (!pmap_demote_pde(kernel_pmap, pde, va)) + panic("pmap_demote_DMAP: PDE failed"); + changed = TRUE; + } + } + if (changed && invalidate) + pmap_invalidate_page(kernel_pmap, va); + PMAP_UNLOCK(kernel_pmap); + } +} + +/* * perform the pmap work for mincore */ int Modified: user/nwhitehorn/ps3/amd64/amd64/trap.c ============================================================================== --- user/nwhitehorn/ps3/amd64/amd64/trap.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/amd64/trap.c Wed Nov 3 15:22:09 2010 (r214740) @@ -83,7 +83,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include #include #ifdef SMP Modified: user/nwhitehorn/ps3/amd64/include/pmap.h ============================================================================== --- user/nwhitehorn/ps3/amd64/include/pmap.h Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/amd64/include/pmap.h Wed Nov 3 15:22:09 2010 (r214740) @@ -307,6 +307,7 @@ extern vm_offset_t virtual_end; void pmap_bootstrap(vm_paddr_t *); int pmap_change_attr(vm_offset_t, vm_size_t, int); +void pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate); void pmap_init_pat(void); void pmap_kenter(vm_offset_t va, vm_paddr_t pa); void *pmap_kenter_temporary(vm_paddr_t pa, int i); Modified: user/nwhitehorn/ps3/arm/arm/elf_trampoline.c ============================================================================== --- user/nwhitehorn/ps3/arm/arm/elf_trampoline.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/arm/arm/elf_trampoline.c Wed Nov 3 15:22:09 2010 (r214740) @@ -159,7 +159,7 @@ _startC(void) #if defined(FLASHADDR) && defined(LOADERRAMADDR) unsigned int pc; - __asm __volatile("adr %0, _start\n" + __asm __volatile("mov %0, pc\n" : "=r" (pc)); if ((FLASHADDR > LOADERRAMADDR && pc >= FLASHADDR) || (FLASHADDR < LOADERRAMADDR && pc < LOADERRAMADDR)) { @@ -173,11 +173,13 @@ _startC(void) */ unsigned int target_addr; unsigned int tmp_sp; + uint32_t src_addr = (uint32_t)&_start - PHYSADDR + FLASHADDR + + (pc - FLASHADDR - ((uint32_t)&_startC - PHYSADDR)) & 0xfffff000; target_addr = (unsigned int)&_start - PHYSADDR + LOADERRAMADDR; tmp_sp = target_addr + 0x100000 + (unsigned int)&_end - (unsigned int)&_start; - memcpy((char *)target_addr, (char *)pc, + memcpy((char *)target_addr, (char *)src_addr, (unsigned int)&_end - (unsigned int)&_start); /* Temporary set the sp and jump to the new location. */ __asm __volatile( Modified: user/nwhitehorn/ps3/boot/ofw/common/main.c ============================================================================== --- user/nwhitehorn/ps3/boot/ofw/common/main.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/boot/ofw/common/main.c Wed Nov 3 15:22:09 2010 (r214740) @@ -41,19 +41,23 @@ extern char bootprog_rev[]; extern char bootprog_date[]; extern char bootprog_maker[]; -u_int32_t acells; +u_int32_t acells, scells; static char bootargs[128]; #define HEAP_SIZE 0x80000 +#define OF_puts(fd, text) OF_write(fd, text, strlen(text)) + void init_heap(void) { void *base; + ihandle_t stdout; if ((base = ofw_alloc_heap(HEAP_SIZE)) == (void *)0xffffffff) { - printf("Heap memory claim failed!\n"); + OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); + OF_puts(stdout, "Heap memory claim failed!\n"); OF_enter(); } @@ -64,25 +68,20 @@ uint64_t memsize(void) { phandle_t memoryp; - struct ofw_reg reg[4]; - struct ofw_reg2 reg2[8]; - int i; - u_int64_t sz, memsz; + cell_t reg[24]; + int i, sz; + u_int64_t memsz; + memsz = 0; memoryp = OF_instance_to_package(memory); - if (acells == 1) { - sz = OF_getprop(memoryp, "reg", ®, sizeof(reg)); - sz /= sizeof(struct ofw_reg); - - for (i = 0, memsz = 0; i < sz; i++) - memsz += reg[i].size; - } else if (acells == 2) { - sz = OF_getprop(memoryp, "reg", ®2, sizeof(reg2)); - sz /= sizeof(struct ofw_reg2); + sz = OF_getprop(memoryp, "reg", ®, sizeof(reg)); + sz /= sizeof(reg[0]); - for (i = 0, memsz = 0; i < sz; i++) - memsz += reg2[i].size; + for (i = 0; i < sz; i += (acells + scells)) { + if (scells > 1) + memsz += (uint64_t)reg[i + acells] << 32; + memsz += reg[i + acells + scells - 1]; } return (memsz); @@ -105,13 +104,9 @@ main(int (*openfirm)(void *)) root = OF_finddevice("/"); - acells = 1; + scells = acells = 1; OF_getprop(root, "#address-cells", &acells, sizeof(acells)); - - /* - * Set up console. - */ - cons_probe(); + OF_getprop(root, "#size-cells", &scells, sizeof(scells)); /* * Initialise the heap as early as possible. Once this is done, @@ -121,6 +116,11 @@ main(int (*openfirm)(void *)) init_heap(); /* + * Set up console. + */ + cons_probe(); + + /* * March through the device switch probing for things. */ for (i = 0; devsw[i] != NULL; i++) Modified: user/nwhitehorn/ps3/boot/ofw/libofw/ofw_memory.c ============================================================================== --- user/nwhitehorn/ps3/boot/ofw/libofw/ofw_memory.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/boot/ofw/libofw/ofw_memory.c Wed Nov 3 15:22:09 2010 (r214740) @@ -118,13 +118,19 @@ ofw_memmap(int acells) void * ofw_alloc_heap(unsigned int size) { - phandle_t memoryp; - struct ofw_reg available; + phandle_t memoryp, root; + cell_t available[4]; + cell_t acells; + + root = OF_finddevice("/"); + acells = 1; + OF_getprop(root, "#address-cells", &acells, sizeof(acells)); memoryp = OF_instance_to_package(memory); - OF_getprop(memoryp, "available", &available, sizeof(available)); + OF_getprop(memoryp, "available", available, sizeof(available)); - heap_base = OF_claim((void *)available.base, size, sizeof(register_t)); + heap_base = OF_claim((void *)available[acells-1], size, + sizeof(register_t)); if (heap_base != (void *)-1) { heap_size = size; Modified: user/nwhitehorn/ps3/boot/ofw/libofw/ofw_net.c ============================================================================== --- user/nwhitehorn/ps3/boot/ofw/libofw/ofw_net.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/boot/ofw/libofw/ofw_net.c Wed Nov 3 15:22:09 2010 (r214740) @@ -230,7 +230,10 @@ punt: static void ofwn_end(struct netif *nif) { +#ifdef BROKEN + /* dma-free freezes at least some Apple ethernet controllers */ OF_call_method("dma-free", netinstance, 2, 0, dmabuf, MAXPHYS); +#endif OF_close(netinstance); } Modified: user/nwhitehorn/ps3/boot/ofw/libofw/openfirm.c ============================================================================== --- user/nwhitehorn/ps3/boot/ofw/libofw/openfirm.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/boot/ofw/libofw/openfirm.c Wed Nov 3 15:22:09 2010 (r214740) @@ -80,8 +80,13 @@ OF_init(int (*openfirm)(void *)) if ((chosen = OF_finddevice("/chosen")) == -1) OF_exit(); - if (OF_getprop(chosen, "memory", &memory, sizeof(memory)) == -1) - OF_exit(); + if (OF_getprop(chosen, "memory", &memory, sizeof(memory)) == -1) { + memory = OF_open("/memory"); + if (memory == -1) + memory = OF_open("/memory@0"); + if (memory == -1) + OF_exit(); + } if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1) OF_exit(); } Modified: user/nwhitehorn/ps3/boot/sparc64/loader/main.c ============================================================================== --- user/nwhitehorn/ps3/boot/sparc64/loader/main.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/boot/sparc64/loader/main.c Wed Nov 3 15:22:09 2010 (r214740) @@ -811,15 +811,15 @@ main(int (*openfirm)(void *)) archsw.arch_autoload = sparc64_autoload; archsw.arch_maphint = sparc64_maphint; + if (init_heap() == (vm_offset_t)-1) + OF_exit(); + setheap((void *)heapva, (void *)(heapva + HEAPSZ)); + /* * Probe for a console. */ cons_probe(); - if (init_heap() == (vm_offset_t)-1) - panic("%s: can't claim heap", __func__); - setheap((void *)heapva, (void *)(heapva + HEAPSZ)); - if ((root = OF_peer(0)) == -1) panic("%s: can't get root phandle", __func__); OF_getprop(root, "compatible", compatible, sizeof(compatible)); Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c ============================================================================== --- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c Wed Nov 3 15:22:09 2010 (r214740) @@ -192,7 +192,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, ASSERT(length <= DMU_MAX_ACCESS); - dbuf_flags = DB_RF_CANFAIL | DB_RF_NEVERWAIT; + dbuf_flags = DB_RF_CANFAIL | DB_RF_NEVERWAIT | DB_RF_HAVESTRUCT; if (flags & DMU_READ_NO_PREFETCH || length > zfetch_array_rd_sz) dbuf_flags |= DB_RF_NOPREFETCH; @@ -209,6 +209,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, os_dsl_dataset->ds_object, (longlong_t)dn->dn_object, dn->dn_datablksz, (longlong_t)offset, (longlong_t)length); + rw_exit(&dn->dn_struct_rwlock); return (EIO); } nblks = 1; @@ -231,9 +232,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, } /* initiate async i/o */ if (read) { - rw_exit(&dn->dn_struct_rwlock); (void) dbuf_read(db, zio, dbuf_flags); - rw_enter(&dn->dn_struct_rwlock, RW_READER); } dbp[i] = &db->db; } @@ -540,7 +539,7 @@ dmu_read(objset_t *os, uint64_t object, { dnode_t *dn; dmu_buf_t **dbp; - int numbufs, i, err; + int numbufs, err; err = dnode_hold(os->os, object, FTAG, &dn); if (err) @@ -551,7 +550,7 @@ dmu_read(objset_t *os, uint64_t object, * block. If we ever do the tail block optimization, we will need to * handle that here as well. */ - if (dn->dn_datablkshift == 0) { + if (dn->dn_maxblkid == 0) { int newsz = offset > dn->dn_datablksz ? 0 : MIN(size, dn->dn_datablksz - offset); bzero((char *)buf + newsz, size - newsz); @@ -560,6 +559,7 @@ dmu_read(objset_t *os, uint64_t object, while (size > 0) { uint64_t mylen = MIN(size, DMU_MAX_ACCESS / 2); + int i; /* * NB: we could do this block-at-a-time, but it's nice Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Wed Nov 3 15:22:09 2010 (r214740) @@ -1031,6 +1031,10 @@ zfs_get_done(dmu_buf_t *db, void *vzgd) VFS_UNLOCK_GIANT(vfslocked); } +#ifdef DEBUG +static int zil_fault_io = 0; +#endif + /* * Get data to generate a TX_WRITE intent log record. */ @@ -1112,7 +1116,21 @@ zfs_get_data(void *arg, lr_write_t *lr, zgd->zgd_rl = rl; zgd->zgd_zilog = zfsvfs->z_log; zgd->zgd_bp = &lr->lr_blkptr; - VERIFY(0 == dmu_buf_hold(os, lr->lr_foid, boff, zgd, &db)); +#ifdef DEBUG + if (zil_fault_io) { + error = EIO; + zil_fault_io = 0; + } else { + error = dmu_buf_hold(os, lr->lr_foid, boff, zgd, &db); + } +#else + error = dmu_buf_hold(os, lr->lr_foid, boff, zgd, &db); +#endif + if (error != 0) { + kmem_free(zgd, sizeof (zgd_t)); + goto out; + } + ASSERT(boff == db->db_offset); lr->lr_blkoff = off - boff; error = dmu_sync(zio, db, &lr->lr_blkptr, Modified: user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c ============================================================================== --- user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c Wed Nov 3 15:22:09 2010 (r214740) @@ -933,6 +933,10 @@ zil_lwb_commit(zilog_t *zilog, itx_t *it } error = zilog->zl_get_data( itx->itx_private, lr, dbuf, lwb->lwb_zio); + if (error == EIO) { + txg_wait_synced(zilog->zl_dmu_pool, txg); + return (lwb); + } if (error) { ASSERT(error == ENOENT || error == EEXIST || error == EALREADY); Modified: user/nwhitehorn/ps3/conf/files ============================================================================== --- user/nwhitehorn/ps3/conf/files Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/files Wed Nov 3 15:22:09 2010 (r214740) @@ -67,12 +67,12 @@ fdt_static_dtb.h optional fdt fdt_dtb_s compile-with "sh $S/tools/fdt/make_dtbh.sh ${FDT_DTS_FILE} ." \ no-obj no-implicit-rule before-depend \ clean "fdt_static_dtb.h" -p16v-alsa%diked.h optional snd_emu10kx pci \ +p16v-alsa%diked.h optional snd_emu10kx pci \ dependency "$S/tools/sound/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/p16v-alsa.h" \ compile-with "CC='${CC}' AWK=${AWK} sh $S/tools/sound/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/p16v-alsa.h p16v-alsa%diked.h" \ no-obj no-implicit-rule before-depend \ clean "p16v-alsa%diked.h" -p17v-alsa%diked.h optional snd_emu10kx pci \ +p17v-alsa%diked.h optional snd_emu10kx pci \ dependency "$S/tools/sound/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/p17v-alsa.h" \ compile-with "CC='${CC}' AWK=${AWK} sh $S/tools/sound/emu10k1-mkalsa.sh $S/gnu/dev/sound/pci/p17v-alsa.h p17v-alsa%diked.h" \ no-obj no-implicit-rule before-depend \ @@ -83,12 +83,12 @@ feeder_eq_gen.h optional sound \ no-obj no-implicit-rule before-depend \ clean "feeder_eq_gen.h" feeder_rate_gen.h optional sound \ - dependency "$S/tools/sound/feeder_rate_mkfilter.awk" \ + dependency "$S/tools/sound/feeder_rate_mkfilter.awk" \ compile-with "${AWK} -f $S/tools/sound/feeder_rate_mkfilter.awk -- ${FEEDER_RATE_PRESETS} > feeder_rate_gen.h" \ no-obj no-implicit-rule before-depend \ clean "feeder_rate_gen.h" snd_fxdiv_gen.h optional sound \ - dependency "$S/tools/sound/snd_fxdiv_gen.awk" \ + dependency "$S/tools/sound/snd_fxdiv_gen.awk" \ compile-with "${AWK} -f $S/tools/sound/snd_fxdiv_gen.awk -- > snd_fxdiv_gen.h" \ no-obj no-implicit-rule before-depend \ clean "snd_fxdiv_gen.h" Modified: user/nwhitehorn/ps3/conf/files.amd64 ============================================================================== --- user/nwhitehorn/ps3/conf/files.amd64 Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/files.amd64 Wed Nov 3 15:22:09 2010 (r214740) @@ -104,7 +104,6 @@ amd64/amd64/cpu_switch.S standard amd64/amd64/db_disasm.c optional ddb amd64/amd64/db_interface.c optional ddb amd64/amd64/db_trace.c optional ddb -amd64/amd64/dump_machdep.c standard amd64/amd64/elf_machdep.c standard amd64/amd64/exception.S standard amd64/amd64/fpu.c standard @@ -122,9 +121,6 @@ amd64/amd64/minidump_machdep.c standard amd64/amd64/mp_machdep.c optional smp amd64/amd64/mp_watchdog.c optional mp_watchdog smp amd64/amd64/mpboot.S optional smp -amd64/amd64/mptable.c optional mptable -amd64/amd64/mptable_pci.c optional mptable pci -amd64/amd64/nexus.c standard amd64/amd64/pmap.c standard amd64/amd64/prof_machdep.c optional profiling-routine amd64/amd64/sigtramp.S standard @@ -321,7 +317,11 @@ x86/isa/isa_dma.c standard x86/isa/nmi.c standard x86/isa/orm.c optional isa x86/pci/qpi.c standard +x86/x86/dump_machdep.c standard x86/x86/io_apic.c standard x86/x86/local_apic.c standard x86/x86/mca.c standard +x86/x86/mptable.c optional mptable +x86/x86/mptable_pci.c optional mptable pci x86/x86/msi.c optional pci +x86/x86/nexus.c standard Modified: user/nwhitehorn/ps3/conf/files.i386 ============================================================================== --- user/nwhitehorn/ps3/conf/files.i386 Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/files.i386 Wed Nov 3 15:22:09 2010 (r214740) @@ -263,7 +263,6 @@ i386/i386/busdma_machdep.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb -i386/i386/dump_machdep.c standard i386/i386/elan-mmcr.c optional cpu_elan | cpu_soekris i386/i386/elf_machdep.c standard i386/i386/exception.s optional native @@ -290,10 +289,7 @@ i386/i386/mp_machdep.c optional native i386/xen/mp_machdep.c optional xen smp i386/i386/mp_watchdog.c optional mp_watchdog smp i386/i386/mpboot.s optional smp native -i386/i386/mptable.c optional apic native i386/xen/mptable.c optional apic xen -i386/i386/mptable_pci.c optional apic pci -i386/i386/nexus.c standard i386/i386/perfmon.c optional perfmon i386/i386/pmap.c optional native i386/xen/pmap.c optional xen @@ -395,7 +391,11 @@ x86/isa/isa_dma.c optional isa x86/isa/nmi.c standard x86/isa/orm.c optional isa x86/pci/qpi.c standard +x86/x86/dump_machdep.c standard x86/x86/io_apic.c optional apic x86/x86/local_apic.c optional apic x86/x86/mca.c standard +x86/x86/mptable.c optional apic native +x86/x86/mptable_pci.c optional apic pci x86/x86/msi.c optional apic pci +x86/x86/nexus.c standard Modified: user/nwhitehorn/ps3/conf/files.pc98 ============================================================================== --- user/nwhitehorn/ps3/conf/files.pc98 Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/files.pc98 Wed Nov 3 15:22:09 2010 (r214740) @@ -138,7 +138,6 @@ i386/i386/busdma_machdep.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb -i386/i386/dump_machdep.c standard i386/i386/elf_machdep.c standard i386/i386/exception.s standard i386/i386/gdb_machdep.c optional gdb @@ -157,9 +156,6 @@ i386/i386/mp_clock.c optional smp i386/i386/mp_machdep.c optional smp i386/i386/mp_watchdog.c optional mp_watchdog smp i386/i386/mpboot.s optional smp -i386/i386/mptable.c optional apic -i386/i386/mptable_pci.c optional apic pci -i386/i386/nexus.c standard i386/i386/perfmon.c optional perfmon i386/i386/pmap.c standard i386/i386/ptrace_machdep.c standard @@ -255,7 +251,11 @@ pc98/pc98/pc98_machdep.c standard x86/isa/atpic.c optional atpic x86/isa/clock.c standard x86/isa/isa.c optional isa +x86/x86/dump_machdep.c standard x86/x86/io_apic.c optional apic x86/x86/local_apic.c optional apic x86/x86/mca.c standard +x86/x86/mptable.c optional apic +x86/x86/mptable_pci.c optional apic pci x86/x86/msi.c optional apic pci +x86/x86/nexus.c standard Modified: user/nwhitehorn/ps3/conf/files.powerpc ============================================================================== --- user/nwhitehorn/ps3/conf/files.powerpc Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/files.powerpc Wed Nov 3 15:22:09 2010 (r214740) @@ -22,6 +22,7 @@ dev/adb/adb_kbd.c optional adb dev/adb/adb_mouse.c optional adb dev/adb/adb_hb_if.m optional adb dev/adb/adb_if.m optional adb +dev/agp/agp_apple.c optional agp powermac dev/cfi/cfi_bus_fdt.c optional cfi fdt dev/fb/fb.c optional sc dev/fdt/fdt_powerpc.c optional fdt Modified: user/nwhitehorn/ps3/conf/kern.post.mk ============================================================================== --- user/nwhitehorn/ps3/conf/kern.post.mk Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/kern.post.mk Wed Nov 3 15:22:09 2010 (r214740) @@ -169,6 +169,9 @@ _ILINKS= machine .if ${MACHINE} != ${MACHINE_CPUARCH} _ILINKS+= ${MACHINE_CPUARCH} .endif +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +_ILINKS+= x86 +.endif # Ensure that the link exists without depending on it when it exists. .for _link in ${_ILINKS} @@ -181,8 +184,8 @@ ${_ILINKS}: @case ${.TARGET} in \ machine) \ path=${S}/${MACHINE}/include ;; \ - ${MACHINE_CPUARCH}) \ - path=${S}/${MACHINE_CPUARCH}/include ;; \ + *) \ + path=${S}/${.TARGET}/include ;; \ esac ; \ ${ECHO} ${.TARGET} "->" $$path ; \ ln -s $$path ${.TARGET} Modified: user/nwhitehorn/ps3/conf/kmod.mk ============================================================================== --- user/nwhitehorn/ps3/conf/kmod.mk Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/kmod.mk Wed Nov 3 15:22:09 2010 (r214740) @@ -238,6 +238,9 @@ _ILINKS=@ machine .if ${MACHINE} != ${MACHINE_CPUARCH} _ILINKS+=${MACHINE_CPUARCH} .endif +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +_ILINKS+=x86 +.endif all: objwarn ${PROG} @@ -263,12 +266,12 @@ SYSDIR= ${_dir} ${_ILINKS}: @case ${.TARGET} in \ - ${MACHINE_CPUARCH}) \ - path=${SYSDIR}/${MACHINE_CPUARCH}/include ;; \ machine) \ path=${SYSDIR}/${MACHINE}/include ;; \ @) \ path=${SYSDIR} ;; \ + *) \ + path=${SYSDIR}/${.TARGET}/include ;; \ esac ; \ path=`(cd $$path && /bin/pwd)` ; \ ${ECHO} ${.TARGET} "->" $$path ; \ Modified: user/nwhitehorn/ps3/conf/options.amd64 ============================================================================== --- user/nwhitehorn/ps3/conf/options.amd64 Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/options.amd64 Wed Nov 3 15:22:09 2010 (r214740) @@ -8,6 +8,7 @@ COUNT_IPIS opt_smp.h MAXMEM PERFMON PMAP_SHPGPERPROC opt_pmap.h +MPTABLE_FORCE_HTT MP_WATCHDOG # Options for emulators. These should only be used at config time, so Modified: user/nwhitehorn/ps3/conf/options.powerpc ============================================================================== --- user/nwhitehorn/ps3/conf/options.powerpc Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/conf/options.powerpc Wed Nov 3 15:22:09 2010 (r214740) @@ -25,3 +25,7 @@ PSIM SC_OFWFB opt_ofwfb.h OFWCONS_POLL_HZ opt_ofw.h + +# AGP debugging support +AGP_DEBUG opt_agp.h + Modified: user/nwhitehorn/ps3/dev/acpica/acpi.c ============================================================================== --- user/nwhitehorn/ps3/dev/acpica/acpi.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/dev/acpica/acpi.c Wed Nov 3 15:22:09 2010 (r214740) @@ -86,6 +86,11 @@ static struct cdevsw acpi_cdevsw = { .d_name = "acpi", }; +struct acpi_interface { + ACPI_STRING *data; + int num; +}; + /* Global mutex for locking access to the ACPI subsystem. */ struct mtx acpi_mutex; @@ -163,6 +168,7 @@ static void acpi_enable_pcie(void); #endif static void acpi_hint_device_unit(device_t acdev, device_t child, const char *name, int *unitp); +static void acpi_reset_interfaces(device_t dev); static device_method_t acpi_methods[] = { /* Device interface */ @@ -232,6 +238,16 @@ SYSCTL_STRING(_debug_acpi, OID_AUTO, acp acpi_ca_version, 0, "Version of Intel ACPI-CA"); /* + * Allow overriding _OSI methods. + */ +static char acpi_install_interface[256]; +TUNABLE_STR("hw.acpi.install_interface", acpi_install_interface, + sizeof(acpi_install_interface)); +static char acpi_remove_interface[256]; +TUNABLE_STR("hw.acpi.remove_interface", acpi_remove_interface, + sizeof(acpi_remove_interface)); + +/* * Allow override of whether methods execute in parallel or not. * Enable this for serial behavior, which fixes "AE_ALREADY_EXISTS" * errors for AML that really can't handle parallel method execution. @@ -467,6 +483,9 @@ acpi_attach(device_t dev) goto out; } + /* Override OS interfaces if the user requested. */ + acpi_reset_interfaces(dev); + /* Load ACPI name space. */ status = AcpiLoadTables(); if (ACPI_FAILURE(status)) { @@ -3473,6 +3492,93 @@ acpi_debug_objects_sysctl(SYSCTL_HANDLER } static int +acpi_parse_interfaces(char *str, struct acpi_interface *iface) +{ + char *p; + size_t len; + int i, j; + + p = str; + while (isspace(*p) || *p == ',') + p++; + len = strlen(p); + if (len == 0) + return (0); + p = strdup(p, M_TEMP); + for (i = 0; i < len; i++) + if (p[i] == ',') + p[i] = '\0'; + i = j = 0; + while (i < len) + if (isspace(p[i]) || p[i] == '\0') + i++; + else { + i += strlen(p + i) + 1; + j++; + } + if (j == 0) { + free(p, M_TEMP); + return (0); + } + iface->data = malloc(sizeof(*iface->data) * j, M_TEMP, M_WAITOK); + iface->num = j; + i = j = 0; + while (i < len) + if (isspace(p[i]) || p[i] == '\0') + i++; + else { + iface->data[j] = p + i; + i += strlen(p + i) + 1; + j++; + } + + return (j); +} + +static void +acpi_free_interfaces(struct acpi_interface *iface) +{ + + free(iface->data[0], M_TEMP); + free(iface->data, M_TEMP); +} + +static void +acpi_reset_interfaces(device_t dev) +{ + struct acpi_interface list; + ACPI_STATUS status; + int i; + + if (acpi_parse_interfaces(acpi_install_interface, &list) > 0) { + for (i = 0; i < list.num; i++) { + status = AcpiInstallInterface(list.data[i]); + if (ACPI_FAILURE(status)) + device_printf(dev, + "failed to install _OSI(\"%s\"): %s\n", + list.data[i], AcpiFormatException(status)); + else if (bootverbose) + device_printf(dev, "installed _OSI(\"%s\")\n", + list.data[i]); + } + acpi_free_interfaces(&list); + } + if (acpi_parse_interfaces(acpi_remove_interface, &list) > 0) { + for (i = 0; i < list.num; i++) { + status = AcpiRemoveInterface(list.data[i]); + if (ACPI_FAILURE(status)) + device_printf(dev, + "failed to remove _OSI(\"%s\"): %s\n", + list.data[i], AcpiFormatException(status)); + else if (bootverbose) + device_printf(dev, "removed _OSI(\"%s\")\n", + list.data[i]); + } + acpi_free_interfaces(&list); + } +} + +static int acpi_pm_func(u_long cmd, void *arg, ...) { int state, acpi_state; Modified: user/nwhitehorn/ps3/dev/agp/agp.c ============================================================================== --- user/nwhitehorn/ps3/dev/agp/agp.c Wed Nov 3 15:15:48 2010 (r214739) +++ user/nwhitehorn/ps3/dev/agp/agp.c Wed Nov 3 15:22:09 2010 (r214740) @@ -219,13 +219,16 @@ agp_generic_attach(device_t dev) * Find and map the aperture, RF_SHAREABLE for DRM but not RF_ACTIVE * because the kernel doesn't need to map it. */ - if (sc->as_aperture_rid == 0) - sc->as_aperture_rid = AGP_APBASE; - sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, - &sc->as_aperture_rid, RF_SHAREABLE); - if (!sc->as_aperture) - return ENOMEM; + if (sc->as_aperture_rid != -1) { + if (sc->as_aperture_rid == 0) + sc->as_aperture_rid = AGP_APBASE; + + sc->as_aperture = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &sc->as_aperture_rid, RF_SHAREABLE); + if (!sc->as_aperture) + return ENOMEM; + } /* * Work out an upper bound for agp memory allocation. This @@ -272,8 +275,9 @@ agp_free_res(device_t dev) { struct agp_softc *sc = device_get_softc(dev); - bus_release_resource(dev, SYS_RES_MEMORY, sc->as_aperture_rid, - sc->as_aperture); + if (sc->as_aperture != NULL) + bus_release_resource(dev, SYS_RES_MEMORY, sc->as_aperture_rid, + sc->as_aperture); mtx_destroy(&sc->as_lock); agp_flush_cache(); } @@ -729,7 +733,10 @@ agp_info_user(device_t dev, agp_info *in info->bridge_id = pci_get_devid(dev); info->agp_mode = pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4); - info->aper_base = rman_get_start(sc->as_aperture); + if (sc->as_aperture) + info->aper_base = rman_get_start(sc->as_aperture); + else + info->aper_base = 0; info->aper_size = AGP_GET_APERTURE(dev) >> 20; info->pg_total = info->pg_system = sc->as_maxmem >> AGP_PAGE_SHIFT; info->pg_used = sc->as_allocated >> AGP_PAGE_SHIFT; @@ -876,6 +883,8 @@ agp_mmap(struct cdev *kdev, vm_ooffset_t if (offset > AGP_GET_APERTURE(dev)) return -1; + if (sc->as_aperture == NULL) + return -1; *paddr = rman_get_start(sc->as_aperture) + offset; return 0; } @@ -917,8 +926,11 @@ agp_get_info(device_t dev, struct agp_in info->ai_mode = pci_read_config(dev, agp_find_caps(dev) + AGP_STATUS, 4); - info->ai_aperture_base = rman_get_start(sc->as_aperture); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Nov 3 20:50:41 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D836D1065675; Wed, 3 Nov 2010 20:50:41 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C82C08FC1A; Wed, 3 Nov 2010 20:50:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA3Kof3g032856; Wed, 3 Nov 2010 20:50:41 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3Kofm2032854; Wed, 3 Nov 2010 20:50:41 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201011032050.oA3Kofm2032854@svn.freebsd.org> From: Doug Barton Date: Wed, 3 Nov 2010 20:50:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214753 - user/dougb/portmaster/files X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 20:50:41 -0000 Author: dougb Date: Wed Nov 3 20:50:41 2010 New Revision: 214753 URL: http://svn.freebsd.org/changeset/base/214753 Log: Fix the entries for --clean-packages[-all] Submitted by: David DEMELIER Modified: user/dougb/portmaster/files/zsh-completions Modified: user/dougb/portmaster/files/zsh-completions ============================================================================== --- user/dougb/portmaster/files/zsh-completions Wed Nov 3 18:49:50 2010 (r214752) +++ user/dougb/portmaster/files/zsh-completions Wed Nov 3 20:50:41 2010 (r214753) @@ -51,8 +51,8 @@ _arguments -A "-*" : \ "-F[fetch distfiles only]" \ "--clean-distfiles[offer to delete stale distfiles]" \ "--clean-distfiles-all[delete stale distfiles without prompting]" \ - "----clean-packages[offer to delete stale packages]" \ - "----clean-packages-all[delete stale packages without prompting]" \ + "--clean-packages[offer to delete stale packages]" \ + "--clean-packages-all[delete stale packages without prompting]" \ "--check-depends[cross-check and update dependency information for all ports]" \ "--check-port-dbdir[check for stale entries in /var/db/ports]" \ "--list-origins[list directories from /usr/ports for root and leaf ports]" \ From owner-svn-src-user@FreeBSD.ORG Wed Nov 3 22:21:21 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 773B51065697; Wed, 3 Nov 2010 22:21:21 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4CEFD8FC0C; Wed, 3 Nov 2010 22:21:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA3MLLN0035690; Wed, 3 Nov 2010 22:21:21 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA3MLLUx035688; Wed, 3 Nov 2010 22:21:21 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201011032221.oA3MLLUx035688@svn.freebsd.org> From: Doug Barton Date: Wed, 3 Nov 2010 22:21:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214764 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 22:21:21 -0000 Author: dougb Date: Wed Nov 3 22:21:21 2010 New Revision: 214764 URL: http://svn.freebsd.org/changeset/base/214764 Log: Bug Fix ======= Since $build_l is no longer being incremented prior to the user's +IGNOREME decision it's no longer necessary to decrement it if the user chooses not to update that port. While I was reading the trace to find this bug I noticed that we are running update_build_l (which in turn updates PM_NEEDS_UPDATE) prior to running check_state (FORBIDDEN|DEPRECATED|BROKEN|IGNORE), so move that check up; and move the "currently installed" and "port directory" messages up as well to give context to any messages from check_state. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Wed Nov 3 22:17:42 2010 (r214763) +++ user/dougb/portmaster/portmaster Wed Nov 3 22:21:21 2010 (r214764) @@ -2947,10 +2947,8 @@ if [ -e "$pdb/$upg_port/+IGNOREME" ]; th *) CUR_DEPS="${CUR_DEPS}${upg_port}:${portdir}:" if [ ${dep_of_deps:-0} -gt 0 ]; then dep_of_deps=$(( $dep_of_deps - 1 )) - if [ -n "$PM_FIRST_PASS" ]; then + [ -n "$PM_FIRST_PASS" ] && num_of_deps=$(( $num_of_deps - 1 )) - build_l="${build_l%\\t*}" - fi fi safe_exit ;; esac @@ -2986,7 +2984,21 @@ else PM_DEPTH="${PM_DEPTH}>> ${upg_port:-$portdir} " fi +echo '' +[ "$$" -eq "$PM_PARENT_PID" -a -n "$upg_port" ] && + echo "===>>> Currently installed version: $upg_port" + +echo "===>>> Port directory: $pd/$portdir" ; echo '' + if [ -n "$PM_FIRST_PASS" -a -z "$FETCH_ONLY" ]; then + if [ -z "$PM_INDEX_ONLY" ]; then + if ! check_state; then + echo " ===>>> If you are sure you can build it, remove the" + echo " $state line in the Makefile and try again." + safe_exit 1 + fi + fi + if [ -n "$upg_port" ]; then update_build_l $upg_port [ -n "$UPDATE_REQ_BYS" -a -n "$RESTART" -a "$$" -eq "$PM_PARENT_PID" ] && @@ -2996,20 +3008,8 @@ if [ -n "$PM_FIRST_PASS" -a -z "$FETCH_O fi fi -echo '' -[ "$$" -eq "$PM_PARENT_PID" -a -n "$upg_port" ] && - echo "===>>> Currently installed version: $upg_port" - -echo "===>>> Port directory: $pd/$portdir" ; echo '' - # Do these things first time through if [ -z "$PM_INDEX_ONLY" -a -z "$PM_BUILDING" -a -z "$SHOW_WORK" -a -z "$NO_ACTION" ]; then - if ! check_state; then - echo " ===>>> If you are sure you can build it, remove the" - echo " $state line in the Makefile and try again." - safe_exit 1 - fi - # Do not start this in the background until we are sure we are going to build [ "$$" -eq "$PM_PARENT_PID" -a -n "$DI_FILES" ] && (read_distinfos)& From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 02:03:27 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C6691065673; Thu, 4 Nov 2010 02:03:27 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2B5FD8FC12; Thu, 4 Nov 2010 02:03:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA423RMc040585; Thu, 4 Nov 2010 02:03:27 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA423RI5040582; Thu, 4 Nov 2010 02:03:27 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040203.oA423RI5040582@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 02:03:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214767 - in user/davidxu/libthr/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 02:03:27 -0000 Author: davidxu Date: Thu Nov 4 02:03:26 2010 New Revision: 214767 URL: http://svn.freebsd.org/changeset/base/214767 Log: To avoid thundering hurd problem on pthread_cond_broadcast, implement wait queue migration. Modified: user/davidxu/libthr/sys/kern/kern_umtx.c user/davidxu/libthr/sys/sys/umtx.h Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Wed Nov 3 23:29:52 2010 (r214766) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 02:03:26 2010 (r214767) @@ -91,6 +91,7 @@ struct umtx_key { uintptr_t b; } both; } info; + struct umtxq_chain * volatile chain; }; /* Priority inheritance mutex info. */ @@ -150,6 +151,8 @@ struct umtx_q { /* The queue we on */ struct umtxq_queue *uq_cur_queue; + + int uq_repair_mutex; }; TAILQ_HEAD(umtxq_head, umtx_q); @@ -160,6 +163,10 @@ struct umtxq_queue { struct umtx_key key; LIST_ENTRY(umtxq_queue) link; int length; + + int binding; + struct umutex *bind_mutex; + struct umtx_key bind_mkey; }; LIST_HEAD(umtxq_list, umtxq_queue); @@ -177,7 +184,7 @@ struct umtxq_chain { LIST_HEAD(, umtxq_queue) uc_spare_queue; /* Busy flag */ - char uc_busy; + volatile char uc_busy; /* Chain lock waiters */ int uc_waiters; @@ -220,10 +227,13 @@ static uma_zone_t umtx_pi_zone; static struct umtxq_chain umtxq_chains[2][UMTX_CHAINS]; static MALLOC_DEFINE(M_UMTX, "umtx", "UMTX queue memory"); static int umtx_pi_allocated; +static int umtx_cv_migrated; SYSCTL_NODE(_debug, OID_AUTO, umtx, CTLFLAG_RW, 0, "umtx debug"); SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_pi_allocated, CTLFLAG_RD, &umtx_pi_allocated, 0, "Allocated umtx_pi"); +SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_migrated, CTLFLAG_RD, + &umtx_cv_migrated, 0, "Thread migrated"); static void umtxq_sysinit(void *); static void umtxq_hash(struct umtx_key *key); @@ -232,7 +242,9 @@ static void umtxq_lock(struct umtx_key * static void umtxq_unlock(struct umtx_key *key); static void umtxq_busy(struct umtx_key *key); static void umtxq_unbusy(struct umtx_key *key); -static void umtxq_insert_queue(struct umtx_q *uq, int q); +static void umtxq_insert_queue(struct umtx_q *, int); +static int umtxq_insert_queue2(struct umtx_q *, int, struct umutex *, + const struct umtx_key *); static void umtxq_remove_queue(struct umtx_q *uq, int q); static int umtxq_sleep(struct umtx_q *uq, const char *wmesg, int timo); static int umtxq_count(struct umtx_key *key); @@ -315,14 +327,30 @@ umtx_key_match(const struct umtx_key *k1 k1->info.both.b == k2->info.both.b); } +static inline void +umtx_key_copy(struct umtx_key *k1, const struct umtx_key *k2) +{ + k1->hash = k2->hash; + k1->type = k2->type; + k1->shared = k2->shared; + k1->info.both = k2->info.both; + k1->chain = k2->chain; +} + static inline struct umtxq_chain * -umtxq_getchain(struct umtx_key *key) +umtxq_calcchain(struct umtx_key *key) { if (key->type <= TYPE_SEM) return (&umtxq_chains[1][key->hash]); return (&umtxq_chains[0][key->hash]); } +static inline struct umtxq_chain * +umtxq_getchain(struct umtx_key *key) +{ + return (key->chain); +} + /* * Lock a chain. */ @@ -331,8 +359,14 @@ umtxq_lock(struct umtx_key *key) { struct umtxq_chain *uc; - uc = umtxq_getchain(key); - mtx_lock(&uc->uc_lock); + for (;;) { + uc = key->chain; + mtx_lock(&uc->uc_lock); + if (key->chain != uc) + mtx_unlock(&uc->uc_lock); + else + break; + } } /* @@ -341,10 +375,7 @@ umtxq_lock(struct umtx_key *key) static inline void umtxq_unlock(struct umtx_key *key) { - struct umtxq_chain *uc; - - uc = umtxq_getchain(key); - mtx_unlock(&uc->uc_lock); + mtx_unlock(&key->chain->uc_lock); } /* @@ -364,8 +395,10 @@ umtxq_busy(struct umtx_key *key) int count = BUSY_SPINS; if (count > 0) { umtxq_unlock(key); - while (uc->uc_busy && --count > 0) + while (uc->uc_busy && --count > 0) { cpu_spinwait(); + uc = key->chain; + } umtxq_lock(key); } } @@ -374,6 +407,9 @@ umtxq_busy(struct umtx_key *key) uc->uc_waiters++; msleep(uc, &uc->uc_lock, 0, "umtxqb", 0); uc->uc_waiters--; + mtx_unlock(&uc->uc_lock); + umtxq_lock(key); + uc = umtxq_getchain(key); } } uc->uc_busy = 1; @@ -414,19 +450,46 @@ umtxq_queue_lookup(struct umtx_key *key, static inline void umtxq_insert_queue(struct umtx_q *uq, int q) { + int error; + + error = umtxq_insert_queue2(uq, q, NULL, NULL); + MPASS(error == 0); +} + +static inline int +umtxq_insert_queue2(struct umtx_q *uq, int q, struct umutex *m, + const struct umtx_key *mkey) +{ struct umtxq_queue *uh; struct umtxq_chain *uc; uc = umtxq_getchain(&uq->uq_key); UMTXQ_LOCKED_ASSERT(uc); - KASSERT((uq->uq_flags & UQF_UMTXQ) == 0, ("umtx_q is already on queue")); + KASSERT((uq->uq_flags & UQF_UMTXQ) == 0, + ("umtx_q is already on queue")); uh = umtxq_queue_lookup(&uq->uq_key, q); if (uh != NULL) { + if (uh->binding) { + if (mkey == NULL || + !umtx_key_match(&uh->bind_mkey, mkey)) + return (EEXIST); + } else { + if (mkey != NULL) + return (EEXIST); + } LIST_INSERT_HEAD(&uc->uc_spare_queue, uq->uq_spare_queue, link); } else { uh = uq->uq_spare_queue; uh->key = uq->uq_key; LIST_INSERT_HEAD(&uc->uc_queue[q], uh, link); + uh->bind_mutex = m; + uh->length = 0; + if (mkey != NULL) { + uh->binding = 1; + uh->bind_mkey = *mkey; + } else { + uh->binding = 0; + } } uq->uq_spare_queue = NULL; @@ -434,7 +497,7 @@ umtxq_insert_queue(struct umtx_q *uq, in uh->length++; uq->uq_flags |= UQF_UMTXQ; uq->uq_cur_queue = uh; - return; + return (0); } static inline void @@ -458,6 +521,8 @@ umtxq_remove_queue(struct umtx_q *uq, in uh = LIST_FIRST(&uc->uc_spare_queue); KASSERT(uh != NULL, ("uc_spare_queue is empty")); LIST_REMOVE(uh, link); + uh->bind_mutex = NULL; + uh->binding = 0; } uq->uq_spare_queue = uh; uq->uq_cur_queue = NULL; @@ -558,9 +623,10 @@ umtxq_sleep(struct umtx_q *uq, const cha UMTXQ_LOCKED_ASSERT(uc); if (!(uq->uq_flags & UQF_UMTXQ)) return (0); - error = msleep(uq, &uc->uc_lock, PCATCH, wmesg, timo); + error = msleep(uq, &uc->uc_lock, PCATCH|PDROP, wmesg, timo); if (error == EWOULDBLOCK) error = ETIMEDOUT; + umtxq_lock(&uq->uq_key); return (error); } @@ -578,6 +644,7 @@ umtx_key_get(void *addr, int type, int s boolean_t wired; key->type = type; + key->chain = NULL; if (share == THREAD_SHARE) { key->shared = 0; key->info.private.vs = td->td_proc->p_vmspace; @@ -607,6 +674,7 @@ umtx_key_get(void *addr, int type, int s } umtxq_hash(key); + key->chain = umtxq_calcchain(key); return (0); } @@ -1209,7 +1277,11 @@ _do_lock_normal(struct thread *td, struc umtxq_unbusy(&uq->uq_key); if (old == owner) error = umtxq_sleep(uq, "umtxn", timo); - umtxq_remove(uq); + if ((uq->uq_flags & UQF_UMTXQ) != 0) { + umtxq_busy(&uq->uq_key); + umtxq_remove(uq); + umtxq_unbusy(&uq->uq_key); + } umtxq_unlock(&uq->uq_key); umtx_key_release(&uq->uq_key); } @@ -1618,12 +1690,14 @@ umtxq_sleep_pi(struct umtx_q *uq, struct mtx_unlock_spin(&umtx_lock); umtxq_unbusy(&uq->uq_key); - if (uq->uq_flags & UQF_UMTXQ) { + if ((uq->uq_flags & UQF_UMTXQ) != 0) { error = msleep(uq, &uc->uc_lock, PCATCH, wmesg, timo); if (error == EWOULDBLOCK) error = ETIMEDOUT; - if (uq->uq_flags & UQF_UMTXQ) { + if ((uq->uq_flags & UQF_UMTXQ) != 0) { + umtxq_busy(&uq->uq_key); umtxq_remove(uq); + umtxq_unbusy(&uq->uq_key); } } mtx_lock_spin(&umtx_lock); @@ -2342,30 +2416,104 @@ do_unlock_umutex(struct thread *td, stru } static int +set_contested_bit(struct umtx_key *mkey, struct umutex *m, + struct umtxq_queue *uhm, int repair) +{ + int do_wake; + int qlen = uhm->length; + uint32_t owner; + + do_wake = 0; + /* + * Set contested bit for mutex when necessary, so that userland + * mutex unlocker will wake up a waiter thread. + */ + owner = fuword32(__DEVOLATILE(uint32_t *, &m->m_owner)); + for (;;) { + if (owner == UMUTEX_UNOWNED) { + if (!repair && qlen == 1) { + do_wake = 1; + break; + } + if ((owner = casuword32(&m->m_owner, UMUTEX_UNOWNED, + UMUTEX_CONTESTED)) == UMUTEX_UNOWNED) { + do_wake = 1; + break; + } + } + if (owner == UMUTEX_CONTESTED) { + do_wake = 1; + break; + } + if ((owner & UMUTEX_CONTESTED) == 0) { + uint32_t old; + old = casuword32(&m->m_owner, owner, + owner|UMUTEX_CONTESTED); + if (old == owner) + break; + owner = old; + } else { + break; + } + } + return (do_wake); +} + +static int do_cv_wait(struct thread *td, struct ucond *cv, struct umutex *m, struct timespec *timeout, u_long wflags) { struct umtx_q *uq; + struct umtx_key mkey, *mkeyp; + struct umutex *bind_mutex; struct timeval tv; struct timespec cts, ets, tts; - uint32_t flags; + struct umtxq_chain *old_chain; + uint32_t flags, mflags; int error; uq = td->td_umtxq; flags = fuword32(&cv->c_flags); + mflags = fuword32(&m->m_flags); error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &uq->uq_key); if (error != 0) return (error); + if ((wflags & CVWAIT_BIND_MUTEX) != 0) { + if ((mflags & UMUTEX_PRIO_INHERIT) != 0) + return (EINVAL); + error = umtx_key_get(m, TYPE_NORMAL_UMUTEX, + GET_SHARE(mflags), &mkey); + if (error != 0) { + umtx_key_release(&uq->uq_key); + return (error); + } + if (mkey.shared == 0) + bind_mutex = m; + else + bind_mutex = NULL; + mkeyp = &mkey; + } else { + bind_mutex = NULL; + mkeyp = NULL; + } + + old_chain = uq->uq_key.chain; umtxq_lock(&uq->uq_key); umtxq_busy(&uq->uq_key); - umtxq_insert(uq); + error = umtxq_insert_queue2(uq, UMTX_SHARED_QUEUE, bind_mutex, mkeyp); + if (error != 0) { + umtxq_unbusy(&uq->uq_key); + umtxq_unlock(&uq->uq_key); + return (error); + } umtxq_unlock(&uq->uq_key); /* - * The magic thing is we should set c_has_waiters to 1 before - * releasing user mutex. + * Set c_has_waiters to 1 before releasing user mutex, also + * don't modify cache line when unnecessary. */ - suword32(__DEVOLATILE(uint32_t *, &cv->c_has_waiters), 1); + if (fuword32(__DEVOLATILE(uint32_t *, &cv->c_has_waiters)) == 0) + suword32(__DEVOLATILE(uint32_t *, &cv->c_has_waiters), 1); umtxq_lock(&uq->uq_key); umtxq_unbusy(&uq->uq_key); @@ -2375,11 +2523,7 @@ do_cv_wait(struct thread *td, struct uco umtxq_lock(&uq->uq_key); if (error == 0) { - if ((wflags & UMTX_CHECK_UNPARKING) && - (td->td_pflags & TDP_WAKEUP)) { - td->td_pflags &= ~TDP_WAKEUP; - error = EINTR; - } else if (timeout == NULL) { + if (timeout == NULL) { error = umtxq_sleep(uq, "ucond", 0); } else { getnanouptime(&ets); @@ -2400,17 +2544,63 @@ do_cv_wait(struct thread *td, struct uco } } } - if ((uq->uq_flags & UQF_UMTXQ) == 0) error = 0; else { - umtxq_remove(uq); + /* + * This must be timeout or interrupted by signal or + * surprious wakeup. + */ + umtxq_busy(&uq->uq_key); + if ((uq->uq_flags & UQF_UMTXQ) != 0) { + int oldlen = uq->uq_cur_queue->length; + umtxq_remove(uq); + if (oldlen == 1 && old_chain == uq->uq_key.chain) { + umtxq_unlock(&uq->uq_key); + suword32( + __DEVOLATILE(uint32_t *, + &cv->c_has_waiters), 0); + umtxq_lock(&uq->uq_key); + } + } + umtxq_unbusy(&uq->uq_key); if (error == ERESTART) error = EINTR; } - umtxq_unlock(&uq->uq_key); + + /* We were moved to mutex queue. */ + if (mkeyp != NULL && + old_chain != uq->uq_key.chain) { + /* + * cv_broadcast can not access the mutex if we are pshared, + * but it still migrate threads to mutex queue, + * we should repair contested bit here. + */ + if ((mflags & USYNC_PROCESS_SHARED) != 0 && uq->uq_repair_mutex) { + uint32_t owner = fuword32( + __DEVOLATILE(void *, &m->m_owner)); + if ((owner & UMUTEX_CONTESTED) == 0) { + struct umtxq_queue *uhm; + umtxq_lock(mkeyp); + umtxq_busy(mkeyp); + uhm = umtxq_queue_lookup(mkeyp, + UMTX_SHARED_QUEUE); + if (uhm != NULL) + set_contested_bit(mkeyp, m, uhm, 1); + umtxq_unbusy(mkeyp); + umtxq_unlock(mkeyp); + } + } + + error = 0; + } umtx_key_release(&uq->uq_key); + if (mkeyp != NULL) + umtx_key_release(mkeyp); + uq->uq_spare_queue->bind_mutex = NULL; + uq->uq_spare_queue->binding = 0; + uq->uq_repair_mutex = 0; return (error); } @@ -2427,6 +2617,7 @@ do_cv_signal(struct thread *td, struct u flags = fuword32(&cv->c_flags); if ((error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &key)) != 0) return (error); + umtxq_lock(&key); umtxq_busy(&key); cnt = umtxq_count(&key); @@ -2446,6 +2637,8 @@ do_cv_signal(struct thread *td, struct u static int do_cv_broadcast(struct thread *td, struct ucond *cv) { + struct umtxq_queue *uh, *uhm, *uh_temp; + struct umtxq_chain *uc, *ucm; struct umtx_key key; int error; uint32_t flags; @@ -2456,17 +2649,142 @@ do_cv_broadcast(struct thread *td, struc umtxq_lock(&key); umtxq_busy(&key); - umtxq_signal(&key, INT_MAX); - umtxq_unlock(&key); + uh = umtxq_queue_lookup(&key, UMTX_SHARED_QUEUE); + if (uh != NULL && uh->binding) { + /* + * To avoid thundering herd problem, if there are waiters, + * try to move them to mutex queue. + */ + struct umutex *bind_mutex = uh->bind_mutex; + struct umtx_key mkey; + struct umtx_q *uq; + int do_wake; + int len, oldlen; + + len = uh->length; + mkey = uh->bind_mkey; + uc = umtxq_getchain(&key); + ucm = umtxq_getchain(&mkey); + LIST_REMOVE(uh, link); - error = suword32(__DEVOLATILE(uint32_t *, &cv->c_has_waiters), 0); + /* + * Before busying mutex sleep-queue, we must unlock cv's + * sleep-queue mutex, because the mutex is unsleepable. + */ + umtxq_unlock(&key); - umtxq_lock(&key); - umtxq_unbusy(&key); - umtxq_unlock(&key); + umtxq_lock(&mkey); + umtxq_busy(&mkey); + umtxq_unlock(&mkey); + umtxq_lock(&key); + umtxq_lock(&mkey); + uhm = umtxq_queue_lookup(&mkey, UMTX_SHARED_QUEUE); - umtx_key_release(&key); - return (error); + /* Change waiter's key (include chain address). */ + TAILQ_FOREACH(uq, &uh->head, uq_link) { + umtx_key_copy(&uq->uq_key, &mkey); + if (uhm != NULL) + uq->uq_cur_queue = uhm; + } + if (uhm == NULL) { + /* + * Mutex has no waiters, just move the queue head to + * new chain. + */ + oldlen = 0; + uh->key = mkey; + uh->bind_mutex = NULL; + uh->binding = 0; + LIST_INSERT_HEAD(&ucm->uc_queue[UMTX_SHARED_QUEUE], + uh, link); + uhm = uh; + } else { + /* + * Otherwise, move cv waiters. + */ + oldlen = uhm->length; + TAILQ_CONCAT(&uhm->head, &uh->head, uq_link); + uhm->length += uh->length; + uh->length = 0; + uh->bind_mutex = NULL; + uh->binding = 0; + LIST_INSERT_HEAD(&ucm->uc_spare_queue, uh, link); + } + + /* + * At this point, cv's queue no longer needs to be accessed, + * NULL it. + */ + uh = NULL; + + /* + * One queue head has already been moved, we need to + * move (n - 1) free queue head to new chain. + */ + while (--len > 0) { + uh_temp = LIST_FIRST(&uc->uc_spare_queue); + LIST_REMOVE(uh_temp, link); + LIST_INSERT_HEAD(&ucm->uc_spare_queue, uh_temp, link); + } + + umtxq_unlock(&mkey); + umtxq_unlock(&key); + + /* Now, the cv does not have any waiter. */ + suword32(__DEVOLATILE(uint32_t *, &cv->c_has_waiters), 0); + + umtxq_lock(&key); + umtxq_unbusy(&key); + umtxq_unlock(&key); + umtx_key_release(&key); + + /* + * Wake one thread when necessary. if before the queue + * migration, there is thread on mutex queue, we don't + * need to wake up a thread, because the mutex contention + * bit should have already been set by other mutex locking + * code. + * For pshared mutex, because different process has different + * address even for same process-shared mutex! + * we don't know where the mutex is in our address space. + * In this situation, we let a thread resumed from cv_wait + * to repair the mutex contention bit. + * XXX Fixme! we should make the repairing thread runs as + * soon as possible, boost its priority. + */ + if (oldlen == 0) { + if (!mkey.shared) { + do_wake = set_contested_bit(&mkey, bind_mutex, + uhm, 0); + } else { + do_wake = 1; + } + } else { + do_wake = 0; + } + + umtxq_lock(&mkey); + if (do_wake) { + uq = TAILQ_FIRST(&uhm->head); + if (uq != NULL) { + if (mkey.shared) + uq->uq_repair_mutex = 1; + umtxq_signal_thread(uq); + } + } + umtxq_unbusy(&mkey); + umtxq_unlock(&mkey); + return (0); + } else { + umtxq_signal(&key, INT_MAX); + umtxq_unlock(&key); + suword32(__DEVOLATILE(uint32_t *, &cv->c_has_waiters), 0); + umtxq_lock(&key); + umtxq_unbusy(&key); + umtxq_unlock(&key); + umtx_key_release(&key); + } + return (0); } static int @@ -2839,7 +3157,9 @@ do_sem_wait(struct thread *td, struct _u umtxq_insert(uq); umtxq_unlock(&uq->uq_key); - suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1); + /* Don't modify cacheline when unnecessary. */ + if (fuword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters)) == 0) + suword32(__DEVOLATILE(uint32_t *, &sem->_has_waiters), 1); count = fuword32(__DEVOLATILE(uint32_t *, &sem->_count)); if (count != 0) { Modified: user/davidxu/libthr/sys/sys/umtx.h ============================================================================== --- user/davidxu/libthr/sys/sys/umtx.h Wed Nov 3 23:29:52 2010 (r214766) +++ user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 02:03:26 2010 (r214767) @@ -82,7 +82,9 @@ #define UMTX_OP_MAX 21 /* flags for UMTX_OP_CV_WAIT */ -#define UMTX_CHECK_UNPARKING 0x01 +#define CVWAIT_CHECK_UNPARKING 0x01 +#define CVWAIT_BIND_MUTEX 0x02 +#define UMTX_CHECK_UNPARKING _CVWAIT_CHECK_UNPARKING #ifndef _KERNEL From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 02:09:36 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD24F106564A; Thu, 4 Nov 2010 02:09:36 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AB5C38FC08; Thu, 4 Nov 2010 02:09:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA429aak040757; Thu, 4 Nov 2010 02:09:36 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA429aEZ040748; Thu, 4 Nov 2010 02:09:36 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040209.oA429aEZ040748@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 02:09:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214768 - in user/davidxu/libthr/lib: libthr.user_requeue libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 02:09:36 -0000 Author: davidxu Date: Thu Nov 4 02:09:36 2010 New Revision: 214768 URL: http://svn.freebsd.org/changeset/base/214768 Log: Save previous work in libthr.user_requeue. Follow the change in kernel, use kernel's requeue function. Added: user/davidxu/libthr/lib/libthr.user_requeue/ - copied from r214766, user/davidxu/libthr/lib/libthr/ Modified: user/davidxu/libthr/lib/libthr/thread/Makefile.inc user/davidxu/libthr/lib/libthr/thread/thr_barrier.c user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/lib/libthr/thread/thr_init.c user/davidxu/libthr/lib/libthr/thread/thr_kern.c user/davidxu/libthr/lib/libthr/thread/thr_list.c user/davidxu/libthr/lib/libthr/thread/thr_mutex.c user/davidxu/libthr/lib/libthr/thread/thr_private.h user/davidxu/libthr/lib/libthr/thread/thr_umtx.c user/davidxu/libthr/lib/libthr/thread/thr_umtx.h Modified: user/davidxu/libthr/lib/libthr/thread/Makefile.inc ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/Makefile.inc Thu Nov 4 02:03:26 2010 (r214767) +++ user/davidxu/libthr/lib/libthr/thread/Makefile.inc Thu Nov 4 02:09:36 2010 (r214768) @@ -45,7 +45,6 @@ SRCS+= \ thr_setschedparam.c \ thr_sig.c \ thr_single_np.c \ - thr_sleepq.c \ thr_spec.c \ thr_spinlock.c \ thr_stack.c \ Modified: user/davidxu/libthr/lib/libthr/thread/thr_barrier.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_barrier.c Thu Nov 4 02:03:26 2010 (r214767) +++ user/davidxu/libthr/lib/libthr/thread/thr_barrier.c Thu Nov 4 02:09:36 2010 (r214768) @@ -102,7 +102,7 @@ _pthread_barrier_wait(pthread_barrier_t } else { cycle = bar->b_cycle; do { - _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0); + _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, CVWAIT_BIND_MUTEX); THR_UMUTEX_LOCK(curthread, &bar->b_lock); /* test cycle to avoid bogus wakeup */ } while (cycle == bar->b_cycle); Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 02:03:26 2010 (r214767) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 02:09:36 2010 (r214768) @@ -45,10 +45,7 @@ int __pthread_cond_timedwait(pthread_con static int cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr); static int cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, int cancel); -static int cond_signal_common(pthread_cond_t *cond); -static int cond_broadcast_common(pthread_cond_t *cond); - -#define CV_PSHARED(cv) (((cv)->c_kerncv.c_flags & USYNC_PROCESS_SHARED) != 0) +static int cond_signal_common(pthread_cond_t *cond, int broadcast); /* * Double underscore versions are cancellation points. Single underscore @@ -77,10 +74,10 @@ cond_init(pthread_cond_t *cond, const pt * Initialise the condition variable structure: */ if (cond_attr == NULL || *cond_attr == NULL) { + pcond->c_pshared = 0; pcond->c_clockid = CLOCK_REALTIME; } else { - if ((*cond_attr)->c_pshared) - pcond->c_kerncv.c_flags |= USYNC_PROCESS_SHARED; + pcond->c_pshared = (*cond_attr)->c_pshared; pcond->c_clockid = (*cond_attr)->c_clockid; } *cond = pcond; @@ -139,10 +136,9 @@ _pthread_cond_destroy(pthread_cond_t *co rval = EINVAL; else { cv = *cond; - if (cv->c_mutex != NULL) - return (EBUSY); _thr_ucond_broadcast(&cv->c_kerncv); *cond = THR_COND_DESTROYED; + /* * Free the memory allocated for the condition * variable structure: @@ -152,43 +148,36 @@ _pthread_cond_destroy(pthread_cond_t *co return (rval); } -struct cond_cancel_info -{ - pthread_mutex_t *mutex; - pthread_cond_t *cond; - int recurse; -}; - -static void -cond_cancel_handler(void *arg) -{ - struct cond_cancel_info *info = (struct cond_cancel_info *)arg; - - _mutex_cv_lock(info->mutex, info->recurse, 1); -} - /* - * Wait on kernel based condition variable. + * Cancellation behaivor: + * Thread may be canceled at start, if thread is canceled, it means it + * did not get a wakeup from pthread_cond_signal(), otherwise, it is + * not canceled. + * Thread cancellation never cause wakeup from pthread_cond_signal() + * to be lost. */ static int -cond_wait_kernel(pthread_cond_t *cond, pthread_mutex_t *mutex, +cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, int cancel) { struct pthread *curthread = _get_curthread(); struct timespec ts, ts2, *tsp; - struct pthread_mutex *m; - struct cond_cancel_info info; pthread_cond_t cv; - int error, error2; + struct pthread_mutex *m; + int recurse; + int ret; + + /* + * If the condition variable is statically initialized, + * perform the dynamic initialization: + */ + CHECK_AND_INIT_COND cv = *cond; + ret = _mutex_cv_detach(mutex, &recurse); + if (__predict_false(ret != 0)) + return (ret); m = *mutex; - error = _mutex_cv_detach(mutex, &info.recurse); - if (__predict_false(error != 0)) - return (error); - - info.mutex = mutex; - info.cond = cond; if (abstime != NULL) { clock_gettime(cv->c_clockid, &ts); @@ -198,131 +187,23 @@ cond_wait_kernel(pthread_cond_t *cond, p tsp = NULL; if (cancel) { - THR_CLEANUP_PUSH(curthread, cond_cancel_handler, &info); _thr_cancel_enter2(curthread, 0); - error = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 1); - info.cond = NULL; - _thr_cancel_leave(curthread, (error != 0)); - THR_CLEANUP_POP(curthread, 0); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, CVWAIT_BIND_MUTEX); + _thr_cancel_leave(curthread, 0); } else { - error = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); - } - if (error == EINTR) - error = 0; - error2 = _mutex_cv_lock(mutex, info.recurse, 1); - return (error || error2); -} - -/* - * Cancellation behaivor: - * Thread may be canceled at start, if thread is canceled, it means it - * did not get a wakeup from pthread_cond_signal(), otherwise, it is - * not canceled. - * Thread cancellation never cause wakeup from pthread_cond_signal() - * to be lost. - */ -static int -cond_wait_queue(pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime, int cancel) -{ - struct pthread *curthread = _get_curthread(); - struct pthread_mutex *m; - struct sleepqueue *sq; - pthread_cond_t cv; - int recurse; - int error; - - cv = *cond; - /* - * Enqueue thread before unlocking mutex, so we can avoid - * sleep lock in pthread_cond_signal whenever possible. - */ - if ((error = _mutex_owned(curthread, mutex)) != 0) - return (error); - sq = _sleepq_lock(cv, CV); - if (cv->c_mutex != NULL && cv->c_mutex != mutex) { - _sleepq_unlock(sq); - return (EINVAL); - } - cv->c_mutex = mutex; - _sleepq_add(sq, curthread); - _thr_clear_wake(curthread); - _sleepq_unlock(sq); - (void)_mutex_cv_unlock(mutex, &recurse); - m = *mutex; - for (;;) { - if (cancel) { - _thr_cancel_enter2(curthread, 0); - error = _thr_sleep(curthread, abstime, cv->c_clockid); - _thr_cancel_leave(curthread, 0); - } else { - error = _thr_sleep(curthread, abstime, cv->c_clockid); - } - _thr_clear_wake(curthread); - - sq = _sleepq_lock(cv, CV); - if (curthread->wchan == NULL) { - /* - * This must be signaled by mutex unlocking, - * they remove us from mutex queue. - */ - _sleepq_unlock(sq); - error = 0; - break; - } if (curthread->wchan == m) { - _sleepq_unlock(sq); - /* - * This must be signaled by cond_signal and there - * is no owner for the mutex. - */ - sq = _sleepq_lock(m, MX); - if (curthread->wchan == m) - _sleepq_remove(sq, curthread); - _sleepq_unlock(sq); - error = 0; - break; - } if (abstime != NULL && error == ETIMEDOUT) { - _sleepq_remove(sq, curthread); - if (_sleepq_empty(sq)) - cv->c_mutex = NULL; - _sleepq_unlock(sq); - break; - } else if (SHOULD_CANCEL(curthread)) { - _sleepq_remove(sq, curthread); - if (_sleepq_empty(sq)) - cv->c_mutex = NULL; - _sleepq_unlock(sq); - (void)_mutex_cv_lock(mutex, recurse, 0); - _pthread_exit(PTHREAD_CANCELED); - } - _sleepq_unlock(sq); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, CVWAIT_BIND_MUTEX); } - _mutex_cv_lock(mutex, recurse, 0); - return (error); -} - -static int -cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime, int cancel) -{ - pthread_cond_t cv; - struct pthread_mutex *m; - - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - CHECK_AND_INIT_COND - if ((m = *mutex) == NULL || m < THR_MUTEX_DESTROYED) - return (EINVAL); - if (IS_SIMPLE_MUTEX(m)) { - if (!CV_PSHARED(cv)) - return cond_wait_queue(cond, mutex, abstime, cancel); - else - return (EINVAL); - } else { - return cond_wait_kernel(cond, mutex, abstime, cancel); + if (ret == EINTR) + ret = 0; + if (ret == 0 || ret == ETIMEDOUT) + return _mutex_cv_lock(mutex, recurse); + else { + /* We know that it didn't unlock the mutex. */ + _mutex_cv_attach(mutex, recurse); + if (cancel) + _thr_testcancel(curthread); } + return (ret); } int @@ -364,74 +245,10 @@ __pthread_cond_timedwait(pthread_cond_t } static int -cond_signal_common(pthread_cond_t *cond) +cond_signal_common(pthread_cond_t *cond, int broadcast) { - pthread_mutex_t *mutex; - struct pthread_mutex *m; - struct pthread *td; - struct pthread_cond *cv; - struct sleepqueue *cv_sq, *mx_sq; - unsigned *waddr = NULL; - - /* - * If the condition variable is statically initialized, perform dynamic - * initialization. - */ - CHECK_AND_INIT_COND - - _thr_ucond_signal(&cv->c_kerncv); - - if (CV_PSHARED(cv)) - return (0); - - /* There is no waiter. */ - if (cv->c_mutex == NULL) - return (0); - - cv_sq = _sleepq_lock(cv, CV); - if (_sleepq_empty(cv_sq)) { - _sleepq_unlock(cv_sq); - return (0); - } - /* - * Check if we owned the temporarily binding mutex, - * if owned, we can migrate thread to mutex wait - * queue without waking up thread. - */ - if ((mutex = cv->c_mutex) != NULL) - m = *mutex; - else { - _sleepq_unlock(cv_sq); - PANIC("mutex == NULL"); - } - - td = _sleepq_first(cv_sq); - if (m->m_owner == NULL) - waddr = WAKE_ADDR(td); - _sleepq_remove(cv_sq, td); - mx_sq = _sleepq_lock(m, MX); - _sleepq_add(mx_sq, td); - _mutex_set_contested(m); - _sleepq_unlock(mx_sq); - if (_sleepq_empty(cv_sq)) - cv->c_mutex = NULL; - _sleepq_unlock(cv_sq); - if (waddr != NULL) { - _thr_set_wake(waddr); - _thr_umtx_wake(waddr, INT_MAX, 0); - } - return (0); -} - -static int -cond_broadcast_common(pthread_cond_t *cond) -{ - pthread_mutex_t *mutex; - struct pthread_mutex *m; - struct pthread *td; - struct pthread_cond *cv; - struct sleepqueue *cv_sq, *mx_sq; - unsigned *waddr = NULL; + pthread_cond_t cv; + int ret = 0; /* * If the condition variable is statically initialized, perform dynamic @@ -439,58 +256,23 @@ cond_broadcast_common(pthread_cond_t *co */ CHECK_AND_INIT_COND - _thr_ucond_broadcast(&cv->c_kerncv); - - if (CV_PSHARED(cv)) - return (0); - - /* There is no waiter. */ - if (cv->c_mutex == NULL) - return (0); - - cv_sq = _sleepq_lock(cv, CV); - if (_sleepq_empty(cv_sq)) { - _sleepq_unlock(cv_sq); - return (0); - } - /* - * Check if we owned the temporarily binding mutex, - * if owned, we can migrate thread to mutex wait - * queue without waking up thread. - */ - if ((mutex = cv->c_mutex) != NULL) - m = *mutex; - else { - _sleepq_unlock(cv_sq); - PANIC("mutex == NULL"); - } - - td = _sleepq_first(cv_sq); - if (m->m_owner == NULL) - waddr = WAKE_ADDR(td); - mx_sq = _sleepq_lock(m, MX); - _sleepq_concat(mx_sq, cv_sq); - _mutex_set_contested(m); - _sleepq_unlock(mx_sq); - cv->c_mutex = NULL; - _sleepq_unlock(cv_sq); - if (waddr != NULL) { - _thr_set_wake(waddr); - _thr_umtx_wake(waddr, INT_MAX, 0); - } - return (0); + if (!broadcast) + ret = _thr_ucond_signal(&cv->c_kerncv); + else + ret = _thr_ucond_broadcast(&cv->c_kerncv); + return (ret); } int _pthread_cond_signal(pthread_cond_t * cond) { - return (cond_signal_common(cond)); + return (cond_signal_common(cond, 0)); } int _pthread_cond_broadcast(pthread_cond_t * cond) { - return (cond_broadcast_common(cond)); + return (cond_signal_common(cond, 1)); } Modified: user/davidxu/libthr/lib/libthr/thread/thr_init.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_init.c Thu Nov 4 02:03:26 2010 (r214767) +++ user/davidxu/libthr/lib/libthr/thread/thr_init.c Thu Nov 4 02:09:36 2010 (r214768) @@ -444,7 +444,6 @@ init_private(void) _thr_once_init(); _thr_spinlock_init(); _thr_list_init(); - _sleepq_init(); /* * Avoid reinitializing some things if they don't need to be, Modified: user/davidxu/libthr/lib/libthr/thread/thr_kern.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_kern.c Thu Nov 4 02:03:26 2010 (r214767) +++ user/davidxu/libthr/lib/libthr/thread/thr_kern.c Thu Nov 4 02:09:36 2010 (r214768) @@ -31,7 +31,6 @@ #include #include #include -#include #include "thr_private.h" @@ -42,93 +41,6 @@ #define DBG_MSG(x...) #endif -static struct umutex addr_lock; -static struct wake_addr *wake_addr_head; -static struct wake_addr default_wake_addr; -static struct umutex mutex_link_lock; -static struct mutex_queue mutex_link_freeq; - -struct wake_addr * -_thr_alloc_wake_addr(void) -{ - struct pthread *curthread; - struct wake_addr *p; - - if (_thr_initial == NULL) { - return &default_wake_addr; - } - - curthread = _get_curthread(); - - THR_UMUTEX_LOCK(curthread, &addr_lock); - if (wake_addr_head == NULL) { - unsigned i; - unsigned pagesize = getpagesize(); - struct wake_addr *pp = (struct wake_addr *)mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - for (i = 1; i < pagesize/sizeof(struct wake_addr); ++i) - pp[i].link = &pp[i+1]; - pp[i-1].link = NULL; - wake_addr_head = &pp[1]; - p = &pp[0]; - } else { - p = wake_addr_head; - wake_addr_head = p->link; - } - THR_UMUTEX_UNLOCK(curthread, &addr_lock); - return (p); -} - -void -_thr_release_wake_addr(struct wake_addr *wa) -{ - struct pthread *curthread = _get_curthread(); - - if (wa == &default_wake_addr) - return; - THR_UMUTEX_LOCK(curthread, &addr_lock); - wa->link = wake_addr_head; - wake_addr_head = wa; - THR_UMUTEX_UNLOCK(curthread, &addr_lock); -} - -void -_thr_mutex_link_init(void) -{ - TAILQ_INIT(&mutex_link_freeq); - _thr_umutex_init(&mutex_link_lock); -} - -struct mutex_link * -_thr_mutex_link_alloc(void) -{ - struct pthread *curthread = _get_curthread(); - struct mutex_link *p; - - THR_LOCK_ACQUIRE(curthread, &mutex_link_lock); - p = TAILQ_FIRST(&mutex_link_freeq); - if (p == NULL) { - unsigned i; - unsigned pagesize = getpagesize(); - struct mutex_link *pp = (struct mutex_link *)mmap(NULL, getpagesize(), - PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - for (i = 1; i < pagesize/sizeof(struct mutex_link); ++i) - TAILQ_INSERT_TAIL(&mutex_link_freeq, &pp[i], qe); - p = &pp[0]; - } - THR_LOCK_RELEASE(curthread, &mutex_link_lock); - return (p); -} - -void -_thr_mutex_link_free(struct mutex_link *p) -{ - struct pthread *curthread = _get_curthread(); - - THR_LOCK_ACQUIRE(curthread, &mutex_link_lock); - TAILQ_INSERT_TAIL(&mutex_link_freeq, p, qe); - THR_LOCK_RELEASE(curthread, &mutex_link_lock); -} - /* * This is called when the first thread (other than the initial * thread) is created. @@ -218,29 +130,3 @@ _thr_setscheduler(lwpid_t lwpid, int pol _schedparam_to_rtp(policy, param, &rtp); return (rtprio_thread(RTP_SET, lwpid, &rtp)); } - -/* Sleep on thread wakeup address */ -int -_thr_sleep(struct pthread *curthread, const struct timespec *abstime, int clockid) -{ - struct timespec *tsp, ts, ts2; - int error; - - if (abstime != NULL) { - if (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || - abstime->tv_nsec >= 1000000000) { - return (EINVAL); - } - clock_gettime(clockid, &ts); - TIMESPEC_SUB(&ts2, abstime, &ts); - if (ts2.tv_sec < 0 || ts2.tv_nsec <= 0) - return (ETIMEDOUT); - tsp = &ts2; - } else { - tsp = NULL; - } - - error = _thr_umtx_wait_uint(&curthread->wake_addr->value, - 0, tsp, 0); - return (error); -} Modified: user/davidxu/libthr/lib/libthr/thread/thr_list.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_list.c Thu Nov 4 02:03:26 2010 (r214767) +++ user/davidxu/libthr/lib/libthr/thread/thr_list.c Thu Nov 4 02:09:36 2010 (r214768) @@ -165,8 +165,6 @@ _thr_alloc(struct pthread *curthread) if (tcb != NULL) { memset(thread, 0, sizeof(*thread)); thread->tcb = tcb; - thread->wake_addr = _thr_alloc_wake_addr(); - thread->sleepqueue = _sleepq_alloc(); } else { thr_destroy(curthread, thread); atomic_fetchadd_int(&total_threads, -1); @@ -195,8 +193,6 @@ _thr_free(struct pthread *curthread, str thread->tcb = NULL; if ((curthread == NULL) || (free_thread_count >= MAX_CACHED_THREADS)) { thr_destroy(curthread, thread); - _thr_release_wake_addr(thread->wake_addr); - _sleepq_free(thread->sleepqueue); atomic_fetchadd_int(&total_threads, -1); } else { /* Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Thu Nov 4 02:03:26 2010 (r214767) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Thu Nov 4 02:09:36 2010 (r214768) @@ -45,8 +45,24 @@ #include "thr_private.h" -#ifndef UMUTEX_TIDMASK -#define UMUTEX_TIDMASK (~UMUTEX_CONTESTED) +#if defined(_PTHREADS_INVARIANTS) +#define MUTEX_INIT_LINK(m) do { \ + (m)->m_qe.tqe_prev = NULL; \ + (m)->m_qe.tqe_next = NULL; \ +} while (0) +#define MUTEX_ASSERT_IS_OWNED(m) do { \ + if (__predict_false((m)->m_qe.tqe_prev == NULL))\ + PANIC("mutex is not on list"); \ +} while (0) +#define MUTEX_ASSERT_NOT_OWNED(m) do { \ + if (__predict_false((m)->m_qe.tqe_prev != NULL || \ + (m)->m_qe.tqe_next != NULL)) \ + PANIC("mutex is on list"); \ +} while (0) +#else +#define MUTEX_INIT_LINK(m) +#define MUTEX_ASSERT_IS_OWNED(m) +#define MUTEX_ASSERT_NOT_OWNED(m) #endif /* @@ -77,6 +93,8 @@ static int mutex_self_trylock(pthread_mu static int mutex_self_lock(pthread_mutex_t, const struct timespec *abstime); static int mutex_unlock_common(pthread_mutex_t *); +static int mutex_lock_sleep(struct pthread *, pthread_mutex_t, + const struct timespec *); __weak_reference(__pthread_mutex_init, pthread_mutex_init); __strong_reference(__pthread_mutex_init, _pthread_mutex_init); @@ -129,13 +147,14 @@ mutex_init(pthread_mutex_t *mutex, pmutex->m_type = attr->m_type; pmutex->m_owner = NULL; - pmutex->m_recurse = 0; + pmutex->m_count = 0; pmutex->m_refcount = 0; pmutex->m_spinloops = 0; pmutex->m_yieldloops = 0; + MUTEX_INIT_LINK(pmutex); switch(attr->m_protocol) { case PTHREAD_PRIO_NONE: - pmutex->m_lock.m_owner = 0; + pmutex->m_lock.m_owner = UMUTEX_UNOWNED; pmutex->m_lock.m_flags = 0; break; case PTHREAD_PRIO_INHERIT: @@ -154,6 +173,7 @@ mutex_init(pthread_mutex_t *mutex, _thr_spinloops ? _thr_spinloops: MUTEX_ADAPTIVE_SPINS; pmutex->m_yieldloops = _thr_yieldloops; } + *mutex = pmutex; return (0); } @@ -161,71 +181,33 @@ mutex_init(pthread_mutex_t *mutex, static int init_static(struct pthread *thread, pthread_mutex_t *mutex) { - int error; + int ret; THR_LOCK_ACQUIRE(thread, &_mutex_static_lock); if (*mutex == THR_MUTEX_INITIALIZER) - error = mutex_init(mutex, &_pthread_mutexattr_default, calloc); + ret = mutex_init(mutex, &_pthread_mutexattr_default, calloc); else if (*mutex == THR_ADAPTIVE_MUTEX_INITIALIZER) - error = mutex_init(mutex, &_pthread_mutexattr_adaptive_default, calloc); + ret = mutex_init(mutex, &_pthread_mutexattr_adaptive_default, calloc); else - error = 0; + ret = 0; THR_LOCK_RELEASE(thread, &_mutex_static_lock); - return (error); + return (ret); } static void set_inherited_priority(struct pthread *curthread, struct pthread_mutex *m) { - struct mutex_link *ml2; + struct pthread_mutex *m2; - ml2 = TAILQ_LAST(&curthread->pp_mutexq, mutex_queue); - if (ml2 != NULL) - m->m_lock.m_ceilings[1] = ml2->mutexp->m_lock.m_ceilings[0]; + m2 = TAILQ_LAST(&curthread->pp_mutexq, mutex_queue); + if (m2 != NULL) + m->m_lock.m_ceilings[1] = m2->m_lock.m_ceilings[0]; else m->m_lock.m_ceilings[1] = -1; } -static void -enqueue_mutex(struct pthread *curthread, struct pthread_mutex *m) -{ - m->m_owner = curthread; - struct mutex_link *ml = _thr_mutex_link_alloc(); - ml->mutexp = m; - if (((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0) - TAILQ_INSERT_TAIL(&curthread->mutexq, ml, qe); - else - TAILQ_INSERT_TAIL(&curthread->pp_mutexq, ml, qe); -} - -static void -dequeue_mutex(struct pthread *curthread, struct pthread_mutex *m) -{ - struct mutex_link *ml; - - if ((((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) { - TAILQ_FOREACH(ml, &curthread->mutexq, qe) { - if (ml->mutexp == m) { - TAILQ_REMOVE(&curthread->mutexq, ml, qe); - _thr_mutex_link_free(ml); - break; - } - } - } else { - TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) { - if (ml->mutexp == m) { - TAILQ_REMOVE(&curthread->mutexq, ml, qe); - set_inherited_priority(curthread, m); - _thr_mutex_link_free(ml); - break; - } - } - } - m->m_owner = NULL; -} - int __pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutex_attr) @@ -243,18 +225,18 @@ _pthread_mutex_init_calloc_cb(pthread_mu .m_protocol = PTHREAD_PRIO_NONE, .m_ceiling = 0 }; - int error; + int ret; - error = mutex_init(mutex, &attr, calloc_cb); - if (error == 0) + ret = mutex_init(mutex, &attr, calloc_cb); + if (ret == 0) (*mutex)->m_private = 1; - return (error); + return (ret); } void _mutex_fork(struct pthread *curthread) { - struct mutex_link *ml; + struct pthread_mutex *m; /* * Fix mutex ownership for child process. @@ -265,10 +247,11 @@ _mutex_fork(struct pthread *curthread) * process shared mutex is not supported, so I * am not worried. */ - TAILQ_FOREACH(ml, &curthread->mutexq, qe) - ml->mutexp->m_lock.m_owner = TID(curthread); - TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) - ml->mutexp->m_lock.m_owner = TID(curthread) | UMUTEX_CONTESTED; + + TAILQ_FOREACH(m, &curthread->mutexq, m_qe) + m->m_lock.m_owner = TID(curthread); + TAILQ_FOREACH(m, &curthread->pp_mutexq, m_qe) + m->m_lock.m_owner = TID(curthread) | UMUTEX_CONTESTED; } int @@ -287,6 +270,7 @@ _pthread_mutex_destroy(pthread_mutex_t * ret = EBUSY; } else { *mutex = THR_MUTEX_DESTROYED; + MUTEX_ASSERT_NOT_OWNED(m); free(m); ret = 0; } @@ -295,66 +279,48 @@ _pthread_mutex_destroy(pthread_mutex_t * return (ret); } +#define ENQUEUE_MUTEX(curthread, m) \ + do { \ + (m)->m_owner = curthread; \ + /* Add to the list of owned mutexes: */ \ + MUTEX_ASSERT_NOT_OWNED((m)); \ + if (((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0) \ + TAILQ_INSERT_TAIL(&curthread->mutexq, (m), m_qe);\ + else \ + TAILQ_INSERT_TAIL(&curthread->pp_mutexq, (m), m_qe);\ + } while (0) + #define CHECK_AND_INIT_MUTEX \ if (__predict_false((m = *mutex) <= THR_MUTEX_DESTROYED)) { \ if (m == THR_MUTEX_DESTROYED) \ return (EINVAL); \ - int error; \ - error = init_static(_get_curthread(), mutex); \ - if (error) \ - return (error); \ + int ret; \ + ret = init_static(_get_curthread(), mutex); \ + if (ret) \ + return (ret); \ m = *mutex; \ } -static inline int -set_lockword(struct pthread_mutex *m) -{ - uint32_t old; - - if (atomic_cmpset_acq_32(&m->m_lockword, 0, MTX_LOCKED)) - return (0); - old = m->m_lockword; - while ((old & MTX_LOCKED) == 0) { - if (atomic_cmpset_acq_32(&m->m_lockword, old, old|MTX_LOCKED)) - return (0); - old = m->m_lockword; - } - return (EBUSY); -} - static int mutex_trylock_common(pthread_mutex_t *mutex) { struct pthread *curthread = _get_curthread(); struct pthread_mutex *m = *mutex; - int error; - + uint32_t id; + int ret; + + id = TID(curthread); if (m->m_private) THR_CRITICAL_ENTER(curthread); - if (IS_SIMPLE_MUTEX(m)) { - if (set_lockword(m) == 0) { - m->m_owner = curthread; - return (0); - } - - if (m->m_owner == curthread) - error = mutex_self_trylock(m); - else - error = EBUSY; - } else { - uint32_t id; - - id = TID(curthread); - error = _thr_umutex_trylock(&m->m_lock, id); - if (__predict_true(error == 0)) { - enqueue_mutex(curthread, m); - } else if (m->m_owner == curthread) { - error = mutex_self_trylock(m); - } /* else {} */ - } - if (error != 0 && m->m_private) + ret = _thr_umutex_trylock(&m->m_lock, id); + if (__predict_true(ret == 0)) { + ENQUEUE_MUTEX(curthread, m); + } else if (m->m_owner == curthread) { + ret = mutex_self_trylock(m); + } /* else {} */ + if (ret && m->m_private) THR_CRITICAL_LEAVE(curthread); - return (error); + return (ret); } int @@ -367,157 +333,92 @@ __pthread_mutex_trylock(pthread_mutex_t return (mutex_trylock_common(mutex)); } -/* Lock user-mode queue based mutex. */ static int -mutex_lock_queued(struct pthread_mutex *m, +mutex_lock_sleep(struct pthread *curthread, struct pthread_mutex *m, const struct timespec *abstime) { - struct pthread *curthread = _get_curthread(); - struct sleepqueue *sq; - uint32_t old; - int error = 0; - int spin; + uint32_t id, owner; + int count; + int ret; if (m->m_owner == curthread) return mutex_self_lock(m, abstime); - if (__predict_false(abstime != NULL && - (abstime->tv_sec < 0 || abstime->tv_nsec < 0 || - abstime->tv_nsec >= 1000000000))) - return (EINVAL); - - spin = m->m_spinloops; - for (;;) { - if (!_thr_is_smp) - goto sleep; - while (spin-- > 0) { - /* - * For adaptive mutexes, spin for a bit in the expectation - * that if the application requests this mutex type then - * the lock is likely to be released quickly and it is - * faster than entering the kernel - */ - old = m->m_lockword; - if ((old & MTX_LOCKED) == 0) { - if (set_lockword(m) == 0) { - m->m_owner = curthread; - error = 0; - goto out; - } + id = TID(curthread); + /* + * For adaptive mutexes, spin for a bit in the expectation + * that if the application requests this mutex type then + * the lock is likely to be released quickly and it is + * faster than entering the kernel + */ + if (__predict_false( + (m->m_lock.m_flags & + (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) != 0)) + goto sleep_in_kernel; + + if (!_thr_is_smp) + goto yield_loop; + + count = m->m_spinloops; + while (count--) { + owner = m->m_lock.m_owner; + if ((owner & ~UMUTEX_CONTESTED) == 0) { + if (atomic_cmpset_acq_32(&m->m_lock.m_owner, owner, id|owner)) { + ret = 0; + goto done; } - CPU_SPINWAIT; } -sleep: - _thr_clear_wake(curthread); + CPU_SPINWAIT; + } - sq = _sleepq_lock(m, MX); - if (curthread->wchan == NULL) - _sleepq_add(sq, curthread); - _sleepq_unlock(sq); - old = m->m_lockword; - /* Set contested bit. */ - while ((old & MTX_LOCKED) != 0 && (old & MTX_CONTESTED) == 0) { - if (atomic_cmpset_acq_32(&m->m_lockword, - old, old|MTX_CONTESTED)) - break; - old = m->m_lockword; - } - if ((old & MTX_LOCKED) != 0) { - error = _thr_sleep(curthread, abstime, CLOCK_REALTIME); - if (error != EINTR) { - if (curthread->wchan != NULL) { - sq = _sleepq_lock(m, MX); - if (curthread->wchan != NULL) - _sleepq_remove(sq, curthread); - _sleepq_unlock(sq); - } - } else - error = 0; - old = m->m_lockword; - } - if (set_lockword(m) == 0) { - m->m_owner = curthread; - error = 0; - break; +yield_loop: + count = m->m_yieldloops; + while (count--) { + _sched_yield(); + owner = m->m_lock.m_owner; + if ((owner & ~UMUTEX_CONTESTED) == 0) { + if (atomic_cmpset_acq_32(&m->m_lock.m_owner, owner, id|owner)) { + ret = 0; + goto done; + } } - if (error != 0) - break; - spin = m->m_spinloops; } -out: - if (curthread->wchan != NULL) { - sq = _sleepq_lock(m, MX); - if (curthread->wchan != NULL) - _sleepq_remove(sq, curthread); - _sleepq_unlock(sq); - } - return (error); -} -/* Enter kernel and lock mutex */ -static int -mutex_lock_kernel(struct pthread_mutex *m, - const struct timespec *abstime) -{ - struct pthread *curthread = _get_curthread(); - uint32_t id; - int error; - *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 06:06:41 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7EA9106566C; Thu, 4 Nov 2010 06:06:41 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A58678FC1F; Thu, 4 Nov 2010 06:06:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA466fu1045887; Thu, 4 Nov 2010 06:06:41 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA466f1Z045885; Thu, 4 Nov 2010 06:06:41 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040606.oA466f1Z045885@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 06:06:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214769 - user/davidxu/libthr/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 06:06:41 -0000 Author: davidxu Date: Thu Nov 4 06:06:41 2010 New Revision: 214769 URL: http://svn.freebsd.org/changeset/base/214769 Log: Change cv_signal to move thread from condition variable's queue to mutex queue. Modified: user/davidxu/libthr/sys/kern/kern_umtx.c Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 02:09:36 2010 (r214768) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:06:41 2010 (r214769) @@ -227,13 +227,30 @@ static uma_zone_t umtx_pi_zone; static struct umtxq_chain umtxq_chains[2][UMTX_CHAINS]; static MALLOC_DEFINE(M_UMTX, "umtx", "UMTX queue memory"); static int umtx_pi_allocated; -static int umtx_cv_migrated; SYSCTL_NODE(_debug, OID_AUTO, umtx, CTLFLAG_RW, 0, "umtx debug"); SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_pi_allocated, CTLFLAG_RD, &umtx_pi_allocated, 0, "Allocated umtx_pi"); -SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_migrated, CTLFLAG_RD, - &umtx_cv_migrated, 0, "Thread migrated"); + +#define UMTX_STATE +#ifdef UMTX_STATE +static int umtx_cv_broadcast_migrate; +static int umtx_cv_signal_migrate; +static int umtx_cv_insert_failure; +static int umtx_cv_unlock_failure; +SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_broadcast_migrate, CTLFLAG_RD, + &umtx_cv_broadcast_migrate, 0, "cv_broadcast thread migrated"); +SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_signal_migrate, CTLFLAG_RD, + &umtx_cv_signal_migrate, 0, "cv_signal thread migrated"); +SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_insert_failure, CTLFLAG_RD, + &umtx_cv_insert_failure, 0, "cv_wait failure"); +SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_unlock_failure, CTLFLAG_RD, + &umtx_cv_unlock_failure, 0, "cv_wait unlock mutex failure"); +#define UMTX_STATE_INC(var) umtx_##var++ +#define UMTX_STATE_ADD(var, val) (umtx_##var += (val)) +#else +#define UMTX_STATE_INC(var) +#endif static void umtxq_sysinit(void *); static void umtxq_hash(struct umtx_key *key); @@ -2416,8 +2433,7 @@ do_unlock_umutex(struct thread *td, stru } static int -set_contested_bit(struct umtx_key *mkey, struct umutex *m, - struct umtxq_queue *uhm, int repair) +set_contested_bit(struct umutex *m, struct umtxq_queue *uhm, int repair) { int do_wake; int qlen = uhm->length; @@ -2464,7 +2480,7 @@ do_cv_wait(struct thread *td, struct uco struct timespec *timeout, u_long wflags) { struct umtx_q *uq; - struct umtx_key mkey, *mkeyp; + struct umtx_key mkey, *mkeyp, savekey; struct umutex *bind_mutex; struct timeval tv; struct timespec cts, ets, tts; @@ -2478,6 +2494,7 @@ do_cv_wait(struct thread *td, struct uco error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &uq->uq_key); if (error != 0) return (error); + savekey = uq->uq_key; if ((wflags & CVWAIT_BIND_MUTEX) != 0) { if ((mflags & UMUTEX_PRIO_INHERIT) != 0) return (EINVAL); @@ -2502,6 +2519,7 @@ do_cv_wait(struct thread *td, struct uco umtxq_busy(&uq->uq_key); error = umtxq_insert_queue2(uq, UMTX_SHARED_QUEUE, bind_mutex, mkeyp); if (error != 0) { + UMTX_STATE_INC(cv_insert_failure); umtxq_unbusy(&uq->uq_key); umtxq_unlock(&uq->uq_key); return (error); @@ -2520,6 +2538,8 @@ do_cv_wait(struct thread *td, struct uco umtxq_unlock(&uq->uq_key); error = do_unlock_umutex(td, m); + if (error) + UMTX_STATE_INC(cv_unlock_failure); umtxq_lock(&uq->uq_key); if (error == 0) { @@ -2587,7 +2607,7 @@ do_cv_wait(struct thread *td, struct uco uhm = umtxq_queue_lookup(mkeyp, UMTX_SHARED_QUEUE); if (uhm != NULL) - set_contested_bit(mkeyp, m, uhm, 1); + set_contested_bit(m, uhm, 1); umtxq_unbusy(mkeyp); umtxq_unlock(mkeyp); } @@ -2595,7 +2615,12 @@ do_cv_wait(struct thread *td, struct uco error = 0; } - umtx_key_release(&uq->uq_key); + /* + * Note that we should release a saved key, because if we + * were migrated, the vmobject reference is no the original, + * however, we should release the original. + */ + umtx_key_release(&savekey); if (mkeyp != NULL) umtx_key_release(mkeyp); uq->uq_spare_queue->bind_mutex = NULL; @@ -2605,14 +2630,64 @@ do_cv_wait(struct thread *td, struct uco } /* + * Entered with queue busied but not locked, exits with queue locked. + */ +static void +cv_after_migration(int oldlen, struct umutex *bind_mutex, + struct umtxq_queue *uhm) +{ + struct umtx_q *uq; + int do_wake = 0; + int shared = uhm->key.shared; + + /* + * Wake one thread when necessary. if before the queue + * migration, there is thread on mutex queue, we don't + * need to wake up a thread, because the mutex contention + * bit should have already been set by other mutex locking + * code. + * For pshared mutex, because different process has different + * address even for same process-shared mutex! + * we don't know where the mutex is in our address space. + * In this situation, we let a thread resumed from cv_wait + * to repair the mutex contention bit. + * XXX Fixme! we should make the repairing thread runs as + * soon as possible, boost its priority. + */ + + if (oldlen == 0) { + if (!shared) { + do_wake = set_contested_bit(bind_mutex, uhm, 0); + } else { + do_wake = 1; + } + } else { + do_wake = 0; + } + + umtxq_lock(&uhm->key); + if (do_wake) { + uq = TAILQ_FIRST(&uhm->head); + if (uq != NULL) { + if (shared) + uq->uq_repair_mutex = 1; + umtxq_signal_thread(uq); + } + } +} + +/* * Signal a userland condition variable. */ static int do_cv_signal(struct thread *td, struct ucond *cv) { + struct umtxq_queue *uh, *uhm; + struct umtxq_chain *uc, *ucm; + struct umtx_q *uq; struct umtx_key key; - int error, cnt, nwake; - uint32_t flags; + int error, len; + uint32_t flags, owner; flags = fuword32(&cv->c_flags); if ((error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &key)) != 0) @@ -2620,18 +2695,90 @@ do_cv_signal(struct thread *td, struct u umtxq_lock(&key); umtxq_busy(&key); - cnt = umtxq_count(&key); - nwake = umtxq_signal(&key, 1); - if (cnt <= nwake) { + uh = umtxq_queue_lookup(&key, UMTX_SHARED_QUEUE); + if (uh == NULL) { + int has_waiters = fuword32(__DEVOLATILE(uint32_t *, + &cv->c_has_waiters)); + if (has_waiters) { + suword32(__DEVOLATILE(uint32_t *, + &cv->c_has_waiters), 0); + } + umtxq_unbusy(&key); umtxq_unlock(&key); - error = suword32( - __DEVOLATILE(uint32_t *, &cv->c_has_waiters), 0); + umtx_key_release(&key); + return (0); + } + + len = uh->length; + + if (uh->binding) { + struct umutex *bind_mutex = uh->bind_mutex; + struct umtx_key mkey; + int oldlen; + + mkey = uh->bind_mkey; + umtxq_unlock(&key); + + if (!mkey.shared) { + owner = fuword32(__DEVOLATILE(void *, + &bind_mutex->m_owner)); + /*If mutex is not locked, wake up one */ + if ((owner & ~UMUTEX_CONTESTED) == 0) { + goto wake_one; + } + } + + /* Try to move thread between mutex and cv queues. */ + uc = umtxq_getchain(&key); + ucm = umtxq_getchain(&mkey); + + umtxq_lock(&mkey); + umtxq_busy(&mkey); + umtxq_unlock(&mkey); umtxq_lock(&key); + umtxq_lock(&mkey); + uhm = umtxq_queue_lookup(&mkey, UMTX_SHARED_QUEUE); + if (uhm == NULL) + oldlen = 0; + else + oldlen = uhm->length; + uq = TAILQ_FIRST(&uh->head); + umtxq_remove_queue(uq, UMTX_SHARED_QUEUE); + umtx_key_copy(&uq->uq_key, &mkey); + umtxq_insert(uq); + if (uhm == NULL) + uhm = uq->uq_cur_queue; + umtxq_unlock(&mkey); + umtxq_unlock(&key); + UMTX_STATE_INC(cv_signal_migrate); + if (len == 1) + suword32(__DEVOLATILE(uint32_t *, + &cv->c_has_waiters), 0); + + umtxq_lock(&key); + umtxq_unbusy(&key); + umtxq_unlock(&key); + umtx_key_release(&key); + + cv_after_migration(oldlen, bind_mutex, uhm); + + umtxq_unbusy(&mkey); + umtxq_unlock(&mkey); + return (0); + } else { + umtxq_unlock(&key); } + +wake_one: + if (len == 1) + suword32(__DEVOLATILE(uint32_t *, &cv->c_has_waiters), 0); + umtxq_lock(&key); + uq = TAILQ_FIRST(&uh->head); + umtxq_signal_thread(uq); umtxq_unbusy(&key); umtxq_unlock(&key); umtx_key_release(&key); - return (error); + return (0); } static int @@ -2658,7 +2805,6 @@ do_cv_broadcast(struct thread *td, struc struct umutex *bind_mutex = uh->bind_mutex; struct umtx_key mkey; struct umtx_q *uq; - int do_wake; int len, oldlen; len = uh->length; @@ -2711,6 +2857,8 @@ do_cv_broadcast(struct thread *td, struc LIST_INSERT_HEAD(&ucm->uc_spare_queue, uh, link); } + UMTX_STATE_ADD(cv_broadcast_migrate, len); + /* * At this point, cv's queue no longer needs to be accessed, * NULL it. @@ -2738,40 +2886,8 @@ do_cv_broadcast(struct thread *td, struc umtxq_unlock(&key); umtx_key_release(&key); - /* - * Wake one thread when necessary. if before the queue - * migration, there is thread on mutex queue, we don't - * need to wake up a thread, because the mutex contention - * bit should have already been set by other mutex locking - * code. - * For pshared mutex, because different process has different - * address even for same process-shared mutex! - * we don't know where the mutex is in our address space. - * In this situation, we let a thread resumed from cv_wait - * to repair the mutex contention bit. - * XXX Fixme! we should make the repairing thread runs as - * soon as possible, boost its priority. - */ - if (oldlen == 0) { - if (!mkey.shared) { - do_wake = set_contested_bit(&mkey, bind_mutex, - uhm, 0); - } else { - do_wake = 1; - } - } else { - do_wake = 0; - } + cv_after_migration(oldlen, bind_mutex, uhm); - umtxq_lock(&mkey); - if (do_wake) { - uq = TAILQ_FIRST(&uhm->head); - if (uq != NULL) { - if (mkey.shared) - uq->uq_repair_mutex = 1; - umtxq_signal_thread(uq); - } - } umtxq_unbusy(&mkey); umtxq_unlock(&mkey); return (0); From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 06:11:39 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 69D4810656A4; Thu, 4 Nov 2010 06:11:39 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 588F88FC1E; Thu, 4 Nov 2010 06:11:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA46BddB046025; Thu, 4 Nov 2010 06:11:39 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA46BdAO046023; Thu, 4 Nov 2010 06:11:39 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040611.oA46BdAO046023@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 06:11:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214770 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 06:11:39 -0000 Author: davidxu Date: Thu Nov 4 06:11:39 2010 New Revision: 214770 URL: http://svn.freebsd.org/changeset/base/214770 Log: Cancel thread when it is not signaled by others. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 06:06:41 2010 (r214769) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 06:11:39 2010 (r214770) @@ -193,11 +193,16 @@ cond_wait_common(pthread_cond_t *cond, p } else { ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, CVWAIT_BIND_MUTEX); } - if (ret == EINTR) - ret = 0; - if (ret == 0 || ret == ETIMEDOUT) - return _mutex_cv_lock(mutex, recurse); - else { + + if (ret == 0) { + _mutex_cv_lock(mutex, recurse); + } else if (ret == EINTR || ret == ETIMEDOUT) { + _mutex_cv_lock(mutex, recurse); + if (cancel) + _thr_testcancel(curthread); + if (ret == EINTR) + ret = 0; + } else { /* We know that it didn't unlock the mutex. */ _mutex_cv_attach(mutex, recurse); if (cancel) From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 06:37:15 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A81761065673; Thu, 4 Nov 2010 06:37:15 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 96DBB8FC12; Thu, 4 Nov 2010 06:37:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA46bFEC046649; Thu, 4 Nov 2010 06:37:15 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA46bFIO046647; Thu, 4 Nov 2010 06:37:15 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040637.oA46bFIO046647@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 06:37:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214771 - user/davidxu/libthr/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 06:37:15 -0000 Author: davidxu Date: Thu Nov 4 06:37:15 2010 New Revision: 214771 URL: http://svn.freebsd.org/changeset/base/214771 Log: Fix some comments. and ignore error code from umutex_unlock. Modified: user/davidxu/libthr/sys/kern/kern_umtx.c Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:11:39 2010 (r214770) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:37:15 2010 (r214771) @@ -2538,8 +2538,10 @@ do_cv_wait(struct thread *td, struct uco umtxq_unlock(&uq->uq_key); error = do_unlock_umutex(td, m); - if (error) + if (error) { UMTX_STATE_INC(cv_unlock_failure); + error = 0; /* ignore the error */ + } umtxq_lock(&uq->uq_key); if (error == 0) { @@ -2617,7 +2619,7 @@ do_cv_wait(struct thread *td, struct uco } /* * Note that we should release a saved key, because if we - * were migrated, the vmobject reference is no the original, + * were migrated, the vmobject reference is no longer the original, * however, we should release the original. */ umtx_key_release(&savekey); @@ -2722,7 +2724,7 @@ do_cv_signal(struct thread *td, struct u if (!mkey.shared) { owner = fuword32(__DEVOLATILE(void *, &bind_mutex->m_owner)); - /*If mutex is not locked, wake up one */ + /* If mutex is not locked, wake up one. */ if ((owner & ~UMUTEX_CONTESTED) == 0) { goto wake_one; } From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 06:51:54 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 23791106566C; Thu, 4 Nov 2010 06:51:54 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 112CC8FC16; Thu, 4 Nov 2010 06:51:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA46prIE046976; Thu, 4 Nov 2010 06:51:53 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA46prH7046971; Thu, 4 Nov 2010 06:51:53 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040651.oA46prH7046971@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 06:51:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214772 - in user/davidxu/libthr: lib/libthr/thread sys/kern sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 06:51:54 -0000 Author: davidxu Date: Thu Nov 4 06:51:53 2010 New Revision: 214772 URL: http://svn.freebsd.org/changeset/base/214772 Log: Define UCOND_BIND_MUTEX flag to bind a umutex to a ucond, it indicates a protocol if the condition variable is shared among processes. the system call argument CVWAIT_BIND_MUTEX is removed. Modified: user/davidxu/libthr/lib/libthr/thread/thr_barrier.c user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/sys/kern/kern_umtx.c user/davidxu/libthr/sys/sys/umtx.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_barrier.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_barrier.c Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/lib/libthr/thread/thr_barrier.c Thu Nov 4 06:51:53 2010 (r214772) @@ -102,7 +102,7 @@ _pthread_barrier_wait(pthread_barrier_t } else { cycle = bar->b_cycle; do { - _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, CVWAIT_BIND_MUTEX); + _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0); THR_UMUTEX_LOCK(curthread, &bar->b_lock); /* test cycle to avoid bogus wakeup */ } while (cycle == bar->b_cycle); Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 06:51:53 2010 (r214772) @@ -80,6 +80,7 @@ cond_init(pthread_cond_t *cond, const pt pcond->c_pshared = (*cond_attr)->c_pshared; pcond->c_clockid = (*cond_attr)->c_clockid; } + pcond->c_kerncv.c_flags |= UCOND_BIND_MUTEX; *cond = pcond; } /* Return the completion status: */ @@ -188,10 +189,10 @@ cond_wait_common(pthread_cond_t *cond, p if (cancel) { _thr_cancel_enter2(curthread, 0); - ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, CVWAIT_BIND_MUTEX); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); _thr_cancel_leave(curthread, 0); } else { - ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, CVWAIT_BIND_MUTEX); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); } if (ret == 0) { Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:51:53 2010 (r214772) @@ -2495,9 +2495,9 @@ do_cv_wait(struct thread *td, struct uco if (error != 0) return (error); savekey = uq->uq_key; - if ((wflags & CVWAIT_BIND_MUTEX) != 0) { + if ((flags & UCOND_BIND_MUTEX) != 0) { if ((mflags & UMUTEX_PRIO_INHERIT) != 0) - return (EINVAL); + goto ignore; error = umtx_key_get(m, TYPE_NORMAL_UMUTEX, GET_SHARE(mflags), &mkey); if (error != 0) { @@ -2510,6 +2510,7 @@ do_cv_wait(struct thread *td, struct uco bind_mutex = NULL; mkeyp = &mkey; } else { +ignore: bind_mutex = NULL; mkeyp = NULL; } Modified: user/davidxu/libthr/sys/sys/umtx.h ============================================================================== --- user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 06:37:15 2010 (r214771) +++ user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 06:51:53 2010 (r214772) @@ -54,6 +54,8 @@ #define URWLOCK_MAX_READERS 0x1fffffffU #define URWLOCK_READER_COUNT(c) ((c) & URWLOCK_MAX_READERS) +#define UCOND_BIND_MUTEX 0x0002 + /* _usem flags */ #define SEM_NAMED 0x0002 @@ -83,7 +85,6 @@ /* flags for UMTX_OP_CV_WAIT */ #define CVWAIT_CHECK_UNPARKING 0x01 -#define CVWAIT_BIND_MUTEX 0x02 #define UMTX_CHECK_UNPARKING _CVWAIT_CHECK_UNPARKING #ifndef _KERNEL From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 07:53:10 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01DA0106566B; Thu, 4 Nov 2010 07:53:10 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E32F08FC1A; Thu, 4 Nov 2010 07:53:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA47r9RF048250; Thu, 4 Nov 2010 07:53:09 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA47r9aI048243; Thu, 4 Nov 2010 07:53:09 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040753.oA47r9aI048243@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 07:53:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214773 - in user/davidxu/libthr: lib/libthr/thread sys/kern sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 07:53:10 -0000 Author: davidxu Date: Thu Nov 4 07:53:09 2010 New Revision: 214773 URL: http://svn.freebsd.org/changeset/base/214773 Log: Introduce cv_wait options: CVWAIT_ABSTIME and CVWAIT_CLOCKID. CVWAIT_ABSTIME indicates the timeout is absolute time. CVWAIT_CLOCKID indicats the clockid should be retrieved from condition variable field c_clockid. This is how POSIX condition varible works. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/lib/libthr/thread/thr_private.h user/davidxu/libthr/lib/libthr/thread/thr_umtx.c user/davidxu/libthr/sys/kern/kern_umtx.c user/davidxu/libthr/sys/sys/_umtx.h user/davidxu/libthr/sys/sys/umtx.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 06:51:53 2010 (r214772) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 07:53:09 2010 (r214773) @@ -74,11 +74,11 @@ cond_init(pthread_cond_t *cond, const pt * Initialise the condition variable structure: */ if (cond_attr == NULL || *cond_attr == NULL) { - pcond->c_pshared = 0; - pcond->c_clockid = CLOCK_REALTIME; + pcond->c_kerncv.c_clockid = CLOCK_REALTIME; } else { - pcond->c_pshared = (*cond_attr)->c_pshared; - pcond->c_clockid = (*cond_attr)->c_clockid; + if ((*cond_attr)->c_pshared) + pcond->c_kerncv.c_flags |= USYNC_PROCESS_SHARED; + pcond->c_kerncv.c_clockid = (*cond_attr)->c_clockid; } pcond->c_kerncv.c_flags |= UCOND_BIND_MUTEX; *cond = pcond; @@ -162,7 +162,6 @@ cond_wait_common(pthread_cond_t *cond, p const struct timespec *abstime, int cancel) { struct pthread *curthread = _get_curthread(); - struct timespec ts, ts2, *tsp; pthread_cond_t cv; struct pthread_mutex *m; int recurse; @@ -180,19 +179,14 @@ cond_wait_common(pthread_cond_t *cond, p return (ret); m = *mutex; - if (abstime != NULL) { - clock_gettime(cv->c_clockid, &ts); - TIMESPEC_SUB(&ts2, abstime, &ts); - tsp = &ts2; - } else - tsp = NULL; - if (cancel) { _thr_cancel_enter2(curthread, 0); - ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, abstime, + CVWAIT_ABSTIME|CVWAIT_CLOCKID); _thr_cancel_leave(curthread, 0); } else { - ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, tsp, 0); + ret = _thr_ucond_wait(&cv->c_kerncv, &m->m_lock, abstime, + CVWAIT_ABSTIME|CVWAIT_CLOCKID); } if (ret == 0) { Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Thu Nov 4 06:51:53 2010 (r214772) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Thu Nov 4 07:53:09 2010 (r214773) @@ -169,8 +169,6 @@ struct pthread_mutex_attr { struct pthread_cond { struct ucond c_kerncv; - int c_pshared; - int c_clockid; }; struct pthread_cond_attr { Modified: user/davidxu/libthr/lib/libthr/thread/thr_umtx.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Thu Nov 4 06:51:53 2010 (r214772) +++ user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Thu Nov 4 07:53:09 2010 (r214773) @@ -180,12 +180,6 @@ int _thr_ucond_wait(struct ucond *cv, struct umutex *m, const struct timespec *timeout, int flags) { - if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 && - timeout->tv_nsec <= 0))) { - struct pthread *curthread = _get_curthread(); - _thr_umutex_unlock(m, TID(curthread)); - return (ETIMEDOUT); - } return _umtx_op_err(cv, UMTX_OP_CV_WAIT, flags, m, __DECONST(void*, timeout)); } Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 06:51:53 2010 (r214772) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 07:53:09 2010 (r214773) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -2486,6 +2487,7 @@ do_cv_wait(struct thread *td, struct uco struct timespec cts, ets, tts; struct umtxq_chain *old_chain; uint32_t flags, mflags; + uint32_t clockid; int error; uq = td->td_umtxq; @@ -2494,6 +2496,18 @@ do_cv_wait(struct thread *td, struct uco error = umtx_key_get(cv, TYPE_CV, GET_SHARE(flags), &uq->uq_key); if (error != 0) return (error); + + if ((wflags & CVWAIT_CLOCKID) != 0) { + clockid = fuword32(&cv->c_clockid); + if (clockid < CLOCK_REALTIME || + clockid >= CLOCK_THREAD_CPUTIME_ID) { + /* hmm, only HW clock id will work. */ + return (EINVAL); + } + } else { + clockid = CLOCK_REALTIME; + } + savekey = uq->uq_key; if ((flags & UCOND_BIND_MUTEX) != 0) { if ((mflags & UMUTEX_PRIO_INHERIT) != 0) @@ -2549,14 +2563,22 @@ ignore: if (timeout == NULL) { error = umtxq_sleep(uq, "ucond", 0); } else { - getnanouptime(&ets); - timespecadd(&ets, timeout); - TIMESPEC_TO_TIMEVAL(&tv, timeout); + if ((wflags & CVWAIT_ABSTIME) == 0) { + kern_clock_gettime(td, clockid, &ets); + timespecadd(&ets, timeout); + tts = *timeout; + } else { /* absolute time */ + ets = *timeout; + tts = *timeout; + kern_clock_gettime(td, clockid, &cts); + timespecsub(&tts, &cts); + } + TIMESPEC_TO_TIMEVAL(&tv, &tts); for (;;) { error = umtxq_sleep(uq, "ucond", tvtohz(&tv)); if (error != ETIMEDOUT) break; - getnanouptime(&cts); + kern_clock_gettime(td, clockid, &cts); if (timespeccmp(&cts, &ets, >=)) { error = ETIMEDOUT; break; Modified: user/davidxu/libthr/sys/sys/_umtx.h ============================================================================== --- user/davidxu/libthr/sys/sys/_umtx.h Thu Nov 4 06:51:53 2010 (r214772) +++ user/davidxu/libthr/sys/sys/_umtx.h Thu Nov 4 07:53:09 2010 (r214773) @@ -46,7 +46,8 @@ struct umutex { struct ucond { volatile __uint32_t c_has_waiters; /* Has waiters in kernel */ __uint32_t c_flags; /* Flags of the condition variable */ - __uint32_t c_spare[2]; /* Spare space */ + __uint32_t c_clockid; /* Clock id */ + __uint32_t c_spare[1]; /* Spare space */ }; struct urwlock { Modified: user/davidxu/libthr/sys/sys/umtx.h ============================================================================== --- user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 06:51:53 2010 (r214772) +++ user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 07:53:09 2010 (r214773) @@ -85,6 +85,9 @@ /* flags for UMTX_OP_CV_WAIT */ #define CVWAIT_CHECK_UNPARKING 0x01 +#define CVWAIT_ABSTIME 0x02 +#define CVWAIT_CLOCKID 0x04 + #define UMTX_CHECK_UNPARKING _CVWAIT_CHECK_UNPARKING #ifndef _KERNEL From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 08:58:16 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C26C2106566B; Thu, 4 Nov 2010 08:58:16 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AF4AB8FC13; Thu, 4 Nov 2010 08:58:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA48wGIU049778; Thu, 4 Nov 2010 08:58:16 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA48wGxa049774; Thu, 4 Nov 2010 08:58:16 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011040858.oA48wGxa049774@svn.freebsd.org> From: David Xu Date: Thu, 4 Nov 2010 08:58:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214775 - in user/davidxu/libthr: lib/libthr/thread sys/kern sys/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 08:58:16 -0000 Author: davidxu Date: Thu Nov 4 08:58:16 2010 New Revision: 214775 URL: http://svn.freebsd.org/changeset/base/214775 Log: Introduce UMUTEX_ABSTIME option, so we can reduce a clock_gettime syscall in userland. Modified: user/davidxu/libthr/lib/libthr/thread/thr_umtx.c user/davidxu/libthr/sys/kern/kern_umtx.c user/davidxu/libthr/sys/sys/umtx.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_umtx.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Thu Nov 4 08:51:45 2010 (r214774) +++ user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Thu Nov 4 08:58:16 2010 (r214775) @@ -66,7 +66,8 @@ __thr_umutex_lock(struct umutex *mtx, ui owner = mtx->m_owner; if ((owner & ~UMUTEX_CONTESTED) == 0 && - atomic_cmpset_acq_32(&mtx->m_owner, owner, id|owner)) + atomic_cmpset_acq_32(&mtx->m_owner, owner, + id|owner)) return (0); } } @@ -78,40 +79,32 @@ int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, const struct timespec *ets) { - struct timespec timo, cts; uint32_t owner; int ret; - clock_gettime(CLOCK_REALTIME, &cts); - TIMESPEC_SUB(&timo, ets, &cts); - - if (timo.tv_sec < 0) - return (ETIMEDOUT); - for (;;) { - if ((mtx->m_flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0) { + if ((mtx->m_flags & + (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0) { /* wait in kernel */ - ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_WAIT, 0, 0, &timo); + ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_WAIT, + UMUTEX_ABSTIME, NULL, __DECONST(void*, ets)); /* now try to lock it */ owner = mtx->m_owner; if ((owner & ~UMUTEX_CONTESTED) == 0 && - atomic_cmpset_acq_32(&mtx->m_owner, owner, id|owner)) + atomic_cmpset_acq_32(&mtx->m_owner, owner, + id|owner)) { return (0); + } } else { - ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_LOCK, 0, 0, &timo); + ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_LOCK, + UMUTEX_ABSTIME, NULL, __DECONST(void *, ets)); if (ret == 0) break; } if (ret == ETIMEDOUT) break; - clock_gettime(CLOCK_REALTIME, &cts); - TIMESPEC_SUB(&timo, ets, &cts); - if (timo.tv_sec < 0 || (timo.tv_sec == 0 && timo.tv_nsec == 0)) { - ret = ETIMEDOUT; - break; - } } return (ret); } @@ -122,7 +115,8 @@ __thr_umutex_unlock(struct umutex *mtx, #ifndef __ia64__ /* XXX this logic has a race-condition on ia64. */ if ((mtx->m_flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0) { - atomic_cmpset_rel_32(&mtx->m_owner, id | UMUTEX_CONTESTED, UMUTEX_CONTESTED); + atomic_cmpset_rel_32(&mtx->m_owner, id | UMUTEX_CONTESTED, + UMUTEX_CONTESTED); return _umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE, 0, 0, 0); } #endif /* __ia64__ */ @@ -159,15 +153,16 @@ _thr_umtx_wait_uint(volatile u_int *mtx, timeout->tv_nsec <= 0))) return (ETIMEDOUT); return _umtx_op_err(__DEVOLATILE(void *, mtx), - shared ? UMTX_OP_WAIT_UINT : UMTX_OP_WAIT_UINT_PRIVATE, id, 0, + shared ? UMTX_OP_WAIT_UINT : UMTX_OP_WAIT_UINT_PRIVATE, id, 0, __DECONST(void*, timeout)); } int _thr_umtx_wake(volatile void *mtx, int nr_wakeup, int shared) { - return _umtx_op_err(__DEVOLATILE(void *, mtx), shared ? UMTX_OP_WAKE : UMTX_OP_WAKE_PRIVATE, - nr_wakeup, 0, 0); + return _umtx_op_err(__DEVOLATILE(void *, mtx), + shared ? UMTX_OP_WAKE : UMTX_OP_WAKE_PRIVATE, + nr_wakeup, 0, 0); } void Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 08:51:45 2010 (r214774) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Thu Nov 4 08:58:16 2010 (r214775) @@ -2369,9 +2369,9 @@ _do_lock_umutex(struct thread *td, struc */ static int do_lock_umutex(struct thread *td, struct umutex *m, - struct timespec *timeout, int mode) + struct timespec *timeout, int mode, int wflags) { - struct timespec ts, ts2, ts3; + struct timespec cts, ets, tts; struct timeval tv; uint32_t flags; int error; @@ -2386,21 +2386,30 @@ do_lock_umutex(struct thread *td, struct if (error == EINTR && mode != _UMUTEX_WAIT) error = ERESTART; } else { - getnanouptime(&ts); - timespecadd(&ts, timeout); - TIMESPEC_TO_TIMEVAL(&tv, timeout); + const clockid_t clockid = CLOCK_REALTIME; + if ((wflags & UMUTEX_ABSTIME) == 0) { + kern_clock_gettime(td, clockid, &ets); + timespecadd(&ets, timeout); + tts = *timeout; + } else { /* absolute time */ + ets = *timeout; + tts = *timeout; + kern_clock_gettime(td, clockid, &cts); + timespecsub(&tts, &cts); + } + TIMESPEC_TO_TIMEVAL(&tv, &tts); for (;;) { error = _do_lock_umutex(td, m, flags, tvtohz(&tv), mode); if (error != ETIMEDOUT) break; - getnanouptime(&ts2); - if (timespeccmp(&ts2, &ts, >=)) { + kern_clock_gettime(td, clockid, &cts); + if (timespeccmp(&cts, &ets, >=)) { error = ETIMEDOUT; break; } - ts3 = ts; - timespecsub(&ts3, &ts2); - TIMESPEC_TO_TIMEVAL(&tv, &ts3); + tts = ets; + timespecsub(&tts, &cts); + TIMESPEC_TO_TIMEVAL(&tv, &tts); } /* Timed-locking is not restarted. */ if (error == ERESTART) @@ -3513,13 +3522,13 @@ __umtx_op_lock_umutex(struct thread *td, } ts = &timeout; } - return do_lock_umutex(td, uap->obj, ts, 0); + return do_lock_umutex(td, uap->obj, ts, 0, uap->val); } static int __umtx_op_trylock_umutex(struct thread *td, struct _umtx_op_args *uap) { - return do_lock_umutex(td, uap->obj, NULL, _UMUTEX_TRY); + return do_lock_umutex(td, uap->obj, NULL, _UMUTEX_TRY, 0); } static int @@ -3542,7 +3551,7 @@ __umtx_op_wait_umutex(struct thread *td, } ts = &timeout; } - return do_lock_umutex(td, uap->obj, ts, _UMUTEX_WAIT); + return do_lock_umutex(td, uap->obj, ts, _UMUTEX_WAIT, uap->val); } static int Modified: user/davidxu/libthr/sys/sys/umtx.h ============================================================================== --- user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 08:51:45 2010 (r214774) +++ user/davidxu/libthr/sys/sys/umtx.h Thu Nov 4 08:58:16 2010 (r214775) @@ -83,6 +83,9 @@ #define UMTX_OP_SEM_WAKE 20 #define UMTX_OP_MAX 21 +/* flags for UMUTEX_LOCK */ +#define UMUTEX_ABSTIME 0x01 + /* flags for UMTX_OP_CV_WAIT */ #define CVWAIT_CHECK_UNPARKING 0x01 #define CVWAIT_ABSTIME 0x02 From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 18:14:37 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 99ED3106566C; Thu, 4 Nov 2010 18:14:37 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 893078FC13; Thu, 4 Nov 2010 18:14:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA4IEboF068300; Thu, 4 Nov 2010 18:14:37 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4IEbbA068298; Thu, 4 Nov 2010 18:14:37 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201011041814.oA4IEbbA068298@svn.freebsd.org> From: Ed Schouten Date: Thu, 4 Nov 2010 18:14:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214794 - user/ed/compiler-rt/lib/libcompiler_rt X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 18:14:37 -0000 Author: ed Date: Thu Nov 4 18:14:37 2010 New Revision: 214794 URL: http://svn.freebsd.org/changeset/base/214794 Log: Fall back to MACHINE_ARCH. Don't build the optimized ppc bits on powerpc64. Modified: user/ed/compiler-rt/lib/libcompiler_rt/Makefile Modified: user/ed/compiler-rt/lib/libcompiler_rt/Makefile ============================================================================== --- user/ed/compiler-rt/lib/libcompiler_rt/Makefile Thu Nov 4 18:00:25 2010 (r214793) +++ user/ed/compiler-rt/lib/libcompiler_rt/Makefile Thu Nov 4 18:14:37 2010 (r214794) @@ -10,7 +10,7 @@ CFLAGS+=${PICFLAG} .if ${MACHINE_CPUARCH} == "amd64" CRTARCH=x86_64 -.elif ${MACHINE_CPUARCH} == "powerpc" +.elif ${MACHINE_ARCH} == "powerpc" CRTARCH=ppc .else CRTARCH=${MACHINE_CPUARCH} From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 18:19:46 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D86ED106566B; Thu, 4 Nov 2010 18:19:45 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C7CCA8FC17; Thu, 4 Nov 2010 18:19:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA4IJjTu068495; Thu, 4 Nov 2010 18:19:45 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4IJjhn068493; Thu, 4 Nov 2010 18:19:45 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201011041819.oA4IJjhn068493@svn.freebsd.org> From: Ed Schouten Date: Thu, 4 Nov 2010 18:19:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214795 - user/ed/compiler-rt/lib/libcompiler_rt X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 18:19:46 -0000 Author: ed Date: Thu Nov 4 18:19:45 2010 New Revision: 214795 URL: http://svn.freebsd.org/changeset/base/214795 Log: Remove PowerPC entirely. Nothing from that subdir gets built anyway. Modified: user/ed/compiler-rt/lib/libcompiler_rt/Makefile Modified: user/ed/compiler-rt/lib/libcompiler_rt/Makefile ============================================================================== --- user/ed/compiler-rt/lib/libcompiler_rt/Makefile Thu Nov 4 18:14:37 2010 (r214794) +++ user/ed/compiler-rt/lib/libcompiler_rt/Makefile Thu Nov 4 18:19:45 2010 (r214795) @@ -10,8 +10,6 @@ CFLAGS+=${PICFLAG} .if ${MACHINE_CPUARCH} == "amd64" CRTARCH=x86_64 -.elif ${MACHINE_ARCH} == "powerpc" -CRTARCH=ppc .else CRTARCH=${MACHINE_CPUARCH} .endif From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 18:24:06 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 679C2106566C; Thu, 4 Nov 2010 18:24:06 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5134A8FC13; Thu, 4 Nov 2010 18:24:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA4IO6qf068700; Thu, 4 Nov 2010 18:24:06 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4IO5DF068682; Thu, 4 Nov 2010 18:24:05 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201011041824.oA4IO5DF068682@svn.freebsd.org> From: Ed Schouten Date: Thu, 4 Nov 2010 18:24:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214796 - in user/ed/compiler-rt: . bin/rm bin/sh bin/stty cddl/contrib/opensolaris/cmd/ztest cddl/contrib/opensolaris/lib/libzpool/common contrib/bind9 contrib/bind9/bin/dnssec contrib... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 18:24:06 -0000 Author: ed Date: Thu Nov 4 18:24:05 2010 New Revision: 214796 URL: http://svn.freebsd.org/changeset/base/214796 Log: Merge from HEAD, so I can make universe, create diffs, etc. Added: user/ed/compiler-rt/contrib/wpa/patches/ - copied from r214794, head/contrib/wpa/patches/ user/ed/compiler-rt/contrib/wpa/src/ap/ - copied from r214794, head/contrib/wpa/src/ap/ user/ed/compiler-rt/contrib/wpa/src/crypto/.gitignore - copied unchanged from r214794, head/contrib/wpa/src/crypto/.gitignore user/ed/compiler-rt/contrib/wpa/src/crypto/aes-cbc.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-cbc.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-ctr.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-ctr.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-eax.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-eax.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-encblock.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-encblock.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-internal-dec.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-internal-dec.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-internal-enc.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-internal-enc.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-internal.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-omac1.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-omac1.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-unwrap.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-unwrap.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes-wrap.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes-wrap.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes_i.h - copied unchanged from r214794, head/contrib/wpa/src/crypto/aes_i.h user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_internal-cipher.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/crypto_internal-cipher.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_internal-modexp.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/crypto_internal-modexp.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_internal-rsa.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/crypto_internal-rsa.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_nss.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/crypto_nss.c user/ed/compiler-rt/contrib/wpa/src/crypto/des-internal.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/des-internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/des_i.h - copied unchanged from r214794, head/contrib/wpa/src/crypto/des_i.h user/ed/compiler-rt/contrib/wpa/src/crypto/dh_group5.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/dh_group5.c user/ed/compiler-rt/contrib/wpa/src/crypto/dh_group5.h - copied unchanged from r214794, head/contrib/wpa/src/crypto/dh_group5.h user/ed/compiler-rt/contrib/wpa/src/crypto/fips_prf_cryptoapi.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/fips_prf_cryptoapi.c user/ed/compiler-rt/contrib/wpa/src/crypto/fips_prf_gnutls.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/fips_prf_gnutls.c user/ed/compiler-rt/contrib/wpa/src/crypto/fips_prf_internal.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/fips_prf_internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/fips_prf_nss.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/fips_prf_nss.c user/ed/compiler-rt/contrib/wpa/src/crypto/fips_prf_openssl.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/fips_prf_openssl.c user/ed/compiler-rt/contrib/wpa/src/crypto/md4-internal.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/md4-internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/md5-internal.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/md5-internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/md5-non-fips.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/md5-non-fips.c user/ed/compiler-rt/contrib/wpa/src/crypto/md5_i.h - copied unchanged from r214794, head/contrib/wpa/src/crypto/md5_i.h user/ed/compiler-rt/contrib/wpa/src/crypto/milenage.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/milenage.c user/ed/compiler-rt/contrib/wpa/src/crypto/milenage.h - copied unchanged from r214794, head/contrib/wpa/src/crypto/milenage.h user/ed/compiler-rt/contrib/wpa/src/crypto/sha1-internal.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/sha1-internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/sha1-pbkdf2.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/sha1-pbkdf2.c user/ed/compiler-rt/contrib/wpa/src/crypto/sha1-tlsprf.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/sha1-tlsprf.c user/ed/compiler-rt/contrib/wpa/src/crypto/sha1-tprf.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/sha1-tprf.c user/ed/compiler-rt/contrib/wpa/src/crypto/sha1_i.h - copied unchanged from r214794, head/contrib/wpa/src/crypto/sha1_i.h user/ed/compiler-rt/contrib/wpa/src/crypto/sha256-internal.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/sha256-internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/tls_nss.c - copied unchanged from r214794, head/contrib/wpa/src/crypto/tls_nss.c user/ed/compiler-rt/contrib/wpa/src/drivers/.gitignore - copied unchanged from r214794, head/contrib/wpa/src/drivers/.gitignore user/ed/compiler-rt/contrib/wpa/src/drivers/drivers.mak - copied unchanged from r214794, head/contrib/wpa/src/drivers/drivers.mak user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_aka.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_aka.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_fast.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_fast.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_gpsk.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_gpsk.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_gtc.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_gtc.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_identity.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_identity.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_ikev2.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_ikev2.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_md5.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_md5.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_methods.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_methods.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_mschapv2.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_mschapv2.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_pax.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_pax.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_peap.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_peap.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_psk.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_psk.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_sake.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_sake.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_sim.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_sim.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_tls.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_tls.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_tls_common.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_tls_common.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_tnc.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_tnc.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_ttls.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_ttls.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_vendor_test.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_vendor_test.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_server_wsc.c - copied unchanged from r214794, head/contrib/wpa/src/eap_server/eap_server_wsc.c user/ed/compiler-rt/contrib/wpa/src/eapol_auth/ - copied from r214794, head/contrib/wpa/src/eapol_auth/ user/ed/compiler-rt/contrib/wpa/src/lib.rules - copied unchanged from r214794, head/contrib/wpa/src/lib.rules user/ed/compiler-rt/contrib/wpa/src/radius/.gitignore - copied unchanged from r214794, head/contrib/wpa/src/radius/.gitignore user/ed/compiler-rt/contrib/wpa/src/tls/.gitignore - copied unchanged from r214794, head/contrib/wpa/src/tls/.gitignore user/ed/compiler-rt/contrib/wpa/src/tls/pkcs1.c - copied unchanged from r214794, head/contrib/wpa/src/tls/pkcs1.c user/ed/compiler-rt/contrib/wpa/src/tls/pkcs1.h - copied unchanged from r214794, head/contrib/wpa/src/tls/pkcs1.h user/ed/compiler-rt/contrib/wpa/src/tls/pkcs5.c - copied unchanged from r214794, head/contrib/wpa/src/tls/pkcs5.c user/ed/compiler-rt/contrib/wpa/src/tls/pkcs5.h - copied unchanged from r214794, head/contrib/wpa/src/tls/pkcs5.h user/ed/compiler-rt/contrib/wpa/src/tls/pkcs8.c - copied unchanged from r214794, head/contrib/wpa/src/tls/pkcs8.c user/ed/compiler-rt/contrib/wpa/src/tls/pkcs8.h - copied unchanged from r214794, head/contrib/wpa/src/tls/pkcs8.h user/ed/compiler-rt/contrib/wpa/src/utils/.gitignore - copied unchanged from r214794, head/contrib/wpa/src/utils/.gitignore user/ed/compiler-rt/contrib/wpa/src/utils/list.h - copied unchanged from r214794, head/contrib/wpa/src/utils/list.h user/ed/compiler-rt/contrib/wpa/src/utils/radiotap.c - copied unchanged from r214794, head/contrib/wpa/src/utils/radiotap.c user/ed/compiler-rt/contrib/wpa/src/utils/radiotap.h - copied unchanged from r214794, head/contrib/wpa/src/utils/radiotap.h user/ed/compiler-rt/contrib/wpa/src/utils/radiotap_iter.h - copied unchanged from r214794, head/contrib/wpa/src/utils/radiotap_iter.h user/ed/compiler-rt/contrib/wpa/src/utils/trace.c - copied unchanged from r214794, head/contrib/wpa/src/utils/trace.c user/ed/compiler-rt/contrib/wpa/src/utils/trace.h - copied unchanged from r214794, head/contrib/wpa/src/utils/trace.h user/ed/compiler-rt/contrib/wpa/src/wps/http.h - copied unchanged from r214794, head/contrib/wpa/src/wps/http.h user/ed/compiler-rt/contrib/wpa/src/wps/http_client.c - copied unchanged from r214794, head/contrib/wpa/src/wps/http_client.c user/ed/compiler-rt/contrib/wpa/src/wps/http_client.h - copied unchanged from r214794, head/contrib/wpa/src/wps/http_client.h user/ed/compiler-rt/contrib/wpa/src/wps/http_server.c - copied unchanged from r214794, head/contrib/wpa/src/wps/http_server.c user/ed/compiler-rt/contrib/wpa/src/wps/http_server.h - copied unchanged from r214794, head/contrib/wpa/src/wps/http_server.h user/ed/compiler-rt/contrib/wpa/src/wps/ndef.c - copied unchanged from r214794, head/contrib/wpa/src/wps/ndef.c user/ed/compiler-rt/contrib/wpa/src/wps/upnp_xml.c - copied unchanged from r214794, head/contrib/wpa/src/wps/upnp_xml.c user/ed/compiler-rt/contrib/wpa/src/wps/upnp_xml.h - copied unchanged from r214794, head/contrib/wpa/src/wps/upnp_xml.h user/ed/compiler-rt/contrib/wpa/src/wps/wps_er.c - copied unchanged from r214794, head/contrib/wpa/src/wps/wps_er.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_er.h - copied unchanged from r214794, head/contrib/wpa/src/wps/wps_er.h user/ed/compiler-rt/contrib/wpa/src/wps/wps_er_ssdp.c - copied unchanged from r214794, head/contrib/wpa/src/wps/wps_er_ssdp.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_nfc.c - copied unchanged from r214794, head/contrib/wpa/src/wps/wps_nfc.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_nfc_pn531.c - copied unchanged from r214794, head/contrib/wpa/src/wps/wps_nfc_pn531.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_ufd.c - copied unchanged from r214794, head/contrib/wpa/src/wps/wps_ufd.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_upnp_ap.c - copied unchanged from r214794, head/contrib/wpa/src/wps/wps_upnp_ap.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/.gitignore - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/.gitignore user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ap.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/ap.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ap.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/ap.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/bgscan.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/bgscan.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/bgscan.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/bgscan.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/bgscan_simple.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/bgscan_simple.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/bss.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/bss.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/bss.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/bss.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/dbus/ - copied from r214794, head/contrib/wpa/wpa_supplicant/dbus/ user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/.gitignore - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/doc/docbook/.gitignore user/ed/compiler-rt/contrib/wpa/wpa_supplicant/driver_i.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/driver_i.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/eap_register.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/eap_register.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/examples/60_wpa_supplicant - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/examples/60_wpa_supplicant user/ed/compiler-rt/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new-getall.py - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new-getall.py user/ed/compiler-rt/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new-signals.py - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new-signals.py user/ed/compiler-rt/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new-wps.py - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new-wps.py user/ed/compiler-rt/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new.py - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new.py user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ibss_rsn.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/ibss_rsn.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ibss_rsn.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/ibss_rsn.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/notify.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/notify.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/notify.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/notify.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/scan.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/scan.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/sme.c - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/sme.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/sme.h - copied unchanged from r214794, head/contrib/wpa/wpa_supplicant/sme.h user/ed/compiler-rt/sys/dev/agp/agp_apple.c - copied unchanged from r214794, head/sys/dev/agp/agp_apple.c user/ed/compiler-rt/sys/x86/include/ - copied from r214794, head/sys/x86/include/ user/ed/compiler-rt/tools/regression/bin/sh/parser/alias3.0 - copied unchanged from r214794, head/tools/regression/bin/sh/parser/alias3.0 Replaced: user/ed/compiler-rt/contrib/wpa/hostapd/ - copied from r214794, head/contrib/wpa/hostapd/ user/ed/compiler-rt/contrib/wpa/hostapd/ChangeLog - copied unchanged from r214794, head/contrib/wpa/hostapd/ChangeLog user/ed/compiler-rt/contrib/wpa/hostapd/Makefile - copied unchanged from r214794, head/contrib/wpa/hostapd/Makefile user/ed/compiler-rt/contrib/wpa/hostapd/README - copied unchanged from r214794, head/contrib/wpa/hostapd/README user/ed/compiler-rt/contrib/wpa/hostapd/README-WPS - copied unchanged from r214794, head/contrib/wpa/hostapd/README-WPS user/ed/compiler-rt/contrib/wpa/hostapd/ctrl_iface.c - copied unchanged from r214794, head/contrib/wpa/hostapd/ctrl_iface.c user/ed/compiler-rt/contrib/wpa/hostapd/ctrl_iface.h - copied unchanged from r214794, head/contrib/wpa/hostapd/ctrl_iface.h user/ed/compiler-rt/contrib/wpa/hostapd/defconfig - copied unchanged from r214794, head/contrib/wpa/hostapd/defconfig user/ed/compiler-rt/contrib/wpa/hostapd/eap_testing.txt - copied unchanged from r214794, head/contrib/wpa/hostapd/eap_testing.txt user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.8 - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.8 user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.accept - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.accept user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.conf - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.conf user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.deny - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.deny user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.eap_user - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.eap_user user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.radius_clients - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.radius_clients user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.sim_db - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.sim_db user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.vlan - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.vlan user/ed/compiler-rt/contrib/wpa/hostapd/hostapd.wpa_psk - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd.wpa_psk user/ed/compiler-rt/contrib/wpa/hostapd/hostapd_cli.1 - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd_cli.1 user/ed/compiler-rt/contrib/wpa/hostapd/hostapd_cli.c - copied unchanged from r214794, head/contrib/wpa/hostapd/hostapd_cli.c user/ed/compiler-rt/contrib/wpa/hostapd/logwatch/ - copied from r214794, head/contrib/wpa/hostapd/logwatch/ user/ed/compiler-rt/contrib/wpa/hostapd/logwatch/README - copied unchanged from r214794, head/contrib/wpa/hostapd/logwatch/README user/ed/compiler-rt/contrib/wpa/hostapd/logwatch/hostapd - copied unchanged from r214794, head/contrib/wpa/hostapd/logwatch/hostapd user/ed/compiler-rt/contrib/wpa/hostapd/logwatch/hostapd.conf - copied unchanged from r214794, head/contrib/wpa/hostapd/logwatch/hostapd.conf user/ed/compiler-rt/contrib/wpa/hostapd/nt_password_hash.c - copied unchanged from r214794, head/contrib/wpa/hostapd/nt_password_hash.c user/ed/compiler-rt/contrib/wpa/hostapd/wired.conf - copied unchanged from r214794, head/contrib/wpa/hostapd/wired.conf Deleted: user/ed/compiler-rt/contrib/wpa/src/common/nl80211_copy.h user/ed/compiler-rt/contrib/wpa/src/common/wireless_copy.h user/ed/compiler-rt/contrib/wpa/src/crypto/aes.c user/ed/compiler-rt/contrib/wpa/src/crypto/aes_wrap.c user/ed/compiler-rt/contrib/wpa/src/crypto/des.c user/ed/compiler-rt/contrib/wpa/src/crypto/md4.c user/ed/compiler-rt/contrib/wpa/src/crypto/rc4.h user/ed/compiler-rt/contrib/wpa/src/drivers/radiotap.c user/ed/compiler-rt/contrib/wpa/src/drivers/radiotap.h user/ed/compiler-rt/contrib/wpa/src/drivers/radiotap_iter.h user/ed/compiler-rt/contrib/wpa/src/drivers/scan_helpers.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_aka.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_fast.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_gpsk.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_gtc.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_identity.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_ikev2.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_md5.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_methods.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_mschapv2.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_pax.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_peap.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_psk.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_sake.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_sim.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_tls.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_tls_common.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_tnc.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_ttls.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_vendor_test.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_wsc.c user/ed/compiler-rt/contrib/wpa/src/hlr_auc_gw/Makefile user/ed/compiler-rt/contrib/wpa/src/hlr_auc_gw/hlr_auc_gw.c user/ed/compiler-rt/contrib/wpa/src/hlr_auc_gw/hlr_auc_gw.milenage_db user/ed/compiler-rt/contrib/wpa/src/hlr_auc_gw/milenage.c user/ed/compiler-rt/contrib/wpa/src/hlr_auc_gw/milenage.h user/ed/compiler-rt/contrib/wpa/src/tls/asn1_test.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface_dbus.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface_dbus.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface_dbus_handlers.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface_dbus_handlers.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/dbus-wpa_supplicant.conf user/ed/compiler-rt/contrib/wpa/wpa_supplicant/dbus-wpa_supplicant.service user/ed/compiler-rt/contrib/wpa/wpa_supplicant/dbus_dict_helpers.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/dbus_dict_helpers.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/code_structure.doxygen user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/ctrl_iface.doxygen user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/doxygen.fast user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/doxygen.full user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/driver_wrapper.doxygen user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/eap.doxygen user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/kerneldoc2doxygen.pl user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/mainpage.doxygen user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/porting.doxygen user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/testing_tools.doxygen user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/wpa_supplicant.fig user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_aes.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_md4.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_md5.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_ms_funcs.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_sha1.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_sha256.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_x509v3.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_x509v3_nist.sh user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_x509v3_nist2.sh user/ed/compiler-rt/sys/amd64/include/apicreg.h user/ed/compiler-rt/sys/amd64/include/mca.h user/ed/compiler-rt/sys/i386/include/apicreg.h user/ed/compiler-rt/sys/i386/include/mca.h user/ed/compiler-rt/sys/pc98/include/apicreg.h user/ed/compiler-rt/sys/pc98/include/mca.h Modified: user/ed/compiler-rt/ObsoleteFiles.inc user/ed/compiler-rt/bin/rm/rm.1 user/ed/compiler-rt/bin/sh/eval.c user/ed/compiler-rt/bin/sh/parser.c user/ed/compiler-rt/bin/sh/sh.1 user/ed/compiler-rt/bin/stty/key.c user/ed/compiler-rt/cddl/contrib/opensolaris/cmd/ztest/ztest.c user/ed/compiler-rt/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c user/ed/compiler-rt/contrib/bind9/CHANGES user/ed/compiler-rt/contrib/bind9/README user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keygen.html user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-signzone.html user/ed/compiler-rt/contrib/bind9/bin/named/include/named/globals.h user/ed/compiler-rt/contrib/bind9/bin/named/main.c user/ed/compiler-rt/contrib/bind9/bin/named/query.c user/ed/compiler-rt/contrib/bind9/bin/named/server.c user/ed/compiler-rt/contrib/bind9/bin/nsupdate/nsupdate.html user/ed/compiler-rt/contrib/bind9/doc/arm/Bv9ARM-book.xml user/ed/compiler-rt/contrib/bind9/doc/arm/Bv9ARM.ch06.html user/ed/compiler-rt/contrib/bind9/doc/arm/Bv9ARM.ch07.html user/ed/compiler-rt/contrib/bind9/doc/arm/Bv9ARM.ch08.html user/ed/compiler-rt/contrib/bind9/doc/arm/Bv9ARM.ch09.html user/ed/compiler-rt/contrib/bind9/doc/arm/Bv9ARM.html user/ed/compiler-rt/contrib/bind9/doc/arm/Bv9ARM.pdf user/ed/compiler-rt/contrib/bind9/doc/arm/isc-logo.eps user/ed/compiler-rt/contrib/bind9/doc/arm/isc-logo.pdf user/ed/compiler-rt/contrib/bind9/doc/arm/man.dig.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.dnssec-dsfromkey.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.dnssec-keyfromlabel.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.dnssec-keygen.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.dnssec-signzone.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.host.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.named-checkconf.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.named-checkzone.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.named.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.nsupdate.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.rndc-confgen.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.rndc.conf.html user/ed/compiler-rt/contrib/bind9/doc/arm/man.rndc.html user/ed/compiler-rt/contrib/bind9/lib/dns/adb.c user/ed/compiler-rt/contrib/bind9/lib/dns/api user/ed/compiler-rt/contrib/bind9/lib/dns/include/dns/diff.h user/ed/compiler-rt/contrib/bind9/lib/dns/include/dns/ncache.h user/ed/compiler-rt/contrib/bind9/lib/dns/include/dns/rdataset.h user/ed/compiler-rt/contrib/bind9/lib/dns/include/dns/resolver.h user/ed/compiler-rt/contrib/bind9/lib/dns/include/dns/result.h user/ed/compiler-rt/contrib/bind9/lib/dns/include/dns/types.h user/ed/compiler-rt/contrib/bind9/lib/dns/include/dns/validator.h user/ed/compiler-rt/contrib/bind9/lib/dns/ncache.c user/ed/compiler-rt/contrib/bind9/lib/dns/rbtdb.c user/ed/compiler-rt/contrib/bind9/lib/dns/rdatalist.c user/ed/compiler-rt/contrib/bind9/lib/dns/rdataset.c user/ed/compiler-rt/contrib/bind9/lib/dns/rdataslab.c user/ed/compiler-rt/contrib/bind9/lib/dns/resolver.c user/ed/compiler-rt/contrib/bind9/lib/dns/result.c user/ed/compiler-rt/contrib/bind9/lib/dns/sdb.c user/ed/compiler-rt/contrib/bind9/lib/dns/sdlz.c user/ed/compiler-rt/contrib/bind9/lib/dns/validator.c user/ed/compiler-rt/contrib/bind9/lib/dns/view.c user/ed/compiler-rt/contrib/bind9/lib/isc/api user/ed/compiler-rt/contrib/bind9/lib/isc/include/isc/mem.h user/ed/compiler-rt/contrib/bind9/lib/isc/mem.c user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_buffer.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_config.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_context.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_gabn.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_gai_strerror.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_getaddrinfo.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_gethostent.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_getipnode.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_getnameinfo.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_getrrsetbyname.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_gnba.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_hstrerror.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_inetntop.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_noop.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_packet.html user/ed/compiler-rt/contrib/bind9/lib/lwres/man/lwres_resutil.html user/ed/compiler-rt/contrib/bind9/version user/ed/compiler-rt/contrib/gdb/gdb/dwarf2read.c user/ed/compiler-rt/contrib/gdb/gdb/mipsfbsd-tdep.c user/ed/compiler-rt/contrib/tzdata/australasia user/ed/compiler-rt/contrib/wpa/src/Makefile user/ed/compiler-rt/contrib/wpa/src/common/Makefile user/ed/compiler-rt/contrib/wpa/src/common/defs.h user/ed/compiler-rt/contrib/wpa/src/common/ieee802_11_common.c user/ed/compiler-rt/contrib/wpa/src/common/ieee802_11_common.h user/ed/compiler-rt/contrib/wpa/src/common/ieee802_11_defs.h user/ed/compiler-rt/contrib/wpa/src/common/privsep_commands.h user/ed/compiler-rt/contrib/wpa/src/common/version.h user/ed/compiler-rt/contrib/wpa/src/common/wpa_common.c user/ed/compiler-rt/contrib/wpa/src/common/wpa_common.h user/ed/compiler-rt/contrib/wpa/src/common/wpa_ctrl.h user/ed/compiler-rt/contrib/wpa/src/crypto/Makefile user/ed/compiler-rt/contrib/wpa/src/crypto/aes.h user/ed/compiler-rt/contrib/wpa/src/crypto/crypto.h user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_cryptoapi.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_gnutls.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_libtomcrypt.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_none.c user/ed/compiler-rt/contrib/wpa/src/crypto/crypto_openssl.c user/ed/compiler-rt/contrib/wpa/src/crypto/dh_groups.c user/ed/compiler-rt/contrib/wpa/src/crypto/md5.c user/ed/compiler-rt/contrib/wpa/src/crypto/md5.h user/ed/compiler-rt/contrib/wpa/src/crypto/ms_funcs.c user/ed/compiler-rt/contrib/wpa/src/crypto/ms_funcs.h user/ed/compiler-rt/contrib/wpa/src/crypto/rc4.c user/ed/compiler-rt/contrib/wpa/src/crypto/sha1.c user/ed/compiler-rt/contrib/wpa/src/crypto/sha1.h user/ed/compiler-rt/contrib/wpa/src/crypto/sha256.c user/ed/compiler-rt/contrib/wpa/src/crypto/tls.h user/ed/compiler-rt/contrib/wpa/src/crypto/tls_gnutls.c user/ed/compiler-rt/contrib/wpa/src/crypto/tls_internal.c user/ed/compiler-rt/contrib/wpa/src/crypto/tls_none.c user/ed/compiler-rt/contrib/wpa/src/crypto/tls_openssl.c user/ed/compiler-rt/contrib/wpa/src/crypto/tls_schannel.c user/ed/compiler-rt/contrib/wpa/src/drivers/Makefile user/ed/compiler-rt/contrib/wpa/src/drivers/driver.h user/ed/compiler-rt/contrib/wpa/src/drivers/driver_ndis.c user/ed/compiler-rt/contrib/wpa/src/drivers/driver_ndis.h user/ed/compiler-rt/contrib/wpa/src/drivers/driver_ndiswrapper.c user/ed/compiler-rt/contrib/wpa/src/drivers/driver_wired.c user/ed/compiler-rt/contrib/wpa/src/drivers/drivers.c user/ed/compiler-rt/contrib/wpa/src/eap_common/Makefile user/ed/compiler-rt/contrib/wpa/src/eap_common/chap.c user/ed/compiler-rt/contrib/wpa/src/eap_common/chap.h user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_fast_common.c user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_gpsk_common.c user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_pax_common.c user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_peap_common.c user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_psk_common.c user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_sake_common.c user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_sim_common.c user/ed/compiler-rt/contrib/wpa/src/eap_common/eap_sim_common.h user/ed/compiler-rt/contrib/wpa/src/eap_common/ikev2_common.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/Makefile user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap.h user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_aka.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_config.h user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_fast.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_fast_pac.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_leap.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_md5.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_methods.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_methods.h user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_mschapv2.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_pax.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_peap.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_psk.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_sim.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_tls.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_tls_common.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_tls_common.h user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_tnc.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_ttls.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/eap_wsc.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/ikev2.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/mschapv2.c user/ed/compiler-rt/contrib/wpa/src/eap_peer/mschapv2.h user/ed/compiler-rt/contrib/wpa/src/eap_server/Makefile user/ed/compiler-rt/contrib/wpa/src/eap_server/eap.h user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_i.h user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_methods.h user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_sim_db.c user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_sim_db.h user/ed/compiler-rt/contrib/wpa/src/eap_server/eap_tls_common.h user/ed/compiler-rt/contrib/wpa/src/eap_server/ikev2.c user/ed/compiler-rt/contrib/wpa/src/eap_server/tncs.c user/ed/compiler-rt/contrib/wpa/src/eapol_supp/Makefile user/ed/compiler-rt/contrib/wpa/src/eapol_supp/eapol_supp_sm.c user/ed/compiler-rt/contrib/wpa/src/eapol_supp/eapol_supp_sm.h user/ed/compiler-rt/contrib/wpa/src/l2_packet/Makefile user/ed/compiler-rt/contrib/wpa/src/l2_packet/l2_packet_freebsd.c user/ed/compiler-rt/contrib/wpa/src/l2_packet/l2_packet_ndis.c user/ed/compiler-rt/contrib/wpa/src/radius/Makefile user/ed/compiler-rt/contrib/wpa/src/radius/radius.c user/ed/compiler-rt/contrib/wpa/src/radius/radius.h user/ed/compiler-rt/contrib/wpa/src/radius/radius_client.c user/ed/compiler-rt/contrib/wpa/src/radius/radius_client.h user/ed/compiler-rt/contrib/wpa/src/radius/radius_server.c user/ed/compiler-rt/contrib/wpa/src/radius/radius_server.h user/ed/compiler-rt/contrib/wpa/src/rsn_supp/Makefile user/ed/compiler-rt/contrib/wpa/src/rsn_supp/peerkey.c user/ed/compiler-rt/contrib/wpa/src/rsn_supp/pmksa_cache.c user/ed/compiler-rt/contrib/wpa/src/rsn_supp/pmksa_cache.h user/ed/compiler-rt/contrib/wpa/src/rsn_supp/preauth.c user/ed/compiler-rt/contrib/wpa/src/rsn_supp/preauth.h user/ed/compiler-rt/contrib/wpa/src/rsn_supp/wpa.c user/ed/compiler-rt/contrib/wpa/src/rsn_supp/wpa.h user/ed/compiler-rt/contrib/wpa/src/rsn_supp/wpa_ft.c user/ed/compiler-rt/contrib/wpa/src/rsn_supp/wpa_i.h user/ed/compiler-rt/contrib/wpa/src/rsn_supp/wpa_ie.c user/ed/compiler-rt/contrib/wpa/src/rsn_supp/wpa_ie.h user/ed/compiler-rt/contrib/wpa/src/tls/Makefile user/ed/compiler-rt/contrib/wpa/src/tls/asn1.c user/ed/compiler-rt/contrib/wpa/src/tls/asn1.h user/ed/compiler-rt/contrib/wpa/src/tls/rsa.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_client.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_client_read.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_client_write.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_common.h user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_cred.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_record.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_record.h user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_server.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_server_read.c user/ed/compiler-rt/contrib/wpa/src/tls/tlsv1_server_write.c user/ed/compiler-rt/contrib/wpa/src/tls/x509v3.c user/ed/compiler-rt/contrib/wpa/src/tls/x509v3.h user/ed/compiler-rt/contrib/wpa/src/utils/Makefile user/ed/compiler-rt/contrib/wpa/src/utils/base64.c user/ed/compiler-rt/contrib/wpa/src/utils/build_config.h user/ed/compiler-rt/contrib/wpa/src/utils/common.c user/ed/compiler-rt/contrib/wpa/src/utils/common.h user/ed/compiler-rt/contrib/wpa/src/utils/eloop.c user/ed/compiler-rt/contrib/wpa/src/utils/eloop.h user/ed/compiler-rt/contrib/wpa/src/utils/eloop_none.c user/ed/compiler-rt/contrib/wpa/src/utils/eloop_win.c user/ed/compiler-rt/contrib/wpa/src/utils/ip_addr.h user/ed/compiler-rt/contrib/wpa/src/utils/os.h user/ed/compiler-rt/contrib/wpa/src/utils/os_internal.c user/ed/compiler-rt/contrib/wpa/src/utils/os_unix.c user/ed/compiler-rt/contrib/wpa/src/utils/uuid.c user/ed/compiler-rt/contrib/wpa/src/utils/uuid.h user/ed/compiler-rt/contrib/wpa/src/utils/wpa_debug.c user/ed/compiler-rt/contrib/wpa/src/utils/wpa_debug.h user/ed/compiler-rt/contrib/wpa/src/utils/wpabuf.c user/ed/compiler-rt/contrib/wpa/src/utils/wpabuf.h user/ed/compiler-rt/contrib/wpa/src/wps/Makefile user/ed/compiler-rt/contrib/wpa/src/wps/httpread.c user/ed/compiler-rt/contrib/wpa/src/wps/httpread.h user/ed/compiler-rt/contrib/wpa/src/wps/wps.c user/ed/compiler-rt/contrib/wpa/src/wps/wps.h user/ed/compiler-rt/contrib/wpa/src/wps/wps_attr_build.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_attr_parse.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_attr_process.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_common.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_defs.h user/ed/compiler-rt/contrib/wpa/src/wps/wps_dev_attr.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_enrollee.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_i.h user/ed/compiler-rt/contrib/wpa/src/wps/wps_registrar.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_upnp.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_upnp.h user/ed/compiler-rt/contrib/wpa/src/wps/wps_upnp_event.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_upnp_i.h user/ed/compiler-rt/contrib/wpa/src/wps/wps_upnp_ssdp.c user/ed/compiler-rt/contrib/wpa/src/wps/wps_upnp_web.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ChangeLog user/ed/compiler-rt/contrib/wpa/wpa_supplicant/Makefile user/ed/compiler-rt/contrib/wpa/wpa_supplicant/README user/ed/compiler-rt/contrib/wpa/wpa_supplicant/README-WPS user/ed/compiler-rt/contrib/wpa/wpa_supplicant/config.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/config.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/config_file.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/config_ssid.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface_named_pipe.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface_udp.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/ctrl_iface_unix.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/defconfig user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_background.8 user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_cli.8 user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_gui.8 user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_passphrase.8 user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_priv.8 user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_supplicant.8 user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_supplicant.conf.5 user/ed/compiler-rt/contrib/wpa/wpa_supplicant/doc/docbook/wpa_supplicant.sgml user/ed/compiler-rt/contrib/wpa/wpa_supplicant/eapol_test.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/events.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/main.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/mlme.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/mlme.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/nmake.mak user/ed/compiler-rt/contrib/wpa/wpa_supplicant/preauth_test.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/scan.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_eap_sim_common.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/tests/test_wpa.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/todo.txt user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpa_cli.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpa_passphrase.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpa_priv.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpa_supplicant.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpa_supplicant.conf user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpa_supplicant.nsi user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpa_supplicant_i.h user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wpas_glue.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wps_supplicant.c user/ed/compiler-rt/contrib/wpa/wpa_supplicant/wps_supplicant.h user/ed/compiler-rt/include/Makefile user/ed/compiler-rt/include/termios.h user/ed/compiler-rt/lib/bind/config.h user/ed/compiler-rt/lib/bind/isc/isc/platform.h user/ed/compiler-rt/lib/clang/Makefile user/ed/compiler-rt/lib/libc/gen/Makefile.inc user/ed/compiler-rt/lib/libc/gen/Symbol.map user/ed/compiler-rt/lib/libc/gen/tcsetattr.3 user/ed/compiler-rt/lib/libc/gen/termios.c user/ed/compiler-rt/lib/libthr/thread/thr_attr.c user/ed/compiler-rt/libexec/getty/main.c user/ed/compiler-rt/libexec/rlogind/rlogind.c user/ed/compiler-rt/libexec/rtld-elf/rtld.c user/ed/compiler-rt/libexec/rtld-elf/rtld.h user/ed/compiler-rt/sbin/camcontrol/camcontrol.c user/ed/compiler-rt/sbin/hastd/primary.c user/ed/compiler-rt/share/man/man9/BUS_SETUP_INTR.9 user/ed/compiler-rt/share/man/man9/locking.9 user/ed/compiler-rt/share/man/man9/sysctl_ctx_init.9 user/ed/compiler-rt/share/misc/bsd-family-tree user/ed/compiler-rt/sys/amd64/acpica/acpi_wakeup.c user/ed/compiler-rt/sys/amd64/acpica/madt.c user/ed/compiler-rt/sys/amd64/amd64/apic_vector.S user/ed/compiler-rt/sys/amd64/amd64/genassym.c user/ed/compiler-rt/sys/amd64/amd64/machdep.c user/ed/compiler-rt/sys/amd64/amd64/mp_machdep.c user/ed/compiler-rt/sys/amd64/amd64/mp_watchdog.c user/ed/compiler-rt/sys/amd64/amd64/pmap.c user/ed/compiler-rt/sys/amd64/amd64/trap.c user/ed/compiler-rt/sys/arm/arm/elf_trampoline.c user/ed/compiler-rt/sys/conf/files user/ed/compiler-rt/sys/conf/files.powerpc user/ed/compiler-rt/sys/conf/kern.post.mk user/ed/compiler-rt/sys/conf/kmod.mk user/ed/compiler-rt/sys/conf/options.powerpc user/ed/compiler-rt/sys/dev/acpica/acpi.c user/ed/compiler-rt/sys/dev/agp/agp.c user/ed/compiler-rt/sys/dev/ata/chipsets/ata-intel.c user/ed/compiler-rt/sys/dev/e1000/e1000_82571.c user/ed/compiler-rt/sys/dev/e1000/if_em.c user/ed/compiler-rt/sys/dev/e1000/if_lem.c user/ed/compiler-rt/sys/dev/e1000/if_lem.h user/ed/compiler-rt/sys/dev/mii/e1000phy.c user/ed/compiler-rt/sys/dev/mii/mii_physubr.c user/ed/compiler-rt/sys/dev/mii/miivar.h user/ed/compiler-rt/sys/dev/usb/net/uhso.c user/ed/compiler-rt/sys/dev/usb/serial/u3g.c user/ed/compiler-rt/sys/dev/usb/serial/uark.c user/ed/compiler-rt/sys/dev/usb/serial/ubsa.c user/ed/compiler-rt/sys/dev/usb/serial/ubser.c user/ed/compiler-rt/sys/dev/usb/serial/uchcom.c user/ed/compiler-rt/sys/dev/usb/serial/ucycom.c user/ed/compiler-rt/sys/dev/usb/serial/ufoma.c user/ed/compiler-rt/sys/dev/usb/serial/uftdi.c user/ed/compiler-rt/sys/dev/usb/serial/ugensa.c user/ed/compiler-rt/sys/dev/usb/serial/uipaq.c user/ed/compiler-rt/sys/dev/usb/serial/umct.c user/ed/compiler-rt/sys/dev/usb/serial/umodem.c user/ed/compiler-rt/sys/dev/usb/serial/umoscom.c user/ed/compiler-rt/sys/dev/usb/serial/uplcom.c user/ed/compiler-rt/sys/dev/usb/serial/usb_serial.c user/ed/compiler-rt/sys/dev/usb/serial/usb_serial.h user/ed/compiler-rt/sys/dev/usb/serial/uslcom.c user/ed/compiler-rt/sys/dev/usb/serial/uvisor.c user/ed/compiler-rt/sys/dev/usb/serial/uvscom.c user/ed/compiler-rt/sys/dev/usb/usbdevs user/ed/compiler-rt/sys/geom/geom_event.c user/ed/compiler-rt/sys/i386/acpica/acpi_wakeup.c user/ed/compiler-rt/sys/i386/acpica/madt.c user/ed/compiler-rt/sys/i386/i386/apic_vector.s user/ed/compiler-rt/sys/i386/i386/genassym.c user/ed/compiler-rt/sys/i386/i386/machdep.c user/ed/compiler-rt/sys/i386/i386/mp_machdep.c user/ed/compiler-rt/sys/i386/i386/mp_watchdog.c user/ed/compiler-rt/sys/i386/i386/mpboot.s user/ed/compiler-rt/sys/i386/i386/trap.c user/ed/compiler-rt/sys/i386/xen/mp_machdep.c user/ed/compiler-rt/sys/i386/xen/mptable.c user/ed/compiler-rt/sys/kern/kern_clock.c user/ed/compiler-rt/sys/kern/kern_cpuset.c user/ed/compiler-rt/sys/kern/kern_timeout.c user/ed/compiler-rt/sys/kern/sched_ule.c user/ed/compiler-rt/sys/kern/vfs_cache.c user/ed/compiler-rt/sys/mips/cavium/octeon_ebt3000_cf.c user/ed/compiler-rt/sys/mips/cavium/octopci.c user/ed/compiler-rt/sys/modules/Makefile user/ed/compiler-rt/sys/modules/agp/Makefile user/ed/compiler-rt/sys/netinet/if_ether.c user/ed/compiler-rt/sys/netinet/libalias/alias.c user/ed/compiler-rt/sys/netipsec/ipsec.c user/ed/compiler-rt/sys/pc98/include/bus.h user/ed/compiler-rt/sys/pc98/pc98/busiosubr.c user/ed/compiler-rt/sys/pc98/pc98/machdep.c user/ed/compiler-rt/sys/powerpc/aim/copyinout.c user/ed/compiler-rt/sys/powerpc/aim/mmu_oea.c user/ed/compiler-rt/sys/powerpc/aim/mmu_oea64.c user/ed/compiler-rt/sys/powerpc/aim/slb.c user/ed/compiler-rt/sys/powerpc/aim/swtch32.S user/ed/compiler-rt/sys/powerpc/aim/swtch64.S user/ed/compiler-rt/sys/powerpc/aim/trap.c user/ed/compiler-rt/sys/powerpc/aim/trap_subr32.S user/ed/compiler-rt/sys/powerpc/aim/trap_subr64.S user/ed/compiler-rt/sys/powerpc/aim/vm_machdep.c user/ed/compiler-rt/sys/powerpc/conf/GENERIC user/ed/compiler-rt/sys/powerpc/conf/GENERIC64 user/ed/compiler-rt/sys/powerpc/conf/NOTES user/ed/compiler-rt/sys/powerpc/include/pcb.h user/ed/compiler-rt/sys/powerpc/include/slb.h user/ed/compiler-rt/sys/powerpc/include/sr.h user/ed/compiler-rt/sys/powerpc/powermac/cpcht.c user/ed/compiler-rt/sys/powerpc/powerpc/exec_machdep.c user/ed/compiler-rt/sys/powerpc/powerpc/genassym.c user/ed/compiler-rt/sys/sys/interrupt.h user/ed/compiler-rt/sys/vm/uma_core.c user/ed/compiler-rt/sys/vm/vm_phys.c user/ed/compiler-rt/sys/vm/vm_reserv.c user/ed/compiler-rt/sys/x86/x86/io_apic.c user/ed/compiler-rt/sys/x86/x86/local_apic.c user/ed/compiler-rt/sys/x86/x86/mca.c user/ed/compiler-rt/sys/x86/x86/mptable.c user/ed/compiler-rt/sys/x86/x86/msi.c user/ed/compiler-rt/sys/x86/x86/nexus.c user/ed/compiler-rt/usr.bin/kdump/kdump.1 user/ed/compiler-rt/usr.bin/locate/locate/locate.rc user/ed/compiler-rt/usr.bin/locate/locate/updatedb.sh user/ed/compiler-rt/usr.sbin/config/mkmakefile.c user/ed/compiler-rt/usr.sbin/mfiutil/mfi_cmd.c user/ed/compiler-rt/usr.sbin/tcpdump/tcpdump/Makefile user/ed/compiler-rt/usr.sbin/tcpdump/tcpdump/config.h user/ed/compiler-rt/usr.sbin/wpa/hostapd/Makefile user/ed/compiler-rt/usr.sbin/wpa/hostapd/driver_freebsd.c user/ed/compiler-rt/usr.sbin/wpa/wpa_passphrase/Makefile user/ed/compiler-rt/usr.sbin/wpa/wpa_supplicant/Makefile user/ed/compiler-rt/usr.sbin/wpa/wpa_supplicant/driver_freebsd.c Directory Properties: user/ed/compiler-rt/ (props changed) user/ed/compiler-rt/cddl/contrib/opensolaris/ (props changed) user/ed/compiler-rt/contrib/bind9/ (props changed) user/ed/compiler-rt/contrib/binutils/ (props changed) user/ed/compiler-rt/contrib/bzip2/ (props changed) user/ed/compiler-rt/contrib/ee/ (props changed) user/ed/compiler-rt/contrib/expat/ (props changed) user/ed/compiler-rt/contrib/file/ (props changed) user/ed/compiler-rt/contrib/gdb/ (props changed) user/ed/compiler-rt/contrib/gdtoa/ (props changed) user/ed/compiler-rt/contrib/gnu-sort/ (props changed) user/ed/compiler-rt/contrib/groff/ (props changed) user/ed/compiler-rt/contrib/less/ (props changed) user/ed/compiler-rt/contrib/libpcap/ (props changed) user/ed/compiler-rt/contrib/llvm/ (props changed) user/ed/compiler-rt/contrib/llvm/tools/clang/ (props changed) user/ed/compiler-rt/contrib/ncurses/ (props changed) user/ed/compiler-rt/contrib/netcat/ (props changed) user/ed/compiler-rt/contrib/ntp/ (props changed) user/ed/compiler-rt/contrib/one-true-awk/ (props changed) user/ed/compiler-rt/contrib/openbsm/ (props changed) user/ed/compiler-rt/contrib/openpam/ (props changed) user/ed/compiler-rt/contrib/pf/ (props changed) user/ed/compiler-rt/contrib/sendmail/ (props changed) user/ed/compiler-rt/contrib/tcpdump/ (props changed) user/ed/compiler-rt/contrib/tcsh/ (props changed) user/ed/compiler-rt/contrib/top/ (props changed) user/ed/compiler-rt/contrib/top/install-sh (props changed) user/ed/compiler-rt/contrib/tzcode/stdtime/ (props changed) user/ed/compiler-rt/contrib/tzcode/zic/ (props changed) user/ed/compiler-rt/contrib/tzdata/ (props changed) user/ed/compiler-rt/contrib/wpa/ (props changed) user/ed/compiler-rt/contrib/xz/ (props changed) user/ed/compiler-rt/crypto/openssh/ (props changed) user/ed/compiler-rt/crypto/openssl/ (props changed) user/ed/compiler-rt/lib/libc/ (props changed) user/ed/compiler-rt/lib/libc/stdtime/ (props changed) user/ed/compiler-rt/lib/libutil/ (props changed) user/ed/compiler-rt/lib/libz/ (props changed) user/ed/compiler-rt/sbin/ (props changed) user/ed/compiler-rt/sbin/ipfw/ (props changed) user/ed/compiler-rt/share/mk/bsd.arch.inc.mk (props changed) user/ed/compiler-rt/share/zoneinfo/ (props changed) user/ed/compiler-rt/sys/ (props changed) user/ed/compiler-rt/sys/amd64/include/xen/ (props changed) user/ed/compiler-rt/sys/cddl/contrib/opensolaris/ (props changed) user/ed/compiler-rt/sys/contrib/dev/acpica/ (props changed) user/ed/compiler-rt/sys/contrib/pf/ (props changed) user/ed/compiler-rt/sys/contrib/x86emu/ (props changed) user/ed/compiler-rt/sys/dev/xen/xenpci/ (props changed) user/ed/compiler-rt/usr.bin/calendar/ (props changed) user/ed/compiler-rt/usr.bin/csup/ (props changed) user/ed/compiler-rt/usr.bin/procstat/ (props changed) user/ed/compiler-rt/usr.sbin/zic/ (props changed) Modified: user/ed/compiler-rt/ObsoleteFiles.inc ============================================================================== --- user/ed/compiler-rt/ObsoleteFiles.inc Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/ObsoleteFiles.inc Thu Nov 4 18:24:05 2010 (r214796) @@ -14,6 +14,11 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20101101: headers moved to machine/ to x86/ +.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386" +OLD_FILES+=usr/include/machine/apicreg.h +OLD_FILES+=usr/include/machine/mca.h +.endif # 20101020: catch up with vm_page_sleep_if_busy rename OLD_FILES+=usr/share/man/man9/vm_page_sleep_busy.9.gz # 20101011: removed subblock.h from liblzma Modified: user/ed/compiler-rt/bin/rm/rm.1 ============================================================================== --- user/ed/compiler-rt/bin/rm/rm.1 Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/bin/rm/rm.1 Thu Nov 4 18:24:05 2010 (r214796) @@ -32,7 +32,7 @@ .\" @(#)rm.1 8.5 (Berkeley) 12/5/94 .\" $FreeBSD$ .\" -.Dd October 8, 2010 +.Dd October 31, 2010 .Dt RM 1 .Os .Sh NAME @@ -100,6 +100,11 @@ Specifying this flag for a read only fil .Nm to generate an error message and exit. The file will not be removed or overwritten. +.Pp +N.B.: The +.Fl P +flag is not considered a security feature +.Pq see Sx BUGS . .It Fl R Attempt to remove the file hierarchy rooted in each .Ar file @@ -229,8 +234,12 @@ command appeared in .Sh BUGS The .Fl P -option assumes that the underlying file system updates existing blocks -in-place and does not store new data in a new location. -This is true for UFS, but not for ZFS or other file systems which use -copy-on-write semantics. -In addition, only regular files are overwritten. +option assumes that the underlying storage overwrites file blocks +when data is written to an existing offset. +Several factors including the file system and its backing store could defeat +this assumption. +This includes, but is not limited to file systems that use a +Copy-On-Write strategy (e.g. ZFS or UFS when snapshots are being used), Flash +media that are using a wear leveling algorithm, or when the backing datastore +does journaling, etc. +In addition, only regular files are overwritten, other types of files are not. Modified: user/ed/compiler-rt/bin/sh/eval.c ============================================================================== --- user/ed/compiler-rt/bin/sh/eval.c Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/bin/sh/eval.c Thu Nov 4 18:24:05 2010 (r214796) @@ -196,6 +196,7 @@ void evaltree(union node *n, int flags) { int do_etest; + union node *next; do_etest = 0; if (n == NULL) { @@ -203,84 +204,88 @@ evaltree(union node *n, int flags) exitstatus = 0; goto out; } + do { + next = NULL; #ifndef NO_HISTORY - displayhist = 1; /* show history substitutions done with fc */ + displayhist = 1; /* show history substitutions done with fc */ #endif - TRACE(("evaltree(%p: %d) called\n", (void *)n, n->type)); - switch (n->type) { - case NSEMI: - evaltree(n->nbinary.ch1, flags & ~EV_EXIT); - if (evalskip) - goto out; - evaltree(n->nbinary.ch2, flags); - break; - case NAND: - evaltree(n->nbinary.ch1, EV_TESTED); - if (evalskip || exitstatus != 0) { - goto out; + TRACE(("evaltree(%p: %d) called\n", (void *)n, n->type)); + switch (n->type) { + case NSEMI: + evaltree(n->nbinary.ch1, flags & ~EV_EXIT); + if (evalskip) + goto out; + next = n->nbinary.ch2; + break; + case NAND: + evaltree(n->nbinary.ch1, EV_TESTED); + if (evalskip || exitstatus != 0) { + goto out; + } + next = n->nbinary.ch2; + break; + case NOR: + evaltree(n->nbinary.ch1, EV_TESTED); + if (evalskip || exitstatus == 0) + goto out; + next = n->nbinary.ch2; + break; + case NREDIR: + evalredir(n, flags); + break; + case NSUBSHELL: + evalsubshell(n, flags); + do_etest = !(flags & EV_TESTED); + break; + case NBACKGND: + evalsubshell(n, flags); + break; + case NIF: { + evaltree(n->nif.test, EV_TESTED); + if (evalskip) + goto out; + if (exitstatus == 0) + next = n->nif.ifpart; + else if (n->nif.elsepart) + next = n->nif.elsepart; + else + exitstatus = 0; + break; } - evaltree(n->nbinary.ch2, flags); - break; - case NOR: - evaltree(n->nbinary.ch1, EV_TESTED); - if (evalskip || exitstatus == 0) - goto out; - evaltree(n->nbinary.ch2, flags); - break; - case NREDIR: - evalredir(n, flags); - break; - case NSUBSHELL: - evalsubshell(n, flags); - do_etest = !(flags & EV_TESTED); - break; - case NBACKGND: - evalsubshell(n, flags); - break; - case NIF: { - evaltree(n->nif.test, EV_TESTED); - if (evalskip) - goto out; - if (exitstatus == 0) - evaltree(n->nif.ifpart, flags); - else if (n->nif.elsepart) - evaltree(n->nif.elsepart, flags); - else + case NWHILE: + case NUNTIL: + evalloop(n, flags & ~EV_EXIT); + break; + case NFOR: + evalfor(n, flags & ~EV_EXIT); + break; + case NCASE: + evalcase(n, flags); + break; + case NDEFUN: + defun(n->narg.text, n->narg.next); exitstatus = 0; - break; - } - case NWHILE: - case NUNTIL: - evalloop(n, flags & ~EV_EXIT); - break; - case NFOR: - evalfor(n, flags & ~EV_EXIT); - break; - case NCASE: - evalcase(n, flags); - break; - case NDEFUN: - defun(n->narg.text, n->narg.next); - exitstatus = 0; - break; - case NNOT: - evaltree(n->nnot.com, EV_TESTED); - exitstatus = !exitstatus; - break; - - case NPIPE: - evalpipe(n); - do_etest = !(flags & EV_TESTED); - break; - case NCMD: - evalcommand(n, flags, (struct backcmd *)NULL); - do_etest = !(flags & EV_TESTED); - break; - default: - out1fmt("Node type = %d\n", n->type); - flushout(&output); - break; - } + break; + case NNOT: + evaltree(n->nnot.com, EV_TESTED); + exitstatus = !exitstatus; + break; + + case NPIPE: + evalpipe(n); + do_etest = !(flags & EV_TESTED); + break; + case NCMD: + evalcommand(n, flags, (struct backcmd *)NULL); + do_etest = !(flags & EV_TESTED); + break; + default: + out1fmt("Node type = %d\n", n->type); + flushout(&output); + break; + } + n = next; + } while (n != NULL); out: if (pendingsigs) dotrap(); Modified: user/ed/compiler-rt/bin/sh/parser.c ============================================================================== --- user/ed/compiler-rt/bin/sh/parser.c Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/bin/sh/parser.c Thu Nov 4 18:24:05 2010 (r214796) @@ -69,6 +69,11 @@ __FBSDID("$FreeBSD$"); #define EOFMARKLEN 79 #define PROMPTLEN 128 +/* values of checkkwd variable */ +#define CHKALIAS 0x1 +#define CHKKWD 0x2 +#define CHKNL 0x4 + /* values returned by readtoken */ #include "token.h" @@ -102,9 +107,6 @@ static int startlinno; /* line # where static int funclinno; /* line # where the current function started */ static struct parser_temp *parser_temp; -/* XXX When 'noaliases' is set to one, no alias expansion takes place. */ -static int noaliases = 0; - static union node *list(int, int); static union node *andor(void); @@ -227,13 +229,13 @@ parsecmd(int interact) static union node * list(int nlflag, int erflag) { - union node *n1, *n2, *n3; + union node *ntop, *n1, *n2, *n3; int tok; - checkkwd = 2; + checkkwd = CHKNL | CHKKWD | CHKALIAS; if (!nlflag && !erflag && tokendlist[peektoken()]) return NULL; - n1 = NULL; + ntop = n1 = NULL; for (;;) { n2 = andor(); tok = readtoken(); @@ -250,14 +252,21 @@ list(int nlflag, int erflag) n2 = n3; } } - if (n1 == NULL) { - n1 = n2; + if (ntop == NULL) + ntop = n2; + else if (n1 == NULL) { + n1 = (union node *)stalloc(sizeof (struct nbinary)); + n1->type = NSEMI; + n1->nbinary.ch1 = ntop; + n1->nbinary.ch2 = n2; + ntop = n1; } else { n3 = (union node *)stalloc(sizeof (struct nbinary)); n3->type = NSEMI; - n3->nbinary.ch1 = n1; + n3->nbinary.ch1 = n1->nbinary.ch2; n3->nbinary.ch2 = n2; + n1->nbinary.ch2 = n3; n1 = n3; } switch (tok) { @@ -269,28 +278,28 @@ list(int nlflag, int erflag) if (tok == TNL) { parseheredoc(); if (nlflag) - return n1; + return ntop; } else if (tok == TEOF && nlflag) { parseheredoc(); - return n1; + return ntop; } else { tokpushback++; } - checkkwd = 2; + checkkwd = CHKNL | CHKKWD | CHKALIAS; if (!nlflag && !erflag && tokendlist[peektoken()]) - return n1; + return ntop; break; case TEOF: if (heredoclist) parseheredoc(); else pungetc(); /* push back EOF on input */ - return n1; + return ntop; default: if (nlflag || erflag) synexpect(-1); tokpushback++; - return n1; + return ntop; } } } @@ -332,7 +341,7 @@ pipeline(void) int negate, t; negate = 0; - checkkwd = 2; + checkkwd = CHKNL | CHKKWD | CHKALIAS; TRACE(("pipeline: entered\n")); while (readtoken() == TNOT) negate = !negate; @@ -348,7 +357,7 @@ pipeline(void) do { prev = lp; lp = (struct nodelist *)stalloc(sizeof (struct nodelist)); - checkkwd = 2; + checkkwd = CHKNL | CHKKWD | CHKALIAS; t = readtoken(); tokpushback++; if (t == TNOT) @@ -381,7 +390,7 @@ command(void) union node *redir, **rpp; int t; - checkkwd = 2; + checkkwd = CHKNL | CHKKWD | CHKALIAS; redir = NULL; n1 = NULL; rpp = &redir; @@ -422,7 +431,7 @@ command(void) } if (readtoken() != TFI) synexpect(TFI); - checkkwd = 1; + checkkwd = CHKKWD | CHKALIAS; break; case TWHILE: case TUNTIL: { @@ -438,7 +447,7 @@ TRACE(("expecting DO got %s %s\n", tokna n1->nbinary.ch2 = list(0, 0); if (readtoken() != TDONE) synexpect(TDONE); - checkkwd = 1; + checkkwd = CHKKWD | CHKALIAS; break; } case TFOR: @@ -480,7 +489,7 @@ TRACE(("expecting DO got %s %s\n", tokna if (lasttoken != TNL && lasttoken != TSEMI) tokpushback++; } - checkkwd = 2; + checkkwd = CHKNL | CHKKWD | CHKALIAS; if ((t = readtoken()) == TDO) t = TDONE; else if (t == TBEGIN) @@ -490,7 +499,7 @@ TRACE(("expecting DO got %s %s\n", tokna n1->nfor.body = list(0, 0); if (readtoken() != t) synexpect(t); - checkkwd = 1; + checkkwd = CHKKWD | CHKALIAS; break; case TCASE: n1 = (union node *)stalloc(sizeof (struct ncase)); @@ -506,8 +515,7 @@ TRACE(("expecting DO got %s %s\n", tokna if (lasttoken != TWORD || ! equal(wordtext, "in")) synerror("expecting \"in\""); cpp = &n1->ncase.cases; - noaliases = 1; /* turn off alias expansion */ - checkkwd = 2, readtoken(); + checkkwd = CHKNL | CHKKWD, readtoken(); while (lasttoken != TESAC) { *cpp = cp = (union node *)stalloc(sizeof (struct nclist)); cp->type = NCLIST; @@ -519,28 +527,28 @@ TRACE(("expecting DO got %s %s\n", tokna ap->type = NARG; ap->narg.text = wordtext; ap->narg.backquote = backquotelist; - if (checkkwd = 2, readtoken() != TPIPE) + checkkwd = CHKNL | CHKKWD; + if (readtoken() != TPIPE) break; app = &ap->narg.next; readtoken(); } ap->narg.next = NULL; if (lasttoken != TRP) - noaliases = 0, synexpect(TRP); + synexpect(TRP); cp->nclist.body = list(0, 0); - checkkwd = 2; + checkkwd = CHKNL | CHKKWD | CHKALIAS; if ((t = readtoken()) != TESAC) { if (t != TENDCASE) - noaliases = 0, synexpect(TENDCASE); + synexpect(TENDCASE); else - checkkwd = 2, readtoken(); + checkkwd = CHKNL | CHKKWD, readtoken(); } cpp = &cp->nclist.next; } - noaliases = 0; /* reset alias expansion */ *cpp = NULL; - checkkwd = 1; + checkkwd = CHKKWD | CHKALIAS; break; case TLP: n1 = (union node *)stalloc(sizeof (struct nredir)); @@ -549,13 +557,13 @@ TRACE(("expecting DO got %s %s\n", tokna n1->nredir.redirect = NULL; if (readtoken() != TRP) synexpect(TRP); - checkkwd = 1; + checkkwd = CHKKWD | CHKALIAS; break; case TBEGIN: n1 = list(0, 0); if (readtoken() != TEND) synexpect(TEND); - checkkwd = 1; + checkkwd = CHKKWD | CHKALIAS; break; /* Handle an empty command like other simple commands. */ case TBACKGND: @@ -789,7 +797,6 @@ static int readtoken(void) { int t; - int savecheckkwd = checkkwd; struct alias *ap; #ifdef DEBUG int alreadyseen = tokpushback; @@ -798,25 +805,24 @@ readtoken(void) top: t = xxreadtoken(); - if (checkkwd) { - /* - * eat newlines - */ - if (checkkwd == 2) { - checkkwd = 0; - while (t == TNL) { - parseheredoc(); - t = xxreadtoken(); - } - } else - checkkwd = 0; - /* - * check for keywords and aliases - */ - if (t == TWORD && !quoteflag) - { - const char * const *pp; + /* + * eat newlines + */ + if (checkkwd & CHKNL) { + while (t == TNL) { + parseheredoc(); + t = xxreadtoken(); + } + } + /* + * check for keywords and aliases + */ + if (t == TWORD && !quoteflag) + { + const char * const *pp; + + if (checkkwd & CHKKWD) for (pp = parsekwd; *pp; pp++) { if (**pp == *wordtext && equal(*pp, wordtext)) { @@ -825,16 +831,16 @@ readtoken(void) goto out; } } - if (noaliases == 0 && - (ap = lookupalias(wordtext, 1)) != NULL) { - pushstring(ap->val, strlen(ap->val), ap); - checkkwd = savecheckkwd; - goto top; - } + if (checkkwd & CHKALIAS && + (ap = lookupalias(wordtext, 1)) != NULL) { + pushstring(ap->val, strlen(ap->val), ap); + goto top; } -out: - checkkwd = (t == TNOT) ? savecheckkwd : 0; } +out: + if (t != TNOT) + checkkwd = 0; + #ifdef DEBUG if (!alreadyseen) TRACE(("token %s %s\n", tokname[t], t == TWORD ? wordtext : "")); Modified: user/ed/compiler-rt/bin/sh/sh.1 ============================================================================== --- user/ed/compiler-rt/bin/sh/sh.1 Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/bin/sh/sh.1 Thu Nov 4 18:24:05 2010 (r214796) @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd October 16, 2010 +.Dd October 31, 2010 .Dt SH 1 .Os .Sh NAME @@ -40,9 +40,24 @@ .Nd command interpreter (shell) .Sh SYNOPSIS .Nm -.Op Fl /+abCEefIimnPpsTuVvx +.Op Fl /+abCEefIimnPpTuVvx .Op Fl /+o Ar longname -.Op Fl c Ar string +.Oo +.Ar script +.Op Ar arg ... +.Oc +.Nm +.Op Fl /+abCEefIimnPpTuVvx +.Op Fl /+o Ar longname +.Fl c Ar string +.Oo +.Ar name +.Op Ar arg ... +.Oc +.Nm +.Op Fl /+abCEefIimnPpTuVvx +.Op Fl /+o Ar longname +.Fl s .Op Ar arg ... .Sh DESCRIPTION The @@ -1109,7 +1124,12 @@ the process ID and its exit status until .Ic wait built-in command reports completion of the process. .It Li $0 -(zero) Expands to the name of the shell or shell script. +(zero) Expands to the name of the shell script if passed on the command line, +the +.Ar name +operand if given (with +.Fl c ) +or otherwise argument 0 passed to the shell. .El .Ss Special Variables The following variables are set by the shell or Modified: user/ed/compiler-rt/bin/stty/key.c ============================================================================== --- user/ed/compiler-rt/bin/stty/key.c Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/bin/stty/key.c Thu Nov 4 18:24:05 2010 (r214796) @@ -257,14 +257,15 @@ f_rows(struct info *ip) void f_sane(struct info *ip) { + struct termios def; - ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & CLOCAL); - ip->t.c_iflag = TTYDEF_IFLAG; - ip->t.c_iflag |= ICRNL; + cfmakesane(&def); + ip->t.c_cflag = def.c_cflag | (ip->t.c_cflag & CLOCAL); + ip->t.c_iflag = def.c_iflag; /* preserve user-preference flags in lflag */ #define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH) - ip->t.c_lflag = TTYDEF_LFLAG | (ip->t.c_lflag & LKEEP); - ip->t.c_oflag = TTYDEF_OFLAG; + ip->t.c_lflag = def.c_lflag | (ip->t.c_lflag & LKEEP); + ip->t.c_oflag = def.c_oflag; ip->set = 1; } Modified: user/ed/compiler-rt/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- user/ed/compiler-rt/cddl/contrib/opensolaris/cmd/ztest/ztest.c Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/cddl/contrib/opensolaris/cmd/ztest/ztest.c Thu Nov 4 18:24:05 2010 (r214796) @@ -3362,8 +3362,7 @@ ztest_verify_blocks(char *pool) int isalen; FILE *fp; - if (realpath(progname, zdb) == NULL) - assert(!"realpath() failed"); + strlcpy(zdb, "/usr/bin/ztest", sizeof(zdb)); /* zdb lives in /usr/sbin, while ztest lives in /usr/bin */ bin = strstr(zdb, "/usr/bin/"); Modified: user/ed/compiler-rt/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c ============================================================================== --- user/ed/compiler-rt/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c Thu Nov 4 18:24:05 2010 (r214796) @@ -308,9 +308,9 @@ cv_timedwait(kcondvar_t *cv, kmutex_t *m struct timeval tv; clock_t delta; - ASSERT(abstime > 0); + abstime += lbolt; top: - delta = abstime; + delta = abstime - lbolt; if (delta <= 0) return (-1); @@ -321,7 +321,7 @@ top: ts.tv_nsec = tv.tv_usec * 1000 + (delta % hz) * (NANOSEC / hz); ASSERT(ts.tv_nsec >= 0); - if(ts.tv_nsec >= NANOSEC) { + if (ts.tv_nsec >= NANOSEC) { ts.tv_sec++; ts.tv_nsec -= NANOSEC; } Modified: user/ed/compiler-rt/contrib/bind9/CHANGES ============================================================================== --- user/ed/compiler-rt/contrib/bind9/CHANGES Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/CHANGES Thu Nov 4 18:24:05 2010 (r214796) @@ -1,9 +1,48 @@ - --- 9.6.2-P2 released --- + --- 9.6-ESV-R2 released --- + +2939. [func] Check that named successfully skips NSEC3 records + that fail to match the NSEC3PARAM record currently + in use. [RT# 21868] + +2937. [bug] Worked around an apparent race condition in over + memory conditions. Without this fix a DNS cache DB or + ADB could incorrectly stay in an over memory state, + effectively refusing further caching, which + subsequently made a BIND 9 caching server unworkable. + This fix prevents this problem from happening by + polling the state of the memory context, rather than + making a copy of the state, which appeared to cause + a race. This is a "workaround" in that it doesn't + solve the possible race per se, but several experiments + proved this change solves the symptom. Also, the + polling overhead hasn't been reported to be an issue. + This bug should only affect a caching server that + specifies a finite max-cache-size. It's also quite + likely that the bug happens only when enabling threads, + but it's not confirmed yet. [RT #21818] + +2925. [bug] Named failed to accept uncachable negative responses + from insecure zones. [RT# 21555] + +2921. [bug] The resolver could attempt to destroy a fetch context + too soon. [RT #19878] + +2900. [bug] The placeholder negative caching element was not + properly constructed triggering a INSIST in + dns_ncache_towire(). [RT #21346] + +2890. [bug] Handle the introduction of new trusted-keys and + DS, DLV RRsets better. [RT #21097] + +2869. [bug] Fix arguments to dns_keytable_findnextkeynode() call. + [RT #20877] + + --- 9.6-ESV-R1 released --- 2876. [bug] Named could return SERVFAIL for negative responses from unsigned zones. [RT #21131] - --- 9.6.2-P1 released --- + --- 9.6-ESV released --- 2852. [bug] Handle broken DNSSEC trust chains better. [RT #15619] Modified: user/ed/compiler-rt/contrib/bind9/README ============================================================================== --- user/ed/compiler-rt/contrib/bind9/README Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/README Thu Nov 4 18:24:05 2010 (r214796) @@ -42,6 +42,12 @@ BIND 9 Stichting NLnet - NLnet Foundation Nominum, Inc. +BIND 9.6-ESV (Extended Support Version) + + BIND 9.6-ESV will be supported until March 31, 2013, at + which time you will need to upgrade to the current release + of BIND. + BIND 9.6.2 BIND 9.6.2 is a maintenance release, fixing bugs in 9.6.1. Modified: user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html ============================================================================== --- user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-dsfromkey.html Thu Nov 4 18:24:05 2010 (r214796) @@ -1,5 +1,5 @@ - + @@ -33,14 +33,14 @@

dnssec-dsfromkey {-s} [-v level] [-1] [-2] [-a alg] [-c class] [-d dir] {dnsname}

-

DESCRIPTION

+

DESCRIPTION

dnssec-dsfromkey outputs the Delegation Signer (DS) resource record (RR), as defined in RFC 3658 and RFC 4509, for the given key(s).

-

OPTIONS

+

OPTIONS

-1

@@ -81,7 +81,7 @@

-

EXAMPLE

+

EXAMPLE

To build the SHA-256 DS RR from the Kexample.com.+003+26160 @@ -96,7 +96,7 @@

-

FILES

+

FILES

The keyfile can be designed by the key identification Knnnn.+aaa+iiiii or the full file name @@ -110,13 +110,13 @@

-

CAVEAT

+

CAVEAT

A keyfile error can give a "file not found" even if the file exists.

-

SEE ALSO

+

SEE ALSO

dnssec-keygen(8), dnssec-signzone(8), BIND 9 Administrator Reference Manual, @@ -125,7 +125,7 @@

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html ============================================================================== --- user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keyfromlabel.html Thu Nov 4 18:24:05 2010 (r214796) @@ -13,7 +13,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + @@ -31,7 +31,7 @@

dnssec-keyfromlabel {-a algorithm} {-l label} [-c class] [-f flag] [-k] [-n nametype] [-p protocol] [-t type] [-v level] {name}

-

DESCRIPTION

+

DESCRIPTION

dnssec-keyfromlabel gets keys with the given label from a crypto hardware and builds key files for DNSSEC (Secure DNS), as defined in RFC 2535 @@ -39,7 +39,7 @@

-

OPTIONS

+

OPTIONS

-a algorithm
@@ -120,7 +120,7 @@
-

GENERATED KEY FILES

+

GENERATED KEY FILES

When dnssec-keyfromlabel completes successfully, @@ -161,7 +161,7 @@

-

SEE ALSO

+

SEE ALSO

dnssec-keygen(8), dnssec-signzone(8), BIND 9 Administrator Reference Manual, @@ -169,7 +169,7 @@

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keygen.html ============================================================================== --- user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keygen.html Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-keygen.html Thu Nov 4 18:24:05 2010 (r214796) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + @@ -32,7 +32,7 @@

dnssec-keygen {-a algorithm} {-b keysize} {-n nametype} [-c class] [-e] [-f flag] [-g generator] [-h] [-k] [-p protocol] [-r randomdev] [-s strength] [-t type] [-v level] {name}

-

DESCRIPTION

+

DESCRIPTION

dnssec-keygen generates keys for DNSSEC (Secure DNS), as defined in RFC 2535 and RFC 4034. It can also generate keys for use with @@ -45,7 +45,7 @@

-

OPTIONS

+

OPTIONS

-a algorithm
@@ -155,7 +155,7 @@
-

GENERATED KEYS

+

GENERATED KEYS

When dnssec-keygen completes successfully, @@ -201,7 +201,7 @@

-

EXAMPLE

+

EXAMPLE

To generate a 768-bit DSA key for the domain example.com, the following command would be @@ -222,7 +222,7 @@

-

SEE ALSO

+

SEE ALSO

dnssec-signzone(8), BIND 9 Administrator Reference Manual, RFC 2539, @@ -231,7 +231,7 @@

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-signzone.html ============================================================================== --- user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-signzone.html Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/bin/dnssec/dnssec-signzone.html Thu Nov 4 18:24:05 2010 (r214796) @@ -14,7 +14,7 @@ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. --> - + @@ -32,7 +32,7 @@

dnssec-signzone [-a] [-c class] [-d directory] [-e end-time] [-f output-file] [-g] [-h] [-k key] [-l domain] [-i interval] [-I input-format] [-j jitter] [-N soa-seria l-format] [-o origin] [-O output-format] [-p] [-P] [-r randomdev] [-s start-time] [-t] [-v level] [-z] [-3 salt] [-H iterations] [-A] {zonefile} [key...]

-

DESCRIPTION

+

DESCRIPTION

dnssec-signzone signs a zone. It generates NSEC and RRSIG records and produces a signed version of the @@ -43,7 +43,7 @@

-

OPTIONS

+

OPTIONS

-a

@@ -273,7 +273,7 @@

-

EXAMPLE

+

EXAMPLE

The following command signs the example.com zone with the DSA key generated by dnssec-keygen @@ -302,7 +302,7 @@ db.example.com.signed %

-

KNOWN BUGS

+

KNOWN BUGS

dnssec-signzone was designed so that it could sign a zone partially, using only a subset of the DNSSEC keys @@ -327,14 +327,14 @@ db.example.com.signed

-

SEE ALSO

+

SEE ALSO

dnssec-keygen(8), BIND 9 Administrator Reference Manual, RFC 4033.

-

AUTHOR

+

AUTHOR

Internet Systems Consortium

Modified: user/ed/compiler-rt/contrib/bind9/bin/named/include/named/globals.h ============================================================================== --- user/ed/compiler-rt/contrib/bind9/bin/named/include/named/globals.h Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/bin/named/include/named/globals.h Thu Nov 4 18:24:05 2010 (r214796) @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2008, 2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: globals.h,v 1.80 2008/11/16 22:49:18 marka Exp $ */ +/* $Id: globals.h,v 1.80.84.2 2010/06/26 23:46:15 tbox Exp $ */ #ifndef NAMED_GLOBALS_H #define NAMED_GLOBALS_H 1 @@ -132,6 +132,7 @@ EXTERN int ns_g_listen INIT(3); EXTERN isc_time_t ns_g_boottime; EXTERN isc_boolean_t ns_g_memstatistics INIT(ISC_FALSE); EXTERN isc_boolean_t ns_g_clienttest INIT(ISC_FALSE); +EXTERN isc_boolean_t ns_g_nosoa INIT(ISC_FALSE); #undef EXTERN #undef INIT Modified: user/ed/compiler-rt/contrib/bind9/bin/named/main.c ============================================================================== --- user/ed/compiler-rt/contrib/bind9/bin/named/main.c Thu Nov 4 18:19:45 2010 (r214795) +++ user/ed/compiler-rt/contrib/bind9/bin/named/main.c Thu Nov 4 18:24:05 2010 (r214796) @@ -1,5 +1,5 @@ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 19:07:53 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17FAA106571F; Thu, 4 Nov 2010 19:07:53 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 06C4A8FC1C; Thu, 4 Nov 2010 19:07:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA4J7qRE070077; Thu, 4 Nov 2010 19:07:52 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4J7qMK070073; Thu, 4 Nov 2010 19:07:52 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201011041907.oA4J7qMK070073@svn.freebsd.org> From: Xin LI Date: Thu, 4 Nov 2010 19:07:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214801 - user/delphij/patch X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 19:07:53 -0000 Author: delphij Date: Thu Nov 4 19:07:52 2010 New Revision: 214801 URL: http://svn.freebsd.org/changeset/base/214801 Log: Sync with OpenBSD as of today. Changes: - Manual page improvement (add EXIT STATUS section) - Output normal messages to stdout to match GNU behavior. Modified: user/delphij/patch/patch.1 user/delphij/patch/patch.c user/delphij/patch/util.c Modified: user/delphij/patch/patch.1 ============================================================================== --- user/delphij/patch/patch.1 Thu Nov 4 19:05:35 2010 (r214800) +++ user/delphij/patch/patch.1 Thu Nov 4 19:07:52 2010 (r214801) @@ -1,4 +1,4 @@ -.\" $OpenBSD: patch.1,v 1.25 2009/02/08 17:33:01 jmc Exp $ +.\" $OpenBSD: patch.1,v 1.26 2010/09/03 11:09:29 jmc Exp $ .\" Copyright 1986, Larry Wall .\" .\" Redistribution and use in source and binary forms, with or without @@ -20,7 +20,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd February 20, 2009 +.Dd September 3, 2010 .Dt PATCH 1 .Os .Sh NAME @@ -604,33 +604,33 @@ used to read input when .Nm prompts the user .El -.Sh DIAGNOSTICS -Too many to list here, but generally indicative that -.Nm -couldn't parse your patch file. -.Pp -The message -.Qq Hmm... -indicates that there is unprocessed text in the patch file and that -.Nm -is attempting to intuit whether there is a patch in that text and, if so, -what kind of patch it is. -.Pp +.Sh EXIT STATUS The .Nm utility exits with one of the following values: .Pp -.Bl -tag -width Ds -compact -offset indent -.It \&0 +.Bl -tag -width Ds -offset indent -compact +.It 0 Successful completion. -.It \&1 +.It 1 One or more lines were written to a reject file. -.It \*[Gt]\&1 +.It \*(Gt1 An error occurred. .El .Pp When applying a set of patches in a loop it behooves you to check this exit status so you don't apply a later patch to a partially patched file. +.Sh DIAGNOSTICS +Too many to list here, but generally indicative that +.Nm +couldn't parse your patch file. +.Pp +The message +.Qq Hmm... +indicates that there is unprocessed text in the patch file and that +.Nm +is attempting to intuit whether there is a patch in that text and, if so, +what kind of patch it is. .Sh SEE ALSO .Xr diff 1 .Sh STANDARDS Modified: user/delphij/patch/patch.c ============================================================================== --- user/delphij/patch/patch.c Thu Nov 4 19:05:35 2010 (r214800) +++ user/delphij/patch/patch.c Thu Nov 4 19:07:52 2010 (r214801) @@ -1,4 +1,4 @@ -/* $OpenBSD: patch.c,v 1.48 2009/10/27 23:59:41 deraadt Exp $ */ +/* $OpenBSD: patch.c,v 1.49 2010/07/24 01:10:12 ray Exp $ */ /* * patch - a program to apply diffs to original files @@ -112,9 +112,6 @@ static bool reverse_flag_specified = fal /* buffer holding the name of the rejected patch file. */ static char rejname[NAME_MAX + 1]; -/* buffer for stderr */ -static char serrbuf[BUFSIZ]; - /* how many input lines have been irretractibly output */ static LINENUM last_frozen_line = 0; @@ -153,7 +150,8 @@ main(int argc, char *argv[]) const char *tmpdir; char *v; - setbuf(stderr, serrbuf); + setlinebuf(stdout); + setlinebuf(stderr); for (i = 0; i < MAXFILEC; i++) filearg[i] = NULL; Modified: user/delphij/patch/util.c ============================================================================== --- user/delphij/patch/util.c Thu Nov 4 19:05:35 2010 (r214800) +++ user/delphij/patch/util.c Thu Nov 4 19:07:52 2010 (r214801) @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.34 2010/01/08 13:27:59 oga Exp $ */ +/* $OpenBSD: util.c,v 1.35 2010/07/24 01:10:12 ray Exp $ */ /* * patch - a program to apply diffs to original files @@ -203,9 +203,9 @@ say(const char *fmt, ...) va_list ap; va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + vfprintf(stdout, fmt, ap); va_end(ap); - fflush(stderr); + fflush(stdout); } /* From owner-svn-src-user@FreeBSD.ORG Thu Nov 4 22:05:51 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8490106566B; Thu, 4 Nov 2010 22:05:50 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B763C8FC18; Thu, 4 Nov 2010 22:05:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA4M5oR6074617; Thu, 4 Nov 2010 22:05:50 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA4M5oj9074615; Thu, 4 Nov 2010 22:05:50 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201011042205.oA4M5oj9074615@svn.freebsd.org> From: Doug Barton Date: Thu, 4 Nov 2010 22:05:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214813 - user/dougb/portmaster X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2010 22:05:51 -0000 Author: dougb Date: Thu Nov 4 22:05:50 2010 New Revision: 214813 URL: http://svn.freebsd.org/changeset/base/214813 Log: Only print the fast-resume message if we're building. Otherwise we might not know all the ports that need updating. Modified: user/dougb/portmaster/portmaster Modified: user/dougb/portmaster/portmaster ============================================================================== --- user/dougb/portmaster/portmaster Thu Nov 4 21:50:19 2010 (r214812) +++ user/dougb/portmaster/portmaster Thu Nov 4 22:05:50 2010 (r214813) @@ -212,7 +212,7 @@ parent_exit () { fi PM_NEEDS_UPDATE=${PM_NEEDS_UPDATE# } - if [ -n "$1" -a -n "$PM_NEEDS_UPDATE" ]; then + if [ -n "$1" -a -n "$PM_NEEDS_UPDATE" -a -n "$PM_BUILDING" ]; then echo '' echo "===>>> You can restart from the point of failure with this command line:" echo " ${0##*/} $PM_NEEDS_UPDATE" From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 00:07:56 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 775D610656A4; Fri, 5 Nov 2010 00:07:56 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 502638FC18; Fri, 5 Nov 2010 00:07:56 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA507uCq077227; Fri, 5 Nov 2010 00:07:56 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA507ufo077223; Fri, 5 Nov 2010 00:07:56 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050007.oA507ufo077223@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 00:07:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214814 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 00:07:56 -0000 Author: davidxu Date: Fri Nov 5 00:07:56 2010 New Revision: 214814 URL: http://svn.freebsd.org/changeset/base/214814 Log: Merge condition variable work from previous work from libthr.user_requeue. if the current thread is using the simple mutex, use userlevel cv, otherwise use kernel based cv. userlevel cv is fast. may there are other cases, thread should use kernel based cv. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/lib/libthr/thread/thr_mutex.c user/davidxu/libthr/lib/libthr/thread/thr_private.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Thu Nov 4 22:05:50 2010 (r214813) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 00:07:56 2010 (r214814) @@ -80,6 +80,7 @@ cond_init(pthread_cond_t *cond, const pt pcond->c_kerncv.c_flags |= USYNC_PROCESS_SHARED; pcond->c_kerncv.c_clockid = (*cond_attr)->c_clockid; } + _thr_umutex_init(&pcond->c_lock); pcond->c_kerncv.c_flags |= UCOND_BIND_MUTEX; *cond = pcond; } @@ -137,6 +138,8 @@ _pthread_cond_destroy(pthread_cond_t *co rval = EINVAL; else { cv = *cond; + if (cv->c_waiters != 0) + return (EBUSY); _thr_ucond_broadcast(&cv->c_kerncv); *cond = THR_COND_DESTROYED; @@ -158,7 +161,7 @@ _pthread_cond_destroy(pthread_cond_t *co * to be lost. */ static int -cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, +cond_wait_kernel(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime, int cancel) { struct pthread *curthread = _get_curthread(); @@ -167,12 +170,6 @@ cond_wait_common(pthread_cond_t *cond, p int recurse; int ret; - /* - * If the condition variable is statically initialized, - * perform the dynamic initialization: - */ - CHECK_AND_INIT_COND - cv = *cond; ret = _mutex_cv_detach(mutex, &recurse); if (__predict_false(ret != 0)) @@ -206,6 +203,102 @@ cond_wait_common(pthread_cond_t *cond, p return (ret); } +static int +cond_wait_user(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime, int cancel) +{ + struct pthread *curthread = _get_curthread(); + struct timespec ts, ts2, *tsp; + int recurse; + pthread_cond_t cv; + int ret; + uint64_t seq, bseq; + + cv = *cond; + THR_UMUTEX_LOCK(curthread, &cv->c_lock); + cv->c_waiters++; + ret = _mutex_cv_unlock(mutex, &recurse); + if (__predict_false(ret != 0)) { + cv->c_waiters--; + THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + return (ret); + } + + if (abstime != NULL) { + clock_gettime(cv->c_kerncv.c_clockid, &ts); + TIMESPEC_SUB(&ts2, abstime, &ts); + tsp = &ts2; + } else + tsp = NULL; + + bseq = cv->c_broadcast_seq; + for(;;) { + seq = cv->c_seq; + THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + + if (cancel) { + _thr_cancel_enter2(curthread, 0); + ret = _thr_umtx_wait_uint((u_int *)&cv->c_seq, + (u_int)seq, tsp, 0); + _thr_cancel_leave(curthread, 0); + } else { + ret = _thr_umtx_wait_uint((u_int *)&cv->c_seq, + (u_int)seq, tsp, 0); + } + + THR_UMUTEX_LOCK(curthread, &cv->c_lock); + if (cv->c_broadcast_seq != bseq) { + ret = 0; + break; + } + if (cv->c_signaled > 0) { + cv->c_signaled--; + ret = 0; + break; + } else if (cancel && SHOULD_CANCEL(curthread) && + !THR_IN_CRITICAL(curthread)) { + THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + _pthread_exit(PTHREAD_CANCELED); + } + } + THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + + if (ret == EINTR) + ret = 0; + _mutex_cv_lock(mutex, recurse); + return (ret); +} + + +static int +cond_wait_common(pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime, int cancel) +{ + struct pthread *curthread = _get_curthread(); + struct pthread_mutex *m; + pthread_cond_t cv; + int err; + + /* + * If the condition variable is statically initialized, + * perform the dynamic initialization: + */ + CHECK_AND_INIT_COND + + if ((err = _mutex_owned(curthread, mutex)) != 0) + return (err); + + m = *mutex; + if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) != + (cv->c_kerncv.c_flags & USYNC_PROCESS_SHARED)) + return (EINVAL); + + if (m->m_lock.m_flags & (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_INHERIT)) + return cond_wait_kernel(cond, mutex, abstime, cancel); + else + return cond_wait_user(cond, mutex, abstime, cancel); +} + int _pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { @@ -247,8 +340,8 @@ __pthread_cond_timedwait(pthread_cond_t static int cond_signal_common(pthread_cond_t *cond, int broadcast) { + struct pthread *curthread = _get_curthread(); pthread_cond_t cv; - int ret = 0; /* * If the condition variable is statically initialized, perform dynamic @@ -257,10 +350,30 @@ cond_signal_common(pthread_cond_t *cond, CHECK_AND_INIT_COND if (!broadcast) - ret = _thr_ucond_signal(&cv->c_kerncv); + _thr_ucond_signal(&cv->c_kerncv); else - ret = _thr_ucond_broadcast(&cv->c_kerncv); - return (ret); + _thr_ucond_broadcast(&cv->c_kerncv); + + if (cv->c_waiters == 0) + return (0); + + THR_UMUTEX_LOCK(curthread, &cv->c_lock); + if (cv->c_waiters > 0) { + if (!broadcast) { + cv->c_seq++; + cv->c_signaled++; + cv->c_waiters--; + _thr_umtx_wake(&cv->c_seq, 1, 0); + } else { + cv->c_seq++; + cv->c_broadcast_seq++; + cv->c_waiters = 0; + cv->c_signaled = 0; + _thr_umtx_wake(&cv->c_seq, INT_MAX, 0); + } + } + THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + return (0); } int Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Thu Nov 4 22:05:50 2010 (r214813) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 00:07:56 2010 (r214814) @@ -548,12 +548,10 @@ mutex_self_lock(struct pthread_mutex *m, return (ret); } -static int -mutex_unlock_common(pthread_mutex_t *mutex) +int +_mutex_owned(struct pthread *curthread, const pthread_mutex_t *mutex) { - struct pthread *curthread = _get_curthread(); struct pthread_mutex *m; - uint32_t id; m = *mutex; if (__predict_false(m <= THR_MUTEX_DESTROYED)) { @@ -561,12 +559,26 @@ mutex_unlock_common(pthread_mutex_t *mut return (EINVAL); return (EPERM); } - /* * Check if the running thread is not the owner of the mutex. */ if (__predict_false(m->m_owner != curthread)) return (EPERM); + return (0); +} + +static int +mutex_unlock_common(pthread_mutex_t *mutex) +{ + struct pthread *curthread = _get_curthread(); + struct pthread_mutex *m; + uint32_t id; + int err; + + if ((err = _mutex_owned(curthread, mutex)) != 0) + return (err); + + m = *mutex; id = TID(curthread); if (__predict_false( @@ -607,6 +619,41 @@ _mutex_cv_lock(pthread_mutex_t *mutex, i } int +_mutex_cv_unlock(pthread_mutex_t *mutex, int *count) +{ + struct pthread *curthread = _get_curthread(); + struct pthread_mutex *m; + int err; + + if ((err = _mutex_owned(curthread, mutex)) != 0) + return (err); + + m = *mutex; + + /* + * Clear the count in case this is a recursive mutex. + */ + *count = m->m_count; + m->m_refcount++; + m->m_count = 0; + m->m_owner = NULL; + /* Remove the mutex from the threads queue. */ + MUTEX_ASSERT_IS_OWNED(m); + if (__predict_true((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) + TAILQ_REMOVE(&curthread->mutexq, m, m_qe); + else { + TAILQ_REMOVE(&curthread->pp_mutexq, m, m_qe); + set_inherited_priority(curthread, m); + } + MUTEX_INIT_LINK(m); + _thr_umutex_unlock(&m->m_lock, TID(curthread)); + + if (m->m_private) + THR_CRITICAL_LEAVE(curthread); + return (0); +} + +int _mutex_cv_attach(pthread_mutex_t *mutex, int count) { struct pthread * curthread = _get_curthread(); @@ -625,19 +672,12 @@ _mutex_cv_detach(pthread_mutex_t *mutex, { struct pthread *curthread = _get_curthread(); struct pthread_mutex *m; + int err; - m = *mutex; - if (__predict_false(m <= THR_MUTEX_DESTROYED)) { - if (m == THR_MUTEX_DESTROYED) - return (EINVAL); - return (EPERM); - } + if ((err = _mutex_owned(curthread, mutex)) != 0) + return (err); - /* - * Check if the running thread is not the owner of the mutex. - */ - if (__predict_false(m->m_owner != curthread)) - return (EPERM); + m = *mutex; /* * Clear the count in case this is a recursive mutex. Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Thu Nov 4 22:05:50 2010 (r214813) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Fri Nov 5 00:07:56 2010 (r214814) @@ -169,6 +169,15 @@ struct pthread_mutex_attr { struct pthread_cond { struct ucond c_kerncv; + /* + * Following is userlevel condition variable which is + * used for time-sharing scheduling, it is a bit fast. + */ + struct umutex c_lock; + int c_waiters; + int c_signaled; + uint32_t c_seq; + uint64_t c_broadcast_seq; }; struct pthread_cond_attr { @@ -674,8 +683,10 @@ extern struct umutex _thr_event_lock __h __BEGIN_DECLS int _thr_setthreaded(int) __hidden; int _mutex_cv_lock(pthread_mutex_t *, int count) __hidden; +int _mutex_cv_unlock(pthread_mutex_t *, int *count) __hidden; int _mutex_cv_attach(pthread_mutex_t *, int count) __hidden; int _mutex_cv_detach(pthread_mutex_t *, int *count) __hidden; +int _mutex_owned(struct pthread *, const pthread_mutex_t *) __hidden; int _mutex_reinit(pthread_mutex_t *) __hidden; void _mutex_fork(struct pthread *curthread) __hidden; void _libpthread_init(struct pthread *) __hidden; From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 00:25:14 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3EA27106566C; Fri, 5 Nov 2010 00:25:14 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2D1248FC12; Fri, 5 Nov 2010 00:25:14 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA50PEer077644; Fri, 5 Nov 2010 00:25:14 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA50PEVb077642; Fri, 5 Nov 2010 00:25:14 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050025.oA50PEVb077642@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 00:25:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214815 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 00:25:14 -0000 Author: davidxu Date: Fri Nov 5 00:25:13 2010 New Revision: 214815 URL: http://svn.freebsd.org/changeset/base/214815 Log: Move clock_gettime() after lock released. we should have another UMTX_OP_WAIT with absolute timeout to save syscalls. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 00:07:56 2010 (r214814) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 00:25:13 2010 (r214815) @@ -224,18 +224,18 @@ cond_wait_user(pthread_cond_t *cond, pth return (ret); } - if (abstime != NULL) { - clock_gettime(cv->c_kerncv.c_clockid, &ts); - TIMESPEC_SUB(&ts2, abstime, &ts); - tsp = &ts2; - } else - tsp = NULL; - bseq = cv->c_broadcast_seq; for(;;) { seq = cv->c_seq; THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + if (abstime != NULL) { + clock_gettime(cv->c_kerncv.c_clockid, &ts); + TIMESPEC_SUB(&ts2, abstime, &ts); + tsp = &ts2; + } else + tsp = NULL; + if (cancel) { _thr_cancel_enter2(curthread, 0); ret = _thr_umtx_wait_uint((u_int *)&cv->c_seq, @@ -255,10 +255,12 @@ cond_wait_user(pthread_cond_t *cond, pth cv->c_signaled--; ret = 0; break; + } else if (ret == ETIMEDOUT) { + break; } else if (cancel && SHOULD_CANCEL(curthread) && !THR_IN_CRITICAL(curthread)) { - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); - _pthread_exit(PTHREAD_CANCELED); + THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + _pthread_exit(PTHREAD_CANCELED); } } THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); @@ -289,6 +291,7 @@ cond_wait_common(pthread_cond_t *cond, p return (err); m = *mutex; + if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) != (cv->c_kerncv.c_flags & USYNC_PROCESS_SHARED)) return (EINVAL); From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 00:31:10 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F0FC106564A; Fri, 5 Nov 2010 00:31:10 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F1B098FC0C; Fri, 5 Nov 2010 00:31:09 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA50V9fF077874; Fri, 5 Nov 2010 00:31:09 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA50V9Lg077872; Fri, 5 Nov 2010 00:31:09 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050031.oA50V9Lg077872@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 00:31:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214816 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 00:31:10 -0000 Author: davidxu Date: Fri Nov 5 00:31:09 2010 New Revision: 214816 URL: http://svn.freebsd.org/changeset/base/214816 Log: Don't check EINTR, we don't break loop for user level cv. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 00:25:13 2010 (r214815) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 00:31:09 2010 (r214816) @@ -264,9 +264,6 @@ cond_wait_user(pthread_cond_t *cond, pth } } THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); - - if (ret == EINTR) - ret = 0; _mutex_cv_lock(mutex, recurse); return (ret); } From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 01:50:19 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2672D1065672; Fri, 5 Nov 2010 01:50:19 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 13FC48FC18; Fri, 5 Nov 2010 01:50:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA51oITN079975; Fri, 5 Nov 2010 01:50:18 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA51oILc079970; Fri, 5 Nov 2010 01:50:18 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050150.oA51oILc079970@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 01:50:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214818 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 01:50:19 -0000 Author: davidxu Date: Fri Nov 5 01:50:18 2010 New Revision: 214818 URL: http://svn.freebsd.org/changeset/base/214818 Log: To reduce the size of condition variable, use a simple integer as lock, Also none timesharing thread use kernel based cv, because the simple lock can not protect priority inversion, and no intention to make it PI or PP mutex which is too heavy for normal use. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/lib/libthr/thread/thr_private.h user/davidxu/libthr/lib/libthr/thread/thr_umtx.c user/davidxu/libthr/lib/libthr/thread/thr_umtx.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 00:56:21 2010 (r214817) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 01:50:18 2010 (r214818) @@ -80,7 +80,6 @@ cond_init(pthread_cond_t *cond, const pt pcond->c_kerncv.c_flags |= USYNC_PROCESS_SHARED; pcond->c_kerncv.c_clockid = (*cond_attr)->c_clockid; } - _thr_umutex_init(&pcond->c_lock); pcond->c_kerncv.c_flags |= UCOND_BIND_MUTEX; *cond = pcond; } @@ -215,19 +214,19 @@ cond_wait_user(pthread_cond_t *cond, pth uint64_t seq, bseq; cv = *cond; - THR_UMUTEX_LOCK(curthread, &cv->c_lock); + THR_UMTX_ACQUIRE(curthread, &cv->c_lock); cv->c_waiters++; ret = _mutex_cv_unlock(mutex, &recurse); if (__predict_false(ret != 0)) { cv->c_waiters--; - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + THR_UMTX_RELEASE(curthread, &cv->c_lock); return (ret); } bseq = cv->c_broadcast_seq; for(;;) { seq = cv->c_seq; - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + THR_UMTX_RELEASE(curthread, &cv->c_lock); if (abstime != NULL) { clock_gettime(cv->c_kerncv.c_clockid, &ts); @@ -246,7 +245,7 @@ cond_wait_user(pthread_cond_t *cond, pth (u_int)seq, tsp, 0); } - THR_UMUTEX_LOCK(curthread, &cv->c_lock); + THR_UMTX_ACQUIRE(curthread, &cv->c_lock); if (cv->c_broadcast_seq != bseq) { ret = 0; break; @@ -259,11 +258,11 @@ cond_wait_user(pthread_cond_t *cond, pth break; } else if (cancel && SHOULD_CANCEL(curthread) && !THR_IN_CRITICAL(curthread)) { - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + THR_UMTX_RELEASE(curthread, &cv->c_lock); _pthread_exit(PTHREAD_CANCELED); } } - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + THR_UMTX_RELEASE(curthread, &cv->c_lock); _mutex_cv_lock(mutex, recurse); return (ret); } @@ -293,7 +292,8 @@ cond_wait_common(pthread_cond_t *cond, p (cv->c_kerncv.c_flags & USYNC_PROCESS_SHARED)) return (EINVAL); - if (m->m_lock.m_flags & (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_INHERIT)) + if (curthread->attr.sched_policy != SCHED_OTHER || + (m->m_lock.m_flags & (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_INHERIT)) != 0) return cond_wait_kernel(cond, mutex, abstime, cancel); else return cond_wait_user(cond, mutex, abstime, cancel); @@ -340,7 +340,7 @@ __pthread_cond_timedwait(pthread_cond_t static int cond_signal_common(pthread_cond_t *cond, int broadcast) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread = _get_curthread(); pthread_cond_t cv; /* @@ -357,7 +357,7 @@ cond_signal_common(pthread_cond_t *cond, if (cv->c_waiters == 0) return (0); - THR_UMUTEX_LOCK(curthread, &cv->c_lock); + THR_UMTX_ACQUIRE(curthread, &cv->c_lock); if (cv->c_waiters > 0) { if (!broadcast) { cv->c_seq++; @@ -372,7 +372,7 @@ cond_signal_common(pthread_cond_t *cond, _thr_umtx_wake(&cv->c_seq, INT_MAX, 0); } } - THR_UMUTEX_UNLOCK(curthread, &cv->c_lock); + THR_UMTX_RELEASE(curthread, &cv->c_lock); return (0); } Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Fri Nov 5 00:56:21 2010 (r214817) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Fri Nov 5 01:50:18 2010 (r214818) @@ -173,7 +173,7 @@ struct pthread_cond { * Following is userlevel condition variable which is * used for time-sharing scheduling, it is a bit fast. */ - struct umutex c_lock; + uint32_t c_lock; int c_waiters; int c_signaled; uint32_t c_seq; @@ -553,6 +553,22 @@ do { \ #define THR_THREAD_LOCK(curthrd, thr) THR_LOCK_ACQUIRE(curthrd, &(thr)->lock) #define THR_THREAD_UNLOCK(curthrd, thr) THR_LOCK_RELEASE(curthrd, &(thr)->lock) + +#define THR_UMTX_ACQUIRE(thrd, lck) \ +do { \ + (thrd)->locklevel++; \ + _thr_umtx_lock_spin(lck); \ +} while (0) + +#define THR_UMTX_RELEASE(thrd, lck) \ +do { \ + THR_ASSERT_LOCKLEVEL(thrd); \ + _thr_umtx_unlock((lck)); \ + (thrd)->locklevel--; \ + _thr_ast(thrd); \ +} while (0) + + #define THREAD_LIST_RDLOCK(curthrd) \ do { \ (curthrd)->locklevel++; \ Modified: user/davidxu/libthr/lib/libthr/thread/thr_umtx.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Fri Nov 5 00:56:21 2010 (r214817) +++ user/davidxu/libthr/lib/libthr/thread/thr_umtx.c Fri Nov 5 01:50:18 2010 (r214818) @@ -251,3 +251,58 @@ _thr_rwl_unlock(struct urwlock *rwlock) if (_thr_rwlock_unlock(rwlock)) PANIC("unlock error"); } + +int +__thr_umtx_lock(volatile umtx_t *mtx) +{ + int v; + + do { + v = *mtx; + if (v == 2 || atomic_cmpset_acq_int(mtx, 1, 2)) + _thr_umtx_wait_uint(mtx, 2, NULL, 0); + } while (!atomic_cmpset_acq_int(mtx, 0, 2)); + return (0); +} + +#define LOOPS 500 + +int +__thr_umtx_lock_spin(volatile umtx_t *mtx) +{ + int v; + int i; + + if (!_thr_is_smp) + return _thr_umtx_lock(mtx); + + do { + i = LOOPS; + while (i-- > 0) { + if (*mtx == 0) + break; + CPU_SPINWAIT; + } + v = *mtx; + if (v == 2 || atomic_cmpset_acq_int(mtx, 1, 2)) + _thr_umtx_wait_uint(mtx, 2, NULL, 0); + } while (!atomic_cmpset_acq_int(mtx, 0, 2)); + return (0); +} + +void +__thr_umtx_unlock(volatile umtx_t *mtx) +{ + int v; + + for (;;) { + v = *mtx; + if (atomic_cmpset_acq_int(mtx, v, v-1)) { + if (v != 1) { + *mtx = 0; + _thr_umtx_wake(mtx, 1, 0); + } + break; + } + } +} Modified: user/davidxu/libthr/lib/libthr/thread/thr_umtx.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_umtx.h Fri Nov 5 00:56:21 2010 (r214817) +++ user/davidxu/libthr/lib/libthr/thread/thr_umtx.h Fri Nov 5 01:50:18 2010 (r214818) @@ -35,6 +35,8 @@ #define DEFAULT_UMUTEX {0,0,{0,0},{0,0,0,0}} #define DEFAULT_URWLOCK {0,0,0,0,{0,0,0,0}} +typedef uint32_t umtx_t; + int __thr_umutex_lock(struct umutex *mtx, uint32_t id) __hidden; int __thr_umutex_timedlock(struct umutex *mtx, uint32_t id, const struct timespec *timeout) __hidden; @@ -66,6 +68,10 @@ void _thr_rwl_rdlock(struct urwlock *rwl void _thr_rwl_wrlock(struct urwlock *rwlock) __hidden; void _thr_rwl_unlock(struct urwlock *rwlock) __hidden; +int __thr_umtx_lock(volatile umtx_t *mtx); +int __thr_umtx_lock_spin(volatile umtx_t *mtx); +void __thr_umtx_unlock(volatile umtx_t *mtx); + static inline int _thr_umutex_trylock(struct umutex *mtx, uint32_t id) { @@ -193,4 +199,28 @@ _thr_rwlock_unlock(struct urwlock *rwloc } return (__thr_rwlock_unlock(rwlock)); } + +static inline int +_thr_umtx_lock(volatile umtx_t *mtx) +{ + if (atomic_cmpset_acq_int(mtx, 0, 1)) + return (0); + return (__thr_umtx_lock(mtx)); +} + +static inline int +_thr_umtx_lock_spin(volatile umtx_t *mtx) +{ + if (atomic_cmpset_acq_int(mtx, 0, 1)) + return (0); + return (__thr_umtx_lock_spin(mtx)); +} + +static inline void +_thr_umtx_unlock(volatile umtx_t *mtx) +{ + if (atomic_cmpset_acq_int(mtx, 1, 0)) + return; + __thr_umtx_unlock(mtx); +} #endif From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 06:35:11 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5080E1065670; Fri, 5 Nov 2010 06:35:11 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3275B8FC14; Fri, 5 Nov 2010 06:35:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA56ZBJp087044; Fri, 5 Nov 2010 06:35:11 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA56ZBKW087041; Fri, 5 Nov 2010 06:35:11 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050635.oA56ZBKW087041@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 06:35:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214823 - in user/davidxu/libthr/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 06:35:11 -0000 Author: davidxu Date: Fri Nov 5 06:35:10 2010 New Revision: 214823 URL: http://svn.freebsd.org/changeset/base/214823 Log: Introduce a bit flag UMUTEX_SIMPLE for umutex, so that it does not use thread id to lock and unlock. this is necessary, because a link entry can not be embedded into mutex which will be shared between processes, because if other process do incorrect think, it corrupt your link list. But to let unlocking after fork() to work, we either should link it into list to remember it or use a id which can be atomatically duplicated. We use pthread pointer, the bit UMUTEX_SIMPLE_OWNER indicates if the mutex is locked or unlocked. Modified: user/davidxu/libthr/sys/kern/kern_umtx.c user/davidxu/libthr/sys/sys/umtx.h Modified: user/davidxu/libthr/sys/kern/kern_umtx.c ============================================================================== --- user/davidxu/libthr/sys/kern/kern_umtx.c Fri Nov 5 05:11:54 2010 (r214822) +++ user/davidxu/libthr/sys/kern/kern_umtx.c Fri Nov 5 06:35:10 2010 (r214823) @@ -228,17 +228,26 @@ static uma_zone_t umtx_pi_zone; static struct umtxq_chain umtxq_chains[2][UMTX_CHAINS]; static MALLOC_DEFINE(M_UMTX, "umtx", "UMTX queue memory"); static int umtx_pi_allocated; +#ifdef SMP +static int umtx_cvsig_migrate = 0; +#else +static int umtx_cvsig_migrate = 1; +#endif SYSCTL_NODE(_debug, OID_AUTO, umtx, CTLFLAG_RW, 0, "umtx debug"); SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_pi_allocated, CTLFLAG_RD, &umtx_pi_allocated, 0, "Allocated umtx_pi"); +SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cvsig_migrate, CTLFLAG_RW, + &umtx_cvsig_migrate, 0, "cvsig migrate"); + #define UMTX_STATE #ifdef UMTX_STATE static int umtx_cv_broadcast_migrate; static int umtx_cv_signal_migrate; static int umtx_cv_insert_failure; static int umtx_cv_unlock_failure; +static int umtx_timedlock_count; SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_broadcast_migrate, CTLFLAG_RD, &umtx_cv_broadcast_migrate, 0, "cv_broadcast thread migrated"); SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_signal_migrate, CTLFLAG_RD, @@ -247,6 +256,8 @@ SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_c &umtx_cv_insert_failure, 0, "cv_wait failure"); SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_cv_unlock_failure, CTLFLAG_RD, &umtx_cv_unlock_failure, 0, "cv_wait unlock mutex failure"); +SYSCTL_INT(_debug_umtx, OID_AUTO, umtx_timedlock_count, CTLFLAG_RD, + &umtx_timedlock_count, 0, "umutex timedlock count"); #define UMTX_STATE_INC(var) umtx_##var++ #define UMTX_STATE_ADD(var, val) (umtx_##var += (val)) #else @@ -1202,7 +1213,10 @@ _do_lock_normal(struct thread *td, struc uint32_t owner, old, id; int error = 0; - id = td->td_tid; + if (flags & UMUTEX_SIMPLE) + id = UMUTEX_SIMPLE_OWNER; + else + id = td->td_tid; uq = td->td_umtxq; /* @@ -1321,7 +1335,10 @@ do_unlock_normal(struct thread *td, stru int error; int count; - id = td->td_tid; + if (flags & UMUTEX_SIMPLE) + id = UMUTEX_SIMPLE_OWNER; + else + id = td->td_tid; /* * Make sure we own this mtx. */ @@ -2066,7 +2083,10 @@ _do_lock_pp(struct thread *td, struct um uint32_t owner, id; int error, pri, old_inherited_pri, su; - id = td->td_tid; + if (flags & UMUTEX_SIMPLE) + id = UMUTEX_SIMPLE_OWNER; + else + id = td->td_tid; uq = td->td_umtxq; if ((error = umtx_key_get(m, TYPE_PP_UMUTEX, GET_SHARE(flags), &uq->uq_key)) != 0) @@ -2196,7 +2216,10 @@ do_unlock_pp(struct thread *td, struct u uint32_t rceiling; int error, pri, new_inherited_pri, su; - id = td->td_tid; + if (flags & UMUTEX_SIMPLE) + id = UMUTEX_SIMPLE_OWNER; + else + id = td->td_tid; uq = td->td_umtxq; su = (priv_check(td, PRIV_SCHED_RTPRIO) == 0); @@ -2284,7 +2307,10 @@ do_set_ceiling(struct thread *td, struct return (EINVAL); if (ceiling > RTP_PRIO_MAX) return (EINVAL); - id = td->td_tid; + if (flags & UMUTEX_SIMPLE) + id = UMUTEX_SIMPLE_OWNER; + else + id = td->td_tid; uq = td->td_umtxq; if ((error = umtx_key_get(m, TYPE_PP_UMUTEX, GET_SHARE(flags), &uq->uq_key)) != 0) @@ -2387,6 +2413,9 @@ do_lock_umutex(struct thread *td, struct error = ERESTART; } else { const clockid_t clockid = CLOCK_REALTIME; + + UMTX_STATE_INC(timedlock_count); + if ((wflags & UMUTEX_ABSTIME) == 0) { kern_clock_gettime(td, clockid, &ets); timespecadd(&ets, timeout); @@ -2720,7 +2749,7 @@ do_cv_signal(struct thread *td, struct u struct umtxq_chain *uc, *ucm; struct umtx_q *uq; struct umtx_key key; - int error, len; + int error, len, migrate; uint32_t flags, owner; flags = fuword32(&cv->c_flags); @@ -2744,8 +2773,17 @@ do_cv_signal(struct thread *td, struct u } len = uh->length; - - if (uh->binding) { + switch(umtx_cvsig_migrate) { + case 1: /* auto */ + migrate = (mp_ncpus == 1); + break; + case 0: /* disable */ + migrate = 0; + break; + default: /* always */ + migrate = 1; + } + if (migrate && uh->binding) { struct umutex *bind_mutex = uh->bind_mutex; struct umtx_key mkey; int oldlen; Modified: user/davidxu/libthr/sys/sys/umtx.h ============================================================================== --- user/davidxu/libthr/sys/sys/umtx.h Fri Nov 5 05:11:54 2010 (r214822) +++ user/davidxu/libthr/sys/sys/umtx.h Fri Nov 5 06:35:10 2010 (r214823) @@ -40,10 +40,14 @@ #define UMUTEX_UNOWNED 0x0 #define UMUTEX_CONTESTED 0x80000000U +#define UMUTEX_OWNER_MASK 0x7FFFFFFFU #define UMUTEX_ERROR_CHECK 0x0002 /* Error-checking mutex */ #define UMUTEX_PRIO_INHERIT 0x0004 /* Priority inherited mutex */ #define UMUTEX_PRIO_PROTECT 0x0008 /* Priority protect mutex */ +#define UMUTEX_SIMPLE 0x0010 /* Use simple lock id. */ + +#define UMUTEX_SIMPLE_OWNER 1 /* The simple mutex's lock bit. */ /* urwlock flags */ #define URWLOCK_PREFER_READER 0x0002 From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 06:39:38 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 964C7106566B; Fri, 5 Nov 2010 06:39:38 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69EAB8FC16; Fri, 5 Nov 2010 06:39:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA56dco5087156; Fri, 5 Nov 2010 06:39:38 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA56dcYq087154; Fri, 5 Nov 2010 06:39:38 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050639.oA56dcYq087154@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 06:39:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214824 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 06:39:38 -0000 Author: davidxu Date: Fri Nov 5 06:39:38 2010 New Revision: 214824 URL: http://svn.freebsd.org/changeset/base/214824 Log: Restore to previous version, don't use THR_UMTX_ACQUIRE, as it is not needed to inhibit signal and other async things. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 06:35:10 2010 (r214823) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 06:39:38 2010 (r214824) @@ -214,19 +214,19 @@ cond_wait_user(pthread_cond_t *cond, pth uint64_t seq, bseq; cv = *cond; - THR_UMTX_ACQUIRE(curthread, &cv->c_lock); + _thr_umtx_lock_spin(&cv->c_lock); cv->c_waiters++; ret = _mutex_cv_unlock(mutex, &recurse); if (__predict_false(ret != 0)) { cv->c_waiters--; - THR_UMTX_RELEASE(curthread, &cv->c_lock); + _thr_umtx_unlock(&cv->c_lock); return (ret); } bseq = cv->c_broadcast_seq; for(;;) { seq = cv->c_seq; - THR_UMTX_RELEASE(curthread, &cv->c_lock); + _thr_umtx_unlock(&cv->c_lock); if (abstime != NULL) { clock_gettime(cv->c_kerncv.c_clockid, &ts); @@ -245,7 +245,7 @@ cond_wait_user(pthread_cond_t *cond, pth (u_int)seq, tsp, 0); } - THR_UMTX_ACQUIRE(curthread, &cv->c_lock); + _thr_umtx_lock_spin(&cv->c_lock); if (cv->c_broadcast_seq != bseq) { ret = 0; break; @@ -258,11 +258,11 @@ cond_wait_user(pthread_cond_t *cond, pth break; } else if (cancel && SHOULD_CANCEL(curthread) && !THR_IN_CRITICAL(curthread)) { - THR_UMTX_RELEASE(curthread, &cv->c_lock); + _thr_umtx_unlock(&cv->c_lock); _pthread_exit(PTHREAD_CANCELED); } } - THR_UMTX_RELEASE(curthread, &cv->c_lock); + _thr_umtx_unlock(&cv->c_lock); _mutex_cv_lock(mutex, recurse); return (ret); } @@ -340,7 +340,6 @@ __pthread_cond_timedwait(pthread_cond_t static int cond_signal_common(pthread_cond_t *cond, int broadcast) { - struct pthread *curthread = _get_curthread(); pthread_cond_t cv; /* @@ -357,7 +356,7 @@ cond_signal_common(pthread_cond_t *cond, if (cv->c_waiters == 0) return (0); - THR_UMTX_ACQUIRE(curthread, &cv->c_lock); + _thr_umtx_lock_spin(&cv->c_lock); if (cv->c_waiters > 0) { if (!broadcast) { cv->c_seq++; @@ -372,7 +371,7 @@ cond_signal_common(pthread_cond_t *cond, _thr_umtx_wake(&cv->c_seq, INT_MAX, 0); } } - THR_UMTX_RELEASE(curthread, &cv->c_lock); + _thr_umtx_unlock(&cv->c_lock); return (0); } From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 06:42:30 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6BEED106564A; Fri, 5 Nov 2010 06:42:30 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 589E98FC0A; Fri, 5 Nov 2010 06:42:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA56gUBw087260; Fri, 5 Nov 2010 06:42:30 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA56gUcG087255; Fri, 5 Nov 2010 06:42:30 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050642.oA56gUcG087255@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 06:42:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214825 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 06:42:30 -0000 Author: davidxu Date: Fri Nov 5 06:42:30 2010 New Revision: 214825 URL: http://svn.freebsd.org/changeset/base/214825 Log: Merge mutex link code from libthr.user_requeue. Now following the change in kernel, we use UMUTEX_SIMPLE bit flag to avoid use thread id from process-private mutex, so we don't need to link mutex into list, this saves some cycles. Not that for priority-protect mutex, we still need to link it, because we should restore correct priority after unlocking a such kind of mutex. Also the priority-inhertied mutex needs to be linked, because we still use thread ID as lock-word. The simplest mutex is now a bit faster then before. Modified: user/davidxu/libthr/lib/libthr/thread/thr_create.c user/davidxu/libthr/lib/libthr/thread/thr_init.c user/davidxu/libthr/lib/libthr/thread/thr_mutex.c user/davidxu/libthr/lib/libthr/thread/thr_private.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_create.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_create.c Fri Nov 5 06:39:38 2010 (r214824) +++ user/davidxu/libthr/lib/libthr/thread/thr_create.c Fri Nov 5 06:42:30 2010 (r214825) @@ -111,8 +111,7 @@ _pthread_create(pthread_t * thread, cons new_thread->cancel_enable = 1; new_thread->cancel_async = 0; /* Initialize the mutex queue: */ - TAILQ_INIT(&new_thread->mutexq); - TAILQ_INIT(&new_thread->pp_mutexq); + _thr_mutex_link_init(new_thread); /* Initialise hooks in the thread structure: */ if (new_thread->attr.suspend == THR_CREATE_SUSPENDED) { Modified: user/davidxu/libthr/lib/libthr/thread/thr_init.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_init.c Fri Nov 5 06:39:38 2010 (r214824) +++ user/davidxu/libthr/lib/libthr/thread/thr_init.c Fri Nov 5 06:42:30 2010 (r214825) @@ -89,13 +89,15 @@ struct pthread_attr _pthread_attr_defaul struct pthread_mutex_attr _pthread_mutexattr_default = { .m_type = PTHREAD_MUTEX_DEFAULT, .m_protocol = PTHREAD_PRIO_NONE, - .m_ceiling = 0 + .m_ceiling = 0, + .m_pshared = 0 }; struct pthread_mutex_attr _pthread_mutexattr_adaptive_default = { .m_type = PTHREAD_MUTEX_ADAPTIVE_NP, .m_protocol = PTHREAD_PRIO_NONE, - .m_ceiling = 0 + .m_ceiling = 0, + .m_pshared = 0 }; /* Default condition variable attributes: */ @@ -412,8 +414,7 @@ init_main_thread(struct pthread *thread) thr_set_name(thread->tid, "initial thread"); /* Initialize the mutex queue: */ - TAILQ_INIT(&thread->mutexq); - TAILQ_INIT(&thread->pp_mutexq); + _thr_mutex_link_init(thread); thread->state = PS_RUNNING; Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 06:39:38 2010 (r214824) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 06:42:30 2010 (r214825) @@ -41,29 +41,21 @@ #include #include #include +#include #include "un-namespace.h" #include "thr_private.h" -#if defined(_PTHREADS_INVARIANTS) -#define MUTEX_INIT_LINK(m) do { \ - (m)->m_qe.tqe_prev = NULL; \ - (m)->m_qe.tqe_next = NULL; \ -} while (0) -#define MUTEX_ASSERT_IS_OWNED(m) do { \ - if (__predict_false((m)->m_qe.tqe_prev == NULL))\ - PANIC("mutex is not on list"); \ -} while (0) -#define MUTEX_ASSERT_NOT_OWNED(m) do { \ - if (__predict_false((m)->m_qe.tqe_prev != NULL || \ - (m)->m_qe.tqe_next != NULL)) \ - PANIC("mutex is on list"); \ -} while (0) -#else -#define MUTEX_INIT_LINK(m) -#define MUTEX_ASSERT_IS_OWNED(m) -#define MUTEX_ASSERT_NOT_OWNED(m) -#endif +#define CHECK_AND_INIT_MUTEX \ + if (__predict_false((m = *mutex) <= THR_MUTEX_DESTROYED)) { \ + if (m == THR_MUTEX_DESTROYED) \ + return (EINVAL); \ + int error; \ + error = init_static(_get_curthread(), mutex); \ + if (error) \ + return (error); \ + m = *mutex; \ + } /* * For adaptive mutexes, how many times to spin doing trylock2 @@ -95,6 +87,8 @@ static int mutex_self_lock(pthread_mutex static int mutex_unlock_common(pthread_mutex_t *); static int mutex_lock_sleep(struct pthread *, pthread_mutex_t, const struct timespec *); +static void enqueue_mutex(struct pthread *, struct pthread_mutex *); +static void dequeue_mutex(struct pthread *, struct pthread_mutex *); __weak_reference(__pthread_mutex_init, pthread_mutex_init); __strong_reference(__pthread_mutex_init, _pthread_mutex_init); @@ -146,16 +140,16 @@ mutex_init(pthread_mutex_t *mutex, return (ENOMEM); pmutex->m_type = attr->m_type; - pmutex->m_owner = NULL; + pmutex->m_ownertd = NULL; pmutex->m_count = 0; pmutex->m_refcount = 0; pmutex->m_spinloops = 0; pmutex->m_yieldloops = 0; - MUTEX_INIT_LINK(pmutex); switch(attr->m_protocol) { case PTHREAD_PRIO_NONE: pmutex->m_lock.m_owner = UMUTEX_UNOWNED; - pmutex->m_lock.m_flags = 0; + if (attr->m_pshared == 0) + pmutex->m_lock.m_flags |= UMUTEX_SIMPLE; break; case PTHREAD_PRIO_INHERIT: pmutex->m_lock.m_owner = UMUTEX_UNOWNED; @@ -164,10 +158,13 @@ mutex_init(pthread_mutex_t *mutex, case PTHREAD_PRIO_PROTECT: pmutex->m_lock.m_owner = UMUTEX_CONTESTED; pmutex->m_lock.m_flags = UMUTEX_PRIO_PROTECT; + if (attr->m_pshared == 0) + pmutex->m_lock.m_flags |= UMUTEX_SIMPLE; pmutex->m_lock.m_ceilings[0] = attr->m_ceiling; break; } - + if (attr->m_pshared != 0) + pmutex->m_lock.m_flags |= USYNC_PROCESS_SHARED; if (pmutex->m_type == PTHREAD_MUTEX_ADAPTIVE_NP) { pmutex->m_spinloops = _thr_spinloops ? _thr_spinloops: MUTEX_ADAPTIVE_SPINS; @@ -196,17 +193,6 @@ init_static(struct pthread *thread, pthr return (ret); } -static void -set_inherited_priority(struct pthread *curthread, struct pthread_mutex *m) -{ - struct pthread_mutex *m2; - - m2 = TAILQ_LAST(&curthread->pp_mutexq, mutex_queue); - if (m2 != NULL) - m->m_lock.m_ceilings[1] = m2->m_lock.m_ceilings[0]; - else - m->m_lock.m_ceilings[1] = -1; -} int __pthread_mutex_init(pthread_mutex_t *mutex, @@ -236,22 +222,14 @@ _pthread_mutex_init_calloc_cb(pthread_mu void _mutex_fork(struct pthread *curthread) { - struct pthread_mutex *m; + struct mutex_link *ml; /* - * Fix mutex ownership for child process. - * note that process shared mutex should not - * be inherited because owner is forking thread - * which is in parent process, they should be - * removed from the owned mutex list, current, - * process shared mutex is not supported, so I - * am not worried. + * Fix mutex ownership for child process. Only PI mutex need to + * be changed, because we still use TID as lock-word. */ - - TAILQ_FOREACH(m, &curthread->mutexq, m_qe) - m->m_lock.m_owner = TID(curthread); - TAILQ_FOREACH(m, &curthread->pp_mutexq, m_qe) - m->m_lock.m_owner = TID(curthread) | UMUTEX_CONTESTED; + TAILQ_FOREACH(ml, &curthread->pi_mutexq, qe) + ml->mutexp->m_lock.m_owner = TID(curthread); } int @@ -266,11 +244,11 @@ _pthread_mutex_destroy(pthread_mutex_t * } else if (m == THR_MUTEX_DESTROYED) { ret = EINVAL; } else { - if (m->m_owner != NULL || m->m_refcount != 0) { + if ((m->m_lock.m_owner & UMUTEX_OWNER_MASK) != 0 || + m->m_refcount != 0) { ret = EBUSY; } else { *mutex = THR_MUTEX_DESTROYED; - MUTEX_ASSERT_NOT_OWNED(m); free(m); ret = 0; } @@ -279,28 +257,6 @@ _pthread_mutex_destroy(pthread_mutex_t * return (ret); } -#define ENQUEUE_MUTEX(curthread, m) \ - do { \ - (m)->m_owner = curthread; \ - /* Add to the list of owned mutexes: */ \ - MUTEX_ASSERT_NOT_OWNED((m)); \ - if (((m)->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0) \ - TAILQ_INSERT_TAIL(&curthread->mutexq, (m), m_qe);\ - else \ - TAILQ_INSERT_TAIL(&curthread->pp_mutexq, (m), m_qe);\ - } while (0) - -#define CHECK_AND_INIT_MUTEX \ - if (__predict_false((m = *mutex) <= THR_MUTEX_DESTROYED)) { \ - if (m == THR_MUTEX_DESTROYED) \ - return (EINVAL); \ - int ret; \ - ret = init_static(_get_curthread(), mutex); \ - if (ret) \ - return (ret); \ - m = *mutex; \ - } - static int mutex_trylock_common(pthread_mutex_t *mutex) { @@ -309,15 +265,24 @@ mutex_trylock_common(pthread_mutex_t *mu uint32_t id; int ret; - id = TID(curthread); + if ((m->m_lock.m_flags & UMUTEX_SIMPLE) != 0) + id = UMUTEX_SIMPLE_OWNER; + else + id = TID(curthread); if (m->m_private) THR_CRITICAL_ENTER(curthread); ret = _thr_umutex_trylock(&m->m_lock, id); if (__predict_true(ret == 0)) { - ENQUEUE_MUTEX(curthread, m); - } else if (m->m_owner == curthread) { - ret = mutex_self_trylock(m); - } /* else {} */ + enqueue_mutex(curthread, m); + } else { + if ((m->m_lock.m_flags & UMUTEX_SIMPLE) != 0) { + if (m->m_ownertd == curthread) + ret = mutex_self_trylock(m); + } else { + if ((m->m_lock.m_owner & UMUTEX_OWNER_MASK) == id) + ret = mutex_self_trylock(m); + } + } if (ret && m->m_private) THR_CRITICAL_LEAVE(curthread); return (ret); @@ -341,10 +306,16 @@ mutex_lock_sleep(struct pthread *curthre int count; int ret; - if (m->m_owner == curthread) - return mutex_self_lock(m, abstime); - id = TID(curthread); + if ((m->m_lock.m_flags & UMUTEX_SIMPLE) != 0) { + if (m->m_ownertd == curthread) + return mutex_self_lock(m, abstime); + id = UMUTEX_SIMPLE_OWNER; + } else { + id = TID(curthread); + if ((m->m_lock.m_owner & UMUTEX_OWNER_MASK) == id) + return mutex_self_lock(m, abstime); + } /* * For adaptive mutexes, spin for a bit in the expectation * that if the application requests this mutex type then @@ -362,7 +333,7 @@ mutex_lock_sleep(struct pthread *curthre count = m->m_spinloops; while (count--) { owner = m->m_lock.m_owner; - if ((owner & ~UMUTEX_CONTESTED) == 0) { + if ((owner & UMUTEX_OWNER_MASK) == 0) { if (atomic_cmpset_acq_32(&m->m_lock.m_owner, owner, id|owner)) { ret = 0; goto done; @@ -396,7 +367,7 @@ sleep_in_kernel: } done: if (ret == 0) - ENQUEUE_MUTEX(curthread, m); + enqueue_mutex(curthread, m); return (ret); } @@ -406,12 +377,18 @@ mutex_lock_common(struct pthread_mutex * const struct timespec *abstime, int cvattach) { struct pthread *curthread = _get_curthread(); + uint32_t id; int ret; + if ((m->m_lock.m_flags & UMUTEX_SIMPLE) != 0) + id = UMUTEX_SIMPLE_OWNER; + else + id = TID(curthread); + if (m->m_private && !cvattach) THR_CRITICAL_ENTER(curthread); - if (_thr_umutex_trylock2(&m->m_lock, TID(curthread)) == 0) { - ENQUEUE_MUTEX(curthread, m); + if (_thr_umutex_trylock2(&m->m_lock, id) == 0) { + enqueue_mutex(curthread, m); ret = 0; } else { ret = mutex_lock_sleep(curthread, m, abstime); @@ -551,7 +528,7 @@ mutex_self_lock(struct pthread_mutex *m, int _mutex_owned(struct pthread *curthread, const pthread_mutex_t *mutex) { - struct pthread_mutex *m; + struct pthread_mutex *m; m = *mutex; if (__predict_false(m <= THR_MUTEX_DESTROYED)) { @@ -559,11 +536,17 @@ _mutex_owned(struct pthread *curthread, return (EINVAL); return (EPERM); } + /* * Check if the running thread is not the owner of the mutex. */ - if (__predict_false(m->m_owner != curthread)) - return (EPERM); + if ((m->m_lock.m_flags & UMUTEX_SIMPLE) != 0) { + if (__predict_false(m->m_ownertd != curthread)) + return (EPERM); + } else { + if ((m->m_lock.m_owner & UMUTEX_OWNER_MASK) != TID(curthread)) + return (EPERM); + } return (0); } @@ -580,22 +563,16 @@ mutex_unlock_common(pthread_mutex_t *mut m = *mutex; - id = TID(curthread); if (__predict_false( m->m_type == PTHREAD_MUTEX_RECURSIVE && m->m_count > 0)) { m->m_count--; } else { - m->m_owner = NULL; - /* Remove the mutex from the threads queue. */ - MUTEX_ASSERT_IS_OWNED(m); - if (__predict_true((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) - TAILQ_REMOVE(&curthread->mutexq, m, m_qe); - else { - TAILQ_REMOVE(&curthread->pp_mutexq, m, m_qe); - set_inherited_priority(curthread, m); - } - MUTEX_INIT_LINK(m); + if ((m->m_lock.m_flags & UMUTEX_SIMPLE) != 0) + id = UMUTEX_SIMPLE_OWNER; + else + id = TID(curthread); + dequeue_mutex(curthread, m); _thr_umutex_unlock(&m->m_lock, id); } if (m->m_private) @@ -623,6 +600,7 @@ _mutex_cv_unlock(pthread_mutex_t *mutex, { struct pthread *curthread = _get_curthread(); struct pthread_mutex *m; + uint32_t id; int err; if ((err = _mutex_owned(curthread, mutex)) != 0) @@ -636,17 +614,12 @@ _mutex_cv_unlock(pthread_mutex_t *mutex, *count = m->m_count; m->m_refcount++; m->m_count = 0; - m->m_owner = NULL; - /* Remove the mutex from the threads queue. */ - MUTEX_ASSERT_IS_OWNED(m); - if (__predict_true((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) - TAILQ_REMOVE(&curthread->mutexq, m, m_qe); - else { - TAILQ_REMOVE(&curthread->pp_mutexq, m, m_qe); - set_inherited_priority(curthread, m); - } - MUTEX_INIT_LINK(m); - _thr_umutex_unlock(&m->m_lock, TID(curthread)); + dequeue_mutex(curthread, m); + if ((m->m_lock.m_flags & UMUTEX_SIMPLE) != 0) + id = UMUTEX_SIMPLE_OWNER; + else + id = TID(curthread); + _thr_umutex_unlock(&m->m_lock, id); if (m->m_private) THR_CRITICAL_LEAVE(curthread); @@ -661,7 +634,7 @@ _mutex_cv_attach(pthread_mutex_t *mutex, int ret; m = *mutex; - ENQUEUE_MUTEX(curthread, m); + enqueue_mutex(curthread, m); m->m_refcount--; m->m_count += count; return (ret); @@ -685,16 +658,7 @@ _mutex_cv_detach(pthread_mutex_t *mutex, *count = m->m_count; m->m_refcount++; m->m_count = 0; - m->m_owner = NULL; - /* Remove the mutex from the threads queue. */ - MUTEX_ASSERT_IS_OWNED(m); - if (__predict_true((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) == 0)) - TAILQ_REMOVE(&curthread->mutexq, m, m_qe); - else { - TAILQ_REMOVE(&curthread->pp_mutexq, m, m_qe); - set_inherited_priority(curthread, m); - } - MUTEX_INIT_LINK(m); + dequeue_mutex(curthread, m); return (0); } @@ -722,7 +686,8 @@ _pthread_mutex_setprioceiling(pthread_mu int ceiling, int *old_ceiling) { struct pthread *curthread = _get_curthread(); - struct pthread_mutex *m, *m1, *m2; + struct mutex_link *ml, *ml1, *ml2; + struct pthread_mutex *m; int ret; m = *mutex; @@ -733,21 +698,26 @@ _pthread_mutex_setprioceiling(pthread_mu ret = __thr_umutex_set_ceiling(&m->m_lock, ceiling, old_ceiling); if (ret != 0) return (ret); - - if (m->m_owner == curthread) { - MUTEX_ASSERT_IS_OWNED(m); - m1 = TAILQ_PREV(m, mutex_queue, m_qe); - m2 = TAILQ_NEXT(m, m_qe); - if ((m1 != NULL && m1->m_lock.m_ceilings[0] > (u_int)ceiling) || - (m2 != NULL && m2->m_lock.m_ceilings[0] < (u_int)ceiling)) { - TAILQ_REMOVE(&curthread->pp_mutexq, m, m_qe); - TAILQ_FOREACH(m2, &curthread->pp_mutexq, m_qe) { - if (m2->m_lock.m_ceilings[0] > (u_int)ceiling) { - TAILQ_INSERT_BEFORE(m2, m, m_qe); + if (((m->m_lock.m_flags & UMUTEX_SIMPLE) && (m->m_ownertd == curthread)) || + (m->m_lock.m_owner & UMUTEX_OWNER_MASK) == TID(curthread)) { + TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) { + if (ml->mutexp == m) + break; + } + if (ml == NULL) /* howto ? */ + return (0); + ml1 = TAILQ_PREV(ml, mutex_link_list, qe); + ml2 = TAILQ_NEXT(ml, qe); + if ((ml1 != NULL && ml1->mutexp->m_lock.m_ceilings[0] > (u_int)ceiling) || + (ml2 != NULL && ml2->mutexp->m_lock.m_ceilings[0] < (u_int)ceiling)) { + TAILQ_REMOVE(&curthread->pp_mutexq, ml, qe); + TAILQ_FOREACH(ml2, &curthread->pp_mutexq, qe) { + if (ml2->mutexp->m_lock.m_ceilings[0] > (u_int)ceiling) { + TAILQ_INSERT_BEFORE(ml2, ml, qe); return (0); } } - TAILQ_INSERT_TAIL(&curthread->pp_mutexq, m, m_qe); + TAILQ_INSERT_TAIL(&curthread->pp_mutexq, ml, qe); } } return (0); @@ -800,10 +770,128 @@ __pthread_mutex_setyieldloops_np(pthread int _pthread_mutex_isowned_np(pthread_mutex_t *mutex) { - struct pthread_mutex *m; + return (_mutex_owned(_get_curthread(), mutex) == 0); +} - m = *mutex; - if (m <= THR_MUTEX_DESTROYED) - return (0); - return (m->m_owner == _get_curthread()); +void +_thr_mutex_link_init(struct pthread *td) +{ + TAILQ_INIT(&td->mutex_link_freeq); + TAILQ_INIT(&td->mutex_link_pages); + TAILQ_INIT(&td->pi_mutexq); + TAILQ_INIT(&td->pp_mutexq); +} + +struct mutex_link * +_thr_mutex_link_alloc(void) +{ + struct pthread *curthread = _get_curthread(); + struct mutex_link *p; + unsigned i; + + p = TAILQ_FIRST(&curthread->mutex_link_freeq); + if (p == NULL) { + struct mutex_link *pp = (struct mutex_link *)mmap(NULL, + _thr_page_size, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); + for (i = 2; i < _thr_page_size/sizeof(struct mutex_link); ++i) + TAILQ_INSERT_TAIL(&curthread->mutex_link_freeq, &pp[i], qe); + pp[0].mutexp = (struct pthread_mutex *)pp; /* the page address */ + TAILQ_INSERT_HEAD(&curthread->mutex_link_pages, &pp[0], qe); + p = &pp[1]; + } + _thread_printf(2, "%s alloc p=%x\n", __func__, p); + return (p); +} + +void +_thr_mutex_link_free(struct mutex_link *ml) +{ + struct pthread *curthread = _get_curthread(); + + TAILQ_INSERT_TAIL(&curthread->mutex_link_freeq, ml, qe); +} + +void +_thr_mutex_link_exit(struct pthread *curthread) +{ + struct mutex_link *ml, *ml2; + + TAILQ_FOREACH_SAFE(ml, &curthread->mutex_link_pages, qe, ml2) { + TAILQ_REMOVE(&curthread->mutex_link_pages, ml, qe); + munmap(ml->mutexp, _thr_page_size); + } + TAILQ_INIT(&curthread->mutex_link_freeq); +} + +static void +set_inherited_priority(struct pthread *curthread, struct pthread_mutex *m) +{ + struct mutex_link *ml2; + + ml2 = TAILQ_LAST(&curthread->pp_mutexq, mutex_link_list); + if (ml2 != NULL) + m->m_lock.m_ceilings[1] = ml2->mutexp->m_lock.m_ceilings[0]; + else + m->m_lock.m_ceilings[1] = -1; +} + +static void +enqueue_mutex(struct pthread *curthread, struct pthread_mutex *m) +{ + struct mutex_link *ml; + + if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) == 0) + m->m_ownertd = curthread; + + /* + * For PP mutex, we should restore previous priority after a PP + * mutex is unlocked, so we should remember every PP mutex. + */ + if ((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) != 0) { + ml = _thr_mutex_link_alloc(); + ml->mutexp = m; + TAILQ_INSERT_TAIL(&curthread->pp_mutexq, ml, qe); + } else if ((m->m_lock.m_flags & (UMUTEX_PRIO_INHERIT | + USYNC_PROCESS_SHARED)) == UMUTEX_PRIO_INHERIT) { + /* + * To make unlocking after fork() work, we need to link it, + * because we still use TID as lock-word for PI mutex. + * However, processs-shared mutex only has one copy, it should + * not be unlockable for child process, so we don't link it. + */ + if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) == 0) { + ml = _thr_mutex_link_alloc(); + ml->mutexp = m; + TAILQ_INSERT_TAIL(&curthread->pi_mutexq, ml, qe); + } + } +} + +static void +dequeue_mutex(struct pthread *curthread, struct pthread_mutex *m) +{ + struct mutex_link *ml; + + if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) == 0) + m->m_ownertd = NULL; + + if ((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) != 0) { + TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) { + if (ml->mutexp == m) { + TAILQ_REMOVE(&curthread->pp_mutexq, ml, qe); + set_inherited_priority(curthread, m); + _thr_mutex_link_free(ml); + break; + } + } + } else if ((m->m_lock.m_flags & (UMUTEX_PRIO_INHERIT | + USYNC_PROCESS_SHARED)) == UMUTEX_PRIO_INHERIT) { + TAILQ_FOREACH(ml, &curthread->pi_mutexq, qe) { + if (ml->mutexp == m) { + TAILQ_REMOVE(&curthread->pi_mutexq, ml, qe); + _thr_mutex_link_free(ml); + break; + } + } + } } Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Fri Nov 5 06:39:38 2010 (r214824) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Fri Nov 5 06:42:30 2010 (r214825) @@ -82,7 +82,7 @@ struct mutex_link { struct pthread_mutex *mutexp; }; -TAILQ_HEAD(mutex_queue, pthread_mutex); +TAILQ_HEAD(mutex_link_list, mutex_link); /* Signal to do cancellation */ #define SIGCANCEL 32 @@ -141,32 +141,23 @@ TAILQ_HEAD(mutex_queue, pthread_mutex); #define THR_RWLOCK_DESTROYED ((struct pthread_rwlock *)1) struct pthread_mutex { - /* - * Lock for accesses to this structure. - */ - struct umutex m_lock; - enum pthread_mutextype m_type; - struct pthread *m_owner; - int m_count; - int m_refcount; - int m_spinloops; - int m_yieldloops; - int m_private; - /* - * Link for all mutexes a thread currently owns. - */ - TAILQ_ENTRY(pthread_mutex) m_qe; + struct umutex m_lock; + enum pthread_mutextype m_type; + struct pthread *m_ownertd; + int m_count; + int m_refcount; + int m_spinloops; + int m_yieldloops; + int m_private; }; struct pthread_mutex_attr { enum pthread_mutextype m_type; int m_protocol; int m_ceiling; + int m_pshared; }; -#define PTHREAD_MUTEXATTR_STATIC_INITIALIZER \ - { PTHREAD_MUTEX_DEFAULT, PTHREAD_PRIO_NONE, 0, MUTEX_FLAGS_PRIVATE } - struct pthread_cond { struct ucond c_kerncv; /* @@ -450,10 +441,13 @@ struct pthread { #define TLFLAGS_IN_GCLIST 0x0004 /* thread in gc list */ /* Queue of currently owned NORMAL or PRIO_INHERIT type mutexes. */ - struct mutex_queue mutexq; + struct mutex_link_list pi_mutexq; /* Queue of all owned PRIO_PROTECT mutexes. */ - struct mutex_queue pp_mutexq; + struct mutex_link_list pp_mutexq; + + struct mutex_link_list mutex_link_freeq; + struct mutex_link_list mutex_link_pages; void *ret; struct pthread_specific_elem *specific; @@ -756,6 +750,10 @@ int _schedparam_to_rtp(int policy, const void _thread_bp_create(void); void _thread_bp_death(void); int _sched_yield(void); +void _thr_mutex_link_init(struct pthread *); +struct mutex_link *_thr_mutex_link_alloc(void); +void _thr_mutex_link_free(struct mutex_link *); +void _thr_mutex_link_exit(struct pthread *); void _pthread_cleanup_push(void (*)(void *), void *); void _pthread_cleanup_pop(int); @@ -831,10 +829,6 @@ struct dl_phdr_info; void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info); void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden; void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden; - -void _thr_mutex_link_init(void); -struct mutex_link * _thr_mutex_link_alloc(void); -void _thr_mutex_link_free(struct mutex_link *p); __END_DECLS #endif /* !_THR_PRIVATE_H */ From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 07:03:36 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2806F106564A; Fri, 5 Nov 2010 07:03:36 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1607C8FC14; Fri, 5 Nov 2010 07:03:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA573ZuT087810; Fri, 5 Nov 2010 07:03:35 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA573Z5G087808; Fri, 5 Nov 2010 07:03:35 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050703.oA573Z5G087808@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 07:03:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214826 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 07:03:36 -0000 Author: davidxu Date: Fri Nov 5 07:03:35 2010 New Revision: 214826 URL: http://svn.freebsd.org/changeset/base/214826 Log: Don't forget to lock the mutex again before doing thread cancellation. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 06:42:30 2010 (r214825) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 07:03:35 2010 (r214826) @@ -259,6 +259,7 @@ cond_wait_user(pthread_cond_t *cond, pth } else if (cancel && SHOULD_CANCEL(curthread) && !THR_IN_CRITICAL(curthread)) { _thr_umtx_unlock(&cv->c_lock); + _mutex_cv_lock(mutex, recurse); _pthread_exit(PTHREAD_CANCELED); } } @@ -292,7 +293,15 @@ cond_wait_common(pthread_cond_t *cond, p (cv->c_kerncv.c_flags & USYNC_PROCESS_SHARED)) return (EINVAL); + /* + * If the thread is real-time thread or if it holds priority mutex, + * it should use kernel based cv, because the cv internal lock + * does not protect priority, it can cause priority inversion. + * Note that if it is robust type of mutex, we should not use + * the internal lock too, because it is not robust. + */ if (curthread->attr.sched_policy != SCHED_OTHER || + curthread->priority_mutex_count != 0 || (m->m_lock.m_flags & (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_INHERIT)) != 0) return cond_wait_kernel(cond, mutex, abstime, cancel); else From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 07:04:32 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8A240106566B; Fri, 5 Nov 2010 07:04:32 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5DD438FC12; Fri, 5 Nov 2010 07:04:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA574W37087866; Fri, 5 Nov 2010 07:04:32 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA574WE6087863; Fri, 5 Nov 2010 07:04:32 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050704.oA574WE6087863@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 07:04:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214827 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 07:04:32 -0000 Author: davidxu Date: Fri Nov 5 07:04:32 2010 New Revision: 214827 URL: http://svn.freebsd.org/changeset/base/214827 Log: Account priority mutex we have locked, in cv_wait we use kernel based cv if the thread helds priority mutex. Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c user/davidxu/libthr/lib/libthr/thread/thr_private.h Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 07:03:35 2010 (r214826) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 07:04:32 2010 (r214827) @@ -865,6 +865,11 @@ enqueue_mutex(struct pthread *curthread, TAILQ_INSERT_TAIL(&curthread->pi_mutexq, ml, qe); } } + if ((m->m_lock.m_flags & + (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_PROTECT)) != 0) { + curthread->priority_mutex_count++; + _thread_printf(2, "priority mutex ++\n"); + } } static void @@ -881,7 +886,7 @@ dequeue_mutex(struct pthread *curthread, TAILQ_REMOVE(&curthread->pp_mutexq, ml, qe); set_inherited_priority(curthread, m); _thr_mutex_link_free(ml); - break; + goto out; } } } else if ((m->m_lock.m_flags & (UMUTEX_PRIO_INHERIT | @@ -890,8 +895,16 @@ dequeue_mutex(struct pthread *curthread, if (ml->mutexp == m) { TAILQ_REMOVE(&curthread->pi_mutexq, ml, qe); _thr_mutex_link_free(ml); - break; + goto out; } } } + return; + +out: + if ((m->m_lock.m_flags & + (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_PROTECT)) != 0) { + _thread_printf(2, "priority mutex --\n"); + curthread->priority_mutex_count--; + } } Modified: user/davidxu/libthr/lib/libthr/thread/thr_private.h ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_private.h Fri Nov 5 07:03:35 2010 (r214826) +++ user/davidxu/libthr/lib/libthr/thread/thr_private.h Fri Nov 5 07:04:32 2010 (r214827) @@ -440,7 +440,7 @@ struct pthread { #define TLFLAGS_IN_TDLIST 0x0002 /* thread in all thread list */ #define TLFLAGS_IN_GCLIST 0x0004 /* thread in gc list */ - /* Queue of currently owned NORMAL or PRIO_INHERIT type mutexes. */ + /* Queue of currently owned PRIO_INHERIT type mutexes. */ struct mutex_link_list pi_mutexq; /* Queue of all owned PRIO_PROTECT mutexes. */ @@ -453,6 +453,9 @@ struct pthread { struct pthread_specific_elem *specific; int specific_data_count; + /* Number of priority mutex held. */ + int priority_mutex_count; + /* Number rwlocks rdlocks held. */ int rdlock_count; From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 07:42:11 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06945106566C; Fri, 5 Nov 2010 07:42:11 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E8DC18FC17; Fri, 5 Nov 2010 07:42:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA57gAkW088619; Fri, 5 Nov 2010 07:42:10 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA57gAD3088617; Fri, 5 Nov 2010 07:42:10 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050742.oA57gAD3088617@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 07:42:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214828 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 07:42:11 -0000 Author: davidxu Date: Fri Nov 5 07:42:10 2010 New Revision: 214828 URL: http://svn.freebsd.org/changeset/base/214828 Log: Oops, remove printf. Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 07:04:32 2010 (r214827) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 07:42:10 2010 (r214828) @@ -799,7 +799,6 @@ _thr_mutex_link_alloc(void) TAILQ_INSERT_HEAD(&curthread->mutex_link_pages, &pp[0], qe); p = &pp[1]; } - _thread_printf(2, "%s alloc p=%x\n", __func__, p); return (p); } @@ -868,7 +867,6 @@ enqueue_mutex(struct pthread *curthread, if ((m->m_lock.m_flags & (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_PROTECT)) != 0) { curthread->priority_mutex_count++; - _thread_printf(2, "priority mutex ++\n"); } } @@ -904,7 +902,6 @@ dequeue_mutex(struct pthread *curthread, out: if ((m->m_lock.m_flags & (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_PROTECT)) != 0) { - _thread_printf(2, "priority mutex --\n"); curthread->priority_mutex_count--; } } From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 07:49:47 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 70CDE1065697; Fri, 5 Nov 2010 07:49:47 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5F2928FC19; Fri, 5 Nov 2010 07:49:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA57nlwB088856; Fri, 5 Nov 2010 07:49:47 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA57nlpO088854; Fri, 5 Nov 2010 07:49:47 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050749.oA57nlpO088854@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 07:49:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214829 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 07:49:47 -0000 Author: davidxu Date: Fri Nov 5 07:49:47 2010 New Revision: 214829 URL: http://svn.freebsd.org/changeset/base/214829 Log: Free memory pages of mutex link. Modified: user/davidxu/libthr/lib/libthr/thread/thr_exit.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_exit.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_exit.c Fri Nov 5 07:42:10 2010 (r214828) +++ user/davidxu/libthr/lib/libthr/thread/thr_exit.c Fri Nov 5 07:49:47 2010 (r214829) @@ -279,6 +279,7 @@ exit_thread(void) /* Tell malloc that the thread is exiting. */ _malloc_thread_cleanup(); + _thr_mutex_link_exit(curthread); THR_LOCK(curthread); curthread->state = PS_DEAD; From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 09:10:17 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 18DFC106566B; Fri, 5 Nov 2010 09:10:17 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E05A18FC18; Fri, 5 Nov 2010 09:10:16 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA59AGCx090783; Fri, 5 Nov 2010 09:10:16 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA59AGYZ090781; Fri, 5 Nov 2010 09:10:16 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050910.oA59AGYZ090781@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 09:10:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214832 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 09:10:17 -0000 Author: davidxu Date: Fri Nov 5 09:10:16 2010 New Revision: 214832 URL: http://svn.freebsd.org/changeset/base/214832 Log: Count priority mutex correctly. Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 09:06:23 2010 (r214831) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Fri Nov 5 09:10:16 2010 (r214832) @@ -847,26 +847,24 @@ enqueue_mutex(struct pthread *curthread, * mutex is unlocked, so we should remember every PP mutex. */ if ((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) != 0) { + curthread->priority_mutex_count++; ml = _thr_mutex_link_alloc(); ml->mutexp = m; TAILQ_INSERT_TAIL(&curthread->pp_mutexq, ml, qe); - } else if ((m->m_lock.m_flags & (UMUTEX_PRIO_INHERIT | - USYNC_PROCESS_SHARED)) == UMUTEX_PRIO_INHERIT) { + } else if ((m->m_lock.m_flags & UMUTEX_PRIO_INHERIT) != 0) { + curthread->priority_mutex_count++; /* * To make unlocking after fork() work, we need to link it, * because we still use TID as lock-word for PI mutex. * However, processs-shared mutex only has one copy, it should - * not be unlockable for child process, so we don't link it. + * not be unlockable for child process, so we don't link it, + * and _mutex_fork() won't find it. */ - if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) == 0) { - ml = _thr_mutex_link_alloc(); - ml->mutexp = m; - TAILQ_INSERT_TAIL(&curthread->pi_mutexq, ml, qe); - } - } - if ((m->m_lock.m_flags & - (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_PROTECT)) != 0) { - curthread->priority_mutex_count++; + if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) != 0) + return; + ml = _thr_mutex_link_alloc(); + ml->mutexp = m; + TAILQ_INSERT_TAIL(&curthread->pi_mutexq, ml, qe); } } @@ -879,29 +877,25 @@ dequeue_mutex(struct pthread *curthread, m->m_ownertd = NULL; if ((m->m_lock.m_flags & UMUTEX_PRIO_PROTECT) != 0) { + curthread->priority_mutex_count--; TAILQ_FOREACH(ml, &curthread->pp_mutexq, qe) { if (ml->mutexp == m) { TAILQ_REMOVE(&curthread->pp_mutexq, ml, qe); set_inherited_priority(curthread, m); _thr_mutex_link_free(ml); - goto out; + break; } } - } else if ((m->m_lock.m_flags & (UMUTEX_PRIO_INHERIT | - USYNC_PROCESS_SHARED)) == UMUTEX_PRIO_INHERIT) { + } else if ((m->m_lock.m_flags & UMUTEX_PRIO_INHERIT) != 0) { + curthread->priority_mutex_count--; + if ((m->m_lock.m_flags & USYNC_PROCESS_SHARED) != 0) + return; TAILQ_FOREACH(ml, &curthread->pi_mutexq, qe) { if (ml->mutexp == m) { TAILQ_REMOVE(&curthread->pi_mutexq, ml, qe); _thr_mutex_link_free(ml); - goto out; + break; } } } - return; - -out: - if ((m->m_lock.m_flags & - (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_PROTECT)) != 0) { - curthread->priority_mutex_count--; - } } From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 09:32:32 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5E600106566B; Fri, 5 Nov 2010 09:32:32 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4C8518FC18; Fri, 5 Nov 2010 09:32:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA59WWwT091319; Fri, 5 Nov 2010 09:32:32 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA59WWBs091317; Fri, 5 Nov 2010 09:32:32 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011050932.oA59WWBs091317@svn.freebsd.org> From: David Xu Date: Fri, 5 Nov 2010 09:32:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214833 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 09:32:32 -0000 Author: davidxu Date: Fri Nov 5 09:32:32 2010 New Revision: 214833 URL: http://svn.freebsd.org/changeset/base/214833 Log: Pass process-shared flag to syscall. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 09:10:16 2010 (r214832) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 09:32:32 2010 (r214833) @@ -60,6 +60,8 @@ __weak_reference(_pthread_cond_destroy, __weak_reference(_pthread_cond_signal, pthread_cond_signal); __weak_reference(_pthread_cond_broadcast, pthread_cond_broadcast); +#define CV_PSHARED(cv) (((cv)->c_kerncv.c_flags & USYNC_PROCESS_SHARED) != 0) + static int cond_init(pthread_cond_t *cond, const pthread_condattr_t *cond_attr) { @@ -238,11 +240,11 @@ cond_wait_user(pthread_cond_t *cond, pth if (cancel) { _thr_cancel_enter2(curthread, 0); ret = _thr_umtx_wait_uint((u_int *)&cv->c_seq, - (u_int)seq, tsp, 0); + (u_int)seq, tsp, CV_PSHARED(cv)); _thr_cancel_leave(curthread, 0); } else { ret = _thr_umtx_wait_uint((u_int *)&cv->c_seq, - (u_int)seq, tsp, 0); + (u_int)seq, tsp, CV_PSHARED(cv)); } _thr_umtx_lock_spin(&cv->c_lock); @@ -371,13 +373,13 @@ cond_signal_common(pthread_cond_t *cond, cv->c_seq++; cv->c_signaled++; cv->c_waiters--; - _thr_umtx_wake(&cv->c_seq, 1, 0); + _thr_umtx_wake(&cv->c_seq, 1, CV_PSHARED(cv)); } else { cv->c_seq++; cv->c_broadcast_seq++; cv->c_waiters = 0; cv->c_signaled = 0; - _thr_umtx_wake(&cv->c_seq, INT_MAX, 0); + _thr_umtx_wake(&cv->c_seq, INT_MAX, CV_PSHARED(cv)); } } _thr_umtx_unlock(&cv->c_lock); From owner-svn-src-user@FreeBSD.ORG Fri Nov 5 13:46:58 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4410106566B; Fri, 5 Nov 2010 13:46:58 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 930338FC14; Fri, 5 Nov 2010 13:46:58 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA5DkwFE098783; Fri, 5 Nov 2010 13:46:58 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA5DkwX0098781; Fri, 5 Nov 2010 13:46:58 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201011051346.oA5DkwX0098781@svn.freebsd.org> From: Ed Schouten Date: Fri, 5 Nov 2010 13:46:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214838 - user/ed/compiler-rt/contrib/compiler-rt/lib X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2010 13:46:58 -0000 Author: ed Date: Fri Nov 5 13:46:58 2010 New Revision: 214838 URL: http://svn.freebsd.org/changeset/base/214838 Log: Disable trampoline_setup() on PPC64. Modified: user/ed/compiler-rt/contrib/compiler-rt/lib/trampoline_setup.c Modified: user/ed/compiler-rt/contrib/compiler-rt/lib/trampoline_setup.c ============================================================================== --- user/ed/compiler-rt/contrib/compiler-rt/lib/trampoline_setup.c Fri Nov 5 13:45:26 2010 (r214837) +++ user/ed/compiler-rt/contrib/compiler-rt/lib/trampoline_setup.c Fri Nov 5 13:46:58 2010 (r214838) @@ -23,7 +23,7 @@ extern void __clear_cache(void* start, v * and then jumps to the target nested function. */ -#if __ppc__ +#if __ppc__ && !defined(__powerpc64__) void __trampoline_setup(uint32_t* trampOnStack, int trampSizeAllocated, const void* realFunc, void* localsPtr) { From owner-svn-src-user@FreeBSD.ORG Sat Nov 6 00:53:55 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C1281065670; Sat, 6 Nov 2010 00:53:55 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EF3988FC08; Sat, 6 Nov 2010 00:53:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oA60rsEt014351; Sat, 6 Nov 2010 00:53:54 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oA60rsOt014349; Sat, 6 Nov 2010 00:53:54 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011060053.oA60rsOt014349@svn.freebsd.org> From: David Xu Date: Sat, 6 Nov 2010 00:53:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214855 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Nov 2010 00:53:55 -0000 Author: davidxu Date: Sat Nov 6 00:53:54 2010 New Revision: 214855 URL: http://svn.freebsd.org/changeset/base/214855 Log: Decrease waiter count when it is timeout or canceled. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Fri Nov 5 22:18:09 2010 (r214854) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Sat Nov 6 00:53:54 2010 (r214855) @@ -257,9 +257,11 @@ cond_wait_user(pthread_cond_t *cond, pth ret = 0; break; } else if (ret == ETIMEDOUT) { + cv->c_waiters--; break; } else if (cancel && SHOULD_CANCEL(curthread) && !THR_IN_CRITICAL(curthread)) { + cv->c_waiters--; _thr_umtx_unlock(&cv->c_lock); _mutex_cv_lock(mutex, recurse); _pthread_exit(PTHREAD_CANCELED);