Re: svn commit: r332789 - head/usr.sbin/pwd_mkdb

2018-04-22 Thread Conrad Meyer
Maybe Relnotes: yes?

On Thu, Apr 19, 2018 at 1:25 PM, Ed Maste  wrote:
> Author: emaste
> Date: Thu Apr 19 20:25:19 2018
> New Revision: 332789
> URL: https://svnweb.freebsd.org/changeset/base/332789
>
> Log:
>   pwd_mkdb: warn that legacy support is deprecated (if specified)
>
>   r283981 switched pwd_mkdb to emit only v4 database entries by default,
>   and introduced a -l (legacy) option emit v3 entries in addition.  The
>   commit message claims that legacy support will be removed in 12.0, so
>   emit a warning now if it is used.
>
> Modified:
>   head/usr.sbin/pwd_mkdb/pwd_mkdb.c
>
> Modified: head/usr.sbin/pwd_mkdb/pwd_mkdb.c
> ==
> --- head/usr.sbin/pwd_mkdb/pwd_mkdb.c   Thu Apr 19 18:34:38 2018
> (r332788)
> +++ head/usr.sbin/pwd_mkdb/pwd_mkdb.c   Thu Apr 19 20:25:19 2018
> (r332789)
> @@ -166,6 +166,8 @@ main(int argc, char *argv[])
>
> if (argc != 1 || (username && (*username == '+' || *username == '-')))
> usage();
> +   if (lflag)
> +   warnx("legacy (v3) database format support is deprecated");
>
> /*
>  * This could be changed to allow the user to interrupt.
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332876 - head/usr.bin/grep

2018-04-22 Thread Kyle Evans
Author: kevans
Date: Sun Apr 22 23:51:24 2018
New Revision: 332876
URL: https://svnweb.freebsd.org/changeset/base/332876

Log:
  bsdgrep: Fix build failure WITHOUT_LZMA (incorrect bracket placement)
  
  Submitted by: sbruno
  Reported by:  sbruno

Modified:
  head/usr.bin/grep/file.c

Modified: head/usr.bin/grep/file.c
==
--- head/usr.bin/grep/file.cSun Apr 22 23:10:37 2018(r332875)
+++ head/usr.bin/grep/file.cSun Apr 22 23:51:24 2018(r332876)
@@ -337,8 +337,8 @@ grep_open(const char *path)
lstrm.avail_out = MAXBUFSIZ;
laction = LZMA_RUN;
break;
-   }
 #endif
+   }
 
/* Fill read buffer, also catches errors early */
if (bufrem == 0 && grep_refill(f) != 0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332875 - head/usr.sbin/pwd_mkdb

2018-04-22 Thread Ed Maste
Author: emaste
Date: Sun Apr 22 23:10:37 2018
New Revision: 332875
URL: https://svnweb.freebsd.org/changeset/base/332875

Log:
  pwd_mkdb: add deprecation notice in manpage too
  
  Followon to r332789; as reported on the -current and -stable lists and
  in review D15144 the -l option will be removed before FreeBSD 12.0.

Modified:
  head/usr.sbin/pwd_mkdb/pwd_mkdb.8

Modified: head/usr.sbin/pwd_mkdb/pwd_mkdb.8
==
--- head/usr.sbin/pwd_mkdb/pwd_mkdb.8   Sun Apr 22 21:27:59 2018
(r332874)
+++ head/usr.sbin/pwd_mkdb/pwd_mkdb.8   Sun Apr 22 23:10:37 2018
(r332875)
@@ -28,7 +28,7 @@
 .\"@(#)pwd_mkdb.8  8.1 (Berkeley) 6/6/93
 .\" $FreeBSD$
 .\"
-.Dd February 5, 2014
+.Dd April 22, 2018
 .Dt PWD_MKDB 8
 .Os
 .Sh NAME
@@ -129,6 +129,11 @@ which enables generation of legacy format
 .Pq v3
 entries.
 The legacy format entries are endianness dependent.
+The
+.Fl l
+option is deprecated and is not present in
+.Fx 12.0
+and later.
 .Pp
 The following options may be specified and will affect the
 generation of legacy entries.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332874 - head/share/misc

2018-04-22 Thread Rebecca Cran
Author: bcran
Date: Sun Apr 22 21:27:59 2018
New Revision: 332874
URL: https://svnweb.freebsd.org/changeset/base/332874

Log:
  Update committers-src.dot to show the mentorship arrangement for myself: 
eadler has agreed to mentor me.

Modified:
  head/share/misc/committers-src.dot

Modified: head/share/misc/committers-src.dot
==
--- head/share/misc/committers-src.dot  Sun Apr 22 20:47:16 2018
(r332873)
+++ head/share/misc/committers-src.dot  Sun Apr 22 21:27:59 2018
(r332874)
@@ -476,6 +476,8 @@ dwmalone -> fanf
 dwmalone -> peadar
 dwmalone -> snb
 
+eadler -> bcran
+
 ed -> dim
 ed -> gavin
 ed -> jilles
@@ -751,7 +753,6 @@ rpaulo -> jmmv
 rpaulo -> lidl
 rpaulo -> ngie
 
-rrs -> bcran
 rrs -> jchandra
 rrs -> tuexen
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332489 - in head: gnu/usr.bin/gdb/kgdb sys/conf sys/dev/dcons sys/dev/hyperv/vmbus/i386 sys/dev/ppc sys/dev/syscons sys/i386/conf sys/i386/i386 sys/i386/include sys/i386/include/pc sy

2018-04-22 Thread Konstantin Belousov
On Sun, Apr 22, 2018 at 10:26:14PM +0300, Konstantin Belousov wrote:
> On Sun, Apr 22, 2018 at 09:06:56PM +0200, Tijl Coosemans wrote:
> > On Fri, 13 Apr 2018 20:30:49 + (UTC) Konstantin Belousov 
> >  wrote:
> > Could this have broken the linux futex syscall?  I have a linux program
> > that gets stuck in linux_sys_futex and becomes unkillable.  Note that the
> > routines in sys/i386/linux/linux_support.s try to do atomic operations on
> > user space addresses.
> 
> Yes, it is quite possible.  I will try to look next week.

Try this.  I only compile-tested it as a module.

diff --git a/sys/compat/linux/linux_futex.c b/sys/compat/linux/linux_futex.c
index 7741983bcd3..a82672eaa4f 100644
--- a/sys/compat/linux/linux_futex.c
+++ b/sys/compat/linux/linux_futex.c
@@ -273,14 +273,6 @@ static int handle_futex_death(struct linux_emuldata *, 
uint32_t *,
 static int fetch_robust_entry(struct linux_robust_list **,
 struct linux_robust_list **, unsigned int *);
 
-/* support.s */
-int futex_xchgl(int oparg, uint32_t *uaddr, int *oldval);
-int futex_addl(int oparg, uint32_t *uaddr, int *oldval);
-int futex_orl(int oparg, uint32_t *uaddr, int *oldval);
-int futex_andl(int oparg, uint32_t *uaddr, int *oldval);
-int futex_xorl(int oparg, uint32_t *uaddr, int *oldval);
-
-
 static int
 futex_copyin_timeout(int op, struct l_timespec *luts, int clockrt,
 struct timespec *ts)
diff --git a/sys/compat/linux/linux_futex.h b/sys/compat/linux/linux_futex.h
index d5798e91560..4171dd70504 100644
--- a/sys/compat/linux/linux_futex.h
+++ b/sys/compat/linux/linux_futex.h
@@ -78,6 +78,11 @@ extern struct mtx futex_mtx;
 #defineFUTEX_TID_MASK  0x3fff
 #defineFUTEX_BITSET_MATCH_ANY  0x
 
+int futex_xchgl(int oparg, uint32_t *uaddr, int *oldval);
+int futex_addl(int oparg, uint32_t *uaddr, int *oldval);
+int futex_orl(int oparg, uint32_t *uaddr, int *oldval);
+int futex_andl(int oparg, uint32_t *uaddr, int *oldval);
+int futex_xorl(int oparg, uint32_t *uaddr, int *oldval);
 void   release_futexes(struct thread *,
struct linux_emuldata *);
 
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index ab48a533893..9fe32a20eb6 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -536,11 +536,10 @@ i386/ibcs2/ibcs2_xenix.c  optional ibcs2
 i386/ibcs2/ibcs2_xenix_sysent.coptional ibcs2
 i386/ibcs2/imgact_coff.c   optional ibcs2
 i386/linux/imgact_linux.c  optional compat_linux
+i386/linux/linux_copyout.c optional compat_linux
 i386/linux/linux_dummy.c   optional compat_linux
 i386/linux/linux_machdep.c optional compat_linux
 i386/linux/linux_ptrace.c  optional compat_linux
-i386/linux/linux_support.s optional compat_linux   \
-   dependency  "linux_assym.h"
 i386/linux/linux_sysent.c  optional compat_linux
 i386/linux/linux_sysvec.c  optional compat_linux
 i386/pci/pci_cfgreg.c  optional pci
diff --git a/sys/i386/i386/copyout.c b/sys/i386/i386/copyout.c
index 3767ff9e54b..9d855eea70e 100644
--- a/sys/i386/i386/copyout.c
+++ b/sys/i386/i386/copyout.c
@@ -97,7 +97,7 @@ copyout_init_tramp(void)
(uintptr_t)suword_fast + setidt_disp);
 }
 
