svn commit: r288475 - head/share/mk

2015-10-01 Thread Bryan Drewery
Author: bdrewery
Date: Fri Oct  2 06:24:09 2015
New Revision: 288475
URL: https://svnweb.freebsd.org/changeset/base/288475

Log:
  META_MODE: Fix stage_links not running in the right order without -j.
  
  This fixes staging errors for non-parallel builds that have LINKS.
  
  Creating hardlinks must always happen after the actual files are installed.
  The staging code was protected by an .ORDER statement that only affected
  parallel -j builds but not non-parallel builds.  Fix this by making the
  real stage_links.SET (stage_links.links, stage_links.mlinks, etc) targets
  depend on the main targets for all of the other possible staging needs.  For
  example, stage_links.links will depend on stage_as and stage_files, which have
  their own dependencies to stage_as.prog or stage_files.prog or 
stage_files.SET,
  which is enough to satistfy the ordering.
  
  Also remove the requirement that symlinks be created last, as they can
  safely be made without the source being present unlike hardlinks.  This also
  fixes symlinks to come before hardlinks as it is possible, in theory, to
  hardlink a symlink.  This is not actually supported here though.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/share/mk/meta.stage.mk

Modified: head/share/mk/meta.stage.mk
==
--- head/share/mk/meta.stage.mk Fri Oct  2 05:30:46 2015(r288474)
+++ head/share/mk/meta.stage.mk Fri Oct  2 06:24:09 2015(r288475)
@@ -237,10 +237,11 @@ stage_as.$s:  .dirdep
 CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes
 
 # stage_*links usually needs to follow any others.
-.for t in ${STAGE_TARGETS:N*links:O:u}
-.ORDER: $t stage_links
-.ORDER: $t stage_symlinks
+.if !empty(STAGE_SETS) && !empty(STAGE_TARGETS:Nstage_links)
+.for s in ${STAGE_SETS:O:u}
+stage_links.$s: ${STAGE_TARGETS:Nstage_links:O:u}
 .endfor
+.endif
 
 # make sure this exists
 staging:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-10-01 Thread Konstantin Belousov
Author: kib
Date: Fri Oct  2 05:27:12 2015
New Revision: 288473
URL: https://svnweb.freebsd.org/changeset/base/288473

Log:
  MFC r288216:
  Use per-cpu values for base and last in tc_cpu_ticks().

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

Modified: stable/10/sys/kern/kern_tc.c
==
--- stable/10/sys/kern/kern_tc.cFri Oct  2 05:04:17 2015
(r288472)
+++ stable/10/sys/kern/kern_tc.cFri Oct  2 05:27:12 2015
(r288473)
@@ -1888,20 +1888,27 @@ SYSINIT(timecounter, SI_SUB_CLOCKS, SI_O
 static int cpu_tick_variable;
 static uint64_tcpu_tick_frequency;
 
+static DPCPU_DEFINE(uint64_t, tc_cpu_ticks_base);
+static DPCPU_DEFINE(unsigned, tc_cpu_ticks_last);
+
 static uint64_t
 tc_cpu_ticks(void)
 {
-   static uint64_t base;
-   static unsigned last;
-   unsigned u;
struct timecounter *tc;
+   uint64_t res, *base;
+   unsigned u, *last;
 
+   critical_enter();
+   base = DPCPU_PTR(tc_cpu_ticks_base);
+   last = DPCPU_PTR(tc_cpu_ticks_last);
tc = timehands->th_counter;
u = tc->tc_get_timecount(tc) & tc->tc_counter_mask;
-   if (u < last)
-   base += (uint64_t)tc->tc_counter_mask + 1;
-   last = u;
-   return (u + base);
+   if (u < *last)
+   *base += (uint64_t)tc->tc_counter_mask + 1;
+   *last = u;
+   res = u + *base;
+   critical_exit();
+   return (res);
 }
 
 void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288472 - svnadmin/conf

2015-10-01 Thread Konstantin Belousov
Author: kib
Date: Fri Oct  2 05:04:17 2015
New Revision: 288472
URL: https://svnweb.freebsd.org/changeset/base/288472

Log:
  Free Jason.
  
  Approved by:  core (implicit)

Modified:
  svnadmin/conf/mentors

Modified: svnadmin/conf/mentors
==
--- svnadmin/conf/mentors   Fri Oct  2 02:21:36 2015(r288471)
+++ svnadmin/conf/mentors   Fri Oct  2 05:04:17 2015(r288472)
@@ -19,7 +19,6 @@ carl  jimharris
 cherry gibbs
 erignn Co-mentor: thompsa
 erjgnn Co-mentor: jfv
-jahkib
 jceel  wkoszek Co-mentor: cognet
 jkhrwatson
 jonathan   rwatson
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r288431 - in head/sys: kern sys vm

2015-10-01 Thread Mark Johnston
On Thu, Oct 01, 2015 at 09:32:45AM -0700, John Baldwin wrote:
> On Wednesday, September 30, 2015 11:06:30 PM Mark Johnston wrote:
> > Author: markj
> > Date: Wed Sep 30 23:06:29 2015
> > New Revision: 288431
> > URL: https://svnweb.freebsd.org/changeset/base/288431
> > 
> > Log:
> >   As a step towards the elimination of PG_CACHED pages, rework the handling
> >   of POSIX_FADV_DONTNEED so that it causes the backing pages to be moved to
> >   the head of the inactive queue instead of being cached.
> >   
> >   This affects the implementation of POSIX_FADV_NOREUSE as well, since it
> >   works by applying POSIX_FADV_DONTNEED to file ranges after they have been
> >   read or written.  At that point the corresponding buffers may still be
> >   dirty, so the previous implementation would coalesce successive ranges and
> >   apply POSIX_FADV_DONTNEED to the result, ensuring that pages backing the
> >   dirty buffers would eventually be cached.  To preserve this behaviour in 
> > an
> >   efficient manner, this change adds a new buf flag, B_NOREUSE, which causes
> >   the pages backing a VMIO buf to be placed at the head of the inactive 
> > queue
> >   when the buf is released.  POSIX_FADV_NOREUSE then works by setting this
> >   flag in bufs that underlie the specified range.
> 
> Putting these pages back on the inactive queue completely defeats the primary
> purpose of DONTNEED and NOREUSE.  The primary purpose is to move the pages out
> of the VM object's tree of pages and into the free pool so that the 
> application
> can instruct the VM to free memory more efficiently than relying on page 
> daemon.
> 
> The implementation used cache pages instead of free as a cheap optimization so
> that if an application did something dumb where it used DONTNEED and then 
> turned
> around and read the file it would not have to go to disk if the pages had not
> yet been reused.  In practice this didn't work out so well because PG_CACHE 
> pages
> don't really work well.
> 
> However, using PG_CACHE was secondary to the primary purpose of explicitly 
> freeing
> memory that an application knew wasn't going to be reused and avoiding the 
> need
> for pagedaemon to run at all.  I think this should be freeing the pages 
> instead of
> keeping them inactive.  If an application uses DONTNEED or NOREUSE and then 
> turns
> around and rereads the file, it generally deserves to have to go to disk for 
> it.

A problem with this is that one application's DONTNEED or NOREUSE hint
would cause every application reading or writing that file to go to
disk, but posix_fadvise(2) is explicitly intended for applications that
wish to provide hints about their own access patterns. I realize that
it's typically used with application-private files, but that's not a
requirement of the interface. Deactivating (or caching) the backing
pages generally avoids this problem.

> 
> I'm pretty sure I had mentioned this to Alan before.  I believe that the idea 
> is
> that pagedaemon should be cheap enough that having it run anyway shouldn't be 
> an
> issue, but I'm a bit skeptical of that. :)  Lock contention is always 
> possible and
> having DONTNEED/NOREUSE move pages to PG_CACHE avoided lock contention with
> pagedaemon during application page faults (since pagedaemon potentially never 
> has
> to run).

That's true, but the page queue locking (and the pagedaemon's
manipulation of the page queue locks) has also become more fine-grained
since posix_fadvise(2) was added. In particular, from some reading of
sys/vm in stable/8, inactive queue scans used to be performed with the
global page queue lock held; it was only dropped to launder dirty pages.
Now, the page queue lock is split into separate locks for the active and
inactive page queues, and the pagedaemon drops the inactive queue lock
for each page in all but a few exceptional cases. Does the optimization
of freeing or caching DONTNEED pages buy us all that much now?

Some synthetic testing in which an application writes out many large
(2G) files and calls posix_fadvise(FADV_DONTNEED) after each one shows
no significant difference in runtime if the buffer pages are deactivated
vs. freed. (My test just modifies vfs_vmio_unwire() to treat B_NOREUSE
identically to B_DIRECT.) Unsurprisingly, I see very little lock
contention in the latter case, but in the former, most of the lock
contention is short (i.e. the mutex is acquired while spinning), and
a large majority of the contention is on the free page queue mutex. If
lock contention there is a concern, wouldn't it be better to try and
address that directly rather than by bypassing the pagedaemon?

> 
> I believe that B_NOREUSE is definitely cleaner, btw.  I had wanted to change
> NOREUSE to work that way but wasn't sure how to do it.
> 
> -- 
> John Baldwin
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr.

svn commit: r288471 - head/sys/net80211

2015-10-01 Thread Adrian Chadd
Author: adrian
Date: Fri Oct  2 02:21:36 2015
New Revision: 288471
URL: https://svnweb.freebsd.org/changeset/base/288471

Log:
  Fix neeed -> neeeded.
  
  Submitted by: Andriy Voskoboinyk 
  Differential Revision:https://reviews.freebsd.org/D3595

Modified:
  head/sys/net80211/ieee80211_crypto_ccmp.c
  head/sys/net80211/ieee80211_crypto_tkip.c
  head/sys/net80211/ieee80211_crypto_wep.c

