Re: svn commit: r286268 - head/usr.bin/wall

2015-08-03 Thread Bruce Evans

On Tue, 4 Aug 2015, Pedro F. Giffuni wrote:


Log:
 Revert r286144 leaving the original fix to the buffer overflow.

 Some developers consider the new code unnecessarily obfuscated.
 There was also a benign off-by-one.

 Discussed with:bde, vangyzen, jmallett


It is this version that is unnecessarily obfuscated.


Modified: head/usr.bin/wall/ttymsg.c
==
--- head/usr.bin/wall/ttymsg.c  Tue Aug  4 02:41:14 2015(r286267)
+++ head/usr.bin/wall/ttymsg.c  Tue Aug  4 02:56:31 2015(r286268)
@@ -62,7 +62,7 @@ ttymsg(struct iovec *iov, int iovcnt, co
struct iovec localiov[7];
ssize_t left, wret;
int cnt, fd;
-   char device[MAXNAMLEN];
+   char device[MAXNAMLEN] = _PATH_DEV;
static char errbuf[1024];
char *p;
int forked;


Half of the string initialization is done by an auto initializer.
Initializations in declarations are specifically forbidden in style(9),
and this is a good example of how to obfuscate code using them.  The
original version using a static initializer was almost as obfuscated,
but it was at least maximally efficient and had a technical reason
for using the initializer.


@@ -71,9 +71,8 @@ ttymsg(struct iovec *iov, int iovcnt, co
if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0])))
return ("too many iov's (change code in wall/ttymsg.c)");

-   strlcpy(device, _PATH_DEV, sizeof(device));
+   strlcat(device, line, sizeof(device));


The other half of the initialization is done using strlcat().


p = device + sizeof(_PATH_DEV) - 1;
-   strlcpy(p, line, sizeof(device) - sizeof(_PATH_DEV));
if (strncmp(p, "pts/", 4) == 0)
p += 4;
if (strchr(p, '/') != NULL) {


In private mail, I pointed out lots more bad code here.  The pointer
'p' was introdiced to avoid writing out the expression for it in
more places, especially in the "pts/" check.  But the "pts/" check
is badly written.  It checks the copy of 'line' in 'device'.  This
is an obfuscated way of checking 'line' itself.  It might be more
secure the check the final string, but it is actually more secure
to check 'line' since this will detect slashes that lost by strlcat()
with no error checking.

This method becomes even more unnatural when combined with the strcat().
We use the knowledge of the prefix to find the place to start for the
check, but don't use this to find the place to start for the concatenation.
These places are the same, and unwinding the obfuscation in the check
requires knowing that they are the same.

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


svn commit: r286278 - head/sys/compat/cloudabi

2015-08-03 Thread Ed Schouten
Author: ed
Date: Tue Aug  4 06:02:03 2015
New Revision: 286278
URL: https://svnweb.freebsd.org/changeset/base/286278

Log:
  Let the CloudABI futex code use umtx_keys.
  
  The CloudABI kernel still passes all of the cloudlibc unit tests.
  
  Reviewed by:  vangyzen
  Differential Revision:https://reviews.freebsd.org/D3286

Modified:
  head/sys/compat/cloudabi/cloudabi_futex.c

Modified: head/sys/compat/cloudabi/cloudabi_futex.c
==
--- head/sys/compat/cloudabi/cloudabi_futex.c   Tue Aug  4 06:01:13 2015
(r286277)
+++ head/sys/compat/cloudabi/cloudabi_futex.c   Tue Aug  4 06:02:03 2015
(r286278)
@@ -35,13 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 
 #include 
 #include 
@@ -105,13 +99,7 @@ struct futex_waiter;
 
 /* Identifier of a location in memory. */
 struct futex_address {
-   /* For process-private objects: address space of the process. */
-   struct vmspace *fa_vmspace;
-   /* For process-shared objects: VM object containing the object. */
-   struct vm_object *  fa_vmobject;
-
-   /* Memory address within address space or offset within VM object. */
-   uintptr_t   fa_offset;
+   struct umtx_key fa_key;
 };
 
 /* A set of waiting threads. */
@@ -225,61 +213,16 @@ static int
 futex_address_create(struct futex_address *fa, struct thread *td,
 const void *object, cloudabi_mflags_t scope)
 {
-   struct vmspace *vs;
-   struct vm_object *vo;
-   vm_map_t map;
-   vm_map_entry_t entry;
-   vm_pindex_t pindex;
-   vm_prot_t prot;
-   boolean_t wired;
 
-   /*
-* Most of the time objects are stored in privately mapped
-* anonymous memory. For these objects we wouldn't need to look
-* up the corresponding VM object. The scope hint provided by
-* userspace allows us to skip the VM map lookup for the common
-* case.
-*
-* POSIX does permit enabling PTHREAD_PROCESS_SHARED on a lock
-* stored in a private mapping, at the cost of additional
-* performance overhead. Fall back to identifying the object by
-* virtual memory address if the mapping isn't shared.
-*/
-   vs = td->td_proc->p_vmspace;
+   KASSERT(td == curthread,
+   ("Can only create umtx keys for the current thread"));
switch (scope) {
-   case CLOUDABI_MAP_SHARED:
-   map = &vs->vm_map;
-   if (vm_map_lookup(&map, (vm_offset_t)object,
-   VM_PROT_COPY | VM_PROT_WRITE, &entry, &vo, &pindex, &prot,
-   &wired) != KERN_SUCCESS)
-   return (EFAULT);
-
-   if (entry->inheritance == VM_INHERIT_SHARE) {
-   /*
-* Address corresponds to a shared mapping.
-* Identify the address by its VM object.
-*/
-   fa->fa_vmspace = NULL;
-   fa->fa_vmobject = vo;
-   vm_object_reference(vo);
-   fa->fa_offset = entry->offset - entry->start +
-   (vm_offset_t)object;
-   vm_map_lookup_done(map, entry);
-   return (0);
-   }
-   vm_map_lookup_done(map, entry);
-   /* FALLTHROUGH */
case CLOUDABI_MAP_PRIVATE:
-   /*
-* Address corresponds to a private mapping. Never
-* identify the address by its VM object, as shadow
-* objects may get inserted if another thread forks.
-* Simply use the VM space instead.
-*/
-   fa->fa_vmspace = vs;
-   fa->fa_vmobject = NULL;
-   fa->fa_offset = (uintptr_t)object;
-   return (0);
+   return (umtx_key_get(object, TYPE_FUTEX, THREAD_SHARE,
+   &fa->fa_key));
+   case CLOUDABI_MAP_SHARED:
+   return (umtx_key_get(object, TYPE_FUTEX, AUTO_SHARE,
+   &fa->fa_key));
default:
return (EINVAL);
}
@@ -289,8 +232,7 @@ static void
 futex_address_free(struct futex_address *fa)
 {
 
-   if (fa->fa_vmobject != NULL)
-   vm_object_deallocate(fa->fa_vmobject);
+   umtx_key_release(&fa->fa_key);
 }
 
 static bool
@@ -298,10 +240,7 @@ futex_address_match(const struct futex_a
 const struct futex_address *fa2)
 {
 
-   /* Either fa_vmspace or fa_vmobject is NULL. */
-   return (fa1->fa_vmspace == fa2->fa_vmspace &&
-   fa1->fa_vmobject == fa2->fa_vmobject &&
-   fa1->fa_offset == fa2->fa_offset);
+   return (umtx_key_match(&fa1->fa_key, &fa2->fa_key));
 }
 
 /*
__

svn commit: r286277 - head/sys/kern

2015-08-03 Thread Ed Schouten
Author: ed
Date: Tue Aug  4 06:01:13 2015
New Revision: 286277
URL: https://svnweb.freebsd.org/changeset/base/286277

Log:
  Fix bad arithmetic in umtx_key_get() to compute object offset.
  
  It looks like umtx_key_get() has the addition and subtraction the wrong
  way around, meaning that it fails to match in certain cases. This causes
  the cloudlibc unit tests to deadlock in certain cases.
  
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D3287

Modified:
  head/sys/kern/kern_umtx.c

Modified: head/sys/kern/kern_umtx.c
==
--- head/sys/kern/kern_umtx.c   Tue Aug  4 05:18:24 2015(r286276)
+++ head/sys/kern/kern_umtx.c   Tue Aug  4 06:01:13 2015(r286277)
@@ -820,8 +820,8 @@ umtx_key_get(const void *addr, int type,
(share == AUTO_SHARE &&
 VM_INHERIT_SHARE == entry->inheritance)) {
key->shared = 1;
-   key->info.shared.offset = entry->offset + entry->start -
-   (vm_offset_t)addr;
+   key->info.shared.offset = (vm_offset_t)addr -
+   entry->start + entry->offset;
vm_object_reference(key->info.shared.object);
} else {
key->shared = 0;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r286267 - head/usr.bin/ypcat

2015-08-03 Thread Bruce Evans

On Tue, 4 Aug 2015, Marcelo Araujo wrote:


Log:
 Remove the 3rd clause of BSD LICENSE.
 Sync the code with the OpenBSD version.
 Small style(9) fix up.


This has many style(9) fix downs.


 Differential Revision: D3212
 Reviewed by:   rodrigc, bapt
 Obtained from: OpenBSD
 Sponsored by:  gandi.net

Modified:
 head/usr.bin/ypcat/ypcat.c

Modified: head/usr.bin/ypcat/ypcat.c
==
--- head/usr.bin/ypcat/ypcat.c  Tue Aug  4 02:34:51 2015(r286266)
+++ head/usr.bin/ypcat/ypcat.c  Tue Aug  4 02:41:14 2015(r286267)
@@ -34,18 +33,20 @@ __FBSDID("$FreeBSD$");
#include 
#include 
#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

#include 
#include 
-#include 
+#include 
#include 

-#include 
-#include 
-#include 
-#include 
-#include 
-#include 


Unsorting.  The old organization was almost perfect except for including
both sys/types and sys/param.h.  Now there isn't even a blank line
separating one pair of the 3 groupes of headers.



+void   usage(void);
+intprintit(u_long, char *, int, char *, int, void *);


Unsorted declarations.

Lost staticization.

usage() was misplaced early in the file, so that since it was static,
it didn't need a forward declaration, except style(9) requires one.
usage() is its main example.



static const struct ypalias {
char *alias, *name;
@@ -64,17 +65,18 @@ static const struct ypalias {

static int key;

-static void
+void


Lost staticization.


usage(void)
{
-   fprintf(stderr, "%s\n%s\n",
-   "usage: ypcat [-kt] [-d domainname] mapname",
-   "   ypcat -x");
+   fprintf(stderr,
+   "usage: ypcat [-kt] [-d domainname] mapname\n"
+   "   ypcat -x\n");


This fixes the indentation, but breaks the string using C90 string
concatenation.  style(9) doesn't specify using the "%s\n%s\n..."
for printing multiple strings on multiple line by example, but
almost all FreeBSD utilities including the old version of this one
provide an example of this.



exit(1);
}

-static int
-printit(unsigned long instatus, char *inkey, int inkeylen, char *inval, int 
invallen, void *dummy __unused)
+int
+printit(u_long instatus, char *inkey, int inkeylen, char *inval, int invallen,
+void *indata)


Lost staticization.


{
if (instatus != YP_TRUE)
return (instatus);
@@ -87,31 +89,29 @@ printit(unsigned long instatus, char *in
int
main(int argc, char *argv[])
{
-   char *domainname = NULL;
+   char *domain = NULL, *inmap;
struct ypall_callback ypcb;
-   char *inmap;
-   int notrans;
-   int c, r;
+   extern char *optarg;
+   extern int optind;


Extern declarations belong in a header file.  Broken programs sometimes
declare them directly to hide the bug that they don't include the correct
header file, but this program still includes the correct header file
(unistd.h>).  Compilers are directed to warn about nested externs at
a not very high WARNS.


+   int notrans, c, r;


Combining the declaration is good, but the variables are still unsorted.


u_int i;

notrans = key = 0;
-
while ((c = getopt(argc, argv, "xd:kt")) != -1)
switch (c) {
case 'x':
-   for (i = 0; i

Further away from KNF.  The code is squished up to avoid line splitting,
but the old version only squished 2 of 3 binary operations and that made
the line length exactly 80.


...
@@ -120,24 +120,29 @@ main(int argc, char *argv[])
if (optind + 1 != argc)
usage();

-   if (!domainname)
-   yp_get_default_domain(&domainname);
+   if (!domain)
+   yp_get_default_domain(&domain);


Still uses '!' on pointers.



inmap = argv[optind];
-   for (i = 0; (!notrans) && i

Squished as above, but now the squishing is not even needed to avoid
line-splitting.


case YPERR_YPBIND:
-   errx(1, "not running ypbind");
+   errx(1, "ypcat: not running ypbind\n");
+   exit(1);


Large regressions.  Now the program name is printed twice, and the
newline at the end of the message is printed twice, and there are 2
exits, with the new one unreachable.


default:
-   errx(1, "no such map %s. reason: %s", inmap, yperr_string(r));
+   errx(1, "No such map %s. Reason: %s\n",
+   inmap, yperr_string(r));
+   exit(1);


As above, except the program name is not printed twice, plus
- the first word after the program name is now capitalized.  This is part
  of a sentence beginning with the program name and a colon.  There are
  various style guides for capitilization after a colon.  FreeBSD uses the
  following inconsistent rules in error messages:
  - don't capitalize
  - however, if the error message is from strerror(), then it capitalizes.
Keep this.

Re: svn commit: r286265 - head/sys/x86/include

2015-08-03 Thread Bruce Evans

On Tue, 4 Aug 2015, Konstantin Belousov wrote:


On Tue, Aug 04, 2015 at 12:11:40AM +, Jung-uk Kim wrote:

Log:
  Always define __va_list for amd64 and restore pre-r232261 behavior for i386.
  Note it allows exotic compilers, e.g., TCC, to build with our stdio.h, etc.


Thanks.


  PR:   201749
  MFC after:1 week

Modified:
  head/sys/x86/include/_types.h

Modified: head/sys/x86/include/_types.h
==
--- head/sys/x86/include/_types.h   Tue Aug  4 00:11:38 2015
(r286264)
+++ head/sys/x86/include/_types.h   Tue Aug  4 00:11:39 2015
(r286265)
@@ -152,8 +152,17 @@ typedefint ___wchar_t;
  */
 #ifdef __GNUCLIKE_BUILTIN_VARARGS
 typedef__builtin_va_list   __va_list;  /* internally known to 
gcc */
-#elif defined(lint)
-typedefchar *  __va_list;  /* pretend */
+#else
+#ifdef __LP64__
+typedefstruct {
+   unsigned int__gpo;
+   unsigned int__fpo;
+   void*__oaa;
+   void*__rsa;
+} __va_list;


Ugh.  This is ugly and has many excical style bugs:
- tab in 'typedef struct'
- use of 'typedef struct' at all.  style(9) forbids this.  structs should
  be declared with a tag and the used directly.  That means
  '#define  __va_list   struct __s_va_list' here
- verbose spelling of 'unsigned'
- ugly indentation from previous
- excessive underscores in struct member names.  Only names in outer
  scope need 2 underscores and .  See stdio.h.


What do the structure fields mean ?  How is it related to the amd64 vararg
ABI ?


It seems ABI compatible, but perhaps not API compatible.  The double
underscores in the names might be to match an API.  But I doubt that old
compilers even support the __LP64__ case.  The certainly don't access
these names in any FreeBSD header.  So the ABI could be matched by
defining __va_list as an array of 3 uint64_t's or as a struct with
unnamed fields or padding.


+#else
+typedefchar *  __va_list;


This still has the '*' misplaced.


+#endif
 #endif
 #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
 && !defined(__NO_GNUC_VA_LIST)


Is this uglyness still necessary?  The gnu-style '&&' in it isn't.  This
seems to be for very old versions of gcc that probably don't have builtin
varargs.  In old versions of this file, the condition
defined(__GNUC_VA_LIST_COMPATIBILITY) was
defined(__GNUC__) && !defined(__INTEL_COMPILER__), so I think this ifdef
is just for defining something used in old gcc's distribution stdarg.h.
The __INTEL_COMPILER__ part of this makes no sense, and
__GNUC_VA_LIST_COMPATIBILITY is now just an obfuscated spelling of
__GNUC__.  Since this is for old gcc internals, non-gcc compilers are
unlikely to need it for compatibility, so the obfuscation is just wrong.

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


Re: svn commit: r286236 - head/share/man/man9

2015-08-03 Thread Konstantin Belousov
On Tue, Aug 04, 2015 at 07:16:50AM +0300, Konstantin Belousov wrote:
> On Mon, Aug 03, 2015 at 01:52:46PM -0400, Benjamin Kaduk wrote:
> > On Mon, Aug 3, 2015 at 12:30 PM, Edward Tomasz Napierala 
> > wrote:
> > 
> > > Author: trasz
> > > Date: Mon Aug  3 16:30:47 2015
> > > New Revision: 286236
> > > URL: https://svnweb.freebsd.org/changeset/base/286236
> > >
> > > Log:
> > >   Document vgonel(9).
> > >
> > 
> > Er, isn't this a step backwards?
> > 
> > % static void vgonel(struct vnode *);
> > 
> > It is only accidental that anything outside vfs_subr.c can call vgonel().
> Indeed, only kernel modules on some architectures could use a hole in
> the kernel linker to reference vgonel(). The kernel itself cannot call
> vgonel() outside vfs_subr.c. There is no point in putting vgonel(9) in
> the man page.

I believe the source of the confusion is the vgonel() definition, which
lacks the static qualifier.  I propose to remove vgonel(9) reference from
the man page and add static to definition.

Might be, a review of all functions in vfs_*.c and fixing their missed
qualifiers would be useful.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r286236 - head/share/man/man9

2015-08-03 Thread Konstantin Belousov
On Mon, Aug 03, 2015 at 01:52:46PM -0400, Benjamin Kaduk wrote:
> On Mon, Aug 3, 2015 at 12:30 PM, Edward Tomasz Napierala 
> wrote:
> 
> > Author: trasz
> > Date: Mon Aug  3 16:30:47 2015
> > New Revision: 286236
> > URL: https://svnweb.freebsd.org/changeset/base/286236
> >
> > Log:
> >   Document vgonel(9).
> >
> 
> Er, isn't this a step backwards?
> 
> % static void vgonel(struct vnode *);
> 
> It is only accidental that anything outside vfs_subr.c can call vgonel().
Indeed, only kernel modules on some architectures could use a hole in
the kernel linker to reference vgonel(). The kernel itself cannot call
vgonel() outside vfs_subr.c. There is no point in putting vgonel(9) in
the man page.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r286265 - head/sys/x86/include

2015-08-03 Thread Konstantin Belousov
On Tue, Aug 04, 2015 at 12:11:40AM +, Jung-uk Kim wrote:
> Author: jkim
> Date: Tue Aug  4 00:11:39 2015
> New Revision: 286265
> URL: https://svnweb.freebsd.org/changeset/base/286265
> 
> Log:
>   Always define __va_list for amd64 and restore pre-r232261 behavior for i386.
>   Note it allows exotic compilers, e.g., TCC, to build with our stdio.h, etc.
>   
>   PR: 201749
>   MFC after:  1 week
> 
> Modified:
>   head/sys/x86/include/_types.h
> 
> Modified: head/sys/x86/include/_types.h
> ==
> --- head/sys/x86/include/_types.h Tue Aug  4 00:11:38 2015
> (r286264)
> +++ head/sys/x86/include/_types.h Tue Aug  4 00:11:39 2015
> (r286265)
> @@ -152,8 +152,17 @@ typedef  int ___wchar_t;
>   */
>  #ifdef __GNUCLIKE_BUILTIN_VARARGS
>  typedef  __builtin_va_list   __va_list;  /* internally known to 
> gcc */
> -#elif defined(lint)
> -typedef  char *  __va_list;  /* pretend */
> +#else
> +#ifdef __LP64__
> +typedef  struct {
> + unsigned int__gpo;
> + unsigned int__fpo;
> + void*__oaa;
> + void*__rsa;
> +} __va_list;
What do the structure fields mean ?  How is it related to the amd64 vararg
ABI ?

> +#else
> +typedef  char *  __va_list;
> +#endif
>  #endif
>  #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
>  && !defined(__NO_GNUC_VA_LIST)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286268 - head/usr.bin/wall

2015-08-03 Thread Pedro F. Giffuni
Author: pfg
Date: Tue Aug  4 02:56:31 2015
New Revision: 286268
URL: https://svnweb.freebsd.org/changeset/base/286268

Log:
  Revert r286144 leaving the original fix to the buffer overflow.
  
  Some developers consider the new code unnecessarily obfuscated.
  There was also a benign off-by-one.
  
  Discussed with:   bde, vangyzen, jmallett

Modified:
  head/usr.bin/wall/ttymsg.c

Modified: head/usr.bin/wall/ttymsg.c
==
--- head/usr.bin/wall/ttymsg.c  Tue Aug  4 02:41:14 2015(r286267)
+++ head/usr.bin/wall/ttymsg.c  Tue Aug  4 02:56:31 2015(r286268)
@@ -62,7 +62,7 @@ ttymsg(struct iovec *iov, int iovcnt, co
struct iovec localiov[7];
ssize_t left, wret;
int cnt, fd;
-   char device[MAXNAMLEN];
+   char device[MAXNAMLEN] = _PATH_DEV;
static char errbuf[1024];
char *p;
int forked;
@@ -71,9 +71,8 @@ ttymsg(struct iovec *iov, int iovcnt, co
if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0])))
return ("too many iov's (change code in wall/ttymsg.c)");
 