-static int
+int
 cp_slow0(vm_offset_t uva, size_t len, bool write,
 void (*f)(vm_offset_t, void *), void *arg)
 {
diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h
index 828b633067d..73c3cba069f 100644
--- a/sys/i386/include/md_var.h
+++ b/sys/i386/include/md_var.h
@@ -55,6 +55,8 @@ structsegment_descriptor;
 union savefpu;
 
 void   bcopyb(const void *from, void *to, size_t len);
+intcp_slow0(vm_offset_t uva, size_t len, bool write,
+   void (*f)(vm_offset_t, void *), void *arg);
 void   cpu_switch_load_gs(void) __asm(__STRING(cpu_switch_load_gs));
 void   copyout_init_tramp(void);
 void   doreti_iret(void) __asm(__STRING(doreti_iret));
diff --git a/sys/i386/linux/linux_copyout.c b/sys/i386/linux/linux_copyout.c
new file mode 100644
index 000..6bb8165ddd9
--- /dev/null
+++ b/sys/i386/linux/linux_copyout.c
@@ -0,0 +1,193 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov 
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * 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 

svn commit: r332873 - in head: share/misc usr.bin/calendar/calendars

2018-04-22 Thread Rebecca Cran
Author: bcran
Date: Sun Apr 22 20:47:16 2018
New Revision: 332873
URL: https://svnweb.freebsd.org/changeset/base/332873

Log:
  Update account and given names in committers-src.dot and calendar.freebsd
  
  I have changed my given name from Bruce to Rebecca, and my FreeBSD account
  from brucec to bcran.
  Update committers-src.dot and calendar.freebsd to show these changes.
  
  Reviewed by:  rrs
  Differential Revision: https://reviews.freebsd.org/D15125

Modified:
  head/share/misc/committers-src.dot
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/share/misc/committers-src.dot
==
--- head/share/misc/committers-src.dot  Sun Apr 22 17:56:39 2018
(r332872)
+++ head/share/misc/committers-src.dot  Sun Apr 22 20:47:16 2018
(r332873)
@@ -122,6 +122,7 @@ avg [label="Andriy Gapon\n...@freebsd.org\n2009/02/18"
 avos [label="Andriy Voskoboinyk\na...@freebsd.org\n2015/09/24"]
 badger [label="Eric Badger\nbad...@freebsd.org\n2016/07/01"]
 bapt [label="Baptiste Daroussin\nb...@freebsd.org\n2011/12/23"]
+bcran [label="Rebecca Cran\nbc...@freebsd.org\n2010/01/29"]
 bde [label="Bruce Evans\n...@freebsd.org\n1994/08/20"]
 bdrewery [label="Bryan Drewery\nbdrew...@freebsd.org\n2013/12/14"]
 benl [label="Ben Laurie\nb...@freebsd.org\n2011/05/18"]
@@ -130,7 +131,6 @@ bms [label="Bruce M Simpson\n...@freebsd.org\n2003/08/
 br [label="Ruslan Bukin\n...@freebsd.org\n2013/09/02"]
 brian [label="Brian Somers\nbr...@freebsd.org\n1996/12/16"]
 brooks [label="Brooks Davis\nbro...@freebsd.org\n2001/06/21"]
-brucec [label="Bruce Cran\nbru...@freebsd.org\n2010/01/29"]
 brueffer [label="Christian Brueffer\nbruef...@freebsd.org\n2006/02/28"]
 bruno [label="Bruno Ducrot\nbr...@freebsd.org\n2005/07/18"]
 bryanv [label="Bryan Venteicher\nbry...@freebsd.org\n2012/11/03"]
@@ -751,7 +751,7 @@ rpaulo -> jmmv
 rpaulo -> lidl
 rpaulo -> ngie
 
-rrs -> brucec
+rrs -> bcran
 rrs -> jchandra
 rrs -> tuexen
 

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdSun Apr 22 17:56:39 
2018(r332872)
+++ head/usr.bin/calendar/calendars/calendar.freebsdSun Apr 22 20:47:16 
2018(r332873)
@@ -185,7 +185,7 @@
 05/13  Pete Fritchman  born in Lansdale, Pennsylvania, 
United States, 1983
 05/14  Tatsumi Hosokawa  born in Tokyo, Japan, 1968
 05/14  Shigeyuku Fukushima  born in Osaka, Japan, 1974
-05/14  Bruce Cran  born in Cambridge, United Kingdom, 1981
+05/14  Rebecca Cran  born in Cambridge, United Kingdom, 1981
 05/15  Hans Petter Selasky  born in Flekkefjord, Norway, 
1982
 05/16  Johann Kois  born in Wolfsberg, Austria, 1975
 05/16  Marcus Alves Grando  born in Florianopolis, Santa 
Catarina, Brazil, 1979
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332489 - in head: gnu/usr.bin/gdb/kgdb sys/conf sys/dev/dcons sys/dev/hyperv/vmbus/i386 sys/dev/ppc sys/dev/syscons sys/i386/conf sys/i386/i386 sys/i386/include sys/i386/include/pc sy

2018-04-22 Thread Konstantin Belousov
On Sun, Apr 22, 2018 at 09:06:56PM +0200, Tijl Coosemans wrote:
> On Fri, 13 Apr 2018 20:30:49 + (UTC) Konstantin Belousov 
>  wrote:
> > Author: kib
> > Date: Fri Apr 13 20:30:49 2018
> > New Revision: 332489
> > URL: https://svnweb.freebsd.org/changeset/base/332489
> > 
> > Log:
> >   i386 4/4G split.
> >   
> >   The change makes the user and kernel address spaces on i386
> >   independent, giving each almost the full 4G of usable virtual addresses
> >   except for one PDE at top used for trampoline and per-CPU trampoline
> >   stacks, and system structures that must be always mapped, namely IDT,
> >   GDT, common TSS and LDT, and process-private TSS and LDT if allocated.
> 
> Could this have broken the linux futex syscall?  I have a linux program
> that gets stuck in linux_sys_futex and becomes unkillable.  Note that the
> routines in sys/i386/linux/linux_support.s try to do atomic operations on
> user space addresses.

Yes, it is quite possible.  I will try to look next week.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332489 - in head: gnu/usr.bin/gdb/kgdb sys/conf sys/dev/dcons sys/dev/hyperv/vmbus/i386 sys/dev/ppc sys/dev/syscons sys/i386/conf sys/i386/i386 sys/i386/include sys/i386/include/pc sy

2018-04-22 Thread Tijl Coosemans
On Fri, 13 Apr 2018 20:30:49 + (UTC) Konstantin Belousov  
wrote:
> Author: kib
> Date: Fri Apr 13 20:30:49 2018
> New Revision: 332489
> URL: https://svnweb.freebsd.org/changeset/base/332489
> 
> Log:
>   i386 4/4G split.
>   
>   The change makes the user and kernel address spaces on i386
>   independent, giving each almost the full 4G of usable virtual addresses
>   except for one PDE at top used for trampoline and per-CPU trampoline
>   stacks, and system structures that must be always mapped, namely IDT,
>   GDT, common TSS and LDT, and process-private TSS and LDT if allocated.

Could this have broken the linux futex syscall?  I have a linux program
that gets stuck in linux_sys_futex and becomes unkillable.  Note that the
routines in sys/i386/linux/linux_support.s try to do atomic operations on
user space addresses.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r332860 - head/sys/kern

2018-04-22 Thread Mark Johnston
On Sat, Apr 21, 2018 at 04:33:33PM -0400, Jonathan Looney wrote:
> On Sat, Apr 21, 2018 at 1:53 PM, Conrad Meyer  wrote:
> >
> > I don't think this should be enabled by default.  Can we leave it
> > disabled by default and let consumers opt-in?
> 
> I'm willing to change the default if there's a good reason or consensus for
> that. However, it is not obvious to me that the default is actually wrong.
> 
> I think its important that we remember where we are when we hit this code.
> 
> By the time we hit this code, we've already panic'd (whether due to a
> "true" panic or a violated assertion). At this point, the system is already
> in an unknown/unexpected state and we want to preserve our ability to
> troubleshoot and/or recover. (And, since we're running a system with
> INVARIANTS, presumably the ability to troubleshoot is important.)
> 
> We may well violate a second assertion simply because the system is in an
> unknown/unexpected state. Once we do that, the question is whether we
> should try to preserve the ability to troubleshoot, or should give up and
> reset the system.
> 
> All too often, my ability to debug assertion violations is hindered because
> the system trips over yet another assertion while dumping the core. If we
> skip the assertion, nothing bad happens. (The post-panic debugging code
> already needs to deal with systems that are inconsistent, and it does a
> pretty good job at it.)

I think we make a decent effort to fix such problems as they arise, but
you are declaring defeat on behalf of everyone. Did you make some effort
to fix or report these issues before resorting to the more drastic
measure taken here?

> On the other hand, I really am not sure what you are worried might happen
> if we skip checking assertions after we've already panic'd. As far as I can
> tell, the likely worst case is that we hit a true panic of some kind. In
> that case, we're no worse off than before.
> 
> I think the one obvious exception is when we're purposely trying to
> validate the post-panic debugging code. In that case, you can change the
> sysctl/tunable to enable troubleshooting.

What about a user whose test system panics and fails to dump? With
assertions enabled, a developer has a better chance of spotting the
problem. Now we need at least one extra round trip to the user to
diagnose the problem, which may not be readily reproducible in the first
place.

> I would honestly appreciate someone explaining the dangers in disabling a
> response to assertion violations after we've already panic'd and are simply
> trying to troubleshoot, because they are not obvious to me. But, I could
> simply be missing them.

The assertions help identify code that is being executed during a dump
when it shouldn't be. In general we rely on users to opt in to running
INVARIANTS kernels because developers don't catch every single bug. With
this change it's harder to be confident in the kernel dump code. (Or in
any post-panic debugging code for that matter.)

I dislike the change and would prefer the default to be inverted. At the
very least I think we should print the assertion message rather than
returning silently from kassert_panic().
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332871 - head/sys/kern

2018-04-22 Thread Tijl Coosemans
Author: tijl
Date: Sun Apr 22 16:05:29 2018
New Revision: 332871
URL: https://svnweb.freebsd.org/changeset/base/332871

Log:
  Make bufdaemon and bufspacedaemon use kthread_suspend_check instead of
  kproc_suspend_check.  In r329612 bufspacedaemon was turned into a thread
  of the bufdaemon process causing both to call kproc_suspend_check with the
  same proc argument and that function contains the following while loop:
  
  while (SIGISMEMBER(p->p_siglist, SIGSTOP)) {
wakeup(>p_siglist);
msleep(>p_siglist, >p_mtx, PPAUSE, "kpsusp", 0);
  }
  
  So one thread wakes up the other and the other wakes up the first again,
  locking up UP machines on shutdown.
  
  Also register the shutdown handlers with SHUTDOWN_PRI_LAST + 100 so they
  run after the syncer has shutdown, because the syncer can cause a
  situation where bufdaemon help is needed to proceed.
  
  PR:   227404
  Reviewed by:  kib
  Tested by:cy, rmacklem

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Sun Apr 22 09:30:07 2018(r332870)
+++ head/sys/kern/vfs_bio.c Sun Apr 22 16:05:29 2018(r332871)
@@ -791,9 +791,12 @@ bufspace_daemon(void *arg)
 {
struct bufdomain *bd;
 
+   EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
+   SHUTDOWN_PRI_LAST + 100);
+
bd = arg;
for (;;) {
-   kproc_suspend_check(curproc);
+   kthread_suspend_check();
 
/*
 * Free buffers from the clean queue until we meet our
@@ -3357,8 +3360,8 @@ buf_daemon()
/*
 * This process needs to be suspended prior to shutdown sync.
 */
-   EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, bufdaemonproc,
-   SHUTDOWN_PRI_LAST);
+   EVENTHANDLER_REGISTER(shutdown_pre_sync, kthread_shutdown, curthread,
+   SHUTDOWN_PRI_LAST + 100);
 
/*
 * Start the buf clean daemons as children threads.
@@ -3381,7 +3384,7 @@ buf_daemon()
bd_request = 0;
mtx_unlock();
 
-   kproc_suspend_check(bufdaemonproc);
+   kthread_suspend_check();
 
/*
 * Save speedupreq for this pass and reset to capture new
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332870 - head/sys/kern

2018-04-22 Thread Mateusz Guzik
Author: mjg
Date: Sun Apr 22 09:30:07 2018
New Revision: 332870
URL: https://svnweb.freebsd.org/changeset/base/332870

Log:
  lockf: slightly depessimize
  
  1. check if P_ADVLOCK is already set and if so, don't lock to set it
  (stolen from DragonFly)
  2. when trying for fast path unlock, check that we are doing unlock
  first instead of taking the interlock for no reason (e.g. if we want
  to *lock*). whilere make it more likely that falling fast path will
  not take the interlock either by checking for state
  
  Note the code is severely pessimized both single- and multithreaded.

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/kern/kern_lockf.c

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cSun Apr 22 06:11:46 2018
(r332869)
+++ head/sys/kern/kern_descrip.cSun Apr 22 09:30:07 2018
(r332870)
@@ -648,9 +648,11 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
error = EBADF;
break;
}
-   PROC_LOCK(p->p_leader);
-   p->p_leader->p_flag |= P_ADVLOCK;
-   PROC_UNLOCK(p->p_leader);
+   if ((p->p_leader->p_flag & P_ADVLOCK) == 0) {
+   PROC_LOCK(p->p_leader);
+   p->p_leader->p_flag |= P_ADVLOCK;
+   PROC_UNLOCK(p->p_leader);
+   }
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK,
flp, flg);
break;
@@ -659,9 +661,11 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_
error = EBADF;
break;
}
-   PROC_LOCK(p->p_leader);
-   p->p_leader->p_flag |= P_ADVLOCK;
-   PROC_UNLOCK(p->p_leader);
+   if ((p->p_leader->p_flag & P_ADVLOCK) == 0) {
+   PROC_LOCK(p->p_leader);
+   p->p_leader->p_flag |= P_ADVLOCK;
+   PROC_UNLOCK(p->p_leader);
+   }
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_SETLK,
flp, flg);
break;

Modified: head/sys/kern/kern_lockf.c
==
--- head/sys/kern/kern_lockf.c  Sun Apr 22 06:11:46 2018(r332869)
+++ head/sys/kern/kern_lockf.c  Sun Apr 22 09:30:07 2018(r332870)
@@ -479,15 +479,15 @@ retry_setlock:
/*
 * Avoid the common case of unlocking when inode has no locks.
 */
-   VI_LOCK(vp);
-   if ((*statep) == NULL) {
-   if (ap->a_op != F_SETLK) {
+   if (ap->a_op != F_SETLK && (*statep) == NULL) {
+   VI_LOCK(vp);
+   if ((*statep) == NULL) {
fl->l_type = F_UNLCK;
VI_UNLOCK(vp);
return (0);
}
+   VI_UNLOCK(vp);
}
-   VI_UNLOCK(vp);
 
/*
 * Map our arguments to an existing lock owner or create one
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r332869 - head/contrib/ofed/libibverbs

2018-04-22 Thread Hans Petter Selasky
Author: hselasky
Date: Sun Apr 22 06:11:46 2018
New Revision: 332869
URL: https://svnweb.freebsd.org/changeset/base/332869

Log:
  Remove the "load drivers" logic from libibverbs.
  
  The "load drivers" logic in the libibverbs configuration file is relevant
  for Linux only.
  
  MFC after:3 days
  Sponsored by: Mellanox Technologies

Modified:
  head/contrib/ofed/libibverbs/init.c

Modified: head/contrib/ofed/libibverbs/init.c
==
--- head/contrib/ofed/libibverbs/init.c Sun Apr 22 03:58:04 2018
(r332868)
+++ head/contrib/ofed/libibverbs/init.c Sun Apr 22 06:11:46 2018
(r332869)
@@ -80,89 +80,10 @@ static struct ibv_driver *head_driver, *tail_driver;
 
 static int find_sysfs_devs(void)
 {
-#ifdef __linux__
char class_path[IBV_SYSFS_PATH_MAX];
-   DIR *class_dir;
-   struct dirent *dent;
struct ibv_sysfs_dev *sysfs_dev = NULL;
char value[8];
int ret = 0;
-
-   if (!check_snprintf(class_path, sizeof(class_path),
-   "%s/class/infiniband_verbs", ibv_get_sysfs_path()))
-   return ENOMEM;
-
-   class_dir = opendir(class_path);
-   if (!class_dir)
-   return ENOSYS;
-
-   while ((dent = readdir(class_dir))) {
-   struct stat buf;
-
-   if (dent->d_name[0] == '.')
-   continue;
-
-   if (!sysfs_dev)
-   sysfs_dev = malloc(sizeof *sysfs_dev);
-   if (!sysfs_dev) {
-   ret = ENOMEM;
-   goto out;
-   }
-
-   if (!check_snprintf(sysfs_dev->sysfs_path, sizeof 
sysfs_dev->sysfs_path,
-   "%s/%s", class_path, dent->d_name))
-   continue;
-
-   if (stat(sysfs_dev->sysfs_path, )) {
-   fprintf(stderr, PFX "Warning: couldn't stat '%s'.\n",
-   sysfs_dev->sysfs_path);
-   continue;
-   }
-
-   if (!S_ISDIR(buf.st_mode))
-   continue;
-
-   if (!check_snprintf(sysfs_dev->sysfs_name, sizeof 
sysfs_dev->sysfs_name,
-   "%s", dent->d_name))
-   continue;
-
-   if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "ibdev",
-   sysfs_dev->ibdev_name,
-   sizeof sysfs_dev->ibdev_name) < 0) {
-   fprintf(stderr, PFX "Warning: no ibdev class attr for 
'%s'.\n",
-   dent->d_name);
-   continue;
-   }
-
-   if (!check_snprintf(
-   sysfs_dev->ibdev_path, sizeof(sysfs_dev->ibdev_path),
-   "%s/class/infiniband/%s", ibv_get_sysfs_path(),
-   sysfs_dev->ibdev_name))
-   continue;
-
-   sysfs_dev->next= sysfs_dev_list;
-   sysfs_dev->have_driver = 0;
-   if (ibv_read_sysfs_file(sysfs_dev->sysfs_path, "abi_version",
-   value, sizeof value) > 0)
-   sysfs_dev->abi_ver = strtol(value, NULL, 10);
-   else
-   sysfs_dev->abi_ver = 0;
-
-   sysfs_dev_list = sysfs_dev;
-   sysfs_dev  = NULL;
-   }
-
- out:
-   if (sysfs_dev)
-   free(sysfs_dev);
-
-   closedir(class_dir);
-   return ret;
-#else
-   char class_path[IBV_SYSFS_PATH_MAX];
-   struct ibv_sysfs_dev *sysfs_dev = NULL;
-   char value[8];
-   int ret = 0;
int i;
 
snprintf(class_path, sizeof class_path, "%s/class/infiniband_verbs",
@@ -208,7 +129,6 @@ static int find_sysfs_devs(void)
free(sysfs_dev);
 
return ret;
-#endif
 }
 
 void verbs_register_driver(const char *name,
@@ -233,185 +153,6 @@ void verbs_register_driver(const char *name,
tail_driver = driver;
 }
 
-#define __IBV_QUOTE(x) #x
-#define IBV_QUOTE(x)   __IBV_QUOTE(x)
-#define DLOPEN_TRAILER "-" IBV_QUOTE(IBV_DEVICE_LIBRARY_EXTENSION) ".so"
-
-static void load_driver(const char *name)
-{
-   char *so_name;
-   void *dlhandle;
-
-   /* If the name is an absolute path then open that path after appending
-  the trailer suffix */
-   if (name[0] == '/') {
-   if (asprintf(_name, "%s" DLOPEN_TRAILER, name) < 0)
-   goto out_asprintf;
-   dlhandle = dlopen(so_name, RTLD_NOW);
-   if (!dlhandle)
-   goto out_dlopen;
-   free(so_name);
-   return;
-   }
-
-   /* If configured with a provider plugin path then try that next */
-   if (sizeof(VERBS_PROVIDER_DIR) > 1) {
-   if (asprintf(_name, VERBS_PROVIDER_DIR