Modified: head/sys/net80211/ieee80211_crypto_ccmp.c
==
--- head/sys/net80211/ieee80211_crypto_ccmp.c   Fri Oct  2 02:09:50 2015
(r288470)
+++ head/sys/net80211/ieee80211_crypto_ccmp.c   Fri Oct  2 02:21:36 2015
(r288471)
@@ -168,7 +168,7 @@ ccmp_encap(struct ieee80211_key *k, stru
ivp[7] = k->wk_keytsc >> 40;/* PN5 */
 
/*
-* Finally, do software encrypt if neeed.
+* Finally, do software encrypt if needed.
 */
if ((k->wk_flags & IEEE80211_KEY_SWENCRYPT) &&
!ccmp_encrypt(k, m, hdrlen))

Modified: head/sys/net80211/ieee80211_crypto_tkip.c
==
--- head/sys/net80211/ieee80211_crypto_tkip.c   Fri Oct  2 02:09:50 2015
(r288470)
+++ head/sys/net80211/ieee80211_crypto_tkip.c   Fri Oct  2 02:21:36 2015
(r288471)
@@ -195,7 +195,7 @@ tkip_encap(struct ieee80211_key *k, stru
ivp[7] = k->wk_keytsc >> 40;/* TSC5 */
 
/*
-* Finally, do software encrypt if neeed.
+* Finally, do software encrypt if needed.
 */
if (k->wk_flags & IEEE80211_KEY_SWENCRYPT) {
if (!tkip_encrypt(ctx, k, m, hdrlen))

Modified: head/sys/net80211/ieee80211_crypto_wep.c
==
--- head/sys/net80211/ieee80211_crypto_wep.cFri Oct  2 02:09:50 2015
(r288470)
+++ head/sys/net80211/ieee80211_crypto_wep.cFri Oct  2 02:21:36 2015
(r288471)
@@ -184,7 +184,7 @@ wep_encap(struct ieee80211_key *k, struc
ivp[3] = keyid;
 
/*
-* Finally, do software encrypt if neeed.
+* Finally, do software encrypt if needed.
 */
if ((k->wk_flags & IEEE80211_KEY_SWENCRYPT) &&
!wep_encrypt(k, m, hdrlen))
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288470 - head/usr.sbin/bhyve

2015-10-01 Thread Peter Grehan
Author: grehan
Date: Fri Oct  2 02:09:50 2015
New Revision: 288470
URL: https://svnweb.freebsd.org/changeset/base/288470

Log:
  - Increase the max number of indirect descriptors to match
the largest that the Windows virtio driver can send down
  
  - Always advertize indirect descriptors. The Illumos virtio
driver won't attach unless this capability is seen.
  
  Reviewed by:  neel

Modified:
  head/usr.sbin/bhyve/pci_virtio_net.c

Modified: head/usr.sbin/bhyve/pci_virtio_net.c
==
--- head/usr.sbin/bhyve/pci_virtio_net.cFri Oct  2 02:08:40 2015
(r288469)
+++ head/usr.sbin/bhyve/pci_virtio_net.cFri Oct  2 02:09:50 2015
(r288470)
@@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$");
 
 #define VTNET_RINGSZ   1024
 
-#define VTNET_MAXSEGS  32
+#define VTNET_MAXSEGS  256
 
 /*
  * Host capabilities.  Note that we only offer a few of these.
@@ -84,7 +84,7 @@ __FBSDID("$FreeBSD$");
 
 #define VTNET_S_HOSTCAPS  \
   ( VIRTIO_NET_F_MAC | VIRTIO_NET_F_MRG_RXBUF | VIRTIO_NET_F_STATUS | \
-VIRTIO_F_NOTIFY_ON_EMPTY)
+VIRTIO_F_NOTIFY_ON_EMPTY | VIRTIO_RING_F_INDIRECT_DESC)
 
 /*
  * PCI config-space "registers"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288469 - stable/10/release/arm

2015-10-01 Thread Glen Barber
Author: gjb
Date: Fri Oct  2 02:08:40 2015
New Revision: 288469
URL: https://svnweb.freebsd.org/changeset/base/288469

Log:
  MFC r288374:
In addition to the ubldr file, also copy ubldr.bin to the
MS-DOS partition.  This will help with transitioning to
a single arm/armv6 userland build which could be used for
all FreeBSD/armv6 images without UBLDR_LOADADDR being set
for each board (ultimately requiring a separate buildworld
for each currently).
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/release/arm/BEAGLEBONE.conf
  stable/10/release/arm/CUBOX-HUMMINGBOARD.conf
  stable/10/release/arm/GUMSTIX.conf
  stable/10/release/arm/PANDABOARD.conf
  stable/10/release/arm/RPI-B.conf
  stable/10/release/arm/RPI2.conf
  stable/10/release/arm/WANDBOARD.conf
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/release/arm/BEAGLEBONE.conf
==
--- stable/10/release/arm/BEAGLEBONE.conf   Fri Oct  2 02:06:36 2015
(r288468)
+++ stable/10/release/arm/BEAGLEBONE.conf   Fri Oct  2 02:08:40 2015
(r288469)
@@ -26,6 +26,8 @@ arm_install_uboot() {
chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/MLO ${FATMOUNT}/MLO
chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+   chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr.bin \
+   ${FATMOUNT}/ubldr.bin
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
sync
umount_loop ${CHROOTDIR}/${FATMOUNT}

Modified: stable/10/release/arm/CUBOX-HUMMINGBOARD.conf
==
--- stable/10/release/arm/CUBOX-HUMMINGBOARD.conf   Fri Oct  2 02:06:36 
2015(r288468)
+++ stable/10/release/arm/CUBOX-HUMMINGBOARD.conf   Fri Oct  2 02:08:40 
2015(r288469)
@@ -28,6 +28,8 @@ arm_install_uboot() {
chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}
chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+   chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr.bin \
+   ${FATMOUNT}/ubldr.bin
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
sync
umount_loop ${CHROOTDIR}/${FATMOUNT}

Modified: stable/10/release/arm/GUMSTIX.conf
==
--- stable/10/release/arm/GUMSTIX.conf  Fri Oct  2 02:06:36 2015
(r288468)
+++ stable/10/release/arm/GUMSTIX.conf  Fri Oct  2 02:08:40 2015
(r288469)
@@ -26,6 +26,8 @@ arm_install_uboot() {
chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/MLO ${FATMOUNT}/MLO
chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+   chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr.bin \
+   ${FATMOUNT}/ubldr.bin
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
sync
umount_loop ${CHROOTDIR}/${FATMOUNT}

Modified: stable/10/release/arm/PANDABOARD.conf
==
--- stable/10/release/arm/PANDABOARD.conf   Fri Oct  2 02:06:36 2015
(r288468)
+++ stable/10/release/arm/PANDABOARD.conf   Fri Oct  2 02:08:40 2015
(r288469)
@@ -26,6 +26,8 @@ arm_install_uboot() {
chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/MLO ${FATMOUNT}/MLO
chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+   chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr.bin \
+   ${FATMOUNT}/ubldr.bin
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
sync
umount_loop ${CHROOTDIR}/${FATMOUNT}

Modified: stable/10/release/arm/RPI-B.conf
==
--- stable/10/release/arm/RPI-B.confFri Oct  2 02:06:36 2015
(r288468)
+++ stable/10/release/arm/RPI-B.confFri Oct  2 02:08:40 2015
(r288469)
@@ -30,6 +30,8 @@ arm_install_uboot() {
${FATMOUNT}/${_UF}
done
chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+   chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr.bin \
+   ${FATMOUNT}/ubldr.bin
chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/dtb/rpi.dtb \
${FATMOUNT}/rpi.dtb
chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot

Modified: stable/10/release/arm/RPI2.conf
==
--- stable/10/release/arm/RPI2.conf Fri Oct  2 02:06:36 2015
(r288468)
+++ stable/10/release/arm/RPI2.conf Fri Oct  2 02:08:40 2015
(r288469)

svn commit: r288468 - stable/10/release/tools

2015-10-01 Thread Glen Barber
Author: gjb
Date: Fri Oct  2 02:06:36 2015
New Revision: 288468
URL: https://svnweb.freebsd.org/changeset/base/288468

Log:
  MFC r288370:
In vm_copy_base(), turn off SU+J on the resultant filesystem,
leaving only SU enabled.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/release/tools/vmimage.subr
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/release/tools/vmimage.subr
==
--- stable/10/release/tools/vmimage.subrThu Oct  1 22:19:41 2015
(r288467)
+++ stable/10/release/tools/vmimage.subrFri Oct  2 02:06:36 2015
(r288468)
@@ -102,7 +102,7 @@ vm_copy_base() {
 
umount_loop /dev/${mdnew}
rmdir ${DESTDIR}/new
-   tunefs -j enable /dev/${mdnew}
+   tunefs -n enable /dev/${mdnew}
mdconfig -d -u ${mdnew}
mv ${VMBASE}.tmp ${VMBASE}
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288467 - stable/10/tests/sys/vm

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 22:19:41 2015
New Revision: 288467
URL: https://svnweb.freebsd.org/changeset/base/288467

Log:
  MFC 287448:
  Add more mmap tests related to character devices.
  - Add cdev-related tests for bad args.
  - Add two simple tests cases for mapping /dev/zero that test for
MAP_ANON-like behavior.

Modified:
  stable/10/tests/sys/vm/mmap_test.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tests/sys/vm/mmap_test.c
==
--- stable/10/tests/sys/vm/mmap_test.c  Thu Oct  1 22:17:27 2015
(r288466)
+++ stable/10/tests/sys/vm/mmap_test.c  Thu Oct  1 22:19:41 2015
(r288467)
@@ -110,18 +110,26 @@ checked_mmap(int prot, int flags, int fd
 ATF_TC_WITHOUT_HEAD(mmap__bad_arguments);
 ATF_TC_BODY(mmap__bad_arguments, tc)
 {
-   int fd;
+   int devstatfd, shmfd, zerofd;
 
-   ATF_REQUIRE((fd = shm_open(SHM_ANON, O_RDWR, 0644)) >= 0);
-   ATF_REQUIRE(ftruncate(fd, getpagesize()) == 0);
+   ATF_REQUIRE((devstatfd = open("/dev/devstat", O_RDONLY)) >= 0);
+   ATF_REQUIRE((shmfd = shm_open(SHM_ANON, O_RDWR, 0644)) >= 0);
+   ATF_REQUIRE(ftruncate(shmfd, getpagesize()) == 0);
+   ATF_REQUIRE((zerofd = open("/dev/zero", O_RDONLY)) >= 0);
 
/* These should work. */
checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON, -1, 0,
"simple MAP_ANON");
-   checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0,
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0,
"simple shm fd shared");
-   checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0,
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, shmfd, 0,
"simple shm fd private");
+   checked_mmap(PROT_READ, MAP_SHARED, zerofd, 0,
+   "simple /dev/zero shared");
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, zerofd, 0,
+   "simple /dev/zero private");
+   checked_mmap(PROT_READ, MAP_SHARED, devstatfd, 0,
+   "simple /dev/devstat shared");
 
 #if 0
/*
@@ -133,7 +141,7 @@ ATF_TC_BODY(mmap__bad_arguments, tc)
/* Extra PROT flags. */
checked_mmap(PROT_READ | PROT_WRITE | 0x10, MAP_ANON, -1, EINVAL,
"MAP_ANON with extra PROT flags");
-   checked_mmap(0x, MAP_SHARED, fd, EINVAL,
+   checked_mmap(0x, MAP_SHARED, shmfd, EINVAL,
"shm fd with garbage PROT");
 
/* Undefined flag. */
@@ -143,11 +151,11 @@ ATF_TC_BODY(mmap__bad_arguments, tc)
/* Both MAP_SHARED and MAP_PRIVATE */
checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE |
MAP_SHARED, -1, EINVAL, "MAP_ANON with both SHARED and PRIVATE");
-   checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_SHARED, fd,
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_SHARED, shmfd,
EINVAL, "shm fd with both SHARED and PRIVATE");
 
/* At least one of MAP_SHARED or MAP_PRIVATE without ANON */
-   checked_mmap(PROT_READ | PROT_WRITE, 0, fd, EINVAL,
+   checked_mmap(PROT_READ | PROT_WRITE, 0, shmfd, EINVAL,
"shm fd without sharing flag");
 #endif
 
@@ -160,6 +168,91 @@ ATF_TC_BODY(mmap__bad_arguments, tc)
/* MAP_ANON should require an fd of -1. */
checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, EINVAL,
"MAP_ANON with fd != -1");
+
+   /* Writable MAP_SHARED should fail on read-only descriptors. */
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, zerofd, EACCES,
+   "MAP_SHARED of read-only /dev/zero");
+
+   /*
+* Character devices other than /dev/zero do not support private
+* mappings.
+*/
+   checked_mmap(PROT_READ, MAP_PRIVATE, devstatfd, EINVAL,
+   "MAP_PRIVATE of /dev/devstat");
+}
+
+ATF_TC_WITHOUT_HEAD(mmap__dev_zero_private);
+ATF_TC_BODY(mmap__dev_zero_private, tc)
+{
+   char *p1, *p2, *p3;
+   size_t i;
+   int fd;
+
+   ATF_REQUIRE((fd = open("/dev/zero", O_RDONLY)) >= 0);
+
+   p1 = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
+   0);
+   ATF_REQUIRE(p1 != MAP_FAILED);
+
+   p2 = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
+   0);
+   ATF_REQUIRE(p2 != MAP_FAILED);
+
+   for (i = 0; i < getpagesize(); i++)
+   ATF_REQUIRE_EQ_MSG(0, p1[i], "byte at p1[%zu] is %x", i, p1[i]);
+
+   ATF_REQUIRE(memcmp(p1, p2, getpagesize()) == 0);
+
+   p1[0] = 1;
+
+   ATF_REQUIRE(p2[0] == 0);
+
+   p2[0] = 2;
+
+   ATF_REQUIRE(p1[0] == 1);
+
+   p3 = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
+   0);
+   ATF_REQUIRE(p3 != MAP_FAILED);
+
+   ATF_REQUIRE(p3[0] == 0);
+}
+
+ATF_TC_WITHOUT_HEAD(mmap__dev_zero_shared);
+ATF_TC_BODY(mmap__dev_zero_shared, tc)
+{
+   char *p1, *p2, *p3;
+   size_t i;
+   int fd;
+
+   AT

svn commit: r288466 - stable/10/tests/sys/vm

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 22:17:27 2015
New Revision: 288466
URL: https://svnweb.freebsd.org/changeset/base/288466

Log:
  MFC 286370:
  Add various tests to ensure that invalid arguments passed to mmap()
  trigger failures.
  
  Note: most of the tests that should provoke an EINVAL error do not
  pass on stable/10 as stable/10 does not have the changes that added
  more strict parameter checking to mmap().  Those changes will not be
  merged to stable/10, so I have disabled them via #if 0 with a comment
  explaining why.

Modified:
  stable/10/tests/sys/vm/mmap_test.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tests/sys/vm/mmap_test.c
==
--- stable/10/tests/sys/vm/mmap_test.c  Thu Oct  1 22:08:16 2015
(r288465)
+++ stable/10/tests/sys/vm/mmap_test.c  Thu Oct  1 22:17:27 2015
(r288466)
@@ -32,6 +32,10 @@
 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 static const struct {
void*addr;
@@ -83,10 +87,86 @@ ATF_TC_BODY(mmap__map_at_zero, tc)
}
 }
 
+static void
+checked_mmap(int prot, int flags, int fd, int error, const char *msg)
+{
+   void *p;
+
+   p = mmap(NULL, getpagesize(), prot, flags, fd, 0);
+   if (p == MAP_FAILED) {
+   if (error == 0)
+   ATF_CHECK_MSG(0, "%s failed with errno %d", msg,
+   errno);
+   else
+   ATF_CHECK_EQ_MSG(error, errno,
+   "%s failed with wrong errno %d (expected %d)", msg,
+   errno, error);
+   } else {
+   ATF_CHECK_MSG(error == 0, "%s succeeded", msg);
+   munmap(p, getpagesize());
+   }
+}
+
+ATF_TC_WITHOUT_HEAD(mmap__bad_arguments);
+ATF_TC_BODY(mmap__bad_arguments, tc)
+{
+   int fd;
+
+   ATF_REQUIRE((fd = shm_open(SHM_ANON, O_RDWR, 0644)) >= 0);
+   ATF_REQUIRE(ftruncate(fd, getpagesize()) == 0);
+
+   /* These should work. */
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON, -1, 0,
+   "simple MAP_ANON");
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0,
+   "simple shm fd shared");
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0,
+   "simple shm fd private");
+
+#if 0
+   /*
+* These tests do not fail without r271635 and followup fixes.
+* Those changes will not be merged to stable/10 since they
+* are potentially disruptive.
+*/
+
+   /* Extra PROT flags. */
+   checked_mmap(PROT_READ | PROT_WRITE | 0x10, MAP_ANON, -1, EINVAL,
+   "MAP_ANON with extra PROT flags");
+   checked_mmap(0x, MAP_SHARED, fd, EINVAL,
+   "shm fd with garbage PROT");
+
+   /* Undefined flag. */
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_RESERVED0080, -1,
+   EINVAL, "Undefined flag");
+
+   /* Both MAP_SHARED and MAP_PRIVATE */
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE |
+   MAP_SHARED, -1, EINVAL, "MAP_ANON with both SHARED and PRIVATE");
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_SHARED, fd,
+   EINVAL, "shm fd with both SHARED and PRIVATE");
+
+   /* At least one of MAP_SHARED or MAP_PRIVATE without ANON */
+   checked_mmap(PROT_READ | PROT_WRITE, 0, fd, EINVAL,
+   "shm fd without sharing flag");
+#endif
+
+   /* MAP_ANON with either sharing flag (impacts fork). */
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0,
+   "shared MAP_ANON");
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0,
+   "private MAP_ANON");
+
+   /* MAP_ANON should require an fd of -1. */
+   checked_mmap(PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, 0, EINVAL,
+   "MAP_ANON with fd != -1");
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
ATF_TP_ADD_TC(tp, mmap__map_at_zero);
+   ATF_TP_ADD_TC(tp, mmap__bad_arguments);
 
return (atf_no_error());
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288465 - stable/10/tests/sys/vm

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 22:08:16 2015
New Revision: 288465
URL: https://svnweb.freebsd.org/changeset/base/288465

Log:
  MFC 286369:
  Convert the map_at_zero test case to ATF.  In particular, this will
  facilitate adding more mmap() tests.

Modified:
  stable/10/tests/sys/vm/Makefile
  stable/10/tests/sys/vm/mmap_test.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tests/sys/vm/Makefile
==
--- stable/10/tests/sys/vm/Makefile Thu Oct  1 21:57:15 2015
(r288464)
+++ stable/10/tests/sys/vm/Makefile Thu Oct  1 22:08:16 2015
(r288465)
@@ -2,6 +2,6 @@
 
 TESTSDIR=  ${TESTSBASE}/sys/vm
 
-TAP_TESTS_C+=  mmap_test
+ATF_TESTS_C+=  mmap_test
 
 .include 

Modified: stable/10/tests/sys/vm/mmap_test.c
==
--- stable/10/tests/sys/vm/mmap_test.c  Thu Oct  1 21:57:15 2015
(r288464)
+++ stable/10/tests/sys/vm/mmap_test.c  Thu Oct  1 22:08:16 2015
(r288465)
@@ -29,16 +29,14 @@
 #include 
 #include 
 #include 
-#include 
 
+#include 
 #include 