-   strlcpy(device, _PATH_DEV, sizeof(device));
+   strlcat(device, line, sizeof(device));
p = device + sizeof(_PATH_DEV) - 1;
-   strlcpy(p, line, sizeof(device) - sizeof(_PATH_DEV));
if (strncmp(p, "pts/", 4) == 0)
p += 4;
if (strchr(p, '/') != NULL) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286267 - head/usr.bin/ypcat

2015-08-03 Thread Marcelo Araujo
Author: araujo (ports committer)
Date: Tue Aug  4 02:41:14 2015
New Revision: 286267
URL: https://svnweb.freebsd.org/changeset/base/286267

Log:
  Remove the 3rd clause of BSD LICENSE.
  Sync the code with the OpenBSD version.
  Small style(9) fix up.
  
  Differential Revision:D3212
  Reviewed by:  rodrigc, bapt
  Obtained from:OpenBSD
  Sponsored by: gandi.net

Modified:
  head/usr.bin/ypcat/ypcat.c

Modified: head/usr.bin/ypcat/ypcat.c
==
--- head/usr.bin/ypcat/ypcat.c  Tue Aug  4 02:34:51 2015(r286266)
+++ head/usr.bin/ypcat/ypcat.c  Tue Aug  4 02:41:14 2015(r286267)
@@ -1,5 +1,7 @@
+/* $OpenBSD: ypcat.c,v 1.16 2015/02/08 23:40:35 deraadt Exp $ */
+
 /*
- * Copyright (c) 1992/3 Theo de Raadt 
+ * Copyright (c) 1992, 1993, 1996 Theo de Raadt 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -10,9 +12,6 @@
  * 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.
- * 3. The name of the author may not be used to endorse or promote
- *products derived from this software without specific prior written
- *permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -34,18 +33,20 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
-#include 
+#include 
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+void   usage(void);
+intprintit(u_long, char *, int, char *, int, void *);
 
 static const struct ypalias {
char *alias, *name;
@@ -64,17 +65,18 @@ static const struct ypalias {
 
 static int key;
 
-static void
+void
 usage(void)
 {
-   fprintf(stderr, "%s\n%s\n",
-   "usage: ypcat [-kt] [-d domainname] mapname",
-   "   ypcat -x");
+   fprintf(stderr,
+   "usage: ypcat [-kt] [-d domainname] mapname\n"
+   "   ypcat -x\n");
exit(1);
 }
 
-static int
-printit(unsigned long instatus, char *inkey, int inkeylen, char *inval, int 
invallen, void *dummy __unused)
+int
+printit(u_long instatus, char *inkey, int inkeylen, char *inval, int invallen,
+void *indata)
 {
if (instatus != YP_TRUE)
return (instatus);
@@ -87,31 +89,29 @@ printit(unsigned long instatus, char *in
 int
 main(int argc, char *argv[])
 {
-   char *domainname = NULL;
+   char *domain = NULL, *inmap;
struct ypall_callback ypcb;
-   char *inmap;
-   int notrans;
-   int c, r;
+   extern char *optarg;
+   extern int optind;
+   int notrans, c, r;
u_int i;
 
notrans = key = 0;
-
while ((c = getopt(argc, argv, "xd:kt")) != -1)
switch (c) {
case 'x':
-   for (i = 0; ihttp://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286266 - head/usr.bin/ypmatch

2015-08-03 Thread Marcelo Araujo
Author: araujo (ports committer)
Date: Tue Aug  4 02:34:51 2015
New Revision: 286266
URL: https://svnweb.freebsd.org/changeset/base/286266

Log:
  Remove the 3rd clause of BSD LICENSE.
  Sync the code with the OpenBSD version.
  
  Differential Revision:D3213
  Reviewed by:  rodrigc, bapt
  Obtained from:OpenBSD
  Sponsored by: gandi.net

Modified:
  head/usr.bin/ypmatch/ypmatch.c

Modified: head/usr.bin/ypmatch/ypmatch.c
==
--- head/usr.bin/ypmatch/ypmatch.c  Tue Aug  4 00:11:39 2015
(r286265)
+++ head/usr.bin/ypmatch/ypmatch.c  Tue Aug  4 02:34:51 2015
(r286266)
@@ -1,5 +1,8 @@
+/* $OpenBSD: ypmatch.c,v 1.16 2015/02/08 23:40:35 deraadt Exp $ */
+/* $NetBSD: ypmatch.c,v 1.8 1996/05/07 01:24:52 jtc Exp $  */
+
 /*
- * Copyright (c) 1992/3 Theo de Raadt 
+ * Copyright (c) 1992, 1993, 1996 Theo de Raadt 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -10,9 +13,6 @@
  * 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.
- * 3. The name of the author may not be used to endorse or promote
- *products derived from this software without specific prior written
- *permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -34,18 +34,19 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+void   usage(void);
 
 static const struct ypalias {
char *alias, *name;
@@ -62,30 +63,37 @@ static const struct ypalias {
{ "ethers", "ethers.byname" },
 };
 
-static void
+void
 usage(void)
 {
-   fprintf(stderr, "%s\n%s\n",
-   "usage: ypmatch [-kt] [-d domainname] key ... mapname",
-   "   ypmatch -x");
+   fprintf(stderr,
+   "usage: ypmatch [-kt] [-d domain] key ... mapname\n"
+   "   ypmatch -x\n");
+   fprintf(stderr,
+   "where\n"
+   "\tmapname may be either a mapname or a nickname for a map.\n"
+   "\t-k prints keys as well as values.\n"
+   "\t-t inhibits map nickname translation.\n"
+   "\t-x dumps the map nickname translation table.\n");
exit(1);
 }
 
 int
 main(int argc, char *argv[])
 {
-   char *domainname = NULL;
-   char *inkey, *inmap, *outbuf;
-   int outbuflen, key, notrans;
+   char *domainname, *inkey, *inmap, *outbuf;
+   extern char *optarg;
+   extern int optind;
+   int outbuflen, key, notrans, rval;
int c, r;
u_int i;
 
+   domainname = NULL;
notrans = key = 0;
-
-   while ((c = getopt(argc, argv, "xd:kt")) != -1)
+   while ((c=getopt(argc, argv, "xd:kt")) != -1)
switch (c) {
case 'x':
-   for (i = 0; ihttp://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286265 - head/sys/x86/include

2015-08-03 Thread Jung-uk Kim
Author: jkim
Date: Tue Aug  4 00:11:39 2015
New Revision: 286265
URL: https://svnweb.freebsd.org/changeset/base/286265

Log:
  Always define __va_list for amd64 and restore pre-r232261 behavior for i386.
  Note it allows exotic compilers, e.g., TCC, to build with our stdio.h, etc.
  
  PR:   201749
  MFC after:1 week

Modified:
  head/sys/x86/include/_types.h

Modified: head/sys/x86/include/_types.h
==
--- head/sys/x86/include/_types.h   Tue Aug  4 00:11:38 2015
(r286264)
+++ head/sys/x86/include/_types.h   Tue Aug  4 00:11:39 2015
(r286265)
@@ -152,8 +152,17 @@ typedefint ___wchar_t;
  */
 #ifdef __GNUCLIKE_BUILTIN_VARARGS
 typedef__builtin_va_list   __va_list;  /* internally known to 
gcc */
-#elif defined(lint)
-typedefchar *  __va_list;  /* pretend */
+#else
+#ifdef __LP64__
+typedefstruct {
+   unsigned int__gpo;
+   unsigned int__fpo;
+   void*__oaa;
+   void*__rsa;
+} __va_list;
+#else
+typedefchar *  __va_list;
+#endif
 #endif
 #if defined(__GNUC_VA_LIST_COMPATIBILITY) && !defined(__GNUC_VA_LIST) \
 && !defined(__NO_GNUC_VA_LIST)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286260 - head/sys/net

2015-08-03 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Aug  3 22:14:45 2015
New Revision: 286260
URL: https://svnweb.freebsd.org/changeset/base/286260

Log:
  Remove the mtx_sleep() from the kqueue f_event filter.
  
  The filter is called from the network hot path and must not sleep.
  
  The filter runs with the descriptor lock held and does not manipulates the
  buffers, so it is not necessary sleep when the hold buffer is in use.
  
  Just ignore the hold buffer contents when it is being copied to user space
  (when hold buffer in use is set).
  
  This fix the "Sleeping thread owns a non-sleepable lock" panic when the
  userland thread is too busy reading the packets from bpf(4).
  
  PR:   200323
  MFC after:2 weeks
  Sponsored by: Rubicon Communications (Netgate)

Modified:
  head/sys/net/bpf.c