-#include 
-#include 
 
 static const struct {
void*addr;
int ok[2];  /* Depending on security.bsd.map_at_zero {0, !=0}. */
-} tests[] = {
+} map_at_zero_tests[] = {
{ (void *)0,{ 0, 1 } }, /* Test sysctl. */
{ (void *)1,{ 0, 0 } },
{ (void *)(PAGE_SIZE - 1),  { 0, 0 } },
@@ -52,54 +50,43 @@ static const struct {
 
 #defineMAP_AT_ZERO "security.bsd.map_at_zero"
 
-int
-main(void)
+ATF_TC_WITHOUT_HEAD(mmap__map_at_zero);
+ATF_TC_BODY(mmap__map_at_zero, tc)
 {
void *p;
size_t len;
-   int i, error, mib[3], map_at_zero;
-
-   error = 0;
-
-   /* Get the current sysctl value of security.bsd.map_at_zero. */
-   len = sizeof(mib) / sizeof(*mib);
-   if (sysctlnametomib(MAP_AT_ZERO, mib, &len) == -1) {
-   printf("1..0 # SKIP: sysctlnametomib(\"%s\") failed: %s\n",
-   MAP_AT_ZERO, strerror(errno));
-   return (0);
-   }
+   unsigned int i;
+   int map_at_zero;
 
len = sizeof(map_at_zero);
-   if (sysctl(mib, 3, &map_at_zero, &len, NULL, 0) == -1) {
-   printf("1..0 # SKIP: sysctl for %s failed: %s\n", MAP_AT_ZERO,
+   if (sysctlbyname(MAP_AT_ZERO, &map_at_zero, &len, NULL, 0) == -1) {
+   atf_tc_skip("sysctl for %s failed: %s\n", MAP_AT_ZERO,
strerror(errno));
-   return (0);
+   return;
}
 
/* Normalize to 0 or 1 for array access. */
map_at_zero = !!map_at_zero;
 
-   printf("1..%zu\n", nitems(tests));
-   for (i = 0; i < (int)nitems(tests); i++) {
-   p = mmap((void *)tests[i].addr, PAGE_SIZE,
+   for (i = 0; i < nitems(map_at_zero_tests); i++) {
+   p = mmap((void *)map_at_zero_tests[i].addr, PAGE_SIZE,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED,
-1, 0);
if (p == MAP_FAILED) {
-   if (tests[i].ok[map_at_zero] != 0)
-   error++;
-   printf("%sok %d # mmap(%p, ...) failed\n",
-   tests[i].ok[map_at_zero] == 0 ? "" : "not ",
-   i + 1,
-   tests[i].addr);
+   ATF_CHECK_MSG(map_at_zero_tests[i].ok[map_at_zero] == 0,
+   "mmap(%p, ...) failed", map_at_zero_tests[i].addr);
} else {
-   if (tests[i].ok[map_at_zero] != 1)
-   error++;
-   printf("%sok %d # mmap(%p, ...) succeeded: p=%p\n",
-   tests[i].ok[map_at_zero] == 1 ? "" : "not ",
-   i + 1,
-   tests[i].addr, p);
+   ATF_CHECK_MSG(map_at_zero_tests[i].ok[map_at_zero] == 1,
+   "mmap(%p, ...) succeeded: p=%p\n",
+   map_at_zero_tests[i].addr, p);
}
}
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+   ATF_TP_ADD_TC(tp, mmap__map_at_zero);
 
-   return (error != 0);
+   return (atf_no_error());
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288464 - in stable: 10/lib/libc/stdio 9/lib/libc/stdio

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 21:57:15 2015
New Revision: 288464
URL: https://svnweb.freebsd.org/changeset/base/288464

Log:
  MFC 286177:
  Fix a couple of markup typos.

Modified:
  stable/9/lib/libc/stdio/open_memstream.3   (contents, props changed)
Directory Properties:
  stable/9/lib/libc/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/lib/libc/stdio/open_memstream.3
Directory Properties:
  stable/10/   (props changed)

Modified: stable/9/lib/libc/stdio/open_memstream.3
==
--- stable/9/lib/libc/stdio/open_memstream.3Thu Oct  1 21:54:43 2015
(r288463)
+++ stable/9/lib/libc/stdio/open_memstream.3Thu Oct  1 21:57:15 2015
(r288464)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 28, 2014
+.Dd August 1, 2015
 .Dt OPEN_MEMSTREAM 3
 .Os
 .Sh NAME
@@ -86,13 +86,13 @@ will contain the start of the memory buf
 will contain the smaller of the current position and the current buffer length.
 .Pp
 After a successful call to
-.Xr fflush 3,
+.Xr fflush 3 ,
 the pointer referenced by
 .Fa bufp
 and the variable referenced by
 .Fa sizep
 are only valid until the next write operation or a call to
-.Xr fclose 3.
+.Xr fclose 3 .
 .Pp
 Once a stream is closed,
 the allocated buffer referenced by
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288464 - in stable: 10/lib/libc/stdio 9/lib/libc/stdio

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 21:57:15 2015
New Revision: 288464
URL: https://svnweb.freebsd.org/changeset/base/288464

Log:
  MFC 286177:
  Fix a couple of markup typos.

Modified:
  stable/10/lib/libc/stdio/open_memstream.3
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/9/lib/libc/stdio/open_memstream.3   (contents, props changed)
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/10/lib/libc/stdio/open_memstream.3
==
--- stable/10/lib/libc/stdio/open_memstream.3   Thu Oct  1 21:54:43 2015
(r288463)
+++ stable/10/lib/libc/stdio/open_memstream.3   Thu Oct  1 21:57:15 2015
(r288464)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 28, 2014
+.Dd August 1, 2015
 .Dt OPEN_MEMSTREAM 3
 .Os
 .Sh NAME
@@ -86,13 +86,13 @@ will contain the start of the memory buf
 will contain the smaller of the current position and the current buffer length.
 .Pp
 After a successful call to
-.Xr fflush 3,
+.Xr fflush 3 ,
 the pointer referenced by
 .Fa bufp
 and the variable referenced by
 .Fa sizep
 are only valid until the next write operation or a call to
-.Xr fclose 3.
+.Xr fclose 3 .
 .Pp
 Once a stream is closed,
 the allocated buffer referenced by
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288463 - in stable: 10/sys/kern 9/sys/kern

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 21:54:43 2015
New Revision: 288463
URL: https://svnweb.freebsd.org/changeset/base/288463

Log:
  MFC 286256:
  kgdb uses td_oncpu to determine if a thread is running and should use
  a pcb from stoppcbs[] rather than the thread's PCB.  However, exited threads
  retained td_oncpu from the last time they ran, and newborn threads had their
  CPU fields cleared to zero during fork and thread creation since they are
  in the set of fields zeroed when threads are setup.  To fix, explicitly
  update the CPU fields for exiting threads in sched_throw() to reflect the
  switch out and reset the CPU fields for new threads in sched_fork_thread()
  to NOCPU.

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

Changes in other areas also in this revision:
Modified:
  stable/9/sys/kern/sched_4bsd.c
  stable/9/sys/kern/sched_ule.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/10/sys/kern/sched_4bsd.c
==
--- stable/10/sys/kern/sched_4bsd.c Thu Oct  1 21:52:25 2015
(r288462)
+++ stable/10/sys/kern/sched_4bsd.c Thu Oct  1 21:54:43 2015
(r288463)
@@ -793,6 +793,8 @@ sched_fork_thread(struct thread *td, str
 {
struct td_sched *ts;
 
+   childtd->td_oncpu = NOCPU;
+   childtd->td_lastcpu = NOCPU;
childtd->td_estcpu = td->td_estcpu;
childtd->td_lock = &sched_lock;
childtd->td_cpuset = cpuset_ref(td->td_cpuset);
@@ -1672,6 +1674,8 @@ sched_throw(struct thread *td)
} else {
lock_profile_release_lock(&sched_lock.lock_object);
MPASS(td->td_lock == &sched_lock);
+   td->td_lastcpu = td->td_oncpu;
+   td->td_oncpu = NOCPU;
}
mtx_assert(&sched_lock, MA_OWNED);
KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));

Modified: stable/10/sys/kern/sched_ule.c
==
--- stable/10/sys/kern/sched_ule.c  Thu Oct  1 21:52:25 2015
(r288462)
+++ stable/10/sys/kern/sched_ule.c  Thu Oct  1 21:54:43 2015
(r288463)
@@ -2071,6 +2071,8 @@ sched_fork_thread(struct thread *td, str
 */
ts = td->td_sched;
ts2 = child->td_sched;
+   child->td_oncpu = NOCPU;
+   child->td_lastcpu = NOCPU;
child->td_lock = TDQ_LOCKPTR(tdq);
child->td_cpuset = cpuset_ref(td->td_cpuset);
ts2->ts_cpu = ts->ts_cpu;
@@ -2694,6 +2696,8 @@ sched_throw(struct thread *td)
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
tdq_load_rem(tdq, td);
lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object);
+   td->td_lastcpu = td->td_oncpu;
+   td->td_oncpu = NOCPU;
}
KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));
newtd = choosethread();
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288463 - in stable: 10/sys/kern 9/sys/kern

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 21:54:43 2015
New Revision: 288463
URL: https://svnweb.freebsd.org/changeset/base/288463

Log:
  MFC 286256:
  kgdb uses td_oncpu to determine if a thread is running and should use
  a pcb from stoppcbs[] rather than the thread's PCB.  However, exited threads
  retained td_oncpu from the last time they ran, and newborn threads had their
  CPU fields cleared to zero during fork and thread creation since they are
  in the set of fields zeroed when threads are setup.  To fix, explicitly
  update the CPU fields for exiting threads in sched_throw() to reflect the
  switch out and reset the CPU fields for new threads in sched_fork_thread()
  to NOCPU.

Modified:
  stable/9/sys/kern/sched_4bsd.c
  stable/9/sys/kern/sched_ule.c
Directory Properties:
  stable/9/sys/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/kern/sched_4bsd.c
  stable/10/sys/kern/sched_ule.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/9/sys/kern/sched_4bsd.c
==
--- stable/9/sys/kern/sched_4bsd.c  Thu Oct  1 21:52:25 2015
(r288462)
+++ stable/9/sys/kern/sched_4bsd.c  Thu Oct  1 21:54:43 2015
(r288463)
@@ -793,6 +793,8 @@ sched_fork_thread(struct thread *td, str
 {
struct td_sched *ts;
 
+   childtd->td_oncpu = NOCPU;
+   childtd->td_lastcpu = NOCPU;
childtd->td_estcpu = td->td_estcpu;
childtd->td_lock = &sched_lock;
childtd->td_cpuset = cpuset_ref(td->td_cpuset);
@@ -1671,6 +1673,8 @@ sched_throw(struct thread *td)
} else {
lock_profile_release_lock(&sched_lock.lock_object);
MPASS(td->td_lock == &sched_lock);
+   td->td_lastcpu = td->td_oncpu;
+   td->td_oncpu = NOCPU;
}
mtx_assert(&sched_lock, MA_OWNED);
KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));

Modified: stable/9/sys/kern/sched_ule.c
==
--- stable/9/sys/kern/sched_ule.c   Thu Oct  1 21:52:25 2015
(r288462)
+++ stable/9/sys/kern/sched_ule.c   Thu Oct  1 21:54:43 2015
(r288463)
@@ -2035,6 +2035,8 @@ sched_fork_thread(struct thread *td, str
 */
ts = td->td_sched;
ts2 = child->td_sched;
+   child->td_oncpu = NOCPU;
+   child->td_lastcpu = NOCPU;
child->td_lock = TDQ_LOCKPTR(TDQ_SELF());
child->td_cpuset = cpuset_ref(td->td_cpuset);
ts2->ts_cpu = ts->ts_cpu;
@@ -2656,6 +2658,8 @@ sched_throw(struct thread *td)
MPASS(td->td_lock == TDQ_LOCKPTR(tdq));
tdq_load_rem(tdq, td);
lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object);
+   td->td_lastcpu = td->td_oncpu;
+   td->td_oncpu = NOCPU;
}
KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));
newtd = choosethread();
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288462 - in head/targets/pseudo: bootstrap-tools stage

2015-10-01 Thread Bryan Drewery
Author: bdrewery
Date: Thu Oct  1 21:52:25 2015
New Revision: 288462
URL: https://svnweb.freebsd.org/changeset/base/288462

Log:
  Don't create cookie until the command is all finished, it or the commands
  after may fail.
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/targets/pseudo/bootstrap-tools/Makefile
  head/targets/pseudo/stage/Makefile

Modified: head/targets/pseudo/bootstrap-tools/Makefile
==
--- head/targets/pseudo/bootstrap-tools/MakefileThu Oct  1 20:54:19 
2015(r288461)
+++ head/targets/pseudo/bootstrap-tools/MakefileThu Oct  1 21:52:25 
2015(r288462)
@@ -43,8 +43,10 @@ BSARGS=  DESTDIR= \
 
 legacy: .MAKE .META
mkdir -p ${LEGACY_TOOLS}
-   ${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${BTOOLSDIR} > $@2
-   ${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${LEGACY_TOOLS} > $@
+   ${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${BTOOLSDIR} \
+   > $@.distrib-dirs_btoolsdir
+   ${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${LEGACY_TOOLS} \
+   > $@.distrib-dirs_legacy_tools
${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
touch $@
 

Modified: head/targets/pseudo/stage/Makefile
==
--- head/targets/pseudo/stage/Makefile  Thu Oct  1 20:54:19 2015
(r288461)
+++ head/targets/pseudo/stage/Makefile  Thu Oct  1 21:52:25 2015
(r288462)
@@ -8,7 +8,9 @@ all:
 # we don't need to see it.
 stage-distrib-dirs: .META
mkdir -p ${STAGE_OBJTOP}
-   ${.MAKE} -C ${SRCTOP}/etc distrib-dirs -DWITH_TESTS 
DESTDIR=${STAGE_OBJTOP} > $@
+   ${.MAKE} -C ${SRCTOP}/etc distrib-dirs -DWITH_TESTS \
+   DESTDIR=${STAGE_OBJTOP} > $@.distrib_dirs
+   touch $@
 
 .include 
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r288453 - in stable/10: lib/libutil sys/sys sys/vm usr.bin/vmstat

2015-10-01 Thread John Baldwin
On Thursday, October 01, 2015 05:09:21 PM John Baldwin wrote:
> Author: jhb
> Date: Thu Oct  1 17:09:20 2015
> New Revision: 288453
> URL: https://svnweb.freebsd.org/changeset/base/288453
> 
> Log:
>   MFC 283624,283630:
>   Export a list of VM objects in the system via a sysctl.  The list can be
>   examined via 'vmstat -o'.  It can be used to determine which files are
>   using physical pages of memory and how much each is using.

Note that userland sysctls in stable/10 are single-threaded.  Thus, other
programs that use sysctls will hang while this new sysctl runs.  Resolving
the pathnames of mapped files can take a while, especially if any NFS files
are mapped (on the order of seconds).  Programs like top(1), ps(1), fstat(1),
vmstat(1), etc. all use sysctls to fetch information, so they will all hang
while 'vmstat -o' runs.  This does not mean the entire machine has locked up,
but it can feel like it.  User beware, etc.

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


svn commit: r288461 - stable/10/sys/x86/acpica

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 20:54:19 2015
New Revision: 288461
URL: https://svnweb.freebsd.org/changeset/base/288461

Log:
  MFC 284175:
  Handle X2APIC entries in the MADT for APICs with an ID < 255.  At least one
  BIOS has been seen to include such entries even though the relevant specs
  require that X2APIC entries only be used for CPUs with an APIC ID >= 255.
  
  This was tested on a system with "plain" local APIC entries in the MADT
  to ensure no regressions, but it has not yet been tested on a system with
  X2APIC entries in the MADT.  Currently such systems do not boot at all,
  and with this change they might now boot correctly.

Modified:
  stable/10/sys/x86/acpica/madt.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/x86/acpica/madt.c
==
--- stable/10/sys/x86/acpica/madt.c Thu Oct  1 20:49:10 2015
(r288460)
+++ stable/10/sys/x86/acpica/madt.c Thu Oct  1 20:54:19 2015
(r288461)
@@ -53,8 +53,8 @@ static struct {
 } *ioapics;
 
 static struct lapic_info {
-   u_int la_enabled:1;
-   u_int la_acpi_id:8;
+   u_int la_enabled;
+   u_int la_acpi_id;
 } lapics[MAX_APIC_ID + 1];
 
 static int madt_found_sci_override;
@@ -220,34 +220,48 @@ madt_walk_table(acpi_subtable_handler *h
 }
 
 static void
+madt_add_cpu(u_int acpi_id, u_int apic_id, u_int flags)
+{
+   struct lapic_info *la;
+
+   /*
+* The MADT does not include a BSP flag, so we have to let the
+* MP code figure out which CPU is the BSP on its own.
+*/
+   if (bootverbose)
+   printf("MADT: Found CPU APIC ID %u ACPI ID %u: %s\n",
+   apic_id, acpi_id, flags & ACPI_MADT_ENABLED ?
+   "enabled" : "disabled");
+   if (!(flags & ACPI_MADT_ENABLED))
+   return;
+   if (apic_id > MAX_APIC_ID) {
+   printf("MADT: Ignoring local APIC ID %u (too high)\n",
+   apic_id);
+   return;
+   }
+
+   la = &lapics[apic_id];
+   KASSERT(la->la_enabled == 0, ("Duplicate local APIC ID %u", apic_id));
+   la->la_enabled = 1;
+   la->la_acpi_id = acpi_id;
+   lapic_create(apic_id, 0);
+}
+
+static void
 madt_probe_cpus_handler(ACPI_SUBTABLE_HEADER *entry, void *arg)
 {
ACPI_MADT_LOCAL_APIC *proc;
-   struct lapic_info *la;
+   ACPI_MADT_LOCAL_X2APIC *x2apic;
 
switch (entry->Type) {
case ACPI_MADT_TYPE_LOCAL_APIC:
-   /*
-* The MADT does not include a BSP flag, so we have to
-* let the MP code figure out which CPU is the BSP on
-* its own.
-*/
proc = (ACPI_MADT_LOCAL_APIC *)entry;
-   if (bootverbose)
-   printf("MADT: Found CPU APIC ID %u ACPI ID %u: %s\n",
-   proc->Id, proc->ProcessorId,
-   (proc->LapicFlags & ACPI_MADT_ENABLED) ?
-   "enabled" : "disabled");
-   if (!(proc->LapicFlags & ACPI_MADT_ENABLED))
-   break;
-   if (proc->Id > MAX_APIC_ID)
-   panic("%s: CPU ID %u too high", __func__, proc->Id);
-   la = &lapics[proc->Id];
-   KASSERT(la->la_enabled == 0,
-   ("Duplicate local APIC ID %u", proc->Id));
-   la->la_enabled = 1;
-   la->la_acpi_id = proc->ProcessorId;
-   lapic_create(proc->Id, 0);
+   madt_add_cpu(proc->ProcessorId, proc->Id, proc->LapicFlags);
+   break;
+   case ACPI_MADT_TYPE_LOCAL_X2APIC:
+   x2apic = (ACPI_MADT_LOCAL_X2APIC *)entry;
+   madt_add_cpu(x2apic->Uid, x2apic->LocalApicId,
+   x2apic->LapicFlags);
break;
}
 }
@@ -503,29 +517,44 @@ madt_parse_nmi(ACPI_MADT_NMI_SOURCE *nmi
  * Parse an entry for an NMI routed to a local APIC LVT pin.
  */
 static void
-madt_parse_local_nmi(ACPI_MADT_LOCAL_APIC_NMI *nmi)
+madt_handle_local_nmi(u_int acpi_id, UINT8 Lint, UINT16 IntiFlags)
 {
u_int apic_id, pin;
 
-   if (nmi->ProcessorId == 0xff)
+   if (acpi_id == 0x)
apic_id = APIC_ID_ALL;
-   else if (madt_find_cpu(nmi->ProcessorId, &apic_id) != 0) {
+   else if (madt_find_cpu(acpi_id, &apic_id) != 0) {
if (bootverbose)
printf("MADT: Ignoring local NMI routed to "
-   "ACPI CPU %u\n", nmi->ProcessorId);
+   "ACPI CPU %u\n", acpi_id);
return;
}
-   if (nmi->Lint == 0)
+   if (Lint == 0)
pin = APIC_LVT_LINT0;
else
pin = APIC_LVT_LINT1;
lapic_set_lvt_mode(apic_id, pin, APIC_LVT_DM_NMI);
-   if (!(nmi->IntiFlags & ACPI_MADT_TRIGGER_CONFORMS))
+   if (!(IntiFlags & ACPI_

svn commit: r288460 - in stable: 10/sys/dev/hwpmc 9/sys/dev/hwpmc

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 20:49:10 2015
New Revision: 288460
URL: https://svnweb.freebsd.org/changeset/base/288460

Log:
  MFC 283121:
  Use the proper mask when reloading sampling PMCs for Core CPUs.

Modified:
  stable/9/sys/dev/hwpmc/hwpmc_core.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/dev/hwpmc/hwpmc_core.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/9/sys/dev/hwpmc/hwpmc_core.c
==
--- stable/9/sys/dev/hwpmc/hwpmc_core.c Thu Oct  1 19:48:10 2015
(r288459)
+++ stable/9/sys/dev/hwpmc/hwpmc_core.c Thu Oct  1 20:49:10 2015
(r288460)
@@ -2458,7 +2458,7 @@ core_intr(int cpu, struct trapframe *tf)
TRAPF_USERMODE(tf));
 
v = pm->pm_sc.pm_reloadcount;
-   v = iaf_reload_count_to_perfctr_value(v);
+   v = iap_reload_count_to_perfctr_value(v);
 
/*
 * Stop the counter, reload it but only restart it if
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288460 - in stable: 10/sys/dev/hwpmc 9/sys/dev/hwpmc

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 20:49:10 2015
New Revision: 288460
URL: https://svnweb.freebsd.org/changeset/base/288460

Log:
  MFC 283121:
  Use the proper mask when reloading sampling PMCs for Core CPUs.

Modified:
  stable/10/sys/dev/hwpmc/hwpmc_core.c
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/9/sys/dev/hwpmc/hwpmc_core.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/10/sys/dev/hwpmc/hwpmc_core.c
==
--- stable/10/sys/dev/hwpmc/hwpmc_core.cThu Oct  1 19:48:10 2015
(r288459)
+++ stable/10/sys/dev/hwpmc/hwpmc_core.cThu Oct  1 20:49:10 2015
(r288460)
@@ -2572,7 +2572,7 @@ core_intr(int cpu, struct trapframe *tf)
TRAPF_USERMODE(tf));
 
v = pm->pm_sc.pm_reloadcount;
-   v = iaf_reload_count_to_perfctr_value(v);
+   v = iap_reload_count_to_perfctr_value(v);
 
/*
 * Stop the counter, reload it but only restart it if
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r288454 - head/usr.bin/truss

2015-10-01 Thread Justin Hibbits
powerpc64 also defines __powerpc64__ in addition to __powerpc__.  This is
likely because unlike amd64, the only major difference between 32-bit and
64-bit is the register size, so mips will likely be the same way.

-Justin
On Oct 1, 2015 2:51 PM, "John Baldwin"  wrote:

> On Thursday, October 01, 2015 05:28:07 PM John Baldwin wrote:
> > Author: jhb
> > Date: Thu Oct  1 17:28:07 2015
> > New Revision: 288454
> > URL: https://svnweb.freebsd.org/changeset/base/288454
> >
> > Log:
> >   - Remove extra integer argument from truncate() and ftruncate().  This
> is
> > probably fallout from the removal of the extra padding argument
> before
> > off_t in 7.  However, that padding still exists for 32-bit powerpc,
> so
> > use QUAD_ALIGN.
> >   - Fix QUAD_ALIGN to be zero for powerpc64.  It should only be set to 1
> > for 32-bit platforms that add padding to align 64-bit arguments.
>
> I'm not sure how the situation is on arm and MIPS, but on powerpc, both the
> 32-bit and 64-bit platforms define __powerpc__ (unlike amd64 which doesn't
> define __i386__ for example) making proper #ifdef's for just 32-bit
> __powerpc__ a bit of a PITA.
>
> --
> John Baldwin
>
>
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r288454 - head/usr.bin/truss

2015-10-01 Thread John Baldwin
On Thursday, October 01, 2015 05:28:07 PM John Baldwin wrote:
> Author: jhb
> Date: Thu Oct  1 17:28:07 2015
> New Revision: 288454
> URL: https://svnweb.freebsd.org/changeset/base/288454
> 
> Log:
>   - Remove extra integer argument from truncate() and ftruncate().  This is
> probably fallout from the removal of the extra padding argument before
> off_t in 7.  However, that padding still exists for 32-bit powerpc, so
> use QUAD_ALIGN.
>   - Fix QUAD_ALIGN to be zero for powerpc64.  It should only be set to 1
> for 32-bit platforms that add padding to align 64-bit arguments.

I'm not sure how the situation is on arm and MIPS, but on powerpc, both the
32-bit and 64-bit platforms define __powerpc__ (unlike amd64 which doesn't
define __i386__ for example) making proper #ifdef's for just 32-bit
__powerpc__ a bit of a PITA.

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


svn commit: r288459 - head/release/arm

2015-10-01 Thread Glen Barber
Author: gjb
Date: Thu Oct  1 19:48:10 2015
New Revision: 288459
URL: https://svnweb.freebsd.org/changeset/base/288459

Log:
  Fix the path to the correct u-boot.bin file to write to
  the disk image, which fixes boot issues.
  
  Tested on:BananaPi
  Sponsored by: The FreeBSD Foundation

Modified:
  head/release/arm/BANANAPI.conf
  head/release/arm/CUBIEBOARD.conf
  head/release/arm/CUBIEBOARD2.conf

Modified: head/release/arm/BANANAPI.conf
==
--- head/release/arm/BANANAPI.conf  Thu Oct  1 19:07:15 2015
(r288458)
+++ head/release/arm/BANANAPI.conf  Thu Oct  1 19:48:10 2015
(r288459)
@@ -22,10 +22,8 @@ arm_install_uboot() {
UBOOT_FILES="u-boot.img"
FATMOUNT="${DESTDIR%${KERNEL}}/fat"
UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
-   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/sunxi-spl.bin \
-   of=/dev/${mddev} bs=1k seek=8
-   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
-   of=/dev/${mddev} bs=1k seek=40 conv=notrunc,sync
+   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/u-boot-sunxi-with-spl.bin \
+   of=/dev/${mddev} bs=1k seek=8 conv=sync
chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}

Modified: head/release/arm/CUBIEBOARD.conf
==
--- head/release/arm/CUBIEBOARD.confThu Oct  1 19:07:15 2015
(r288458)
+++ head/release/arm/CUBIEBOARD.confThu Oct  1 19:48:10 2015
(r288459)
@@ -21,10 +21,8 @@ arm_install_uboot() {
UBOOT_FILES="u-boot.img"
FATMOUNT="${DESTDIR%${KERNEL}}/fat"
UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
-   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/sunxi-spl.bin \
-   of=/dev/${mddev} bs=1k seek=8
-   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
-   of=/dev/${mddev} bs=1k seek=40 conv=notrunc,sync
+   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/u-boot-sunxi-with-spl.bin \
+   of=/dev/${mddev} bs=1k seek=8 conv=sync
chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}

Modified: head/release/arm/CUBIEBOARD2.conf
==
--- head/release/arm/CUBIEBOARD2.conf   Thu Oct  1 19:07:15 2015
(r288458)
+++ head/release/arm/CUBIEBOARD2.conf   Thu Oct  1 19:48:10 2015
(r288459)
@@ -22,10 +22,8 @@ arm_install_uboot() {
UBOOT_FILES="u-boot.img"
FATMOUNT="${DESTDIR%${KERNEL}}/fat"
UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
-   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/sunxi-spl.bin \
-   of=/dev/${mddev} bs=1k seek=8
-   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
-   of=/dev/${mddev} bs=1k seek=40 conv=notrunc,sync
+   chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/u-boot-sunxi-with-spl.bin \
+   of=/dev/${mddev} bs=1k seek=8 conv=sync
chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288458 - head/sys/cam/ctl

2015-10-01 Thread Alexander Motin
Author: mav
Date: Thu Oct  1 19:07:15 2015
New Revision: 288458
URL: https://svnweb.freebsd.org/changeset/base/288458

Log:
  More aggressively fill WUT read pipeline.
  
  On some tests I've measured 5% copy speedup from this.

Modified:
  head/sys/cam/ctl/ctl_tpc.c

Modified: head/sys/cam/ctl/ctl_tpc.c
==
--- head/sys/cam/ctl/ctl_tpc.c  Thu Oct  1 19:02:45 2015(r288457)
+++ head/sys/cam/ctl/ctl_tpc.c  Thu Oct  1 19:07:15 2015(r288458)
@@ -1128,7 +1128,7 @@ static int
 tpc_process_wut(struct tpc_list *list)
 {
struct tpc_io *tio, *tior, *tiow;
-   struct runl run, *prun;
+   struct runl run;
int drange, srange;
off_t doffset, soffset;
off_t srclba, dstlba, numbytes, donebytes, roundbytes;
@@ -1208,8 +1208,7 @@ tpc_process_wut(struct tpc_list *list)
 //srclba, dstlba);
donebytes = 0;
TAILQ_INIT(&run);
-   prun = &run;
-   list->tbdio = 1;
+   list->tbdio = 0;
TAILQ_INIT(&list->allio);
while (donebytes < numbytes) {
roundbytes = numbytes - donebytes;
@@ -1262,8 +1261,8 @@ tpc_process_wut(struct tpc_list *list)
tiow->io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = tiow;
 
TAILQ_INSERT_TAIL(&tior->run, tiow, rlinks);
-   TAILQ_INSERT_TAIL(prun, tior, rlinks);
-   prun = &tior->run;
+   TAILQ_INSERT_TAIL(&run, tior, rlinks);
+   list->tbdio++;
donebytes += roundbytes;
srclba += roundbytes / srcblock;
dstlba += roundbytes / dstblock;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288456 - head/usr.bin/truss

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 18:18:58 2015
New Revision: 288456
URL: https://svnweb.freebsd.org/changeset/base/288456

Log:
  Rather than groveling around in a socket address structure for a socket
  address's length (and then overriding it if it "looks wrong"), use the
  next argument to the system call to determine the length.  This is more
  reliable since this is what the kernel depends on anyway and is also
  simpler.

Modified:
  head/usr.bin/truss/syscalls.c

Modified: head/usr.bin/truss/syscalls.c
==
--- head/usr.bin/truss/syscalls.c   Thu Oct  1 17:50:41 2015
(r288455)
+++ head/usr.bin/truss/syscalls.c   Thu Oct  1 18:18:58 2015
(r288456)
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1288,12 +1289,12 @@ print_arg(struct syscall_args *sc, unsig
fputs(xlookup_bits(rfork_flags, args[sc->offset]), fp);
break;
case Sockaddr: {
-   struct sockaddr_storage ss;
char addr[64];
struct sockaddr_in *lsin;
struct sockaddr_in6 *lsin6;
struct sockaddr_un *sun;
struct sockaddr *sa;
+   socklen_t len;
u_char *q;
 
if (args[sc->offset] == 0) {
@@ -1301,70 +1302,71 @@ print_arg(struct syscall_args *sc, unsig
break;
}
 
-   /* yuck: get ss_len */
-   if (get_struct(pid, (void *)args[sc->offset], (void *)&ss,
-   sizeof(ss.ss_len) + sizeof(ss.ss_family)) == -1) {
-   fprintf(fp, "0x%lx", args[sc->offset]);
-   break;
-   }
-
/*
-* If ss_len is 0, then try to guess from the sockaddr type.
-* AF_UNIX may be initialized incorrectly, so always frob
-* it by using the "right" size.
+* Extract the address length from the next argument.  If
+* this is an output sockaddr (OUT is set), then the
+* next argument is a pointer to a socklen_t.  Otherwise
+* the next argument contains a socklen_t by value.
 */
-   if (ss.ss_len == 0 || ss.ss_family == AF_UNIX) {
-   switch (ss.ss_family) {
-   case AF_INET:
-   ss.ss_len = sizeof(*lsin);
-   break;
-   case AF_INET6:
-   ss.ss_len = sizeof(*lsin6);
-   break;
-   case AF_UNIX:
-   ss.ss_len = sizeof(*sun);
-   break;
-   default:
+   if (sc->type & OUT) {
+   if (get_struct(pid, (void *)args[sc->offset + 1],
+   &len, sizeof(len)) == -1) {
+   fprintf(fp, "0x%lx", args[sc->offset]);
break;
}
+   } else
+   len = args[sc->offset + 1];
+
+   /* If the length is too small, just bail. */
+   if (len < sizeof(*sa)) {
+   fprintf(fp, "0x%lx", args[sc->offset]);
+   break;
}
-   if (ss.ss_len != 0 &&
-   get_struct(pid, (void *)args[sc->offset], (void *)&ss,
-   ss.ss_len) == -1) {
+
+   sa = calloc(1, len);
+   if (get_struct(pid, (void *)args[sc->offset], sa, len) == -1) {
+   free(sa);
fprintf(fp, "0x%lx", args[sc->offset]);
break;
}
 
-   switch (ss.ss_family) {
+   switch (sa->sa_family) {
case AF_INET:
-   lsin = (struct sockaddr_in *)&ss;
+   if (len < sizeof(*lsin))
+   goto sockaddr_short;
+   lsin = (struct sockaddr_in *)(void *)sa;
inet_ntop(AF_INET, &lsin->sin_addr, addr, sizeof(addr));
fprintf(fp, "{ AF_INET %s:%d }", addr,
htons(lsin->sin_port));
break;
case AF_INET6:
-   lsin6 = (struct sockaddr_in6 *)&ss;
+   if (len < sizeof(*lsin6))
+   goto sockaddr_short;
+   lsin6 = (struct sockaddr_in6 *)(void *)sa;
inet_ntop(AF_INET6, &lsin6->sin6_addr, addr,
sizeof(addr));
fprintf(fp, "{ AF_INET6 [%s]:%d }", addr,
htons(lsin6->sin6_port));
brea

svn commit: r288455 - head/usr.bin/truss

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 17:50:41 2015
New Revision: 288455
URL: https://svnweb.freebsd.org/changeset/base/288455

Log:
  The id_t type used to pass IDs to wait6(2) and procctl(6) is a 64-bit
  integer.  Fix the argument decoding to treat this as a quad instead of an
  int.  This includes using QUAD_ALIGN and QUAD_SLOTS as necessary.  To
  continue printing IDs in decimal, add a new QuadHex argument type that
  prints a 64-bit integer in hex, use QuadHex for the existing off_t arguments,
  repurpose Quad to print a 64-bit integer in decimal, and use Quad for id_t
  arguments.
  
  This fixes the decoding of wait6(2) and procctl(2) on 32-bit platforms.

Modified:
  head/usr.bin/truss/syscall.h
  head/usr.bin/truss/syscalls.c

Modified: head/usr.bin/truss/syscall.h
==
--- head/usr.bin/truss/syscall.hThu Oct  1 17:28:07 2015
(r288454)
+++ head/usr.bin/truss/syscall.hThu Oct  1 17:50:41 2015
(r288455)
@@ -42,7 +42,7 @@ enum Argtype { None = 1, Hex, Octal, Int
Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
-   Sysarch, ExecArgs, ExecEnv, PipeFds };
+   Sysarch, ExecArgs, ExecEnv, PipeFds, QuadHex };
 
 #defineARG_MASK0xff
 #defineOUT 0x100

Modified: head/usr.bin/truss/syscalls.c
==
--- head/usr.bin/truss/syscalls.c   Thu Oct  1 17:28:07 2015
(r288454)
+++ head/usr.bin/truss/syscalls.c   Thu Oct  1 17:50:41 2015
(r288455)
@@ -106,13 +106,13 @@ static struct syscall syscalls[] = {
  .args = { { Atfd, 0 }, { Name, 1 }, { Readlinkres | OUT, 2 },
{ Int, 3 } } },
{ .name = "lseek", .ret_type = 2, .nargs = 3,
- .args = { { Int, 0 }, { Quad, 1 + QUAD_ALIGN },
+ .args = { { Int, 0 }, { QuadHex, 1 + QUAD_ALIGN },
{ Whence, 1 + QUAD_SLOTS + QUAD_ALIGN } } },
{ .name = "linux_lseek", .ret_type = 2, .nargs = 3,
  .args = { { Int, 0 }, { Int, 1 }, { Whence, 2 } } },
{ .name = "mmap", .ret_type = 1, .nargs = 6,
  .args = { { Ptr, 0 }, { Int, 1 }, { Mprot, 2 }, { Mmapflags, 3 },
-   { Int, 4 }, { Quad, 5 + QUAD_ALIGN } } },
+   { Int, 4 }, { QuadHex, 5 + QUAD_ALIGN } } },
{ .name = "linux_mkdir", .ret_type = 1, .nargs = 2,
  .args = { { Name | IN, 0 }, { Int, 1 } } },
{ .name = "mprotect", .ret_type = 1, .nargs = 3,
@@ -321,9 +321,9 @@ static struct syscall syscalls[] = {
{ .name = "pipe2", .ret_type = 1, .nargs = 2,
  .args = { { Ptr, 0 }, { Open, 1 } } },
{ .name = "truncate", .ret_type = 1, .nargs = 2,
- .args = { { Name | IN, 0 }, { Quad | IN, 1 + QUAD_ALIGN } } },
+ .args = { { Name | IN, 0 }, { QuadHex | IN, 1 + QUAD_ALIGN } } },
{ .name = "ftruncate", .ret_type = 1, .nargs = 2,
- .args = { { Int | IN, 0 }, { Quad | IN, 1 + QUAD_ALIGN } } },
+ .args = { { Int | IN, 0 }, { QuadHex | IN, 1 + QUAD_ALIGN } } },
{ .name = "kill", .ret_type = 1, .nargs = 2,
  .args = { { Int | IN, 0 }, { Signal | IN, 1 } } },
{ .name = "munmap", .ret_type = 1, .nargs = 2,
@@ -344,10 +344,15 @@ static struct syscall syscalls[] = {
  .args = { { Int, 0 }, { ExitStatus | OUT, 1 }, { Waitoptions, 2 },
{ Rusage | OUT, 3 } } },
{ .name = "wait6", .ret_type = 1, .nargs = 6,
- .args = { { Idtype, 0 }, { Int, 1 }, { ExitStatus | OUT, 2 },
-   { Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } },
+ .args = { { Idtype, 0 }, { Quad, 1 + QUAD_ALIGN },
+   { ExitStatus | OUT, 1 + QUAD_ALIGN + QUAD_SLOTS },
+   { Waitoptions, 2 + QUAD_ALIGN + QUAD_SLOTS },
+   { Rusage | OUT, 3 + QUAD_ALIGN + QUAD_SLOTS },
+   { Ptr, 4 + QUAD_ALIGN + QUAD_SLOTS } } },
{ .name = "procctl", .ret_type = 1, .nargs = 4,
- .args = { { Idtype, 0 }, { Int, 1 }, { Procctl, 2 }, { Ptr, 3 } } },
+ .args = { { Idtype, 0 }, { Quad, 1 + QUAD_ALIGN },
+   { Procctl, 1 + QUAD_ALIGN + QUAD_SLOTS },
+   { Ptr, 2 + QUAD_ALIGN + QUAD_SLOTS } } },
{ .name = "sysarch", .ret_type = 1, .nargs = 2,
  .args = { { Sysarch, 0 }, { Ptr, 1 } } },
{ .name = "_umtx_op", .ret_type = 1, .nargs = 5,
@@ -966,10 +971,14 @@ print_arg(struct syscall_args *sc, unsig
}
 #ifdef __LP64__
case Quad:
+   fprintf(fp, "%ld", args[sc->offset]);
+   break;
+   case QuadHex:
fprintf(fp, "0x%lx", args[sc->offset]);
break;
 #else
-   case Quad: {
+   case Quad:
+   cas

svn commit: r288454 - head/usr.bin/truss

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 17:28:07 2015
New Revision: 288454
URL: https://svnweb.freebsd.org/changeset/base/288454

Log:
  - Remove extra integer argument from truncate() and ftruncate().  This is
probably fallout from the removal of the extra padding argument before
off_t in 7.  However, that padding still exists for 32-bit powerpc, so
use QUAD_ALIGN.
  - Fix QUAD_ALIGN to be zero for powerpc64.  It should only be set to 1
for 32-bit platforms that add padding to align 64-bit arguments.

Modified:
  head/usr.bin/truss/syscalls.c

Modified: head/usr.bin/truss/syscalls.c
==
--- head/usr.bin/truss/syscalls.c   Thu Oct  1 17:09:20 2015
(r288453)
+++ head/usr.bin/truss/syscalls.c   Thu Oct  1 17:28:07 2015
(r288454)
@@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$");
 #include "syscall.h"
 
 /* 64-bit alignment on 32-bit platforms. */
-#ifdef __powerpc__
+#if !defined(__LP64__) && defined(__powerpc__)
 #defineQUAD_ALIGN  1
 #else
 #defineQUAD_ALIGN  0
@@ -320,10 +320,10 @@ static struct syscall syscalls[] = {
  .args = { { PipeFds | OUT, 0 } } },
{ .name = "pipe2", .ret_type = 1, .nargs = 2,
  .args = { { Ptr, 0 }, { Open, 1 } } },
-   { .name = "truncate", .ret_type = 1, .nargs = 3,
- .args = { { Name | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } },
-   { .name = "ftruncate", .ret_type = 1, .nargs = 3,
- .args = { { Int | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } },
+   { .name = "truncate", .ret_type = 1, .nargs = 2,
+ .args = { { Name | IN, 0 }, { Quad | IN, 1 + QUAD_ALIGN } } },
+   { .name = "ftruncate", .ret_type = 1, .nargs = 2,
+ .args = { { Int | IN, 0 }, { Quad | IN, 1 + QUAD_ALIGN } } },
{ .name = "kill", .ret_type = 1, .nargs = 2,
  .args = { { Int | IN, 0 }, { Signal | IN, 1 } } },
{ .name = "munmap", .ret_type = 1, .nargs = 2,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288453 - in stable/10: lib/libutil sys/sys sys/vm usr.bin/vmstat

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 17:09:20 2015
New Revision: 288453
URL: https://svnweb.freebsd.org/changeset/base/288453

Log:
  MFC 283624,283630:
  Export a list of VM objects in the system via a sysctl.  The list can be
  examined via 'vmstat -o'.  It can be used to determine which files are
  using physical pages of memory and how much each is using.

Added:
  stable/10/lib/libutil/kinfo_getvmobject.3
 - copied unchanged from r283624, head/lib/libutil/kinfo_getvmobject.3
  stable/10/lib/libutil/kinfo_getvmobject.c
 - copied unchanged from r283624, head/lib/libutil/kinfo_getvmobject.c
Modified:
  stable/10/lib/libutil/Makefile
  stable/10/lib/libutil/libutil.h
  stable/10/sys/sys/user.h
  stable/10/sys/vm/vm_object.c
  stable/10/usr.bin/vmstat/vmstat.8
  stable/10/usr.bin/vmstat/vmstat.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libutil/Makefile
==
--- stable/10/lib/libutil/Makefile  Thu Oct  1 16:59:07 2015
(r288452)
+++ stable/10/lib/libutil/Makefile  Thu Oct  1 17:09:20 2015
(r288453)
@@ -10,7 +10,8 @@ SHLIB_MAJOR= 9
 
 SRCS=  _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \
hexdump.c humanize_number.c kinfo_getfile.c kinfo_getfile.c \
-   kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c kld.c \
+   kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \
+   kinfo_getvmobject.c kld.c \
login_auth.c login_cap.c \
login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \
pidfile.c property.c pty.c pw_util.c quotafile.c realhostname.c \
@@ -27,7 +28,8 @@ CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../li
 
 MAN+=  expand_number.3 flopen.3 fparseln.3 hexdump.3 \
humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \
-   kinfo_getproc.3 kinfo_getvmmap.3 kld.3 login_auth.3 login_cap.3 \
+   kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \
+   login_auth.3 login_cap.3 \
login_class.3 login_ok.3 login_times.3 login_tty.3 pidfile.3 \
property.3 pty.3 quotafile.3 realhostname.3 realhostname_sa.3 \
_secure_path.3 trimdomain.3 uucplock.3 pw_util.3

Copied: stable/10/lib/libutil/kinfo_getvmobject.3 (from r283624, 
head/lib/libutil/kinfo_getvmobject.3)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/10/lib/libutil/kinfo_getvmobject.3   Thu Oct  1 17:09:20 2015
(r288453, copy of r283624, head/lib/libutil/kinfo_getvmobject.3)
@@ -0,0 +1,74 @@
+.\"
+.\" Copyright (c) 2015 John Baldwin 
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"notice, this list of conditions and the following disclaimer in the
+.\"documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 27, 2015
+.Dt KINFO_GETVMOBJECT 3
+.Os
+.Sh NAME
+.Nm kinfo_getvmobject
+.Nd function for getting system-wide memory information
+.Sh LIBRARY
+.Lb libutil
+.Sh SYNOPSIS
+.In sys/types.h
+.In sys/user.h
+.In libutil.h
+.Ft struct kinfo_vmobject *
+.Fn kinfo_getvmobject "int *cntp"
+.Sh DESCRIPTION
+This function is used to obtain information about the objects using memory
+in the system.
+.Pp
+The
+.Ar cntp
+argument allows the caller to know how many records are returned.
+.Pp
+This function is a wrapper around the
+.Dq vm.objects
+.Xr sysctl 3
+MIB.
+While the kernel returns a packed structure, this function expands the
+data into a fixed record format.
+.Sh RETURN VALUES
+On success the
+.Fn kinfo_getvmobject
+function returns a pointer to an array of
+.Vt struct kinfo_vmobject
+structures as defined by
+.In sys/user.h .
+The array is allocated by an internal call to
+.Xr malloc 3
+and must be free

Re: svn commit: r288452 - head/sys/dev/drm2/i915

2015-10-01 Thread John Baldwin
On Thursday, October 01, 2015 04:59:08 PM John Baldwin wrote:
> Author: jhb
> Date: Thu Oct  1 16:59:07 2015
> New Revision: 288452
> URL: https://svnweb.freebsd.org/changeset/base/288452
> 
> Log:
>   Most error cases in i915_gem_do_execbuffer() jump to one of two labels to
>   release resources (such as unholding pages) when errors occur.  Some
>   recently added error checks return immediately instead of jumping to a
>   label resulting in leaks.  Fix these to jump to a label to do cleanup
>   instead.

I was getting panics due to the hold count on pages being negative in this
function.  The hold counts were quiet high and so I believe that the hold
count overflowed to zero due to these leaks and triggered the panic.

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


svn commit: r288452 - head/sys/dev/drm2/i915

2015-10-01 Thread John Baldwin
Author: jhb
Date: Thu Oct  1 16:59:07 2015
New Revision: 288452
URL: https://svnweb.freebsd.org/changeset/base/288452

Log:
  Most error cases in i915_gem_do_execbuffer() jump to one of two labels to
  release resources (such as unholding pages) when errors occur.  Some
  recently added error checks return immediately instead of jumping to a
  label resulting in leaks.  Fix these to jump to a label to do cleanup
  instead.
  
  Reviewed by:  kib
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D3745

Modified:
  head/sys/dev/drm2/i915/i915_gem_execbuffer.c

Modified: head/sys/dev/drm2/i915/i915_gem_execbuffer.c
==
--- head/sys/dev/drm2/i915/i915_gem_execbuffer.cThu Oct  1 16:34:53 
2015(r288451)
+++ head/sys/dev/drm2/i915/i915_gem_execbuffer.cThu Oct  1 16:59:07 
2015(r288452)
@@ -1151,7 +1151,8 @@ i915_gem_do_execbuffer(struct drm_device
if (ctx_id != 0) {
DRM_DEBUG("Ring %s doesn't support contexts\n",
  ring->name);
-   return -EPERM;
+   ret = -EPERM;
+   goto pre_struct_lock_err;
}
break;
case I915_EXEC_BLT:
@@ -1159,7 +1160,8 @@ i915_gem_do_execbuffer(struct drm_device
if (ctx_id != 0) {
DRM_DEBUG("Ring %s doesn't support contexts\n",
  ring->name);
-   return -EPERM;
+   ret = -EPERM;
+   goto pre_struct_lock_err;
}
break;
default:
@@ -1171,7 +1173,8 @@ i915_gem_do_execbuffer(struct drm_device
if (!intel_ring_initialized(ring)) {
DRM_DEBUG("execbuf with invalid ring: %d\n",
  (int)(args->flags & I915_EXEC_RING_MASK));
-   return -EINVAL;
+   ret = -EINVAL;
+   goto pre_struct_lock_err;
}
 
mode = args->flags & I915_EXEC_CONSTANTS_MASK;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r288431 - in head/sys: kern sys vm

2015-10-01 Thread John Baldwin
On Wednesday, September 30, 2015 11:06:30 PM Mark Johnston wrote:
> Author: markj
> Date: Wed Sep 30 23:06:29 2015
> New Revision: 288431
> URL: https://svnweb.freebsd.org/changeset/base/288431
> 
> Log:
>   As a step towards the elimination of PG_CACHED pages, rework the handling
>   of POSIX_FADV_DONTNEED so that it causes the backing pages to be moved to
>   the head of the inactive queue instead of being cached.
>   
>   This affects the implementation of POSIX_FADV_NOREUSE as well, since it
>   works by applying POSIX_FADV_DONTNEED to file ranges after they have been
>   read or written.  At that point the corresponding buffers may still be
>   dirty, so the previous implementation would coalesce successive ranges and
>   apply POSIX_FADV_DONTNEED to the result, ensuring that pages backing the
>   dirty buffers would eventually be cached.  To preserve this behaviour in an
>   efficient manner, this change adds a new buf flag, B_NOREUSE, which causes
>   the pages backing a VMIO buf to be placed at the head of the inactive queue
>   when the buf is released.  POSIX_FADV_NOREUSE then works by setting this
>   flag in bufs that underlie the specified range.

Putting these pages back on the inactive queue completely defeats the primary
purpose of DONTNEED and NOREUSE.  The primary purpose is to move the pages out
of the VM object's tree of pages and into the free pool so that the application
can instruct the VM to free memory more efficiently than relying on page daemon.

The implementation used cache pages instead of free as a cheap optimization so
that if an application did something dumb where it used DONTNEED and then turned
around and read the file it would not have to go to disk if the pages had not
yet been reused.  In practice this didn't work out so well because PG_CACHE 
pages
don't really work well.

However, using PG_CACHE was secondary to the primary purpose of explicitly 
freeing
memory that an application knew wasn't going to be reused and avoiding the need
for pagedaemon to run at all.  I think this should be freeing the pages instead 
of
keeping them inactive.  If an application uses DONTNEED or NOREUSE and then 
turns
around and rereads the file, it generally deserves to have to go to disk for it.

I'm pretty sure I had mentioned this to Alan before.  I believe that the idea is
that pagedaemon should be cheap enough that having it run anyway shouldn't be an
issue, but I'm a bit skeptical of that. :)  Lock contention is always possible 
and
having DONTNEED/NOREUSE move pages to PG_CACHE avoided lock contention with
pagedaemon during application page faults (since pagedaemon potentially never 
has
to run).

I believe that B_NOREUSE is definitely cleaner, btw.  I had wanted to change
NOREUSE to work that way but wasn't sure how to do it.

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


svn commit: r288451 - head/sys/kern

2015-10-01 Thread Mark Johnston
Author: markj
Date: Thu Oct  1 16:34:53 2015
New Revision: 288451
URL: https://svnweb.freebsd.org/changeset/base/288451

Log:
  Ensure that vop_stdadvise() does not call getblk() on vnodes that have an
  empty bufobj. Otherwise, vnodes belonging to filesystems that do not use the
  buffer cache may trigger assertion failures.
  
  Reported by:  Fabien Keil

Modified:
  head/sys/kern/vfs_default.c

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Thu Oct  1 16:30:20 2015(r288450)
+++ head/sys/kern/vfs_default.c Thu Oct  1 16:34:53 2015(r288451)
@@ -1077,16 +1077,15 @@ vop_stdadvise(struct vop_advise_args *ap
BO_RLOCK(&vp->v_bufobj);
bsize = vp->v_bufobj.bo_bsize;
startn = ap->a_start / bsize;
-   if (ap->a_end == OFF_MAX) {
-   endn = -1;
-   bl = &vp->v_bufobj.bo_clean.bv_hd;
-   if (!TAILQ_EMPTY(bl))
-   endn = TAILQ_LAST(bl, buflists)->b_lblkno;
-   bl = &vp->v_bufobj.bo_dirty.bv_hd;
-   if (!TAILQ_EMPTY(bl) &&
-   endn < TAILQ_LAST(bl, buflists)->b_lblkno)
-   endn = TAILQ_LAST(bl, buflists)->b_lblkno;
-   } else
+   endn = -1;
+   bl = &vp->v_bufobj.bo_clean.bv_hd;
+   if (!TAILQ_EMPTY(bl))
+   endn = TAILQ_LAST(bl, buflists)->b_lblkno;
+   bl = &vp->v_bufobj.bo_dirty.bv_hd;
+   if (!TAILQ_EMPTY(bl) &&
+   endn < TAILQ_LAST(bl, buflists)->b_lblkno)
+   endn = TAILQ_LAST(bl, buflists)->b_lblkno;
+   if (ap->a_end != OFF_MAX && endn != -1)
endn = ap->a_end / bsize;
BO_RUNLOCK(&vp->v_bufobj);
/*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288450 - head/sys/cam/ctl

2015-10-01 Thread Alexander Motin
Author: mav
Date: Thu Oct  1 16:30:20 2015
New Revision: 288450
URL: https://svnweb.freebsd.org/changeset/base/288450

Log:
  Make zero WUT use WRITE SAME with recently allowed NDOB flag.

Modified:
  head/sys/cam/ctl/ctl_tpc.c

Modified: head/sys/cam/ctl/ctl_tpc.c
==
--- head/sys/cam/ctl/ctl_tpc.c  Thu Oct  1 12:57:37 2015(r288449)
+++ head/sys/cam/ctl/ctl_tpc.c  Thu Oct  1 16:30:20 2015(r288450)
@@ -1295,7 +1295,6 @@ complete:
ctl_free_io(tio->io);
free(tio, M_CTL);
}
-   free(list->buf, M_CTL);
if (list->abort) {
ctl_set_task_aborted(list->ctsio);
return (CTL_RETVAL_ERROR);
@@ -1311,7 +1310,6 @@ complete:
}
 
dstblock = list->lun->be_lun->blocksize;
-   list->buf = malloc(dstblock, M_CTL, M_WAITOK | M_ZERO);
TAILQ_INIT(&run);
prun = &run;
list->tbdio = 1;
@@ -1328,9 +1326,9 @@ complete:
TAILQ_INSERT_TAIL(&list->allio, tiow, links);
tiow->io = tpcl_alloc_io();
ctl_scsi_write_same(tiow->io,
-   /*data_ptr*/ list->buf,
-   /*data_len*/ dstblock,
-   /*byte2*/ 0,
+   /*data_ptr*/ NULL,
+   /*data_len*/ 0,
+   /*byte2*/ SWS_NDOB,
/*lba*/ scsi_8btou64(list->range[r].lba),
/*num_blocks*/ len,
/*tag_type*/ CTL_TAG_SIMPLE,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288449 - head/sys/cam/ctl

2015-10-01 Thread Alexander Motin
Author: mav
Date: Thu Oct  1 12:57:37 2015
New Revision: 288449
URL: https://svnweb.freebsd.org/changeset/base/288449

Log:
  Implement SPC-3 exceptions to SPC-2 RESERVE and RELEASE behavior.

Modified:
  head/sys/cam/ctl/ctl.c

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Thu Oct  1 12:15:36 2015(r288448)
+++ head/sys/cam/ctl/ctl.c  Thu Oct  1 12:57:37 2015(r288449)
@@ -5101,6 +5101,13 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsi
ctl_set_reservation_conflict(ctsio);
goto bailout;
}
+
+   /* SPC-3 exceptions to SPC-2 RESERVE and RELEASE behavior. */
+   if (lun->flags & CTL_LUN_PR_RESERVED) {
+   ctl_set_success(ctsio);
+   goto bailout;
+   }
+
lun->flags |= CTL_LUN_RESERVED;
lun->res_idx = residx;
ctl_set_success(ctsio);
@@ -7624,7 +7631,8 @@ retry:
 
res_cap = (struct scsi_per_res_cap *)ctsio->kern_data_ptr;
scsi_ulto2b(sizeof(*res_cap), res_cap->length);
-   res_cap->flags2 |= SPRI_TMV | SPRI_ALLOW_5;
+   res_cap->flags1 = SPRI_CRH;
+   res_cap->flags2 = SPRI_TMV | SPRI_ALLOW_5;
type_mask = SPRI_TM_WR_EX_AR |
SPRI_TM_EX_AC_RO |
SPRI_TM_WR_EX_RO |
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288448 - head/sys/cam/ctl

2015-10-01 Thread Alexander Motin
Author: mav
Date: Thu Oct  1 12:15:36 2015
New Revision: 288448
URL: https://svnweb.freebsd.org/changeset/base/288448

Log:
  Unify PR variable names to reduce confusion.

Modified:
  head/sys/cam/ctl/ctl.c
  head/sys/cam/ctl/ctl_private.h

Modified: head/sys/cam/ctl/ctl.c
==
--- head/sys/cam/ctl/ctl.c  Thu Oct  1 12:09:05 2015(r288447)
+++ head/sys/cam/ctl/ctl.c  Thu Oct  1 12:15:36 2015(r288448)
@@ -781,9 +781,9 @@ alloc:
msg->hdr.nexus.targ_lun = lun->lun;
msg->hdr.nexus.targ_mapped_lun = lun->lun;
msg->lun.flags = lun->flags;
-   msg->lun.pr_generation = lun->PRGeneration;
+   msg->lun.pr_generation = lun->pr_generation;
msg->lun.pr_res_idx = lun->pr_res_idx;
-   msg->lun.pr_res_type = lun->res_type;
+   msg->lun.pr_res_type = lun->pr_res_type;
msg->lun.pr_key_count = lun->pr_key_count;
i = 0;
if (lun->lun_devid) {
@@ -1085,9 +1085,9 @@ ctl_isc_lun_sync(struct ctl_softc *softc
/* If peer is primary and we are not -- use data */
if ((lun->flags & CTL_LUN_PRIMARY_SC) == 0 &&
(lun->flags & CTL_LUN_PEER_SC_PRIMARY)) {
-   lun->PRGeneration = msg->lun.pr_generation;
+   lun->pr_generation = msg->lun.pr_generation;
lun->pr_res_idx = msg->lun.pr_res_idx;
-   lun->res_type = msg->lun.pr_res_type;
+   lun->pr_res_type = msg->lun.pr_res_type;
lun->pr_key_count = msg->lun.pr_key_count;
for (k = 0; k < CTL_MAX_INITIATORS; k++)
ctl_clr_prkey(lun, k);
@@ -5130,7 +5130,7 @@ ctl_start_stop(struct ctl_scsiio *ctsio)
 
residx = ctl_get_initindex(&ctsio->io_hdr.nexus);
if (ctl_get_prkey(lun, residx) == 0 ||
-   (lun->pr_res_idx != residx && lun->res_type < 4)) {
+   (lun->pr_res_idx != residx && lun->pr_res_type < 
4)) {
 
ctl_set_reservation_conflict(ctsio);
ctl_done((union ctl_io *)ctsio);
@@ -7540,7 +7540,7 @@ retry:
goto retry;
}
 
-   scsi_ulto4b(lun->PRGeneration, res_keys->header.generation);
+   scsi_ulto4b(lun->pr_generation, res_keys->header.generation);
 
scsi_ulto4b(sizeof(struct scsi_per_res_key) *
 lun->pr_key_count, res_keys->header.length);
@@ -7571,7 +7571,7 @@ retry:
 
res = (struct scsi_per_res_in_rsrv *)ctsio->kern_data_ptr;
 
-   scsi_ulto4b(lun->PRGeneration, res->header.generation);
+   scsi_ulto4b(lun->pr_generation, res->header.generation);
 
if (lun->flags & CTL_LUN_PR_RESERVED)
{
@@ -7614,7 +7614,7 @@ retry:
scsi_u64to8b(ctl_get_prkey(lun, lun->pr_res_idx),
res->data.reservation);
}
-   res->data.scopetype = lun->res_type;
+   res->data.scopetype = lun->pr_res_type;
break;
}
case SPRI_RC: //report capabilities
@@ -7659,7 +7659,7 @@ retry:
goto retry;
}
 
-   scsi_ulto4b(lun->PRGeneration, res_status->header.generation);
+   scsi_ulto4b(lun->pr_generation, res_status->header.generation);
 
res_desc = &res_status->desc[0];
for (i = 0; i < CTL_MAX_INITIATORS; i++) {
@@ -7671,7 +7671,7 @@ retry:
(lun->pr_res_idx == i ||
 lun->pr_res_idx == CTL_PR_ALL_REGISTRANTS)) {
res_desc->flags = SPRI_FULL_R_HOLDER;
-   res_desc->scopetype = lun->res_type;
+   res_desc->scopetype = lun->pr_res_type;
}
scsi_ulto2b(i / CTL_MAX_INIT_PER_PORT,
res_desc->rel_trgt_port_id);
@@ -7760,11 +7760,11 @@ ctl_pro_preempt(struct ctl_softc *softc,
ctl_est_ua(lun, i, CTL_UA_REG_PREEMPT);
}
lun->pr_key_count = 1;
-   lun->res_type = type;
-   if (lun->res_type != SPR_TYPE_WR_EX_AR
-&& lun->res_type != SPR_TYPE_EX_AC_AR)
+   lun->pr_res_type = type;
+   if (lun->pr_res_type != SPR_TYPE_WR_EX_AR &&
+   lun->pr_res_type != SPR_TYPE_EX_AC_AR)
lun->pr_res_idx = residx;
-   lun->PRGeneration++;
+   lun->pr_generation++;
mtx_unlock(&lun->lun_lock);
 
  

svn commit: r288447 - in head/sys/arm: broadcom/bcm2835 mv

2015-10-01 Thread Andrew Turner
Author: andrew
Date: Thu Oct  1 12:09:05 2015
New Revision: 288447
URL: https://svnweb.freebsd.org/changeset/base/288447

Log:
  An IPI must be cleared before it is handled otherwise next IPI could be
  missed. In other words, if a new request for an IPI is sent while the
  previous request is being handled but the IPI is not cleared yet, the
  clearing of the previous IPI request also clears the new one and the
  handling is missed.
  
  There are only three MP interrupt controllers in ARM now. Two of them are
  fixed by this change, the third one is correct, probably only just by
  accident. The fix is minimalistic as new interrupt framework is awaited.
  
  It was debugged on RPi2 where missing IPI handling together with SCHED_ULE
  led to situation in which tdq_ipipending was not cleared and so IPI_PREEMPT
  was stopped to be sent. Various odditys were found related to slow system
  response time like various events timed out, and slow console response.
  
  Submitted by: Svatopluk Kraus 
  Reviewed by:  loos, kib
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D3722

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2836_mp.c
  head/sys/arm/mv/mpic.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2836_mp.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2836_mp.c  Thu Oct  1 10:52:26 2015
(r288446)
+++ head/sys/arm/broadcom/bcm2835/bcm2836_mp.c  Thu Oct  1 12:09:05 2015
(r288447)
@@ -182,6 +182,8 @@ pic_ipi_read(int i)
if (val == 0)
return (0);
ipi = ffs(val) - 1;
+   BSWR4(MBOX0CLR_CORE(cpu), 1 << ipi);
+   dsb();
return (ipi);
}
return (0x3ff);
@@ -190,12 +192,6 @@ pic_ipi_read(int i)
 void
 pic_ipi_clear(int ipi)
 {
-   int cpu;
-
-   cpu = PCPU_GET(cpuid);
-   dsb();
-   BSWR4(MBOX0CLR_CORE(cpu), 1 << ipi);
-   wmb();
 }
 
 void

Modified: head/sys/arm/mv/mpic.c
==
--- head/sys/arm/mv/mpic.c  Thu Oct  1 10:52:26 2015(r288446)
+++ head/sys/arm/mv/mpic.c  Thu Oct  1 12:09:05 2015(r288447)
@@ -378,10 +378,14 @@ int
 pic_ipi_read(int i __unused)
 {
uint32_t val;
+   int ipi;
 
val = MPIC_CPU_READ(mv_mpic_sc, MPIC_IN_DRBL);
-   if (val)
-   return (ffs(val) - 1);
+   if (val) {
+   ipi = ffs(val) - 1;
+   MPIC_CPU_WRITE(mv_mpic_sc, MPIC_IN_DRBL, ~(1 << ipi));
+   return (ipi);
+   }
 
return (0x3ff);
 }
@@ -389,10 +393,6 @@ pic_ipi_read(int i __unused)
 void
 pic_ipi_clear(int ipi)
 {
-   uint32_t val;
-
-   val = ~(1 << ipi);
-   MPIC_CPU_WRITE(mv_mpic_sc, MPIC_IN_DRBL, val);
 }
 
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288446 - in head: sbin/init sys/dev/acpica sys/kern sys/sys

2015-10-01 Thread Colin Percival
Author: cperciva
Date: Thu Oct  1 10:52:26 2015
New Revision: 288446
URL: https://svnweb.freebsd.org/changeset/base/288446

Log:
  Disable suspend when we're shutting down.  This solves the "tell FreeBSD
  to shut down; close laptop lid" scenario which otherwise tended to end
  with a laptop overheating or the battery dying.
  
  The implementation uses a new sysctl, kern.suspend_blocked; init(8) sets
  this while rc.suspend runs, and the ACPI sleep code ignores requests while
  the sysctl is set.
  
  Discussed on: freebsd-acpi (35 emails)
  MFC after:1 week

Modified:
  head/sbin/init/init.c
  head/sys/dev/acpica/acpi.c
  head/sys/kern/kern_shutdown.c
  head/sys/sys/systm.h

Modified: head/sbin/init/init.c
==
--- head/sbin/init/init.c   Thu Oct  1 10:43:40 2015(r288445)
+++ head/sbin/init/init.c   Thu Oct  1 10:52:26 2015(r288446)
@@ -1487,6 +1487,15 @@ static state_func_t
 death(void)
 {
session_t *sp;
+   int block, blocked;
+   size_t len;
+
+   /* Temporarily block suspend. */
+   len = sizeof(blocked);
+   block = 1;
+   if (sysctlbyname("kern.suspend_blocked", &blocked, &len,
+   &block, sizeof(block)) == -1)
+   blocked = 0;
 
/*
 * Also revoke the TTY here.  Because runshutdown() may reopen
@@ -1503,6 +1512,11 @@ death(void)
/* Try to run the rc.shutdown script within a period of time */
runshutdown();
 
+   /* Unblock suspend if we blocked it. */
+   if (!blocked)
+   sysctlbyname("kern.suspend_blocked", NULL, NULL,
+   &blocked, sizeof(blocked));
+
return (state_func_t) death_single;
 }
 

Modified: head/sys/dev/acpica/acpi.c
==
--- head/sys/dev/acpica/acpi.c  Thu Oct  1 10:43:40 2015(r288445)
+++ head/sys/dev/acpica/acpi.c  Thu Oct  1 10:52:26 2015(r288446)
@@ -2574,8 +2574,11 @@ acpi_ReqSleepState(struct acpi_softc *sc
 if (!acpi_sleep_states[state])
return (EOPNOTSUPP);
 
-/* If a suspend request is already in progress, just return. */
-if (sc->acpi_next_sstate != 0) {
+/*
+ * If a reboot/shutdown/suspend request is already in progress or
+ * suspend is blocked due to an upcoming shutdown, just return.
+ */
+if (rebooting || sc->acpi_next_sstate != 0 || suspend_blocked) {
return (0);
 }
 

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Thu Oct  1 10:43:40 2015
(r288445)
+++ head/sys/kern/kern_shutdown.c   Thu Oct  1 10:52:26 2015
(r288446)
@@ -137,6 +137,10 @@ static int show_busybufs = 1;
 SYSCTL_INT(_kern_shutdown, OID_AUTO, show_busybufs, CTLFLAG_RW,
&show_busybufs, 0, "");
 
+int suspend_blocked = 0;
+SYSCTL_INT(_kern, OID_AUTO, suspend_blocked, CTLFLAG_RW,
+   &suspend_blocked, 0, "Block suspend due to a pending shutdown");
+
 /*
  * Variable panicstr contains argument to first call to panic; used as flag
  * to indicate that the kernel has already called panic.

Modified: head/sys/sys/systm.h
==
--- head/sys/sys/systm.hThu Oct  1 10:43:40 2015(r288445)
+++ head/sys/sys/systm.hThu Oct  1 10:52:26 2015(r288446)
@@ -46,6 +46,7 @@
 #include /* for people using printf mainly */
 
 extern int cold;   /* nonzero if we are doing a cold boot */
+extern int suspend_blocked;/* block suspend due to pending shutdown */
 extern int rebooting;  /* kern_reboot() has been called. */
 extern const char *panicstr;   /* panic message */
 extern char version[]; /* system version */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288445 - head/sys/arm64/arm64

2015-10-01 Thread Andrew Turner
Author: andrew
Date: Thu Oct  1 10:43:40 2015
New Revision: 288445
URL: https://svnweb.freebsd.org/changeset/base/288445

Log:
  Use pmap_load more consistently. While here try to only load the data once
  when we reuse the same data.
  
  Obtained from:EuroBSDCon Devsummit
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm64/arm64/pmap.c

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Thu Oct  1 09:53:12 2015(r288444)
+++ head/sys/arm64/arm64/pmap.c Thu Oct  1 10:43:40 2015(r288445)
@@ -243,6 +243,16 @@ static void _pmap_unwire_l3(pmap_t pmap,
 struct spglist *free);
 static int pmap_unuse_l3(pmap_t, vm_offset_t, pd_entry_t, struct spglist *);
 
+/*
+ * These load the old table data and store the new value.
+ * They need to be atomic as the System MMU may write to the table at
+ * the same time as the CPU.
+ */
+#definepmap_load_store(table, entry) atomic_swap_64(table, entry)
+#definepmap_set(table, mask) atomic_set_64(table, mask)
+#definepmap_load_clear(table) atomic_swap_64(table, 0)
+#definepmap_load(table) (*table)
+
 //
 /* Inline functions */
 //
@@ -277,7 +287,7 @@ pmap_l1_to_l2(pd_entry_t *l1, vm_offset_
 {
pd_entry_t *l2;
 
-   l2 = (pd_entry_t *)PHYS_TO_DMAP(*l1 & ~ATTR_MASK);
+   l2 = (pd_entry_t *)PHYS_TO_DMAP(pmap_load(l1) & ~ATTR_MASK);
return (&l2[pmap_l2_index(va)]);
 }
 
@@ -287,7 +297,7 @@ pmap_l2(pmap_t pmap, vm_offset_t va)
pd_entry_t *l1;
 
l1 = pmap_l1(pmap, va);
-   if ((*l1 & ATTR_DESCR_MASK) != L1_TABLE)
+   if ((pmap_load(l1) & ATTR_DESCR_MASK) != L1_TABLE)
return (NULL);
 
return (pmap_l1_to_l2(l1, va));
@@ -298,7 +308,7 @@ pmap_l2_to_l3(pd_entry_t *l2, vm_offset_
 {
pt_entry_t *l3;
 
-   l3 = (pd_entry_t *)PHYS_TO_DMAP(*l2 & ~ATTR_MASK);
+   l3 = (pd_entry_t *)PHYS_TO_DMAP(pmap_load(l2) & ~ATTR_MASK);
return (&l3[pmap_l3_index(va)]);
 }
 
@@ -308,7 +318,7 @@ pmap_l3(pmap_t pmap, vm_offset_t va)
pd_entry_t *l2;
 
l2 = pmap_l2(pmap, va);
-   if (l2 == NULL || (*l2 & ATTR_DESCR_MASK) != L2_TABLE)
+   if (l2 == NULL || (pmap_load(l2) & ATTR_DESCR_MASK) != L2_TABLE)
return (NULL);
 
return (pmap_l2_to_l3(l2, va));
@@ -326,19 +336,19 @@ pmap_get_tables(pmap_t pmap, vm_offset_t
l1p = pmap_l1(pmap, va);
*l1 = l1p;
 
-   if ((*l1p & ATTR_DESCR_MASK) == L1_BLOCK) {
+   if ((pmap_load(l1p) & ATTR_DESCR_MASK) == L1_BLOCK) {
*l2 = NULL;
*l3 = NULL;
return (true);
}
 
-   if ((*l1p & ATTR_DESCR_MASK) != L1_TABLE)
+   if ((pmap_load(l1p) & ATTR_DESCR_MASK) != L1_TABLE)
return (false);
 
l2p = pmap_l1_to_l2(l1p, va);
*l2 = l2p;
 
-   if ((*l2p & ATTR_DESCR_MASK) == L2_BLOCK) {
+   if ((pmap_load(l2p) & ATTR_DESCR_MASK) == L2_BLOCK) {
*l3 = NULL;
return (true);
}
@@ -348,16 +358,6 @@ pmap_get_tables(pmap_t pmap, vm_offset_t
return (true);
 }
 
-/*
- * These load the old table data and store the new value.
- * They need to be atomic as the System MMU may write to the table at
- * the same time as the CPU.
- */
-#definepmap_load_store(table, entry) atomic_swap_64(table, entry)
-#definepmap_set(table, mask) atomic_set_64(table, mask)
-#definepmap_load_clear(table) atomic_swap_64(table, 0)
-#definepmap_load(table) (*table)
-
 static __inline int
 pmap_is_current(pmap_t pmap)
 {
@@ -799,11 +799,11 @@ pmap_extract(pmap_t pmap, vm_offset_t va
 */
l2p = pmap_l2(pmap, va);
if (l2p != NULL) {
-   l2 = *l2p;
+   l2 = pmap_load(l2p);
if ((l2 & ATTR_DESCR_MASK) == L2_TABLE) {
l3p = pmap_l2_to_l3(l2p, va);
if (l3p != NULL) {
-   l3 = *l3p;
+   l3 = pmap_load(l3p);
 
if ((l3 & ATTR_DESCR_MASK) == L3_PAGE)
pa = (l3 & ~ATTR_MASK) |
@@ -852,23 +852,25 @@ retry:
 vm_paddr_t
 pmap_kextract(vm_offset_t va)
 {
-   pd_entry_t *l2;
+   pd_entry_t *l2p, l2;
pt_entry_t *l3;
vm_paddr_t pa;
 
if (va >= DMAP_MIN_ADDRESS && va < DMAP_MAX_ADDRESS) {
pa = DMAP_TO_PHYS(va);
} else {
-   l2 = pmap_l2(kernel_pmap, va);
-   if (l2 == NULL)
+   l2p = pmap_l2(kernel_pmap, va);
+   if (l2p == NULL)
panic("pmap_kextract: No l2");
-   if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK)
-   return ((*l2 & ~ATTR_MASK) | (va & L2_OFFSET));
+   l2 = pmap_load(l2p);
+   if ((l2 & AT

svn commit: r288444 - head/contrib/netbsd-tests/lib/libc/sys

2015-10-01 Thread Andrew Turner
Author: andrew
Date: Thu Oct  1 09:53:12 2015
New Revision: 288444
URL: https://svnweb.freebsd.org/changeset/base/288444

Log:
  Pass 8 arguments to makecontext on arm64 as this is all we support.
  
  Obtained from:EuroBSDCon Devsummit
  Sponsored by: ABT Systems Ltd

Modified:
  head/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c

Modified: head/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c
==
--- head/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c   Thu Oct  1 
09:44:15 2015(r288443)
+++ head/contrib/netbsd-tests/lib/libc/sys/t_getcontext.c   Thu Oct  1 
09:53:12 2015(r288444)
@@ -53,6 +53,8 @@ run(int n, ...)
va_start(va, n);
 #if defined(__FreeBSD__) && defined(__amd64__)
for (i = 0; i < 5; i++) {
+#elif defined(__FreeBSD__) && defined(__aarch64__)
+   for (i = 0; i < 7; i++) {
 #else
for (i = 0; i < 9; i++) {
 #endif
@@ -116,6 +118,10 @@ ATF_TC_BODY(setcontext_link, tc)
/* FreeBSD/amd64 only permits up to 6 arguments. */
makecontext(&uc[i], (void *)run, 6, i,
0, 1, 2, 3, 4);
+#elif defined(__FreeBSD__) && defined(__aarch64__)
+   /* FreeBSD/arm64 only permits up to 8 arguments. */
+   makecontext(&uc[i], (void *)run, 8, i,
+   0, 1, 2, 3, 4, 5, 6);
 #else
makecontext(&uc[i], (void *)run, 10, i,
0, 1, 2, 3, 4, 5, 6, 7, 8);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288443 - head/sys/arm64/arm64

2015-10-01 Thread Andrew Turner
Author: andrew
Date: Thu Oct  1 09:44:15 2015
New Revision: 288443
URL: https://svnweb.freebsd.org/changeset/base/288443

Log:
  Add the ENTRY/END entries around the exception handlers.
  
  Obtained from:EuroBSDCon Devsummit
  Sponsored by: ABT Systems Ltd

Modified:
  head/sys/arm64/arm64/exception.S

Modified: head/sys/arm64/arm64/exception.S
==
--- head/sys/arm64/arm64/exception.SThu Oct  1 09:40:33 2015
(r288442)
+++ head/sys/arm64/arm64/exception.SThu Oct  1 09:44:15 2015
(r288443)
@@ -131,45 +131,51 @@ __FBSDID("$FreeBSD$");
 2:
 .endm
 
-handle_el1h_sync:
+ENTRY(handle_el1h_sync)
save_registers 1
mov x0, sp
bl  do_el1h_sync
restore_registers 1
eret
+END(handle_el1h_sync)
 
-handle_el1h_irq:
+ENTRY(handle_el1h_irq)
save_registers 1
mov x0, sp
bl  arm_cpu_intr
restore_registers 1
eret
+END(handle_el1h_irq)
 
-handle_el1h_error:
+ENTRY(handle_el1h_error)
brk 0xf13
+END(handle_el1h_error)
 
-handle_el0_sync:
+ENTRY(handle_el0_sync)
save_registers 0
mov x0, sp
bl  do_el0_sync
do_ast
restore_registers 0
eret
+END(handle_el0_sync)
 
-handle_el0_irq:
+ENTRY(handle_el0_irq)
save_registers 0
mov x0, sp
bl  arm_cpu_intr
do_ast
restore_registers 0
eret
+END(handle_el0_irq)
 
-handle_el0_error:
+ENTRY(handle_el0_error)
save_registers 0
mov x0, sp
bl  do_el0_error
brk 0xf23
1: b 1b
+END(handle_el0_error)
 
 .macro vempty
.align 7
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288442 - head/usr.sbin

2015-10-01 Thread Andrew Turner
Author: andrew
Date: Thu Oct  1 09:40:33 2015
New Revision: 288442
URL: https://svnweb.freebsd.org/changeset/base/288442

Log:
  Also build ofwdump on arm64.
  
  Obtained from:EuroBSDCon Devsummit
  Sponsored by: ABT Systems Ltd

Added:
  head/usr.sbin/Makefile.arm64   (contents, props changed)

Added: head/usr.sbin/Makefile.arm64
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/Makefile.arm64Thu Oct  1 09:40:33 2015
(r288442)
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+SUBDIR+=   ofwdump
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288440 - head/etc/etc.aarch64

2015-10-01 Thread Andrew Turner
Author: andrew
Date: Thu Oct  1 09:36:18 2015
New Revision: 288440
URL: https://svnweb.freebsd.org/changeset/base/288440

Log:
  Update the arm64 ttys file to enable the correct uart based on which device
  the console is attached to. This makes this file identical to the 32-bit
  arm version of this file.
  
  Obtained from:EuroBSDCon devsummit
  Sponsored by: ABT Systems Ltd

Modified:
  head/etc/etc.aarch64/ttys

Modified: head/etc/etc.aarch64/ttys
==
--- head/etc/etc.aarch64/ttys   Thu Oct  1 07:48:26 2015(r288439)
+++ head/etc/etc.aarch64/ttys   Thu Oct  1 09:36:18 2015(r288440)
@@ -29,7 +29,7 @@
 # when going to single-user mode.
 consolenoneunknown off secure
 #
-ttyv0  "/usr/libexec/getty Pc" xterm   off  secure
+ttyv0  "/usr/libexec/getty Pc" xterm   onifconsole  secure
 # Virtual terminals
 ttyv1  "/usr/libexec/getty Pc" xterm   off  secure
 ttyv2  "/usr/libexec/getty Pc" xterm   off  secure
@@ -41,9 +41,9 @@ ttyv7 "/usr/libexec/getty Pc" xterm   off
 #ttyv8 "/usr/local/bin/xdm -nodaemon"  xterm   off secure
 # Serial terminals
 # The 'dialup' keyword identifies dialin lines to login, fingerd etc.
-ttyu0  "/usr/libexec/getty std.9600"   vt100   on  secure
-ttyu1  "/usr/libexec/getty std.9600"   dialup  off secure
-ttyu2  "/usr/libexec/getty std.9600"   dialup  off secure
-ttyu3  "/usr/libexec/getty std.9600"   dialup  off secure
+ttyu0  "/usr/libexec/getty 3wire"  vt100   onifconsole  secure
+ttyu1  "/usr/libexec/getty 3wire"  vt100   onifconsole  secure
+ttyu2  "/usr/libexec/getty 3wire"  vt100   onifconsole  secure
+ttyu3  "/usr/libexec/getty 3wire"  vt100   onifconsole  secure
 # Dumb console
 dcons  "/usr/libexec/getty std.9600"   vt100   off secure
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r288438 - in vendor/bind9/dist: . bin/check bin/confgen bin/dig bin/dnssec bin/named bin/named/include/named bin/nsupdate bin/rndc bin/tools doc/arm doc/misc lib/bind9 lib/dns lib/dns/i...

2015-10-01 Thread Erwin Lansing
Author: erwin
Date: Thu Oct  1 07:47:44 2015
New Revision: 288438
URL: https://svnweb.freebsd.org/changeset/base/288438

Log:
  Vendor import of BIND 9.9.8
  
  Sponsored by: DK Hostmaster A/S

Added:
  vendor/bind9/dist/doc/arm/html-fixup.pl   (contents, props changed)
Modified:
  vendor/bind9/dist/CHANGES
  vendor/bind9/dist/README
  vendor/bind9/dist/bin/check/check-tool.c
  vendor/bind9/dist/bin/check/named-checkconf.c
  vendor/bind9/dist/bin/check/named-checkzone.c
  vendor/bind9/dist/bin/confgen/keygen.c
  vendor/bind9/dist/bin/confgen/util.c
  vendor/bind9/dist/bin/dig/dig.1
  vendor/bind9/dist/bin/dig/dig.c
  vendor/bind9/dist/bin/dig/dig.docbook
  vendor/bind9/dist/bin/dig/dig.html
  vendor/bind9/dist/bin/dig/dighost.c
  vendor/bind9/dist/bin/dig/nslookup.c
  vendor/bind9/dist/bin/dnssec/dnssec-dsfromkey.8
  vendor/bind9/dist/bin/dnssec/dnssec-dsfromkey.c
  vendor/bind9/dist/bin/dnssec/dnssec-dsfromkey.docbook
  vendor/bind9/dist/bin/dnssec/dnssec-dsfromkey.html
  vendor/bind9/dist/bin/dnssec/dnssec-keygen.c
  vendor/bind9/dist/bin/dnssec/dnssec-revoke.c
  vendor/bind9/dist/bin/dnssec/dnssec-settime.c
  vendor/bind9/dist/bin/dnssec/dnssec-signzone.c
  vendor/bind9/dist/bin/named/client.c
  vendor/bind9/dist/bin/named/config.c
  vendor/bind9/dist/bin/named/control.c
  vendor/bind9/dist/bin/named/include/named/lwdclient.h
  vendor/bind9/dist/bin/named/include/named/main.h
  vendor/bind9/dist/bin/named/include/named/server.h
  vendor/bind9/dist/bin/named/interfacemgr.c
  vendor/bind9/dist/bin/named/logconf.c
  vendor/bind9/dist/bin/named/lwdclient.c
  vendor/bind9/dist/bin/named/lwresd.c
  vendor/bind9/dist/bin/named/main.c
  vendor/bind9/dist/bin/named/named.8
  vendor/bind9/dist/bin/named/named.docbook
  vendor/bind9/dist/bin/named/named.html
  vendor/bind9/dist/bin/named/query.c
  vendor/bind9/dist/bin/named/server.c
  vendor/bind9/dist/bin/named/statschannel.c
  vendor/bind9/dist/bin/named/update.c
  vendor/bind9/dist/bin/named/xfrout.c
  vendor/bind9/dist/bin/nsupdate/nsupdate.1
  vendor/bind9/dist/bin/nsupdate/nsupdate.c
  vendor/bind9/dist/bin/nsupdate/nsupdate.docbook
  vendor/bind9/dist/bin/nsupdate/nsupdate.html
  vendor/bind9/dist/bin/rndc/rndc.8
  vendor/bind9/dist/bin/rndc/rndc.c
  vendor/bind9/dist/bin/rndc/rndc.docbook
  vendor/bind9/dist/bin/rndc/rndc.html
  vendor/bind9/dist/bin/rndc/util.c
  vendor/bind9/dist/bin/tools/arpaname.c
  vendor/bind9/dist/bin/tools/isc-hmac-fixup.c
  vendor/bind9/dist/bin/tools/named-journalprint.c
  vendor/bind9/dist/config.h.in
  vendor/bind9/dist/configure.in
  vendor/bind9/dist/doc/arm/Bv9ARM-book.xml
  vendor/bind9/dist/doc/arm/Bv9ARM.ch01.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch02.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch03.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch04.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch05.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch06.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch07.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch08.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch09.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch10.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch11.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch12.html
  vendor/bind9/dist/doc/arm/Bv9ARM.ch13.html
  vendor/bind9/dist/doc/arm/Bv9ARM.html
  vendor/bind9/dist/doc/arm/Bv9ARM.pdf
  vendor/bind9/dist/doc/arm/Makefile.in
  vendor/bind9/dist/doc/arm/man.arpaname.html
  vendor/bind9/dist/doc/arm/man.ddns-confgen.html
  vendor/bind9/dist/doc/arm/man.dig.html
  vendor/bind9/dist/doc/arm/man.dnssec-checkds.html
  vendor/bind9/dist/doc/arm/man.dnssec-coverage.html
  vendor/bind9/dist/doc/arm/man.dnssec-dsfromkey.html
  vendor/bind9/dist/doc/arm/man.dnssec-keyfromlabel.html
  vendor/bind9/dist/doc/arm/man.dnssec-keygen.html
  vendor/bind9/dist/doc/arm/man.dnssec-revoke.html
  vendor/bind9/dist/doc/arm/man.dnssec-settime.html
  vendor/bind9/dist/doc/arm/man.dnssec-signzone.html
  vendor/bind9/dist/doc/arm/man.dnssec-verify.html
  vendor/bind9/dist/doc/arm/man.genrandom.html
  vendor/bind9/dist/doc/arm/man.host.html
  vendor/bind9/dist/doc/arm/man.isc-hmac-fixup.html
  vendor/bind9/dist/doc/arm/man.named-checkconf.html
  vendor/bind9/dist/doc/arm/man.named-checkzone.html
  vendor/bind9/dist/doc/arm/man.named-journalprint.html
  vendor/bind9/dist/doc/arm/man.named.html
  vendor/bind9/dist/doc/arm/man.nsec3hash.html
  vendor/bind9/dist/doc/arm/man.nsupdate.html
  vendor/bind9/dist/doc/arm/man.rndc-confgen.html
  vendor/bind9/dist/doc/arm/man.rndc.conf.html
  vendor/bind9/dist/doc/arm/man.rndc.html
  vendor/bind9/dist/doc/arm/notes.html
  vendor/bind9/dist/doc/arm/notes.pdf
  vendor/bind9/dist/doc/arm/notes.xml
  vendor/bind9/dist/doc/misc/rfc-compliance
  vendor/bind9/dist/isc-config.sh.in
  vendor/bind9/dist/lib/bind9/api
  vendor/bind9/dist/lib/bind9/check.c
  vendor/bind9/dist/lib/dns/adb.c
  vendor/bind9/dist/lib/dns/api
  vendor/bind9/dist/lib/dns/cache.c
  vendor/bind9/dist/lib/dns/callbacks.c
  vendor/bind9/dist/lib/dns/client.c
  vendor/bind9/dist/lib/dns/diff.c
  vendor/bind9/dist/l

svn commit: r288439 - vendor/bind9/9.9.8

2015-10-01 Thread Erwin Lansing
Author: erwin
Date: Thu Oct  1 07:48:26 2015
New Revision: 288439
URL: https://svnweb.freebsd.org/changeset/base/288439

Log:
  Tag the 9.9.8 release
  
  Sponsored by: DK Hostmaster A/S

Added:
 - copied from r288438, vendor/bind9/dist/
Directory Properties:
  vendor/bind9/9.9.8/   (props changed)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"