Modified: head/sys/net/bpf.c
==
--- head/sys/net/bpf.c  Mon Aug  3 22:07:50 2015(r286259)
+++ head/sys/net/bpf.c  Mon Aug  3 22:14:45 2015(r286260)
@@ -2035,10 +2035,10 @@ filt_bpfread(struct knote *kn, long hint
ready = bpf_ready(d);
if (ready) {
kn->kn_data = d->bd_slen;
-   while (d->bd_hbuf_in_use)
-   mtx_sleep(&d->bd_hbuf_in_use, &d->bd_lock,
-   PRINET, "bd_hbuf", 0);
-   if (d->bd_hbuf)
+   /*
+* Ignore the hold buffer if it is being copied to user space.
+*/
+   if (!d->bd_hbuf_in_use && d->bd_hbuf)
kn->kn_data += d->bd_hlen;
} else if (d->bd_rtout > 0 && d->bd_state == BPF_IDLE) {
callout_reset(&d->bd_callout, d->bd_rtout,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286259 - head/usr.sbin/pw

2015-08-03 Thread Ed Schouten
Author: ed
Date: Mon Aug  3 22:07:50 2015
New Revision: 286259
URL: https://svnweb.freebsd.org/changeset/base/286259

Log:
  Avoid calling strlen() where we can use the strspn() return value.

Modified:
  head/usr.sbin/pw/pw_group.c
  head/usr.sbin/pw/pw_user.c

Modified: head/usr.sbin/pw/pw_group.c
==
--- head/usr.sbin/pw/pw_group.c Mon Aug  3 21:19:31 2015(r286258)
+++ head/usr.sbin/pw/pw_group.c Mon Aug  3 22:07:50 2015(r286259)
@@ -297,7 +297,7 @@ pw_group_show(int argc, char **argv, cha
};
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, GID_MAX);
else
name = arg1;
@@ -360,7 +360,7 @@ pw_group_del(int argc, char **argv, char
bool nis = false;
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, GID_MAX);
else
name = arg1;
@@ -491,7 +491,7 @@ pw_group_add(int argc, char **argv, char
quiet = precrypted = dryrun = pretty = nis = false;
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, GID_MAX);
else
name = arg1;
@@ -577,7 +577,7 @@ pw_group_mod(int argc, char **argv, char
quiet = pretty = dryrun = nis = precrypted = false;
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, GID_MAX);
else
name = arg1;

Modified: head/usr.sbin/pw/pw_user.c
==
--- head/usr.sbin/pw/pw_user.c  Mon Aug  3 21:19:31 2015(r286258)
+++ head/usr.sbin/pw/pw_user.c  Mon Aug  3 22:07:50 2015(r286259)
@@ -214,7 +214,7 @@ pw_userlock(char *arg1, int mode)
if (arg1 == NULL)
errx(EX_DATAERR, "username or id required");
 
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, UID_MAX);
else
name = arg1;
@@ -709,7 +709,7 @@ pw_user_show(int argc, char **argv, char
bool quiet = false;
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, UID_MAX);
else
name = arg1;
@@ -793,7 +793,7 @@ pw_user_del(int argc, char **argv, char 
bool quiet = false;
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, UID_MAX);
else
name = arg1;
@@ -1124,7 +1124,7 @@ pw_user_add(int argc, char **argv, char 
err(EXIT_FAILURE, "calloc()");
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, UID_MAX);
else
name = arg1;
@@ -1435,7 +1435,7 @@ pw_user_mod(int argc, char **argv, char 
edited = docreatehome = false;
 
if (arg1 != NULL) {
-   if (strspn(arg1, "0123456789") == strlen(arg1))
+   if (arg1[strspn(arg1, "0123456789")] == '\0')
id = pw_checkid(arg1, UID_MAX);
else
name = arg1;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286258 - head/usr.sbin/pw

2015-08-03 Thread Devin Teske
Author: dteske
Date: Mon Aug  3 21:19:31 2015
New Revision: 286258
URL: https://svnweb.freebsd.org/changeset/base/286258

Log:
  Clarify pw(8) manual w/respect to required arguments. Break long lines at
  punctuation while here.
  
  Differential Revision:https://reviews.freebsd.org/D2700
  Reviewed by:  wblock, bapt
  MFC after:3 days
  X-MFC-to: stable/10

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

Modified: head/usr.sbin/pw/pw.8
==
--- head/usr.sbin/pw/pw.8   Mon Aug  3 21:11:33 2015(r286257)
+++ head/usr.sbin/pw/pw.8   Mon Aug  3 21:19:31 2015(r286258)
@@ -35,11 +35,9 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar useradd
-.Op name|uid
+.Oo Fl n Oc name Oo Fl u Ar uid Oc
 .Op Fl C Ar config
 .Op Fl q
-.Op Fl n Ar name
-.Op Fl u Ar uid
 .Op Fl c Ar comment
 .Op Fl d Ar dir
 .Op Fl e Ar date
@@ -61,7 +59,6 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar useradd
-.Op name|uid
 .Fl D
 .Op Fl C Ar config
 .Op Fl q
@@ -81,27 +78,23 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar userdel
-.Op name|uid
-.Op Fl n Ar name
-.Op Fl u Ar uid
+.Oo Fl n Oc name|uid | Fl u Ar uid
 .Op Fl r
 .Op Fl Y
 .Nm
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar usermod
-.Op name|uid
+.Oo Fl n Oc name|uid Oo Fl u Ar newuid Oc | Fl u Ar uid
 .Op Fl C Ar config
 .Op Fl q
-.Op Fl n Ar name
-.Op Fl u Ar uid
 .Op Fl c Ar comment
 .Op Fl d Ar dir
 .Op Fl e Ar date
 .Op Fl p Ar date
 .Op Fl g Ar group
 .Op Fl G Ar grouplist
-.Op Fl l Ar name
+.Op Fl l Ar newname
 .Op Fl m
 .Op Fl M Ar mode
 .Op Fl k Ar dir
@@ -116,9 +109,7 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar usershow
-.Op name|uid
-.Op Fl n Ar name
-.Op Fl u Ar uid
+.Oo Fl n Oc name|uid | Fl u Ar uid
 .Op Fl F
 .Op Fl P
 .Op Fl 7
@@ -133,11 +124,9 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar groupadd
-.Op group|gid
+.Oo Fl n Oc name Oo Fl g Ar gid Oc
 .Op Fl C Ar config
 .Op Fl q
-.Op Fl n Ar group
-.Op Fl g Ar gid
 .Op Fl M Ar members
 .Op Fl o
 .Op Fl h Ar fd | Fl H Ar fd
@@ -148,20 +137,16 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar groupdel
-.Op group|gid
-.Op Fl n Ar name
-.Op Fl g Ar gid
+.Oo Fl n Oc name|gid | Fl g Ar gid
 .Op Fl Y
 .Nm
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar groupmod
-.Op group|gid
+.Oo Fl n Oc name|gid Oo Fl g Ar newgid Oc | Fl g Ar gid
 .Op Fl C Ar config
 .Op Fl q
-.Op Fl n Ar name
-.Op Fl g Ar gid
-.Op Fl l Ar name
+.Op Fl l Ar newname
 .Op Fl M Ar members
 .Op Fl m Ar newmembers
 .Op Fl d Ar oldmembers
@@ -173,9 +158,7 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar groupshow
-.Op group|gid
-.Op Fl n Ar name
-.Op Fl g Ar gid
+.Oo Fl n Oc name|gid | Fl g Ar gid
 .Op Fl F
 .Op Fl P
 .Op Fl a
@@ -189,14 +172,14 @@
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar lock
-.Op name|uid
+.Oo Fl n Oc name|uid | Fl u Ar uid
 .Op Fl C Ar config
 .Op Fl q
 .Nm
 .Op Fl R Ar rootdir
 .Op Fl V Ar etcdir
 .Ar unlock
-.Op name|uid
+.Oo Fl n Oc name|uid | Fl u Ar uid
 .Op Fl C Ar config
 .Op Fl q
 .Sh DESCRIPTION
@@ -250,8 +233,9 @@ all mean the same thing.)
 This flexibility is useful for interactive scripts calling
 .Nm
 for user and group database manipulation.
-Following these keywords, you may optionally specify the user or group name or 
numeric
-id as an alternative to using the
+Following these keywords,
+the user or group name or numeric id may be optionally specified as an
+alternative to using the
 .Fl n Ar name ,
 .Fl u Ar uid ,
 .Fl g Ar gid
@@ -266,12 +250,13 @@ will operate.
 Any paths specified will be relative to
 .Va rootdir .
 .It Fl V Ar etcdir
-This flag sets an alternate location for the password, group and configuration 
files,
-and may be used to maintain a user/group database in an alternate location.
+Set an alternate location for the password, group, and configuration files.
+Can be used to maintain a user/group database in an alternate location.
 If this switch is specified, the system
 .Pa /etc/pw.conf
-will not be sourced for default configuration data, but the file pw.conf in the
-specified directory will be used instead (or none, if it does not exist).
+will not be sourced for default configuration data,
+but the file pw.conf in the specified directory will be used instead
+.Pq or none, if it does not exist .
 The
 .Fl C
 flag may be used to override this behaviour.
@@ -294,7 +279,8 @@ configuration file.
 .It Fl q
 Use of this option causes
 .Nm
-to suppress error messages, which may be useful in interactive environments 
where it
+to suppress error messages,
+which may be useful in interactive environments where it
 is preferable to interpret status codes returned by
 .Nm
 rather than messing up a carefully formatted display.
@@ -338,27 +324,40 @@ and
 .Ar usermod
 commands:
 .Bl -tag -width "-G grouplist"
-.It Fl n Ar name
+.It Oo Fl n Oc Ar name
+Required unless
+.Fl u Ar uid
+is given.
 Specify the user/account name.
+In the case of
+.Ar usermod
+can be a uid.
 .It Fl u Ar uid
+Required if
+.Ar name
+is n

svn commit: r286257 - in head/sys: kern sys

2015-08-03 Thread Ed Schouten
Author: ed
Date: Mon Aug  3 21:11:33 2015
New Revision: 286257
URL: https://svnweb.freebsd.org/changeset/base/286257

Log:
  Add missing const keyword to function parameter.
  
  The umtx_key_get() function does not dereference the address off the
  userspace object. The pointer can safely be const.

Modified:
  head/sys/kern/kern_umtx.c
  head/sys/sys/umtx.h

Modified: head/sys/kern/kern_umtx.c
==
--- head/sys/kern/kern_umtx.c   Mon Aug  3 20:43:36 2015(r286256)
+++ head/sys/kern/kern_umtx.c   Mon Aug  3 21:11:33 2015(r286257)
@@ -793,7 +793,7 @@ umtxq_sleep(struct umtx_q *uq, const cha
  * Convert userspace address into unique logical address.
  */
 int
-umtx_key_get(void *addr, int type, int share, struct umtx_key *key)
+umtx_key_get(const void *addr, int type, int share, struct umtx_key *key)
 {
struct thread *td = curthread;
vm_map_t map;

Modified: head/sys/sys/umtx.h
==
--- head/sys/sys/umtx.h Mon Aug  3 20:43:36 2015(r286256)
+++ head/sys/sys/umtx.h Mon Aug  3 21:11:33 2015(r286257)
@@ -153,7 +153,7 @@ umtx_key_match(const struct umtx_key *k1
 }
 
 int umtx_copyin_timeout(const void *, struct timespec *);
-int umtx_key_get(void *, int, int, struct umtx_key *);
+int umtx_key_get(const void *, int, int, struct umtx_key *);
 void umtx_key_release(struct umtx_key *);
 struct umtx_q *umtxq_alloc(void);
 void umtxq_free(struct umtx_q *);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Warner Losh

> On Aug 3, 2015, at 1:44 PM, Slawa Olhovchenkov  wrote:
> 
> On Tue, Aug 04, 2015 at 03:35:50AM +0800, Julian Elischer wrote:
> 
>> On 8/3/15 8:03 PM, Konstantin Belousov wrote:
>>> On Mon, Aug 03, 2015 at 12:50:19PM +0100, Steven Hartland wrote:
 For this change I don't want to get into fixing the thread0 stack size,
 which can be done later, just
 to provide a reasonable warning to the user that smaller values could
 cause a panic.
>>> Hmm, is it limited to the thread0 only ?  I.e., would only increasing
>>> the initial thread stack size be enough to boot the kernel ?  The zfs
>>> threads do request larger stack size, I know this.
>>> 
>>> Can somebody test the following patch in the i386 configuration which
>>> does not boot ?
>> 
>> I think this is a reasonable thing to do. Thread0 (and proc0) are special.
>> I don't see why giving it a specially sized stack would be a problem.
> 
> This is always do for ARM.
> May be need increase stack size for Thread0 on ARM too?

Seems reasonable. There should be a MI way of doing this, but all the code and 
defines are buried in MD files, so each architecture needs some love to make 
this a reality.

Warner



signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r286256 - head/sys/kern

2015-08-03 Thread John Baldwin
Author: jhb
Date: Mon Aug  3 20:43:36 2015
New Revision: 286256
URL: https://svnweb.freebsd.org/changeset/base/286256

Log:
  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.
  
  Reviewed by:  kib
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D3193

Modified:
  head/sys/kern/sched_4bsd.c
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_4bsd.c
==
--- head/sys/kern/sched_4bsd.c  Mon Aug  3 20:30:27 2015(r286255)
+++ head/sys/kern/sched_4bsd.c  Mon Aug  3 20:43:36 2015(r286256)
@@ -792,6 +792,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: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Mon Aug  3 20:30:27 2015(r286255)
+++ head/sys/kern/sched_ule.c   Mon Aug  3 20:43:36 2015(r286256)
@@ -2080,6 +2080,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;
@@ -2703,6 +2705,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-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286255 - head/sys/vm

2015-08-03 Thread Alan Cox
Author: alc
Date: Mon Aug  3 20:30:27 2015
New Revision: 286255
URL: https://svnweb.freebsd.org/changeset/base/286255

Log:
  Refinements to r281079's sequential access optimization: Prefetched pages,
  which constitute the majority of the pages that are processed by
  vm_fault_dontneed(), are already near the tail of the inactive queue.  Only
  the pages at faulting virtual addresses are actually moved by
  vm_page_advise(..., MADV_DONTNEED).  However, vm_page_advise(...,
  MADV_DONTNEED) is simultaneously too aggressive and passive for the moved
  pages.  It makes most of these pages too easily reclaimable, and at the same
  time it leaves enough pages in the active queue to trigger pageouts by the
  page daemon.  Instead, with this change, the pages at faulting virtual
  addresses are moved to the tail of the inactive queue, where they are
  relatively close to the pages prefetched by the same page fault.
  
  Discussed with:   jeff
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/vm/vm_fault.c

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Mon Aug  3 19:15:19 2015(r286254)
+++ head/sys/vm/vm_fault.c  Mon Aug  3 20:30:27 2015(r286255)
@@ -1081,9 +1081,19 @@ vm_fault_dontneed(const struct faultstat
if (m->valid != VM_PAGE_BITS_ALL ||
vm_page_busied(m))
continue;
+
+   /*
+* Don't clear PGA_REFERENCED, since it would
+* likely represent a reference by a different
+* process.
+*
+* Typically, at this point, prefetched pages
+* are still in the inactive queue.  Only
+* pages that triggered page faults are in the
+* active queue.
+*/
vm_page_lock(m);
-   if (m->hold_count == 0 && m->wire_count == 0)
-   vm_page_advise(m, MADV_DONTNEED);
+   vm_page_deactivate(m);
vm_page_unlock(m);
}
}
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Slawa Olhovchenkov
On Tue, Aug 04, 2015 at 03:35:50AM +0800, Julian Elischer wrote:

> On 8/3/15 8:03 PM, Konstantin Belousov wrote:
> > On Mon, Aug 03, 2015 at 12:50:19PM +0100, Steven Hartland wrote:
> >> For this change I don't want to get into fixing the thread0 stack size,
> >> which can be done later, just
> >> to provide a reasonable warning to the user that smaller values could
> >> cause a panic.
> > Hmm, is it limited to the thread0 only ?  I.e., would only increasing
> > the initial thread stack size be enough to boot the kernel ?  The zfs
> > threads do request larger stack size, I know this.
> >
> > Can somebody test the following patch in the i386 configuration which
> > does not boot ?
> 
> I think this is a reasonable thing to do. Thread0 (and proc0) are special.
> I don't see why giving it a specially sized stack would be a problem.

This is always do for ARM.
May be need increase stack size for Thread0 on ARM too?
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Julian Elischer

On 8/3/15 8:03 PM, Konstantin Belousov wrote:

On Mon, Aug 03, 2015 at 12:50:19PM +0100, Steven Hartland wrote:

For this change I don't want to get into fixing the thread0 stack size,
which can be done later, just
to provide a reasonable warning to the user that smaller values could
cause a panic.

Hmm, is it limited to the thread0 only ?  I.e., would only increasing
the initial thread stack size be enough to boot the kernel ?  The zfs
threads do request larger stack size, I know this.

Can somebody test the following patch in the i386 configuration which
does not boot ?


I think this is a reasonable thing to do. Thread0 (and proc0) are special.
I don't see why giving it a specially sized stack would be a problem.



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


svn commit: r286244 - head/usr.bin/vgrind

2015-08-03 Thread Baptiste Daroussin
Author: bapt
Date: Mon Aug  3 18:47:45 2015
New Revision: 286244
URL: https://svnweb.freebsd.org/changeset/base/286244

Log:
  Remove never used file
  
  Obtained from:DragonFlyBSD

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


Re: svn commit: r286142 - head/sys/net

2015-08-03 Thread Luiz Otavio O Souza
On Sat, Aug 1, 2015 at 6:02 PM, Guy Helmer wrote:
>
>> On Aug 1, 2015, at 4:50 AM, Ed Schouten wrote:
>>
>> Hi Luiz,
>>
>> 2015-07-31 23:43 GMT+02:00 Luiz Otavio O Souza :
>>> -   while (d->bd_hbuf_in_use)
>>> -   mtx_sleep(&d->bd_hbuf_in_use, &d->bd_lock,
>>> -   PRINET, "bd_hbuf", 0);
>>
>> Would it make sense to replace them by an assertion, instead of
>> omitting them entirely?
>>
>> KASSERT(!d->bd_hbuf_in_use, ("..."));
>
> I would appreciate the confidence that would provide.
>
> Guy

Yeah, I agree.  The KASSERT() makes the code even easier to understand.

Note that only one KASSERT() is needed here, because to other case is
specific to zero-copy buffers and the zero-copy buffers cannot be read
with read(2) and this way they never set the in use flag for the hold
buffer.

Committed in r286243.

Thanks!

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


Re: svn commit: r286234 - head/sys/boot/common

2015-08-03 Thread NGie Cooper
On Mon, Aug 3, 2015 at 10:54 AM, Andriy Gapon  wrote:
> On 03/08/2015 19:27, Edward Tomasz Napierala wrote:
>> Author: trasz
>> Date: Mon Aug  3 16:27:36 2015
>> New Revision: 286234
>> URL: https://svnweb.freebsd.org/changeset/base/286234
>>
>> Log:
>>   Fix a problem which made loader(8) load non-kld files twice.
>
> What was the problem?
> The change looks like defensive coding, but it's not clear why the loader 
> would
> attempt to load the same file more than once in the first place.
>
>>   For example, without this patch, the following three lines
>>   in /boot/loader.conf would result in /boot/root.img being preloaded
>>   twice, and two md(4) devices - md0 and md1 - being created.

Repro was something like this IIRC:

- Start module load.
- Hit a key to interrupt the boot so it drops into the loader prompt.
- Hit boot again.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286243 - head/sys/net

2015-08-03 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Aug  3 18:22:31 2015
New Revision: 286243
URL: https://svnweb.freebsd.org/changeset/base/286243

Log:
  Add a KASSERT() to make sure we wont rotate the buffers twice (rotate the
  buffers while the hold buffer is in use).
  
  Suggested by: ed, ghelmer
  MFC with: r286142

Modified:
  head/sys/net/bpf.c

Modified: head/sys/net/bpf.c
==
--- head/sys/net/bpf.c  Mon Aug  3 17:47:02 2015(r286242)
+++ head/sys/net/bpf.c  Mon Aug  3 18:22:31 2015(r286243)
@@ -2412,6 +2412,7 @@ catchpacket(struct bpf_d *d, u_char *pkt
++d->bd_dcount;
return;
}
+   KASSERT(!d->bd_hbuf_in_use, ("hold buffer is in use"));
ROTATE_BUFFERS(d);
do_wakeup = 1;
curlen = 0;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r286234 - head/sys/boot/common

2015-08-03 Thread Andriy Gapon
On 03/08/2015 19:27, Edward Tomasz Napierala wrote:
> Author: trasz
> Date: Mon Aug  3 16:27:36 2015
> New Revision: 286234
> URL: https://svnweb.freebsd.org/changeset/base/286234
> 
> Log:
>   Fix a problem which made loader(8) load non-kld files twice.

What was the problem?
The change looks like defensive coding, but it's not clear why the loader would
attempt to load the same file more than once in the first place.

>   For example, without this patch, the following three lines
>   in /boot/loader.conf would result in /boot/root.img being preloaded
>   twice, and two md(4) devices - md0 and md1 - being created.
>   
>   initmd_load="YES"
>   initmd_type="md_image"
>   initmd_name="/boot/root.img"
>   
>   Reviewed by:marcel@
>   MFC after:  1 month
>   Sponsored by:   The FreeBSD Foundation
>   Differential Revision:  https://reviews.freebsd.org/D3204
> 
> Modified:
>   head/sys/boot/common/module.c
> 
> Modified: head/sys/boot/common/module.c
> ==
> --- head/sys/boot/common/module.c Mon Aug  3 14:58:46 2015
> (r286233)
> +++ head/sys/boot/common/module.c Mon Aug  3 16:27:36 2015
> (r286234)
> @@ -102,6 +102,7 @@ COMMAND_SET(load, "load", "load a kernel
>  static int
>  command_load(int argc, char *argv[])
>  {
> +struct preloaded_file *fp;
>  char *typestr;
>  int  dofile, dokld, ch, error;
>  
> @@ -139,6 +140,13 @@ command_load(int argc, char *argv[])
>   command_errmsg = "invalid load type";
>   return(CMD_ERROR);
>   }
> +
> + fp = file_findfile(argv[1], typestr);
> + if (fp) {
> + sprintf(command_errbuf, "warning: file '%s' already loaded", 
> argv[1]);
> + return (CMD_ERROR);
> + }
> +
>   return (file_loadraw(argv[1], typestr, 1) ? CMD_OK : CMD_ERROR);
>  }
>  /*
> 


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


Re: svn commit: r286236 - head/share/man/man9

2015-08-03 Thread Benjamin Kaduk
On Mon, Aug 3, 2015 at 12:30 PM, Edward Tomasz Napierala 
wrote:

> Author: trasz
> Date: Mon Aug  3 16:30:47 2015
> New Revision: 286236
> URL: https://svnweb.freebsd.org/changeset/base/286236
>
> Log:
>   Document vgonel(9).
>

Er, isn't this a step backwards?

% static void vgonel(struct vnode *);

It is only accidental that anything outside vfs_subr.c can call vgonel().

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


svn commit: r286242 - head/sys/netinet

2015-08-03 Thread Mark Johnston
Author: markj
Date: Mon Aug  3 17:47:02 2015
New Revision: 286242
URL: https://svnweb.freebsd.org/changeset/base/286242

Log:
  The mbuf parameter to ip_output_pfil() must be an output parameter since
  pfil(9) hooks may modify the chain.
  
  X-MFC-With:   r286028

Modified:
  head/sys/netinet/ip_output.c

Modified: head/sys/netinet/ip_output.c
==
--- head/sys/netinet/ip_output.cMon Aug  3 17:39:36 2015
(r286241)
+++ head/sys/netinet/ip_output.cMon Aug  3 17:47:02 2015
(r286242)
@@ -107,18 +107,21 @@ extern int in_mcast_loop;
 extern struct protosw inetsw[];
 
 static inline int
-ip_output_pfil(struct mbuf *m, struct ifnet *ifp, struct inpcb *inp,
-   struct sockaddr_in *dst, int *fibnum, int *error)
+ip_output_pfil(struct mbuf **mp, struct ifnet *ifp, struct inpcb *inp,
+struct sockaddr_in *dst, int *fibnum, int *error)
 {
struct m_tag *fwd_tag = NULL;
+   struct mbuf *m;
struct in_addr odst;
struct ip *ip;
 
+   m = *mp;
ip = mtod(m, struct ip *);
 
/* Run through list of hooks for output packets. */
odst.s_addr = ip->ip_dst.s_addr;
-   *error = pfil_run_hooks(&V_inet_pfil_hook, &m, ifp, PFIL_OUT, inp);
+   *error = pfil_run_hooks(&V_inet_pfil_hook, mp, ifp, PFIL_OUT, inp);
+   m = *mp;
if ((*error) != 0 || m == NULL)
return 1; /* Finished */
 
@@ -552,7 +555,7 @@ sendit:
 
/* Jump over all PFIL processing if hooks are not active. */
if (PFIL_HOOKED(&V_inet_pfil_hook)) {
-   switch (ip_output_pfil(m, ifp, inp, dst, &fibnum, &error)) {
+   switch (ip_output_pfil(&m, ifp, inp, dst, &fibnum, &error)) {
case 1: /* Finished */
goto done;
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286241 - in head/sys/cddl/dev/fbt: . aarch64 arm powerpc x86

2015-08-03 Thread Mark Johnston
Author: markj
Date: Mon Aug  3 17:39:36 2015
New Revision: 286241
URL: https://svnweb.freebsd.org/changeset/base/286241

Log:
  Remove a couple of unused fields from the FBT probe struct.

Modified:
  head/sys/cddl/dev/fbt/aarch64/fbt_isa.c
  head/sys/cddl/dev/fbt/arm/fbt_isa.c
  head/sys/cddl/dev/fbt/fbt.h
  head/sys/cddl/dev/fbt/powerpc/fbt_isa.c
  head/sys/cddl/dev/fbt/x86/fbt_isa.c

Modified: head/sys/cddl/dev/fbt/aarch64/fbt_isa.c
==
--- head/sys/cddl/dev/fbt/aarch64/fbt_isa.c Mon Aug  3 17:02:36 2015
(r286240)
+++ head/sys/cddl/dev/fbt/aarch64/fbt_isa.c Mon Aug  3 17:39:36 2015
(r286241)
@@ -58,7 +58,6 @@ fbt_invop(uintptr_t addr, uintptr_t *sta
 
for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
-   fbt->fbtp_invop_cnt++;
cpu->cpu_dtrace_caller = addr;
 
dtrace_probe(fbt->fbtp_id, frame->tf_x[0],

Modified: head/sys/cddl/dev/fbt/arm/fbt_isa.c
==
--- head/sys/cddl/dev/fbt/arm/fbt_isa.c Mon Aug  3 17:02:36 2015
(r286240)
+++ head/sys/cddl/dev/fbt/arm/fbt_isa.c Mon Aug  3 17:39:36 2015
(r286241)
@@ -56,7 +56,6 @@ fbt_invop(uintptr_t addr, uintptr_t *sta
 
for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
-   fbt->fbtp_invop_cnt++;
cpu->cpu_dtrace_caller = addr;
 
/* TODO: Need 5th parameter from stack */

Modified: head/sys/cddl/dev/fbt/fbt.h
==
--- head/sys/cddl/dev/fbt/fbt.h Mon Aug  3 17:02:36 2015(r286240)
+++ head/sys/cddl/dev/fbt/fbt.h Mon Aug  3 17:39:36 2015(r286241)
@@ -45,8 +45,6 @@ typedef struct fbt_probe {
const char  *fbtp_name;
modctl_t*fbtp_ctl;
int fbtp_loadcnt;
-   int fbtp_primary;
-   int fbtp_invop_cnt;
int fbtp_symindx;
struct fbt_probe *fbtp_next;
 } fbt_probe_t;

Modified: head/sys/cddl/dev/fbt/powerpc/fbt_isa.c
==
--- head/sys/cddl/dev/fbt/powerpc/fbt_isa.c Mon Aug  3 17:02:36 2015
(r286240)
+++ head/sys/cddl/dev/fbt/powerpc/fbt_isa.c Mon Aug  3 17:39:36 2015
(r286241)
@@ -60,7 +60,6 @@ fbt_invop(uintptr_t addr, uintptr_t *sta
 
for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
-   fbt->fbtp_invop_cnt++;
if (fbt->fbtp_roffset == 0) {
cpu->cpu_dtrace_caller = addr;
 

Modified: head/sys/cddl/dev/fbt/x86/fbt_isa.c
==
--- head/sys/cddl/dev/fbt/x86/fbt_isa.c Mon Aug  3 17:02:36 2015
(r286240)
+++ head/sys/cddl/dev/fbt/x86/fbt_isa.c Mon Aug  3 17:39:36 2015
(r286241)
@@ -66,7 +66,6 @@ fbt_invop(uintptr_t addr, uintptr_t *sta
 
for (; fbt != NULL; fbt = fbt->fbtp_hashnext) {
if ((uintptr_t)fbt->fbtp_patchpoint == addr) {
-   fbt->fbtp_invop_cnt++;
if (fbt->fbtp_roffset == 0) {
int i = 0;
/*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r285051 - head/sys/netinet

2015-08-03 Thread Olivier Cochard-Labbé
On Mon, Aug 3, 2015 at 7:19 PM, Ermal Luçi  wrote:

>
>
>
> On Mon, Aug 3, 2015 at 5:18 PM, Olivier Cochard-Labbé 
> wrote:
>
>> On Mon, Aug 3, 2015 at 5:05 PM, Ermal Luçi  wrote:
>>
>>> Hello Olivier,
>>>
>>> its strange seeing so much contention on the arp tables on your PMC
>>> stats.
>>> Do you run ping(to prepopulate arp) or static arp to remove the noise
>>> from that interaction?
>>>
>>
>> ​I'm using static ARP on my devices (and static MAC assignement on
>> switches too) during my benchs.
>>
>
> Then you have to create static ARPs for all your pkt-gen ips :)
>

​No because the static ARP entry correspond to a next-hop router​. And all
destination IPs generated by pkt-gen are "behind" this next-hop.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r285051 - head/sys/netinet

2015-08-03 Thread Ermal Luçi
On Mon, Aug 3, 2015 at 5:18 PM, Olivier Cochard-Labbé 
wrote:

> On Mon, Aug 3, 2015 at 5:05 PM, Ermal Luçi  wrote:
>
>> Hello Olivier,
>>
>> its strange seeing so much contention on the arp tables on your PMC stats.
>> Do you run ping(to prepopulate arp) or static arp to remove the noise
>> from that interaction?
>>
>
> ​I'm using static ARP on my devices (and static MAC assignement on
> switches too) during my benchs.
>

Then you have to create static ARPs for all your pkt-gen ips :)

> ​
>
>
>>
>> Also do you run with flowtable active?
>>
>
> ​No I didn't have "options FLOWTABLE" in my kernel.
>
> Regards,
>
> Olivier
>
>


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

svn commit: r286238 - head/sys/dev/ixgbe

2015-08-03 Thread Sean Bruno
Author: sbruno
Date: Mon Aug  3 16:39:25 2015
New Revision: 286238
URL: https://svnweb.freebsd.org/changeset/base/286238

Log:
  A misplaced #endif in ixgbe_ioctl() causes interface MTU to become
  zero when INET and INET6 are undefined.
  
  PR:   162028
  Differential Revision:https://reviews.freebsd.org/D3187
  Submitted by: hoomanfaza...@gmail.com pluknet
  Reviewed by:  erj hiren gelbius
  MFC after:2 weeks

Modified:
  head/sys/dev/ixgbe/if_ix.c

Modified: head/sys/dev/ixgbe/if_ix.c
==
--- head/sys/dev/ixgbe/if_ix.c  Mon Aug  3 16:35:18 2015(r286237)
+++ head/sys/dev/ixgbe/if_ix.c  Mon Aug  3 16:39:25 2015(r286238)
@@ -828,9 +828,9 @@ ixgbe_ioctl(struct ifnet * ifp, u_long c
struct ifreq*ifr = (struct ifreq *) data;
 #if defined(INET) || defined(INET6)
struct ifaddr *ifa = (struct ifaddr *)data;
-   boolavoid_reset = FALSE;
 #endif
int error = 0;
+   boolavoid_reset = FALSE;
 
switch (command) {
 
@@ -843,7 +843,6 @@ ixgbe_ioctl(struct ifnet * ifp, u_long c
if (ifa->ifa_addr->sa_family == AF_INET6)
avoid_reset = TRUE;
 #endif
-#if defined(INET) || defined(INET6)
/*
** Calling init results in link renegotiation,
** so we avoid doing it when possible.
@@ -852,11 +851,12 @@ ixgbe_ioctl(struct ifnet * ifp, u_long c
ifp->if_flags |= IFF_UP;
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
ixgbe_init(adapter);
+#if defined(INET)
if (!(ifp->if_flags & IFF_NOARP))
arp_ifinit(ifp, ifa);
+#endif
} else
error = ether_ioctl(ifp, command, data);
-#endif
break;
case SIOCSIFMTU:
IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286237 - head/sys/geom

2015-08-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug  3 16:35:18 2015
New Revision: 286237
URL: https://svnweb.freebsd.org/changeset/base/286237

Log:
  Fix panic that would happen on forcibly unmounting devfs (note that
  as it is now, devfs ignores MNT_FORCE anyway, so it needs to be modified
  to trigger the panic) with consumers still opened.
  
  Note that this still results in a leak of r/w/e counters.  It seems
  to be harmless, though.  If anyone knows a better way to approach
  this - please tell.
  
  Discussed with:   kib@, mav@
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D3050

Modified:
  head/sys/geom/geom_dev.c

Modified: head/sys/geom/geom_dev.c
==
--- head/sys/geom/geom_dev.cMon Aug  3 16:30:47 2015(r286236)
+++ head/sys/geom/geom_dev.cMon Aug  3 16:35:18 2015(r286237)
@@ -401,6 +401,20 @@ g_dev_close(struct cdev *dev, int flags,
 #else
e = 0;
 #endif
+
+   /*
+* The vgonel(9) - caused by eg. forced unmount of devfs - calls
+* VOP_CLOSE(9) on devfs vnode without any FREAD or FWRITE flags,
+* which would result in zero deltas, which in turn would cause
+* panic in g_access(9).
+*
+* Note that we cannot zero the counters (ie. do "r = cp->acr"
+* etc) instead, because the consumer might be opened in another
+* devfs instance.
+*/
+   if (r + w + e == 0)
+   return (EINVAL);
+
sc = cp->private;
mtx_lock(&sc->sc_mtx);
sc->sc_open += r + w + e;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286236 - head/share/man/man9

2015-08-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug  3 16:30:47 2015
New Revision: 286236
URL: https://svnweb.freebsd.org/changeset/base/286236

Log:
  Document vgonel(9).
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/man/man9/Makefile
  head/share/man/man9/vgone.9

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileMon Aug  3 16:30:03 2015
(r286235)
+++ head/share/man/man9/MakefileMon Aug  3 16:30:47 2015
(r286236)
@@ -1739,6 +1739,7 @@ MLINKS+=vfs_getopt.9 vfs_copyopt.9 \
vfs_getopt.9 vfs_setopt.9 \
vfs_getopt.9 vfs_setopt_part.9 \
vfs_getopt.9 vfs_setopts.9
+MLINKS+=vgone.9 vgonel.9
 MLINKS+=vhold.9 vdrop.9 \
vhold.9 vdropl.9 \
vhold.9 vholdl.9

Modified: head/share/man/man9/vgone.9
==
--- head/share/man/man9/vgone.9 Mon Aug  3 16:30:03 2015(r286235)
+++ head/share/man/man9/vgone.9 Mon Aug  3 16:30:47 2015(r286236)
@@ -37,6 +37,7 @@
 .In sys/vnode.h
 .Ft void
 .Fn vgone "struct vnode *vp"
+.Fn vgonel "struct vnode *vp"
 .Sh DESCRIPTION
 The
 .Fn vgone
@@ -56,6 +57,11 @@ The
 .Fn vgone
 function takes an exclusively locked vnode, and returns with the vnode
 exclusively locked.
+The
+.Fn vgonel
+differs from
+.Fn vgone
+by requiring the vnode interlock to be held.
 .Sh SEE ALSO
 .Xr vnode 9
 .Sh AUTHORS
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286234 - head/sys/boot/common

2015-08-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug  3 16:27:36 2015
New Revision: 286234
URL: https://svnweb.freebsd.org/changeset/base/286234

Log:
  Fix a problem which made loader(8) load non-kld files twice.
  
  For example, without this patch, the following three lines
  in /boot/loader.conf would result in /boot/root.img being preloaded
  twice, and two md(4) devices - md0 and md1 - being created.
  
  initmd_load="YES"
  initmd_type="md_image"
  initmd_name="/boot/root.img"
  
  Reviewed by:  marcel@
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D3204

Modified:
  head/sys/boot/common/module.c

Modified: head/sys/boot/common/module.c
==
--- head/sys/boot/common/module.c   Mon Aug  3 14:58:46 2015
(r286233)
+++ head/sys/boot/common/module.c   Mon Aug  3 16:27:36 2015
(r286234)
@@ -102,6 +102,7 @@ COMMAND_SET(load, "load", "load a kernel
 static int
 command_load(int argc, char *argv[])
 {
+struct preloaded_file *fp;
 char   *typestr;
 intdofile, dokld, ch, error;
 
@@ -139,6 +140,13 @@ command_load(int argc, char *argv[])
command_errmsg = "invalid load type";
return(CMD_ERROR);
}
+
+   fp = file_findfile(argv[1], typestr);
+   if (fp) {
+   sprintf(command_errbuf, "warning: file '%s' already loaded", 
argv[1]);
+   return (CMD_ERROR);
+   }
+
return (file_loadraw(argv[1], typestr, 1) ? CMD_OK : CMD_ERROR);
 }
 /*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r285051 - head/sys/netinet

2015-08-03 Thread Olivier Cochard-Labbé
On Mon, Aug 3, 2015 at 5:05 PM, Ermal Luçi  wrote:

> Hello Olivier,
>
> its strange seeing so much contention on the arp tables on your PMC stats.
> Do you run ping(to prepopulate arp) or static arp to remove the noise from
> that interaction?
>

​I'm using static ARP on my devices (and static MAC assignement on switches
too) during my benchs.
​


>
> Also do you run with flowtable active?
>

​No I didn't have "options FLOWTABLE" in my kernel.

Regards,

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

Re: svn commit: r285051 - head/sys/netinet

2015-08-03 Thread Ermal Luçi
Hello Olivier,

its strange seeing so much contention on the arp tables on your PMC stats.
Do you run ping(to prepopulate arp) or static arp to remove the noise from
that interaction?

Also do you run with flowtable active?

On Mon, Aug 3, 2015 at 3:06 PM, Olivier Cochard-Labbé 
wrote:

> On Tue, Jul 28, 2015 at 2:42 PM, Gleb Smirnoff 
> wrote:
>
>>
>> Here is suggested patch. Ermal and Oliver, can you please test/benchmark
>> it?
>>
>
> ​Hi,
>
> this patch reduce performanece :-(
>
> Here are the results regarding forwarding:
>
> x r285046.pps.forwarding (IPSEC compiled but not used)
> + r285051.pps.forwarding (IPSEC compiled but not used)
> * r285051-glebius-patched.pps.forwarding (IPSEC compiled but not used)
>
> ++
> |xxx xx
> *   + +++|
> ||_M_A___|
> |_A_| |AM||
>
> ++
> N   Min   MaxMedian   AvgStddev
> x   5397733406951399300  401613.8 4324.9755
> +   5478095482079480869  480543.6 1666.0282
> Difference at 95.0% confidence
> 78929.8 +/- 4779.72
> 19.6532% +/- 1.19013%
> (Student's t, pooled s = 3277.27)
> *   5424720430745427014  427378.4 2351.7439
> Difference at 95.0% confidence
> 25764.6 +/- 5076.98
> 6.41527% +/- 1.26415%
> (Student's t, pooled s = 3481.1)
> ​
>
>
> PMC stats during forwarding bench:
> [root@netgate]/data# pmcannotate pmc.forwarding.out
> /data/debug/boot/kernel/kernel.symbols
> CONVERSION STATISTICS:
>  #samples/total   33880
> Profile trace for function: __rw_rlock() [6.29%]
> Profile trace for function: ip_forward() [4.68%]
> Profile trace for function: ip_output() [4.64%]
> Profile trace for function: binuptime() [4.05%]
> Profile trace for function: igb_mq_start_locked() [3.79%]
> Profile trace for function: igb_rxeof() [3.46%]
> Profile trace for function: tsc_get_timecount_low_lfence() [3.25%]
> Profile trace for function: ether_output() [3.03%]
> Profile trace for function: rtalloc1_fib() [2.77%]
> Profile trace for function: random_ivy_read() [2.64%]
> Profile trace for function: _rw_runlock_cookie() [2.64%]
> Profile trace for function: ether_nh_input() [2.63%]
> Profile trace for function: ip_input() [2.55%]
> Profile trace for function: key_allocsp_default() [2.39%]
> Profile trace for function: igb_mq_start() [2.39%]
> Profile trace for function: bzero() [2.08%]
> Profile trace for function: uma_zalloc_arg() [1.95%]
> Profile trace for function: memcpy() [1.84%]
> Profile trace for function: _mtx_lock_spin_cookie() [1.83%]
> Profile trace for function: bcopy() [1.76%]
> Profile trace for function: random_harvest_queue() [1.63%]
> Profile trace for function: __mtx_lock_sleep() [1.56%]
> Profile trace for function: uma_zfree_arg() [1.47%]
> Profile trace for function: arpresolve() [1.39%]
> Profile trace for function: in_cksumdata() [1.25%]
> Profile trace for function: bounce_bus_dmamap_load_buffer() [1.22%]
> Profile trace for function: bcmp() [1.13%]
> Profile trace for function: rtalloc_ign_fib() [1.11%]
> Profile trace for function: rn_match() [1.03%]
> Profile trace for function: netisr_dispatch_src() [1.03%]
> Profile trace for function: critical_exit() [1.02%]
> Profile trace for function: bus_dmamap_load_mbuf_sg() [0.87%]
> Profile trace for function: spinlock_exit() [0.79%]
> Profile trace for function: in_cksum_skip() [0.75%]
> Profile trace for function: ip_ipsec_output() [0.75%]
> Profile trace for function: acpi_cpu_c1() [0.74%]
> Profile trace for function: in_broadcast() [0.74%]
> Profile trace for function: spinlock_enter() [0.74%]
> Profile trace for function: igb_refresh_mbufs() [0.71%]
> Profile trace for function: in_lltable_lookup() [0.71%]
> Profile trace for function: ip_fastforward() [0.68%]
> Profile trace for function: m_adj() [0.65%]
> Profile trace for function: ether_demux() [0.65%]
> Profile trace for function: _key_freesp() [0.61%]
> Profile trace for function: lockstat_nsecs() [0.60%]
> Profile trace for function: m_freem() [0.58%]
> Profile trace for function: critical_enter() [0.56%]
> Profile trace for function: m_copydata() [0.55%]
> Profile trace for function: mb_free_ext() [0.54%]
> Profile trace for function: pmap_kextract() [0.50%]
>
> ​
>
> ​And about fastforwarding:
> ​
> x 285046.pps.fastforwarding (IPSEC compiled but not used)
> + 285051.pps.fastforwarding (IPSEC compiled but not used)
> * r285051-glebius-patched.pps.fastforwarding (IPSEC compiled but not used)
>
> ++
> |*
> +|
> |* * * *++ +x
> x+ xx x

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

2015-08-03 Thread Zbigniew Bodek
Author: zbb
Date: Mon Aug  3 14:58:46 2015
New Revision: 286233
URL: https://svnweb.freebsd.org/changeset/base/286233

Log:
  Add missing exception number to EL0 sync. abort on ARM64
  
  When doing a data abort from userland it is possible to get
  more than one data abort inside the same exception level.
  Add an appropriate exception number to allow nesting of
  data_abort handler for EL0.
  
  Reviewed by:   andrew
  Obtained from: Semihalf
  Sponsored by:  The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D3276

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

Modified: head/sys/arm64/arm64/trap.c
==
--- head/sys/arm64/arm64/trap.c Mon Aug  3 14:31:06 2015(r286232)
+++ head/sys/arm64/arm64/trap.c Mon Aug  3 14:58:46 2015(r286233)
@@ -329,6 +329,7 @@ do_el0_sync(struct trapframe *frame)
break;
case EXCP_INSN_ABORT_L:
case EXCP_DATA_ABORT_L:
+   case EXCP_DATA_ABORT:
data_abort(frame, esr, 1);
break;
default:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286232 - head/sbin/ipfw

2015-08-03 Thread Alexander V. Chernikov
Author: melifaro
Date: Mon Aug  3 14:31:06 2015
New Revision: 286232
URL: https://svnweb.freebsd.org/changeset/base/286232

Log:
  Fix ipfw range deletion.
  
  Spotted by:   ian,julian

Modified:
  head/sbin/ipfw/ipfw2.c

Modified: head/sbin/ipfw/ipfw2.c
==
--- head/sbin/ipfw/ipfw2.c  Mon Aug  3 13:49:46 2015(r286231)
+++ head/sbin/ipfw/ipfw2.c  Mon Aug  3 14:31:06 2015(r286232)
@@ -3033,9 +3033,10 @@ fill_flags_cmd(ipfw_insn *cmd, enum ipfw
 void
 ipfw_delete(char *av[])
 {
-   int i;
+   int i, j;
int exitval = EX_OK;
int do_set = 0;
+   char *sep;
ipfw_range_tlv rt;
 
av++;
@@ -3053,7 +3054,11 @@ ipfw_delete(char *av[])
 
/* Rule number */
while (*av && isdigit(**av)) {
-   i = atoi(*av); av++;
+   i = strtol(*av, &sep, 10);
+   j = i;
+   if (*sep== '-')
+   j = strtol(sep + 1, NULL, 10);
+   av++;
if (co.do_nat) {
exitval = do_cmd(IP_FW_NAT_DEL, &i, sizeof i);
if (exitval) {
@@ -3068,7 +3073,7 @@ ipfw_delete(char *av[])
rt.flags = IPFW_RCFLAG_SET;
} else {
rt.start_rule = i & 0x;
-   rt.end_rule = i & 0x;
+   rt.end_rule = j & 0x;
if (rt.start_rule == 0 && rt.end_rule == 0)
rt.flags |= IPFW_RCFLAG_ALL;
else
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286231 - in head/sys: amd64/conf i386/conf

2015-08-03 Thread Warner Losh
Author: imp
Date: Mon Aug  3 13:49:46 2015
New Revision: 286231
URL: https://svnweb.freebsd.org/changeset/base/286231

Log:
  Add pmspvc device back to GENERIC. The issues with the device playing
  grabby hands with other driver's devices has been solved.
  
  MFC After: 3 weeks

Modified:
  head/sys/amd64/conf/GENERIC
  head/sys/i386/conf/GENERIC

Modified: head/sys/amd64/conf/GENERIC
==
--- head/sys/amd64/conf/GENERIC Mon Aug  3 13:42:52 2015(r286230)
+++ head/sys/amd64/conf/GENERIC Mon Aug  3 13:49:46 2015(r286231)
@@ -170,8 +170,7 @@ device  ida # Compaq Smart 
RAID
 device mfi # LSI MegaRAID SAS
 device mlx # Mylex DAC960 family
 device mrsas   # LSI/Avago MegaRAID SAS/SATA, 6Gb/s 
and 12Gb/s
-#XXX PCI ID conflicts with ahd(4) and mvs(4)
-#devicepmspcv  # PMC-Sierra SAS/SATA 
Controller driver
+device pmspcv  # PMC-Sierra SAS/SATA Controller driver
 #XXX pointer/int warnings
 #devicepst # Promise Supertrak SX6000
 device twe # 3ware ATA RAID

Modified: head/sys/i386/conf/GENERIC
==
--- head/sys/i386/conf/GENERIC  Mon Aug  3 13:42:52 2015(r286230)
+++ head/sys/i386/conf/GENERIC  Mon Aug  3 13:49:46 2015(r286231)
@@ -175,8 +175,7 @@ device  ida # Compaq Smart 
RAID
 device mfi # LSI MegaRAID SAS
 device mlx # Mylex DAC960 family
 device mrsas   # LSI/Avago MegaRAID SAS/SATA, 6Gb/s 
and 12Gb/s
-#XXX PCI ID conflicts with ahd(4) and mvs(4)
-#devicepmspcv  # PMC-Sierra SAS/SATA 
Controller driver
+device pmspcv  # PMC-Sierra SAS/SATA Controller driver
 device pst # Promise Supertrak SX6000
 device twe # 3ware ATA RAID
 
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Steven Hartland



On 03/08/2015 13:03, Konstantin Belousov wrote:

On Mon, Aug 03, 2015 at 12:50:19PM +0100, Steven Hartland wrote:

For this change I don't want to get into fixing the thread0 stack size,
which can be done later, just
to provide a reasonable warning to the user that smaller values could
cause a panic.

Hmm, is it limited to the thread0 only ?  I.e., would only increasing
the initial thread stack size be enough to boot the kernel ?  The zfs
threads do request larger stack size, I know this.

Can somebody test the following patch in the i386 configuration which
does not boot ?

diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c
index 7a00740..6a00d23 100644
--- a/sys/i386/i386/genassym.c
+++ b/sys/i386/i386/genassym.c
@@ -103,6 +103,7 @@ ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
  ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
  /* ASSYM(UPAGES, UPAGES);*/
  ASSYM(KSTACK_PAGES, KSTACK_PAGES);
+ASSYM(TD0_KSTACK_PAGES, TD0_KSTACK_PAGES);
  ASSYM(PAGE_SIZE, PAGE_SIZE);
  ASSYM(NPTEPG, NPTEPG);
  ASSYM(NPDEPG, NPDEPG);
diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s
index 5bf7944..4d8e22f 100644
--- a/sys/i386/i386/locore.s
+++ b/sys/i386/i386/locore.s
@@ -731,7 +731,7 @@ no_kernend:
movl%esi,R(IdlePTD)
  
  /* Allocate KSTACK */

-   ALLOCPAGES(KSTACK_PAGES)
+   ALLOCPAGES(TD0_KSTACK_PAGES)
movl%esi,R(p0kpa)
addl$KERNBASE, %esi
movl%esi, R(proc0kstack)
@@ -800,7 +800,7 @@ no_kernend:
  
  /* Map proc0's KSTACK in the physical way ... */

movlR(p0kpa), %eax
-   movl$(KSTACK_PAGES), %ecx
+   movl$(TD0_KSTACK_PAGES), %ecx
fillkptphys($PG_RW)
  
  /* Map ISA hole */

diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 2be5dbc..76790f0 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -2445,7 +2445,7 @@ init386(first)
  #endif
  
  	thread0.td_kstack = proc0kstack;

-   thread0.td_kstack_pages = KSTACK_PAGES;
+   thread0.td_kstack_pages = TD0_KSTACK_PAGES;
  
  	/*

 * This may be done better later if it gets more high level
diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h
index b3fd85f..bc79c20 100644
--- a/sys/i386/include/param.h
+++ b/sys/i386/include/param.h
@@ -114,6 +114,11 @@
  #define KSTACK_PAGES 2/* Includes pcb! */
  #endif
  #define KSTACK_GUARD_PAGES 1  /* pages of kstack guard; 0 disables */
+#if KSTACK_PAGES < 3
+#defineTD0_KSTACK_PAGES 4
+#else
+#defineTD0_KSTACK_PAGES KSTACK_PAGES
+#endif
  
  /*

   * Ceiling on amount of swblock kva space, can be changed via
I don't have a reproduction box here I'm afraid, might be an idea to 
post the patch to the following bug reports to see if one of the 
reporters can test:

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201859
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=189355

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


svn commit: r286230 - head/sys/amd64/cloudabi64

2015-08-03 Thread Ed Schouten
Author: ed
Date: Mon Aug  3 13:42:52 2015
New Revision: 286230
URL: https://svnweb.freebsd.org/changeset/base/286230

Log:
  Let CloudABI use the SV_CAPSICUM flag.
  
  CloudABI processes will now start up in capabilities mode.
  
  Reviewed by:  kib

Modified:
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Mon Aug  3 13:41:47 
2015(r286229)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Mon Aug  3 13:42:52 
2015(r286230)
@@ -224,7 +224,7 @@ static struct sysentvec cloudabi64_elf_s
.sv_usrstack= USRSTACK,
.sv_stackprot   = VM_PROT_READ | VM_PROT_WRITE,
.sv_copyout_strings = cloudabi64_copyout_strings,
-   .sv_flags   = SV_ABI_CLOUDABI,
+   .sv_flags   = SV_ABI_CLOUDABI | SV_CAPSICUM,
.sv_set_syscall_retval  = cloudabi64_set_syscall_retval,
.sv_fetch_syscall_args  = cloudabi64_fetch_syscall_args,
.sv_syscallnames= cloudabi64_syscallnames,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286229 - in head/sys: kern sys

2015-08-03 Thread Ed Schouten
Author: ed
Date: Mon Aug  3 13:41:47 2015
New Revision: 286229
URL: https://svnweb.freebsd.org/changeset/base/286229

Log:
  Add sysent flag to switch to capabilities mode on startup.
  
  CloudABI processes should run in capabilities mode automatically. There
  is no need to switch manually (e.g., by calling cap_enter()). Add a
  flag, SV_CAPSICUM, that can be used to call into cap_enter() during
  execve().
  
  Reviewed by:  kib

Modified:
  head/sys/kern/kern_exec.c
  head/sys/sys/sysent.h

Modified: head/sys/kern/kern_exec.c
==
--- head/sys/kern/kern_exec.c   Mon Aug  3 12:14:42 2015(r286228)
+++ head/sys/kern/kern_exec.c   Mon Aug  3 13:41:47 2015(r286229)
@@ -562,6 +562,10 @@ interpret:
goto exec_fail_dealloc;
}
 
+   /* ABI enforces the use of Capsicum. Switch into capabilities mode. */
+   if (SV_PROC_FLAG(p, SV_CAPSICUM))
+   sys_cap_enter(td, NULL);
+
/*
 * Copy out strings (args and env) and initialize stack base
 */

Modified: head/sys/sys/sysent.h
==
--- head/sys/sys/sysent.h   Mon Aug  3 12:14:42 2015(r286228)
+++ head/sys/sys/sysent.h   Mon Aug  3 13:41:47 2015(r286229)
@@ -139,11 +139,12 @@ struct sysentvec {
void(*sv_thread_detach)(struct thread *);
 };
 
-#defineSV_ILP320x000100
-#defineSV_LP64 0x000200
-#defineSV_IA32 0x004000
-#defineSV_AOUT 0x008000
-#defineSV_SHP  0x01
+#defineSV_ILP320x000100/* 32-bit executable. */
+#defineSV_LP64 0x000200/* 64-bit executable. */
+#defineSV_IA32 0x004000/* Intel 32-bit executable. */
+#defineSV_AOUT 0x008000/* a.out executable. */
+#defineSV_SHP  0x01/* Shared page. */
+#defineSV_CAPSICUM 0x02/* Force cap_enter() on 
startup. */
 
 #defineSV_ABI_MASK 0xff
 #defineSV_PROC_FLAG(p, x)  ((p)->p_sysent->sv_flags & (x))
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Fabian Keil
Andriy Gapon  wrote:

> On 30/07/2015 10:24, K. Macy wrote:
> > Just FYI this change introduces a deadlock with with the
> > spa_namespace_lock. Mount will be holding this lock while trying to
> > acquire the spa_namespace_lock. zfskern on the other hand holds the
> > spa_namespace_lock when calling zfs_freebsd_access  which in turn
> > tries to acquire the teardown lock.
> 
> I missed the fact that zpool.cache file is being written with 
> spa_namespace_lock
> held.
> I'll try to either resolve the problem in the next day or I will revert the 
> change.

BTW, there's another (unrelated) spa_namespace_lock issue in 
spa_import_rootpool():
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198563

Fabian


pgpBKvyvuG5Pi.pgp
Description: OpenPGP digital signature


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

2015-08-03 Thread Andriy Gapon
On 30/07/2015 10:24, K. Macy wrote:
> Just FYI this change introduces a deadlock with with the
> spa_namespace_lock. Mount will be holding this lock while trying to
> acquire the spa_namespace_lock. zfskern on the other hand holds the
> spa_namespace_lock when calling zfs_freebsd_access  which in turn
> tries to acquire the teardown lock.

I missed the fact that zpool.cache file is being written with spa_namespace_lock
held.
I'll try to either resolve the problem in the next day or I will revert the 
change.

> I think this makes a pretty strong case for the need to educate
> WITNESS about rrm locks.
> 
> Cheers.
> 
> -K
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Thu, Jul 2, 2015 at 1:32 AM, Andriy Gapon  wrote:
>> Author: avg
>> Date: Thu Jul  2 08:32:02 2015
>> New Revision: 285021
>> URL: https://svnweb.freebsd.org/changeset/base/285021
>>
>> Log:
>>   zfs_mount(MS_REMOUNT): protect zfs_(un)register_callbacks calls
>>
>>   We now take z_teardown_lock as a writer to ensure that there is no I/O
>>   while the filesystem state is in a flux.  Also, zfs_suspend_fs() ->
>>   zfsvfs_teardown() call zfs_unregister_callbacks() and zfs_resume_fs() ->
>>   zfsvfs_setup() call zfs_unregister_callbacks().  Previously there was no
>>   synchronization between those calls and the calls in the re-mounting
>>   case.  That could lead to concurrent execution and a crash.
>>
>>   PR:   180060
>>   Differential Revision:https://reviews.freebsd.org/D2865
>>   Suggested by: mahrens
>>   Reviewed by:  delphij, pho, mahrens, will
>>   MFC after:13 days
>>   Sponsored by: ClusterHQ
>>
>> Modified:
>>   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
>>
>> Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
>> ==
>> --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cThu 
>> Jul  2 08:25:45 2015(r285020)
>> +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cThu 
>> Jul  2 08:32:02 2015(r285021)
>> @@ -1717,9 +1717,19 @@ zfs_mount(vfs_t *vfsp)
>>  * according to those options set in the current VFS options.
>>  */
>> if (vfsp->vfs_flag & MS_REMOUNT) {
>> -   /* refresh mount options */
>> -   zfs_unregister_callbacks(vfsp->vfs_data);
>> +   zfsvfs_t *zfsvfs = vfsp->vfs_data;
>> +
>> +   /*
>> +* Refresh mount options with z_teardown_lock blocking I/O 
>> while
>> +* the filesystem is in an inconsistent state.
>> +* The lock also serializes this code with filesystem
>> +* manipulations between entry to zfs_suspend_fs() and return
>> +* from zfs_resume_fs().
>> +*/
>> +   rrm_enter(&zfsvfs->z_teardown_lock, RW_WRITER, FTAG);
>> +   zfs_unregister_callbacks(zfsvfs);
>> error = zfs_register_callbacks(vfsp);
>> +   rrm_exit(&zfsvfs->z_teardown_lock, FTAG);
>> goto out;
>> }
>>
>> ___
>> svn-src-head@freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/svn-src-head
>> To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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


Re: svn commit: r284297 - in head: cddl/contrib/opensolaris/cmd/lockstat sys/kern sys/sys

2015-08-03 Thread Andriy Gapon
On 26/07/2015 23:27, Scott Long wrote:
> 
>> On Jun 12, 2015, at 4:01 AM, Andriy Gapon  wrote:
>>
>> Author: avg
>> Date: Fri Jun 12 10:01:24 2015
>> New Revision: 284297
>> URL: https://svnweb.freebsd.org/changeset/base/284297
>>
>> Log:
>>  several lockstat improvements
>>
>>  0. For spin events report time spent spinning, not a loop count.
>>  While loop count is much easier and cheaper to obtain it is hard
>>  to reason about the reported numbers, espcially for adaptive locks
>>  where both spinning and sleeping can happen.
>>  So, it's better to compare apples and apples.
>>
> 
> This causes spinning to be exceptionally more expensive just by having
> KDTRACE_HOOKS enabled, whether or not Dtrace is actually in use.  It
> makes it undesirable to deploy with Dtrace by default since it impacts
> performance.  Is there a way to make the expensive collection optional,
> or only enable when dtrace is using the lockstat module?  Also have you
> seen the other recent performance complaint related to this commit?

Sorry for the trouble.  Commit https://svnweb.freebsd.org/changeset/base/285704
should have fixed the problem.  Could you please check if that's so?
Thanks.

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


Re: svn commit: r285051 - head/sys/netinet

2015-08-03 Thread Olivier Cochard-Labbé
On Tue, Jul 28, 2015 at 2:42 PM, Gleb Smirnoff  wrote:

>
> Here is suggested patch. Ermal and Oliver, can you please test/benchmark
> it?
>

​Hi,

this patch reduce performanece :-(

Here are the results regarding forwarding:

x r285046.pps.forwarding (IPSEC compiled but not used)
+ r285051.pps.forwarding (IPSEC compiled but not used)
* r285051-glebius-patched.pps.forwarding (IPSEC compiled but not used)
++
|xxx xx *
+ +++|
||_M_A___|
|_A_| |AM||
++
N   Min   MaxMedian   AvgStddev
x   5397733406951399300  401613.8 4324.9755
+   5478095482079480869  480543.6 1666.0282
Difference at 95.0% confidence
78929.8 +/- 4779.72
19.6532% +/- 1.19013%
(Student's t, pooled s = 3277.27)
*   5424720430745427014  427378.4 2351.7439
Difference at 95.0% confidence
25764.6 +/- 5076.98
6.41527% +/- 1.26415%
(Student's t, pooled s = 3481.1)
​


PMC stats during forwarding bench:
[root@netgate]/data# pmcannotate pmc.forwarding.out
/data/debug/boot/kernel/kernel.symbols
CONVERSION STATISTICS:
 #samples/total   33880
Profile trace for function: __rw_rlock() [6.29%]
Profile trace for function: ip_forward() [4.68%]
Profile trace for function: ip_output() [4.64%]
Profile trace for function: binuptime() [4.05%]
Profile trace for function: igb_mq_start_locked() [3.79%]
Profile trace for function: igb_rxeof() [3.46%]
Profile trace for function: tsc_get_timecount_low_lfence() [3.25%]
Profile trace for function: ether_output() [3.03%]
Profile trace for function: rtalloc1_fib() [2.77%]
Profile trace for function: random_ivy_read() [2.64%]
Profile trace for function: _rw_runlock_cookie() [2.64%]
Profile trace for function: ether_nh_input() [2.63%]
Profile trace for function: ip_input() [2.55%]
Profile trace for function: key_allocsp_default() [2.39%]
Profile trace for function: igb_mq_start() [2.39%]
Profile trace for function: bzero() [2.08%]
Profile trace for function: uma_zalloc_arg() [1.95%]
Profile trace for function: memcpy() [1.84%]
Profile trace for function: _mtx_lock_spin_cookie() [1.83%]
Profile trace for function: bcopy() [1.76%]
Profile trace for function: random_harvest_queue() [1.63%]
Profile trace for function: __mtx_lock_sleep() [1.56%]
Profile trace for function: uma_zfree_arg() [1.47%]
Profile trace for function: arpresolve() [1.39%]
Profile trace for function: in_cksumdata() [1.25%]
Profile trace for function: bounce_bus_dmamap_load_buffer() [1.22%]
Profile trace for function: bcmp() [1.13%]
Profile trace for function: rtalloc_ign_fib() [1.11%]
Profile trace for function: rn_match() [1.03%]
Profile trace for function: netisr_dispatch_src() [1.03%]
Profile trace for function: critical_exit() [1.02%]
Profile trace for function: bus_dmamap_load_mbuf_sg() [0.87%]
Profile trace for function: spinlock_exit() [0.79%]
Profile trace for function: in_cksum_skip() [0.75%]
Profile trace for function: ip_ipsec_output() [0.75%]
Profile trace for function: acpi_cpu_c1() [0.74%]
Profile trace for function: in_broadcast() [0.74%]
Profile trace for function: spinlock_enter() [0.74%]
Profile trace for function: igb_refresh_mbufs() [0.71%]
Profile trace for function: in_lltable_lookup() [0.71%]
Profile trace for function: ip_fastforward() [0.68%]
Profile trace for function: m_adj() [0.65%]
Profile trace for function: ether_demux() [0.65%]
Profile trace for function: _key_freesp() [0.61%]
Profile trace for function: lockstat_nsecs() [0.60%]
Profile trace for function: m_freem() [0.58%]
Profile trace for function: critical_enter() [0.56%]
Profile trace for function: m_copydata() [0.55%]
Profile trace for function: mb_free_ext() [0.54%]
Profile trace for function: pmap_kextract() [0.50%]

​

​And about fastforwarding:
​
x 285046.pps.fastforwarding (IPSEC compiled but not used)
+ 285051.pps.fastforwarding (IPSEC compiled but not used)
* r285051-glebius-patched.pps.fastforwarding (IPSEC compiled but not used)
++
|*
+|
|* * * *++ +x
x+ xx x|
||AM__|
|_MA__|__AM_| |
++
N   Min   MaxMedian   AvgStddev
x   5742683754709750940  749015.6 4944.9059
+   5736459747593738197  740112.4 4511.1611
Difference at 95.0% confidence
-8903.2 +/- 6902.82
-1.18865% +/- 0.921585%
(Student's t, pooled s = 4733)
*   5638356652855646668645263   

svn commit: r286228 - in head/sys: amd64/amd64 amd64/include i386/i386 i386/include x86/x86

2015-08-03 Thread Konstantin Belousov
Author: kib
Date: Mon Aug  3 12:14:42 2015
New Revision: 286228
URL: https://svnweb.freebsd.org/changeset/base/286228

Log:
  Clear the IA32_MISC_ENABLE MSR bit, which limits the max CPUID
  reported, on APs.  We already did this on BSP.
  
  Otherwise, the userspace software which depends on the features
  reported by the high CPUID levels is misbehaving.  In particular, AVX
  detection is non-functional, depending on which CPU thread happens to
  execute when doing CPUID.  Another victim is the libthr signal
  handlers interposer, which needs to save full FPU extended state.
  
  Reported and tested by:   Andre Meiser 
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/amd64/amd64/mp_machdep.c
  head/sys/amd64/include/md_var.h
  head/sys/i386/i386/mp_machdep.c
  head/sys/i386/include/md_var.h
  head/sys/x86/x86/identcpu.c

Modified: head/sys/amd64/amd64/mp_machdep.c
==
--- head/sys/amd64/amd64/mp_machdep.c   Mon Aug  3 12:13:54 2015
(r286227)
+++ head/sys/amd64/amd64/mp_machdep.c   Mon Aug  3 12:14:42 2015
(r286228)
@@ -252,6 +252,7 @@ init_secondary(void)
wrmsr(MSR_FSBASE, 0);   /* User value */
wrmsr(MSR_GSBASE, (u_int64_t)pc);
wrmsr(MSR_KGSBASE, (u_int64_t)pc);  /* XXX User value while we're 
in the kernel */
+   intel_fix_cpuid();
 
lidt(&r_idt);
 

Modified: head/sys/amd64/include/md_var.h
==
--- head/sys/amd64/include/md_var.h Mon Aug  3 12:13:54 2015
(r286227)
+++ head/sys/amd64/include/md_var.h Mon Aug  3 12:14:42 2015
(r286228)
@@ -114,6 +114,7 @@ voiddump_drop_page(vm_paddr_t);
 void   identify_cpu(void);
 void   initializecpu(void);
 void   initializecpucache(void);
+bool   intel_fix_cpuid(void);
 void   fillw(int /*u_short*/ pat, void *base, size_t cnt);
 void   fpstate_drop(struct thread *td);
 intis_physical_memory(vm_paddr_t addr);

Modified: head/sys/i386/i386/mp_machdep.c
==
--- head/sys/i386/i386/mp_machdep.c Mon Aug  3 12:13:54 2015
(r286227)
+++ head/sys/i386/i386/mp_machdep.c Mon Aug  3 12:14:42 2015
(r286228)
@@ -247,6 +247,8 @@ init_secondary(void)
pc->pc_prvspace = pc;
pc->pc_curthread = 0;
 
+   intel_fix_cpuid();
+
gdt_segs[GPRIV_SEL].ssd_base = (int) pc;
gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pc_common_tss;
 

Modified: head/sys/i386/include/md_var.h
==
--- head/sys/i386/include/md_var.h  Mon Aug  3 12:13:54 2015
(r286227)
+++ head/sys/i386/include/md_var.h  Mon Aug  3 12:14:42 2015
(r286228)
@@ -118,6 +118,7 @@ voidfillw(int /*u_short*/ pat, void *ba
 void   fill_based_sd(struct segment_descriptor *sdp, uint32_t base);
 void   initializecpu(void);
 void   initializecpucache(void);
+bool   intel_fix_cpuid(void);
 void   i686_pagezero(void *addr);
 void   sse2_pagezero(void *addr);
 void   init_AMD_Elan_sc520(void);

Modified: head/sys/x86/x86/identcpu.c
==
--- head/sys/x86/x86/identcpu.c Mon Aug  3 12:13:54 2015(r286227)
+++ head/sys/x86/x86/identcpu.c Mon Aug  3 12:14:42 2015(r286228)
@@ -1295,6 +1295,33 @@ identify_hypervisor(void)
 }
 
 /*
+ * Clear "Limit CPUID Maxval" bit and return true if the caller should
+ * get the largest standard CPUID function number again if it is set
+ * from BIOS.  It is necessary for probing correct CPU topology later
+ * and for the correct operation of the AVX-aware userspace.
+ */
+bool
+intel_fix_cpuid(void)
+{
+   uint64_t msr;
+
+   if (cpu_vendor_id != CPU_VENDOR_INTEL)
+   return (false);
+   if ((CPUID_TO_FAMILY(cpu_id) == 0xf &&
+   CPUID_TO_MODEL(cpu_id) >= 0x3) ||
+   (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+   CPUID_TO_MODEL(cpu_id) >= 0xe)) {
+   msr = rdmsr(MSR_IA32_MISC_ENABLE);
+   if ((msr & IA32_MISC_EN_LIMCPUID) != 0) {
+   msr &= ~IA32_MISC_EN_LIMCPUID;
+   wrmsr(MSR_IA32_MISC_ENABLE, msr);
+   return (true);
+   }
+   }
+   return (false);
+}
+
+/*
  * Final stage of CPU identification.
  */
 #ifdef __i386__
@@ -1328,22 +1355,9 @@ identify_cpu(void)
identify_hypervisor();
cpu_vendor_id = find_cpu_vendor_id();
 
-   /*
-* Clear "Limit CPUID Maxval" bit and get the largest standard CPUID
-* function number again if it is set from BIOS.  It is necessary
-* for probing correct CPU topology later.
-* XXX This is only done on the BSP package.
-*/
-   if (cpu_vendor_id == CPU_VENDOR_INTEL && cpu_high > 0 

svn commit: r286227 - in head/sys: dev/cxgb/ulp/tom dev/cxgbe/tom netinet netinet6

2015-08-03 Thread Julien Charbon
Author: jch
Date: Mon Aug  3 12:13:54 2015
New Revision: 286227
URL: https://svnweb.freebsd.org/changeset/base/286227

Log:
  Decompose TCP INP_INFO lock to increase short-lived TCP connections 
scalability:
  
  - The existing TCP INP_INFO lock continues to protect the global inpcb list
stability during full list traversal (e.g. tcp_pcblist()).
  
  - A new INP_LIST lock protects inpcb list actual modifications (inp allocation
and free) and inpcb global counters.
  
  It allows to use TCP INP_INFO_RLOCK lock in critical paths (e.g. tcp_input())
  and INP_INFO_WLOCK only in occasional operations that walk all connections.
  
  PR:   183659
  Differential Revision:https://reviews.freebsd.org/D2599
  Reviewed by:  jhb, adrian
  Tested by:adrian, nitroboost-gmail.com
  Sponsored by: Verisign, Inc.

Modified:
  head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
  head/sys/dev/cxgb/ulp/tom/cxgb_listen.c
  head/sys/dev/cxgbe/tom/t4_connect.c
  head/sys/dev/cxgbe/tom/t4_cpl_io.c
  head/sys/dev/cxgbe/tom/t4_listen.c
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_pcb.h
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/tcp_timewait.c
  head/sys/netinet/tcp_usrreq.c
  head/sys/netinet/toecore.c
  head/sys/netinet6/in6_pcb.c

Modified: head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
==
--- head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Mon Aug  3 11:57:11 2015
(r286226)
+++ head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c Mon Aug  3 12:13:54 2015
(r286227)
@@ -639,7 +639,7 @@ t3_send_fin(struct toedev *tod, struct t
unsigned int tid = toep->tp_tid;
 #endif
 
-   INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
+   INP_INFO_RLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
 
CTR4(KTR_CXGB, "%s: tid %d, toep %p, flags %x", __func__, tid, toep,
@@ -925,12 +925,12 @@ do_act_open_rpl(struct sge_qset *qs, str
 
rc = act_open_rpl_status_to_errno(s);
if (rc != EAGAIN)
-   INP_INFO_WLOCK(&V_tcbinfo);
+   INP_INFO_RLOCK(&V_tcbinfo);
INP_WLOCK(inp);
toe_connect_failed(tod, inp, rc);
toepcb_release(toep);   /* unlocks inp */
if (rc != EAGAIN)
-   INP_INFO_WUNLOCK(&V_tcbinfo);
+   INP_INFO_RUNLOCK(&V_tcbinfo);
 
m_freem(m);
return (0);
@@ -1061,7 +1061,7 @@ send_reset(struct toepcb *toep)
struct adapter *sc = tod->tod_softc;
struct mbuf *m;
 
-   INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
+   INP_INFO_RLOCK_ASSERT(&V_tcbinfo);
INP_WLOCK_ASSERT(inp);
 
CTR4(KTR_CXGB, "%s: tid %d, toep %p (%x)", __func__, tid, toep,
@@ -1172,12 +1172,12 @@ do_rx_data(struct sge_qset *qs, struct r
SOCKBUF_UNLOCK(so_rcv);
INP_WUNLOCK(inp);
 
-   INP_INFO_WLOCK(&V_tcbinfo);
+   INP_INFO_RLOCK(&V_tcbinfo);
INP_WLOCK(inp);
tp = tcp_drop(tp, ECONNRESET);
if (tp)
INP_WUNLOCK(inp);
-   INP_INFO_WUNLOCK(&V_tcbinfo);
+   INP_INFO_RUNLOCK(&V_tcbinfo);
 
m_freem(m);
return (0);
@@ -1222,7 +1222,7 @@ do_peer_close(struct sge_qset *qs, struc
struct tcpcb *tp;
struct socket *so;
 
-   INP_INFO_WLOCK(&V_tcbinfo);
+   INP_INFO_RLOCK(&V_tcbinfo);
INP_WLOCK(inp);
tp = intotcpcb(inp);
 
@@ -1250,7 +1250,7 @@ do_peer_close(struct sge_qset *qs, struc
case TCPS_FIN_WAIT_2:
tcp_twstart(tp);
INP_UNLOCK_ASSERT(inp); /* safe, we have a ref on the  inp */
-   INP_INFO_WUNLOCK(&V_tcbinfo);
+   INP_INFO_RUNLOCK(&V_tcbinfo);
 
INP_WLOCK(inp);
toepcb_release(toep);   /* no more CPLs expected */
@@ -1264,7 +1264,7 @@ do_peer_close(struct sge_qset *qs, struc
 
 done:
INP_WUNLOCK(inp);
-   INP_INFO_WUNLOCK(&V_tcbinfo);
+   INP_INFO_RUNLOCK(&V_tcbinfo);
 
m_freem(m);
return (0);
@@ -1285,7 +1285,7 @@ do_close_con_rpl(struct sge_qset *qs, st
struct tcpcb *tp;
struct socket *so;
 
-   INP_INFO_WLOCK(&V_tcbinfo);
+   INP_INFO_RLOCK(&V_tcbinfo);
INP_WLOCK(inp);
tp = intotcpcb(inp);
 
@@ -1303,7 +1303,7 @@ do_close_con_rpl(struct sge_qset *qs, st
tcp_twstart(tp);
 release:
INP_UNLOCK_ASSERT(inp); /* safe, we have a ref on the  inp */
-   INP_INFO_WUNLOCK(&V_tcbinfo);
+   INP_INFO_RUNLOCK(&V_tcbinfo);
 
INP_WLOCK(inp);
toepcb_release(toep);   /* no more CPLs expected */
@@ -1328,7 +1328,7 @@ release:
 
 done:
INP_WUNLOCK(inp);
-   INP_INFO_WUNLOCK(&V_tcbinfo);
+   INP_INFO_RUNLOCK(&V_tcbinfo);
 
m_freem(m);
retu

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

2015-08-03 Thread Konstantin Belousov
On Mon, Aug 03, 2015 at 12:50:19PM +0100, Steven Hartland wrote:
> For this change I don't want to get into fixing the thread0 stack size, 
> which can be done later, just
> to provide a reasonable warning to the user that smaller values could 
> cause a panic.

Hmm, is it limited to the thread0 only ?  I.e., would only increasing
the initial thread stack size be enough to boot the kernel ?  The zfs
threads do request larger stack size, I know this.

Can somebody test the following patch in the i386 configuration which
does not boot ?

diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c
index 7a00740..6a00d23 100644
--- a/sys/i386/i386/genassym.c
+++ b/sys/i386/i386/genassym.c
@@ -103,6 +103,7 @@ ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
 ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
 /* ASSYM(UPAGES, UPAGES);*/
 ASSYM(KSTACK_PAGES, KSTACK_PAGES);
+ASSYM(TD0_KSTACK_PAGES, TD0_KSTACK_PAGES);
 ASSYM(PAGE_SIZE, PAGE_SIZE);
 ASSYM(NPTEPG, NPTEPG);
 ASSYM(NPDEPG, NPDEPG);
diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s
index 5bf7944..4d8e22f 100644
--- a/sys/i386/i386/locore.s
+++ b/sys/i386/i386/locore.s
@@ -731,7 +731,7 @@ no_kernend:
movl%esi,R(IdlePTD)
 
 /* Allocate KSTACK */
-   ALLOCPAGES(KSTACK_PAGES)
+   ALLOCPAGES(TD0_KSTACK_PAGES)
movl%esi,R(p0kpa)
addl$KERNBASE, %esi
movl%esi, R(proc0kstack)
@@ -800,7 +800,7 @@ no_kernend:
 
 /* Map proc0's KSTACK in the physical way ... */
movlR(p0kpa), %eax
-   movl$(KSTACK_PAGES), %ecx
+   movl$(TD0_KSTACK_PAGES), %ecx
fillkptphys($PG_RW)
 
 /* Map ISA hole */
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 2be5dbc..76790f0 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -2445,7 +2445,7 @@ init386(first)
 #endif
 
thread0.td_kstack = proc0kstack;
-   thread0.td_kstack_pages = KSTACK_PAGES;
+   thread0.td_kstack_pages = TD0_KSTACK_PAGES;
 
/*
 * This may be done better later if it gets more high level
diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h
index b3fd85f..bc79c20 100644
--- a/sys/i386/include/param.h
+++ b/sys/i386/include/param.h
@@ -114,6 +114,11 @@
 #define KSTACK_PAGES 2 /* Includes pcb! */
 #endif
 #define KSTACK_GUARD_PAGES 1   /* pages of kstack guard; 0 disables */
+#if KSTACK_PAGES < 3
+#defineTD0_KSTACK_PAGES 4
+#else
+#defineTD0_KSTACK_PAGES KSTACK_PAGES
+#endif
 
 /*
  * Ceiling on amount of swblock kva space, can be changed via
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Slawa Olhovchenkov
On Mon, Aug 03, 2015 at 12:50:19PM +0100, Steven Hartland wrote:

> > I looked at the possibility of making default kernel stack size
> > configurable by a loader tunable, and the issue is that thread0 gets its
> > stack set up too early (locore for i386, hammer_time() for amd64).  I.e.,
> > it is possible to make the setting effective for all threads after thread0,
> > but not for the one which causes the issue.
> >
> > I do not want to modify ABI between loader and kernel to pass the parameter.
> I've created a review for the current proposed change to look at the 
> kernel var kstack_pages vs
> the compile time define KSTACK_PAGES.
> 
> For this change I don't want to get into fixing the thread0 stack size, 
> which can be done later, just
> to provide a reasonable warning to the user that smaller values could 
> cause a panic.
> 
> @slw I've added peter and kib as reviewers if you phabricator account 
> then feel free to add yourself.

I am currently don't have phabricator account, thanks.


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


svn commit: r286226 - head/sys/dev/iscsi

2015-08-03 Thread Edward Tomasz Napierala
Author: trasz
Date: Mon Aug  3 11:57:11 2015
New Revision: 286226
URL: https://svnweb.freebsd.org/changeset/base/286226

Log:
  Rework the way iSCSI initiator handles system shutdown. This fixes
  hangs on shutdown with LUNs with mounted filesystems over a disconnected
  iSCSI session.
  
  MFC after:1 month
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D3052

Modified:
  head/sys/dev/iscsi/iscsi.c

Modified: head/sys/dev/iscsi/iscsi.c
==
--- head/sys/dev/iscsi/iscsi.c  Mon Aug  3 11:05:02 2015(r286225)
+++ head/sys/dev/iscsi/iscsi.c  Mon Aug  3 11:57:11 2015(r286226)
@@ -2322,11 +2322,23 @@ iscsi_shutdown(struct iscsi_softc *sc)
 {
struct iscsi_session *is;
 
-   ISCSI_DEBUG("removing all sessions due to shutdown");
+   /*
+* Trying to reconnect during system shutdown would lead to hang.
+*/
+   fail_on_disconnection = 1;
 
+   /*
+* If we have any sessions waiting for reconnection, request
+* maintenance thread to fail them immediately instead of waiting
+* for reconnect timeout.
+*/
sx_slock(&sc->sc_lock);
-   TAILQ_FOREACH(is, &sc->sc_sessions, is_next)
-   iscsi_session_terminate(is);
+   TAILQ_FOREACH(is, &sc->sc_sessions, is_next) {
+   ISCSI_SESSION_LOCK(is);
+   if (is->is_waiting_for_iscsid)
+   iscsi_session_reconnect(is);
+   ISCSI_SESSION_UNLOCK(is);
+   }
sx_sunlock(&sc->sc_lock);
 }
 
@@ -2352,12 +2364,7 @@ iscsi_load(void)
}
sc->sc_cdev->si_drv1 = sc;
 
-   /*
-* Note that this needs to get run before dashutdown().  Otherwise,
-* when rebooting with iSCSI session with outstanding requests,
-* but disconnected, dashutdown() will hang on cam_periph_runccb().
-*/
-   sc->sc_shutdown_eh = EVENTHANDLER_REGISTER(shutdown_post_sync,
+   sc->sc_shutdown_eh = EVENTHANDLER_REGISTER(shutdown_pre_sync,
iscsi_shutdown, sc, SHUTDOWN_PRI_FIRST);
 
return (0);
@@ -2375,7 +2382,7 @@ iscsi_unload(void)
}
 
if (sc->sc_shutdown_eh != NULL)
-   EVENTHANDLER_DEREGISTER(shutdown_post_sync, sc->sc_shutdown_eh);
+   EVENTHANDLER_DEREGISTER(shutdown_pre_sync, sc->sc_shutdown_eh);
 
sx_slock(&sc->sc_lock);
TAILQ_FOREACH_SAFE(is, &sc->sc_sessions, is_next, tmp)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Steven Hartland



On 03/08/2015 12:19, Konstantin Belousov wrote:

On Mon, Aug 03, 2015 at 03:52:21AM -0700, Peter Wemm wrote:

On Monday, August 03, 2015 11:31:58 AM Steven Hartland wrote:

On 03/08/2015 10:47, Slawa Olhovchenkov wrote:

On Mon, Aug 03, 2015 at 09:34:10AM +, Steven Hartland wrote:

Author: smh
Date: Mon Aug  3 09:34:09 2015
New Revision: 286223
URL: https://svnweb.freebsd.org/changeset/base/286223

Log:
Fix KSTACK_PAGES check in ZFS module

The check introduced by r285946 failed to add the dependency on

opt_kstack_pages.h which meant the default value for the platform
instead
of the customised options KSTACK_PAGES=X was being tested.

Also wrap in #ifdef __FreeBSD__ for portability.

/usr/src/sys/kern/kern_proc.c:int kstack_pages = KSTACK_PAGES;

May be check variable kstack_pages is best way?
Eliminate dependency on foreign opt_.

I did think of that but as other modules such as dtrace, which is also
cddl code, already have this dependency I went with this.

I'm easy though, if there's a concusses that kstack_pages or possibly
curthread->td_kstack_pages, which would take into account the
possibility of varied thread stack sizes, then I can make that change.

What do others think?

The whole thing has missing the point.

Changing the default for the entire kernel just because the zfs compat
wrappers can't be bothered requesting a suitable value is.. unfortunate..
particularly when it is in freebsd-provided code, not upstream zfs code.

Fix the kproc_kthread_add() calls in do_thread_create() and zvol_geom_run()
instead.  Enforce a lower bound there for zfs threads instead of making the
entire rest of the kernel use more memory.

eg: I'm thinking along these lines:
Index: cddl/compat/opensolaris/sys/proc.h

--- cddl/compat/opensolaris/sys/proc.h  (revision 286224)
+++ cddl/compat/opensolaris/sys/proc.h  (working copy)
@@ -77,6 +77,8 @@
ASSERT(state == TS_RUN);
ASSERT(pp == &p0);
  
+	if (stksize < 16384)

+   stksize = 16384;/* Enforce lower bound on ZFS threads */
error = kproc_kthread_add(proc, arg, &zfsproc, &td, RFSTOPPED,
stksize / PAGE_SIZE, "zfskern", "solthread %p", proc);
if (error == 0) {


Beware, some platforms have large pages (eg: ia64 in -stable has 8k, 16k or
32k pages, from memory).  Specifying an arbitrary number of pages in code
that's supposed to be portable isn't a good idea.

This would not help. Issue is the size of the thread0 stack, which
overflows in this case.

I looked at the possibility of making default kernel stack size
configurable by a loader tunable, and the issue is that thread0 gets its
stack set up too early (locore for i386, hammer_time() for amd64).  I.e.,
it is possible to make the setting effective for all threads after thread0,
but not for the one which causes the issue.

I do not want to modify ABI between loader and kernel to pass the parameter.
I've created a review for the current proposed change to look at the 
kernel var kstack_pages vs

the compile time define KSTACK_PAGES.

For this change I don't want to get into fixing the thread0 stack size, 
which can be done later, just
to provide a reasonable warning to the user that smaller values could 
cause a panic.


@slw I've added peter and kib as reviewers if you phabricator account 
then feel free to add yourself.


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


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

2015-08-03 Thread Slawa Olhovchenkov
On Mon, Aug 03, 2015 at 02:19:42PM +0300, Konstantin Belousov wrote:

> > The whole thing has missing the point.
> > 
> > Changing the default for the entire kernel just because the zfs compat 
> > wrappers can't be bothered requesting a suitable value is.. unfortunate.. 
> > particularly when it is in freebsd-provided code, not upstream zfs code.
> > 
> > Fix the kproc_kthread_add() calls in do_thread_create() and zvol_geom_run() 
> > instead.  Enforce a lower bound there for zfs threads instead of making the 
> > entire rest of the kernel use more memory.
> > 
> > eg: I'm thinking along these lines:
> > Index: cddl/compat/opensolaris/sys/proc.h
> > 
> > --- cddl/compat/opensolaris/sys/proc.h  (revision 286224)
> > +++ cddl/compat/opensolaris/sys/proc.h  (working copy)
> > @@ -77,6 +77,8 @@
> > ASSERT(state == TS_RUN);
> > ASSERT(pp == &p0);
> >  
> > +   if (stksize < 16384)
> > +   stksize = 16384;/* Enforce lower bound on ZFS threads */
> > error = kproc_kthread_add(proc, arg, &zfsproc, &td, RFSTOPPED,
> > stksize / PAGE_SIZE, "zfskern", "solthread %p", proc);
> > if (error == 0) {
> > 
> > 
> > Beware, some platforms have large pages (eg: ia64 in -stable has 8k, 16k or 
> > 32k pages, from memory).  Specifying an arbitrary number of pages in code 
> > that's supposed to be portable isn't a good idea.
> 
> This would not help. Issue is the size of the thread0 stack, which
> overflows in this case.
> 
> I looked at the possibility of making default kernel stack size
> configurable by a loader tunable, and the issue is that thread0 gets its
> stack set up too early (locore for i386, hammer_time() for amd64).  I.e.,
> it is possible to make the setting effective for all threads after thread0,
> but not for the one which causes the issue.
> 
> I do not want to modify ABI between loader and kernel to pass the parameter.

Parsing kenv by asm too complex?
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Konstantin Belousov
On Mon, Aug 03, 2015 at 03:52:21AM -0700, Peter Wemm wrote:
> On Monday, August 03, 2015 11:31:58 AM Steven Hartland wrote:
> > On 03/08/2015 10:47, Slawa Olhovchenkov wrote:
> > > On Mon, Aug 03, 2015 at 09:34:10AM +, Steven Hartland wrote:
> > >> Author: smh
> > >> Date: Mon Aug  3 09:34:09 2015
> > >> New Revision: 286223
> > >> URL: https://svnweb.freebsd.org/changeset/base/286223
> > >> 
> > >> Log:
> > >>Fix KSTACK_PAGES check in ZFS module
> > >>
> > >>The check introduced by r285946 failed to add the dependency on
> > >>opt_kstack_pages.h which meant the default value for the platform
> > >>instead
> > >>of the customised options KSTACK_PAGES=X was being tested.
> > >>
> > >>Also wrap in #ifdef __FreeBSD__ for portability.
> > > 
> > > /usr/src/sys/kern/kern_proc.c:int kstack_pages = KSTACK_PAGES;
> > > 
> > > May be check variable kstack_pages is best way?
> > > Eliminate dependency on foreign opt_.
> > 
> > I did think of that but as other modules such as dtrace, which is also
> > cddl code, already have this dependency I went with this.
> > 
> > I'm easy though, if there's a concusses that kstack_pages or possibly
> > curthread->td_kstack_pages, which would take into account the
> > possibility of varied thread stack sizes, then I can make that change.
> > 
> > What do others think?
> 
> The whole thing has missing the point.
> 
> Changing the default for the entire kernel just because the zfs compat 
> wrappers can't be bothered requesting a suitable value is.. unfortunate.. 
> particularly when it is in freebsd-provided code, not upstream zfs code.
> 
> Fix the kproc_kthread_add() calls in do_thread_create() and zvol_geom_run() 
> instead.  Enforce a lower bound there for zfs threads instead of making the 
> entire rest of the kernel use more memory.
> 
> eg: I'm thinking along these lines:
> Index: cddl/compat/opensolaris/sys/proc.h
> 
> --- cddl/compat/opensolaris/sys/proc.h(revision 286224)
> +++ cddl/compat/opensolaris/sys/proc.h(working copy)
> @@ -77,6 +77,8 @@
>   ASSERT(state == TS_RUN);
>   ASSERT(pp == &p0);
>  
> + if (stksize < 16384)
> + stksize = 16384;/* Enforce lower bound on ZFS threads */
>   error = kproc_kthread_add(proc, arg, &zfsproc, &td, RFSTOPPED,
>   stksize / PAGE_SIZE, "zfskern", "solthread %p", proc);
>   if (error == 0) {
> 
> 
> Beware, some platforms have large pages (eg: ia64 in -stable has 8k, 16k or 
> 32k pages, from memory).  Specifying an arbitrary number of pages in code 
> that's supposed to be portable isn't a good idea.

This would not help. Issue is the size of the thread0 stack, which
overflows in this case.

I looked at the possibility of making default kernel stack size
configurable by a loader tunable, and the issue is that thread0 gets its
stack set up too early (locore for i386, hammer_time() for amd64).  I.e.,
it is possible to make the setting effective for all threads after thread0,
but not for the one which causes the issue.

I do not want to modify ABI between loader and kernel to pass the parameter.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286225 - in head/sys/arm64: arm64 include

2015-08-03 Thread Andrew Turner
Author: andrew
Date: Mon Aug  3 11:05:02 2015
New Revision: 286225
URL: https://svnweb.freebsd.org/changeset/base/286225

Log:
  Pass the pcb to store the vfp state in to vfp_save_state. This fixes a bug
  in savectx where it will be used to store the current state however will
  pass in a pcb when vfp_save_state expected a thread pointer.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm64/arm64/machdep.c
  head/sys/arm64/arm64/swtch.S
  head/sys/arm64/arm64/vfp.c
  head/sys/arm64/arm64/vm_machdep.c
  head/sys/arm64/include/vfp.h

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Mon Aug  3 10:10:49 2015
(r286224)
+++ head/sys/arm64/arm64/machdep.c  Mon Aug  3 11:05:02 2015
(r286225)
@@ -180,7 +180,7 @@ fill_fpregs(struct thread *td, struct fp
 * If we have just been running VFP instructions we will
 * need to save the state to memcpy it below.
 */
-   vfp_save_state(td);
+   vfp_save_state(td, pcb);
 
memcpy(regs->fp_q, pcb->pcb_vfp, sizeof(regs->fp_q));
regs->fp_cr = pcb->pcb_fpcr;
@@ -314,7 +314,7 @@ get_fpcontext(struct thread *td, mcontex
 * If we have just been running VFP instructions we will
 * need to save the state to memcpy it below.
 */
-   vfp_save_state(td);
+   vfp_save_state(td, curpcb);
 
memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_vfp,
sizeof(mcp->mc_fpregs));

Modified: head/sys/arm64/arm64/swtch.S
==
--- head/sys/arm64/arm64/swtch.SMon Aug  3 10:10:49 2015
(r286224)
+++ head/sys/arm64/arm64/swtch.SMon Aug  3 11:05:02 2015
(r286225)
@@ -131,6 +131,8 @@ ENTRY(cpu_switch)
mov x19, x0
mov x20, x1
mov x21, x2
+   /* Load the pcb address */
+   mov x1, x4
bl  vfp_save_state
mov x2, x21
mov x1, x20
@@ -268,9 +270,11 @@ ENTRY(savectx)
 
/* Store the VFP registers */
 #ifdef VFP
-   mov x29, lr
+   mov x28, lr
+   mov x1, x0  /* move pcb to the correct register */
+   mov x0, xzr /* td = NULL */
bl  vfp_save_state
-   mov lr, x29
+   mov lr, x28
 #endif
 
ret

Modified: head/sys/arm64/arm64/vfp.c
==
--- head/sys/arm64/arm64/vfp.c  Mon Aug  3 10:10:49 2015(r286224)
+++ head/sys/arm64/arm64/vfp.c  Mon Aug  3 11:05:02 2015(r286225)
@@ -82,12 +82,18 @@ vfp_discard(struct thread *td)
 }
 
 void
-vfp_save_state(struct thread *td)
+vfp_save_state(struct thread *td, struct pcb *pcb)
 {
__int128_t *vfp_state;
uint64_t fpcr, fpsr;
uint32_t cpacr;
 
+   KASSERT(pcb != NULL, ("NULL vfp pcb"));
+   KASSERT(td == NULL || td->td_pcb == pcb, ("Invalid vfp pcb"));
+
+   if (td == NULL)
+   td = curthread;
+
critical_enter();
/*
 * Only store the registers if the VFP is enabled,
@@ -98,7 +104,7 @@ vfp_save_state(struct thread *td)
KASSERT(PCPU_GET(fpcurthread) == td,
("Storing an invalid VFP state"));
 
-   vfp_state = td->td_pcb->pcb_vfp;
+   vfp_state = pcb->pcb_vfp;
__asm __volatile(
"mrs%0, fpcr\n"
"mrs%1, fpsr\n"
@@ -120,8 +126,8 @@ vfp_save_state(struct thread *td)
"stpq30, q31, [%2, #16 * 30]\n"
: "=&r"(fpcr), "=&r"(fpsr) : "r"(vfp_state));
 
-   td->td_pcb->pcb_fpcr = fpcr;
-   td->td_pcb->pcb_fpsr = fpsr;
+   pcb->pcb_fpcr = fpcr;
+   pcb->pcb_fpsr = fpsr;
 
dsb(ish);
vfp_disable();

Modified: head/sys/arm64/arm64/vm_machdep.c
==
--- head/sys/arm64/arm64/vm_machdep.c   Mon Aug  3 10:10:49 2015
(r286224)
+++ head/sys/arm64/arm64/vm_machdep.c   Mon Aug  3 11:05:02 2015
(r286225)
@@ -74,7 +74,7 @@ cpu_fork(struct thread *td1, struct proc
td1->td_pcb->pcb_tpidr_el0 = READ_SPECIALREG(tpidr_el0);
 #ifdef VFP
if ((td1->td_pcb->pcb_fpflags & PCB_FP_STARTED) != 0)
-   vfp_save_state(td1);
+   vfp_save_state(td1, td1->td_pcb);
 #endif
}
 

Modified: head/sys/arm64/include/vfp.h
==
--- head/sys/arm64/include/vfp.hMon Aug  3 10:10:49 

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

2015-08-03 Thread Slawa Olhovchenkov
On Mon, Aug 03, 2015 at 11:31:58AM +0100, Steven Hartland wrote:

> On 03/08/2015 10:47, Slawa Olhovchenkov wrote:
> > On Mon, Aug 03, 2015 at 09:34:10AM +, Steven Hartland wrote:
> >
> >> Author: smh
> >> Date: Mon Aug  3 09:34:09 2015
> >> New Revision: 286223
> >> URL: https://svnweb.freebsd.org/changeset/base/286223
> >>
> >> Log:
> >>Fix KSTACK_PAGES check in ZFS module
> >>
> >>The check introduced by r285946 failed to add the dependency on
> >>opt_kstack_pages.h which meant the default value for the platform 
> >> instead
> >>of the customised options KSTACK_PAGES=X was being tested.
> >>
> >>Also wrap in #ifdef __FreeBSD__ for portability.
> > /usr/src/sys/kern/kern_proc.c:int kstack_pages = KSTACK_PAGES;
> >
> > May be check variable kstack_pages is best way?
> > Eliminate dependency on foreign opt_.
> >
> I did think of that but as other modules such as dtrace, which is also 
> cddl code, already have this dependency I went with this.
> 
> I'm easy though, if there's a concusses that kstack_pages or possibly 
> curthread->td_kstack_pages, which would take into account the 
> possibility of varied thread stack sizes, then I can make that change.
> 
> What do others think?

ZFS currently don't have true direct dependency from KSTACK_PAGES (no
code like this:

/usr/src/sys/i386/i386/mp_machdep.c:bootSTK = (char 
*)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 4;

This is simple guard check. I.e. change KSTACK_PAGES don't want
recompile zfs.ko.

And less work to somebody converted KSTACK_PAGES to loader tunable.
Most of this code already may be conveted to use kstack_pages w/o
performance impact.
Only 5 lines in 3 asm files need some more work.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Peter Wemm
On Monday, August 03, 2015 11:31:58 AM Steven Hartland wrote:
> On 03/08/2015 10:47, Slawa Olhovchenkov wrote:
> > On Mon, Aug 03, 2015 at 09:34:10AM +, Steven Hartland wrote:
> >> Author: smh
> >> Date: Mon Aug  3 09:34:09 2015
> >> New Revision: 286223
> >> URL: https://svnweb.freebsd.org/changeset/base/286223
> >> 
> >> Log:
> >>Fix KSTACK_PAGES check in ZFS module
> >>
> >>The check introduced by r285946 failed to add the dependency on
> >>opt_kstack_pages.h which meant the default value for the platform
> >>instead
> >>of the customised options KSTACK_PAGES=X was being tested.
> >>
> >>Also wrap in #ifdef __FreeBSD__ for portability.
> > 
> > /usr/src/sys/kern/kern_proc.c:int kstack_pages = KSTACK_PAGES;
> > 
> > May be check variable kstack_pages is best way?
> > Eliminate dependency on foreign opt_.
> 
> I did think of that but as other modules such as dtrace, which is also
> cddl code, already have this dependency I went with this.
> 
> I'm easy though, if there's a concusses that kstack_pages or possibly
> curthread->td_kstack_pages, which would take into account the
> possibility of varied thread stack sizes, then I can make that change.
> 
> What do others think?

The whole thing has missing the point.

Changing the default for the entire kernel just because the zfs compat 
wrappers can't be bothered requesting a suitable value is.. unfortunate.. 
particularly when it is in freebsd-provided code, not upstream zfs code.

Fix the kproc_kthread_add() calls in do_thread_create() and zvol_geom_run() 
instead.  Enforce a lower bound there for zfs threads instead of making the 
entire rest of the kernel use more memory.

eg: I'm thinking along these lines:
Index: cddl/compat/opensolaris/sys/proc.h

--- cddl/compat/opensolaris/sys/proc.h  (revision 286224)
+++ cddl/compat/opensolaris/sys/proc.h  (working copy)
@@ -77,6 +77,8 @@
ASSERT(state == TS_RUN);
ASSERT(pp == &p0);
 
+   if (stksize < 16384)
+   stksize = 16384;/* Enforce lower bound on ZFS threads */
error = kproc_kthread_add(proc, arg, &zfsproc, &td, RFSTOPPED,
stksize / PAGE_SIZE, "zfskern", "solthread %p", proc);
if (error == 0) {


Beware, some platforms have large pages (eg: ia64 in -stable has 8k, 16k or 
32k pages, from memory).  Specifying an arbitrary number of pages in code 
that's supposed to be portable isn't a good idea.

-- 
Peter Wemm - pe...@wemm.org; pe...@freebsd.org; pe...@yahoo-inc.com; KI6FJV
UTF-8: for when a ' or ... just won\342\200\231t do\342\200\246

signature.asc
Description: This is a digitally signed message part.


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

2015-08-03 Thread Steven Hartland

On 03/08/2015 10:47, Slawa Olhovchenkov wrote:

On Mon, Aug 03, 2015 at 09:34:10AM +, Steven Hartland wrote:


Author: smh
Date: Mon Aug  3 09:34:09 2015
New Revision: 286223
URL: https://svnweb.freebsd.org/changeset/base/286223

Log:
   Fix KSTACK_PAGES check in ZFS module
   
   The check introduced by r285946 failed to add the dependency on

   opt_kstack_pages.h which meant the default value for the platform instead
   of the customised options KSTACK_PAGES=X was being tested.
   
   Also wrap in #ifdef __FreeBSD__ for portability.

/usr/src/sys/kern/kern_proc.c:int kstack_pages = KSTACK_PAGES;

May be check variable kstack_pages is best way?
Eliminate dependency on foreign opt_.

I did think of that but as other modules such as dtrace, which is also 
cddl code, already have this dependency I went with this.


I'm easy though, if there's a concusses that kstack_pages or possibly 
curthread->td_kstack_pages, which would take into account the 
possibility of varied thread stack sizes, then I can make that change.


What do others think?

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


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

2015-08-03 Thread Slawa Olhovchenkov
On Mon, Aug 03, 2015 at 09:34:10AM +, Steven Hartland wrote:

> Author: smh
> Date: Mon Aug  3 09:34:09 2015
> New Revision: 286223
> URL: https://svnweb.freebsd.org/changeset/base/286223
> 
> Log:
>   Fix KSTACK_PAGES check in ZFS module
>   
>   The check introduced by r285946 failed to add the dependency on
>   opt_kstack_pages.h which meant the default value for the platform instead
>   of the customised options KSTACK_PAGES=X was being tested.
>   
>   Also wrap in #ifdef __FreeBSD__ for portability.

/usr/src/sys/kern/kern_proc.c:int kstack_pages = KSTACK_PAGES;

May be check variable kstack_pages is best way?
Eliminate dependency on foreign opt_.


>   MFC after:  3 days
>   Sponsored by:   Multiplay
> 
> Modified:
>   head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
> 
> Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
> ==
> --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c   Mon Aug 
>  3 08:04:31 2015(r286222)
> +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c   Mon Aug 
>  3 09:34:09 2015(r286223)
> @@ -132,6 +132,9 @@
>   * distinguish between the operation failing, and
>   * deserialization failing.
>   */
> +#ifdef __FreeBSD__
> +#include "opt_kstack_pages.h"
> +#endif
>  
>  #include 
>  #include 
> @@ -6491,18 +6494,22 @@ static void zfs_shutdown(void *, int);
>  
>  static eventhandler_tag zfs_shutdown_event_tag;
>  
> +#ifdef __FreeBSD__
>  #define ZFS_MIN_KSTACK_PAGES 4
> +#endif
>  
>  int
>  zfs__init(void)
>  {
>  
> +#ifdef __FreeBSD__
>  #if KSTACK_PAGES < ZFS_MIN_KSTACK_PAGES
>   printf("ZFS NOTICE: KSTACK_PAGES is %d which could result in stack "
>   "overflow panic!\nPlease consider adding "
>   "'options KSTACK_PAGES=%d' to your kernel config\n", KSTACK_PAGES,
>   ZFS_MIN_KSTACK_PAGES);
>  #endif
> +#endif
>   zfs_root_token = root_mount_hold("ZFS");
>  
>   mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL);
> ___
> svn-src-...@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/svn-src-all
> To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2015-08-03 Thread Steven Hartland
Author: smh
Date: Mon Aug  3 09:34:09 2015
New Revision: 286223
URL: https://svnweb.freebsd.org/changeset/base/286223

Log:
  Fix KSTACK_PAGES check in ZFS module
  
  The check introduced by r285946 failed to add the dependency on
  opt_kstack_pages.h which meant the default value for the platform instead
  of the customised options KSTACK_PAGES=X was being tested.
  
  Also wrap in #ifdef __FreeBSD__ for portability.
  
  MFC after:3 days
  Sponsored by: Multiplay

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Mon Aug 
 3 08:04:31 2015(r286222)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Mon Aug 
 3 09:34:09 2015(r286223)
@@ -132,6 +132,9 @@
  * distinguish between the operation failing, and
  * deserialization failing.
  */
+#ifdef __FreeBSD__
+#include "opt_kstack_pages.h"
+#endif
 
 #include 
 #include 
@@ -6491,18 +6494,22 @@ static void zfs_shutdown(void *, int);
 
 static eventhandler_tag zfs_shutdown_event_tag;
 
+#ifdef __FreeBSD__
 #define ZFS_MIN_KSTACK_PAGES 4
+#endif
 
 int
 zfs__init(void)
 {
 
+#ifdef __FreeBSD__
 #if KSTACK_PAGES < ZFS_MIN_KSTACK_PAGES
printf("ZFS NOTICE: KSTACK_PAGES is %d which could result in stack "
"overflow panic!\nPlease consider adding "
"'options KSTACK_PAGES=%d' to your kernel config\n", KSTACK_PAGES,
ZFS_MIN_KSTACK_PAGES);
 #endif
+#endif
zfs_root_token = root_mount_hold("ZFS");
 
mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r286221 - head/sys/amd64/cloudabi64

2015-08-03 Thread Ed Schouten
Author: ed
Date: Mon Aug  3 07:29:57 2015
New Revision: 286221
URL: https://svnweb.freebsd.org/changeset/base/286221

Log:
  Set p_osrel to __FreeBSD_version on process startup.
  
  Certain system calls have quirks applied to make them work as if called
  on an older version of FreeBSD. As CloudABI executables don't have the
  FreeBSD OS release number in the ELF header, this value is set to zero,
  making the system calls fall back to typically historic, non-standard
  behaviour.
  
  Reviewed by:  kib

Modified:
  head/sys/amd64/cloudabi64/cloudabi64_sysvec.c

Modified: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Mon Aug  3 07:28:23 
2015(r286220)
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c   Mon Aug  3 07:29:57 
2015(r286221)
@@ -73,10 +73,20 @@ cloudabi64_fixup(register_t **stack_base
 {
char canarybuf[64];
Elf64_Auxargs *args;
+   struct thread *td;
void *argdata, *canary;
size_t argdatalen;
int error;
 
+   /*
+* CloudABI executables do not store the FreeBSD OS release
+* number in their header. Set the OS release number to the
+* latest version of FreeBSD, so that system calls behave as if
+* called natively.
+*/
+   td = curthread;
+   td->td_proc->p_osrel = __FreeBSD_version;
+
/* Store canary for stack smashing protection. */
argdata = *stack_base;
arc4rand(canarybuf, sizeof(canarybuf), 0);
@@ -108,7 +118,7 @@ cloudabi64_fixup(register_t **stack_base
VAL(CLOUDABI_AT_PAGESZ, args->pagesz),
PTR(CLOUDABI_AT_PHDR, args->phdr),
VAL(CLOUDABI_AT_PHNUM, args->phnum),
-   VAL(CLOUDABI_AT_TID, curthread->td_tid),
+   VAL(CLOUDABI_AT_TID, td->td_tid),
 #undef VAL
 #undef PTR
{ .a_type = CLOUDABI_AT_NULL },
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"