Re: svn commit: r230230 - head/sys/dev/random

2012-01-17 Thread Andrey Chernov
On Mon, Jan 16, 2012 at 08:18:10PM +, David Schultz wrote:
> Author: das
> Date: Mon Jan 16 20:18:10 2012
> New Revision: 230230
> URL: http://svn.freebsd.org/changeset/base/230230
> 
> Log:
>   Generate a warning if the kernel's arc4random() is seeded with bogus 
> entropy.

While you are here, could you review/commit my patch to fix bad 31bit
arc4rand() seeding, please?

--- yarrow.c.bak2011-09-26 07:35:48.0 +0400
+++ yarrow.c2012-01-18 10:13:47.0 +0400
@@ -59,6 +59,8 @@ static void reseed(u_int);
 /* The reseed thread mutex */
 struct mtx random_reseed_mtx;
 
+static arc4rand_seeded = 0;
+
 /* Process a single stochastic event off the harvest queue */
 void
 random_process_event(struct harvest *event)
@@ -261,6 +263,11 @@ reseed(u_int fastslow)
 
/* Release the reseed mutex */
mtx_unlock(&random_reseed_mtx);
+
+   if (!arc4rand_seeded) {
+   arc4rand_seeded = 1;
+   arc4rand(NULL, 0, 1);
+   }
 }
 
 /* Internal function to return processed entropy from the PRNG */

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


svn commit: r230299 - head/usr.sbin/tzsetup

2012-01-17 Thread Ed Maste
Author: emaste
Date: Wed Jan 18 04:37:35 2012
New Revision: 230299
URL: http://svn.freebsd.org/changeset/base/230299

Log:
  Fix #ifdef VERBOSE for UTC case
  
  Update verbose output to match what actually happens when selecting
  the UTC option, and when the -n option is used.
  
  Patch updated slightly for new libdialog.
  
  PR:   bin/164042
  Submitted by: Devin Teske 
  MFC after:2 weeks

Modified:
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.c
==
--- head/usr.sbin/tzsetup/tzsetup.c Wed Jan 18 04:37:17 2012
(r230298)
+++ head/usr.sbin/tzsetup/tzsetup.c Wed Jan 18 04:37:35 2012
(r230299)
@@ -659,16 +659,19 @@ install_zoneinfo_file(const char *zonein
copymode = 1;
 
 #ifdef VERBOSE
-   if (copymode)
+   snprintf(title, sizeof(title), "Info");
+   if (zoneinfo_file == NULL)
+   snprintf(prompt, sizeof(prompt),
+   "Removing %s", path_localtime);
+   else if (copymode)
snprintf(prompt, sizeof(prompt),
"Copying %s to %s", zoneinfo_file, path_localtime);
else
snprintf(prompt, sizeof(prompt),
"Creating symbolic link %s to %s",
-   path_localtime,
-   zoneinfo_file == NULL ? "(UTC)" : zoneinfo_file);
+   path_localtime, zoneinfo_file);
if (usedialog)
-   dialog_notify(prompt);
+   dialog_msgbox(title, prompt, 8, 72, 1);
else
fprintf(stderr, "%s\n", prompt);
 #endif
@@ -699,6 +702,10 @@ install_zoneinfo_file(const char *zonein
 
return (DITEM_FAILURE | DITEM_RECREATE);
}
+#ifdef VERBOSE
+   snprintf(prompt, sizeof(prompt),
+   "Removed %s", path_localtime);
+#endif
return (DITEM_LEAVE_MENU);
}
 
@@ -797,23 +804,23 @@ install_zoneinfo_file(const char *zonein
return (DITEM_FAILURE | DITEM_RECREATE);
}
}
-   }
 
 #ifdef VERBOSE
-   snprintf(title, sizeof(title), "Done");
-   if (copymode)
-   snprintf(prompt, sizeof(prompt),
-   "Copied timezone file from %s to %s", zoneinfo_file,
-   path_localtime);
-   else
-   snprintf(prompt, sizeof(prompt),
-   "Created symbolic link from %s to %s", zoneinfo_file,
-   path_localtime);
-   if (usedialog)
-   dialog_msgbox(title, prompt, 8, 72, 1);
-   else
-   fprintf(stderr, "%s\n", prompt);
+   snprintf(title, sizeof(title), "Done");
+   if (copymode)
+   snprintf(prompt, sizeof(prompt),
+   "Copied timezone file from %s to %s",
+   zoneinfo_file, path_localtime);
+   else
+   snprintf(prompt, sizeof(prompt),
+   "Created symbolic link from %s to %s",
+   zoneinfo_file, path_localtime);
+   if (usedialog)
+   dialog_msgbox(title, prompt, 8, 72, 1);
+   else
+   fprintf(stderr, "%s\n", prompt);
 #endif
+   } /* reallydoit */
 
return (DITEM_LEAVE_MENU);
 }
___
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: r230265 - head/sys/contrib/pf/net

2012-01-17 Thread Gleb Smirnoff
On Tue, Jan 17, 2012 at 11:38:12PM +0100, Ermal Lu?i wrote:
E> > On Tue, Jan 17, 2012 at 05:48:10PM +0100, Ermal Lu?i wrote:
E> > E> Maybe it does not hurt in general to keep the V_
E> > E> Some work was done to add it, no?!
E> >
E> > The V_ has been left under __FreeBSD__.
E> >
E> > E> On Tue, Jan 17, 2012 at 1:14 PM, Gleb Smirnoff 
E> > wrote:
E> > E>
E> > E> > Author: glebius
E> > E> > Date: Tue Jan 17 12:14:26 2012
E> > E> > New Revision: 230265
E> > E> > URL: http://svn.freebsd.org/changeset/base/230265
E> > E> >
E> > E> > Log:
E> > E> >  Allocate our mbuf with m_get2().
E> > E> >
E> > E> > Modified:
E> > E> >  head/sys/contrib/pf/net/if_pfsync.c
E> > E> >
E> > E> > Modified: head/sys/contrib/pf/net/if_pfsync.c
E> > E> >
E> > E> >
E> > 
==
E> > E> > --- head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:13:36 2012
E> > E> >  (r230264)
E> > E> > +++ head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:14:26 2012
E> > E> >  (r230265)
E> > E> > @@ -2121,9 +2121,6 @@ pfsync_sendout(void)
E> > E> >  #ifdef notyet
E> > E> >struct tdb *t;
E> > E> >  #endif
E> > E> > -#ifdef __FreeBSD__
E> > E> > -   size_t pktlen;
E> > E> > -#endif
E> > E> >int offset;
E> > E> >int q, count = 0;
E> > E> >
E> > E> > @@ -2145,44 +2142,33 @@ pfsync_sendout(void)
E> > E> >return;
E> > E> >}
E> > E> >
E> > E> > -   MGETHDR(m, M_DONTWAIT, MT_DATA);
E> > E> > -   if (m == NULL) {
E> > E> >  #ifdef __FreeBSD__
E> > E> > +   m = m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr +
E> > sc->sc_len);
E> > E> > +   if (m == NULL) {
E> > E> >sc->sc_ifp->if_oerrors++;
E> > E> > +   V_pfsyncstats.pfsyncs_onomem++;
E> > E> > +   return;
E> > E> > +   }
E> > E> >  #else
E> > E> > +   MGETHDR(m, M_DONTWAIT, MT_DATA);
E> > E> > +   if (m == NULL) {
E> > E> >sc->sc_if.if_oerrors++;
E> > E> > -#endif
E> > E> > -   V_pfsyncstats.pfsyncs_onomem++;
E> > E> > +   pfsyncstats.pfsyncs_onomem++;
E> >
E> ^^
E> What about this?
E> 
E> 
E> > E> >pfsync_drop(sc);
E> > E> >return;
E> > E> >}
E> > E> >
E> > E> > -#ifdef __FreeBSD__
E> > E> > -   pktlen = max_linkhdr + sc->sc_len;
E> > E> > -   if (pktlen > MHLEN) {
E> > E> > -   /* Find the right pool to allocate from. */
E> > E> > -   /* XXX: This is ugly. */
E> > E> > -   m_cljget(m, M_DONTWAIT, pktlen <= MCLBYTES ? MCLBYTES
E> > :
E> > E> > -#if MJUMPAGESIZE != MCLBYTES
E> > E> > -   pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE :
E> > E> > -#endif
E> > E> > -   pktlen <= MJUM9BYTES ? MJUM9BYTES :
E> > MJUM16BYTES);
E> > E> > -#else
E> > E> >if (max_linkhdr + sc->sc_len > MHLEN) {
E> > E> >MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len);
E> > E> > -#endif
E> > E> >if (!ISSET(m->m_flags, M_EXT)) {
E> > E> >m_free(m);
E> > E> > -#ifdef __FreeBSD__
E> > E> > -   sc->sc_ifp->if_oerrors++;
E> > E> > -#else
E> > E> >sc->sc_if.if_oerrors++;
E> > E> > -#endif
E> > E> > -   V_pfsyncstats.pfsyncs_onomem++;
E> > E> > +   pfsyncstats.pfsyncs_onomem++;
E> >
E> ^^^
E> What about this?
E> 
E> 
E> > E> >pfsync_drop(sc);
E> > E> >return;
E> > E> >}
E> > E> >}
E> > E> > +#endif
E> > E> >m->m_data += max_linkhdr;
E> > E> >m->m_len = m->m_pkthdr.len = sc->sc_len;
E> > E> >
E> > E> >

These are not under __FreeBSD__. 

-- 
Totus tuus, Glebius.
___
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: r230296 - head/usr.sbin/tzsetup

2012-01-17 Thread Ed Maste
Author: emaste
Date: Wed Jan 18 04:12:32 2012
New Revision: 230296
URL: http://svn.freebsd.org/changeset/base/230296

Log:
  Don't write /var/db/zoneinfo when zone is not actually changed.
  
  If the specified zone file does not exist or the -n flag is specified,
  do not update /var/db/zoneinfo.
  
  PR:   bin/164039
  Submitted by: Devin Teske 
  MFC after:1 week

Modified:
  head/usr.sbin/tzsetup/tzsetup.c

Modified: head/usr.sbin/tzsetup/tzsetup.c
==
--- head/usr.sbin/tzsetup/tzsetup.c Wed Jan 18 03:07:34 2012
(r230295)
+++ head/usr.sbin/tzsetup/tzsetup.c Wed Jan 18 04:12:32 2012
(r230296)
@@ -829,9 +829,11 @@ install_zoneinfo(const char *zoneinfo)
rv = install_zoneinfo_file(path_zoneinfo_file);
 
/* Save knowledge for later */
-   if ((f = fopen(path_db, "w")) != NULL) {
-   fprintf(f, "%s\n", zoneinfo);
-   fclose(f);
+   if (reallydoit && (rv & DITEM_FAILURE) == 0) {
+   if ((f = fopen(path_db, "w")) != NULL) {
+   fprintf(f, "%s\n", zoneinfo);
+   fclose(f);
+   }
}
 
return (rv);
___
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: r230294 - head/share/man/man4

2012-01-17 Thread Lawrence Stewart
Author: lstewart
Date: Wed Jan 18 03:03:21 2012
New Revision: 230294
URL: http://svn.freebsd.org/changeset/base/230294

Log:
  Specify the correct section (4 instead of 9) in the h_ertt man page's title 
and
  bump the document date.
  
  MFC after:3 days

Modified:
  head/share/man/man4/h_ertt.4

Modified: head/share/man/man4/h_ertt.4
==
--- head/share/man/man4/h_ertt.4Wed Jan 18 02:44:22 2012
(r230293)
+++ head/share/man/man4/h_ertt.4Wed Jan 18 03:03:21 2012
(r230294)
@@ -29,8 +29,8 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 15, 2011
-.Dt H_ERTT 9
+.Dd January 18, 2012
+.Dt H_ERTT 4
 .Os
 .Sh NAME
 .Nm h_ertt
___
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: r230293 - head/usr.sbin/wpa/wpa_supplicant

2012-01-17 Thread Ed Maste
Author: emaste
Date: Wed Jan 18 02:44:22 2012
New Revision: 230293
URL: http://svn.freebsd.org/changeset/base/230293

Log:
  Add missing line continuation \.  It did not cause any issue because
  the same path is already being included in ../Makefile.inc.
  
  PR:   164192
  Submitted by: Devin Teske 
  MFC after:2 weeks

Modified:
  head/usr.sbin/wpa/wpa_supplicant/Makefile

Modified: head/usr.sbin/wpa/wpa_supplicant/Makefile
==
--- head/usr.sbin/wpa/wpa_supplicant/Makefile   Wed Jan 18 02:29:11 2012
(r230292)
+++ head/usr.sbin/wpa/wpa_supplicant/Makefile   Wed Jan 18 02:44:22 2012
(r230293)
@@ -5,7 +5,7 @@
 .PATH.c:${WPA_SUPPLICANT_DISTDIR} \
${WPA_DISTDIR}/src/drivers \
${WPA_DISTDIR}/src/eap_peer \
-   ${WPA_DISTDIR}/src/rsn_supp
+   ${WPA_DISTDIR}/src/rsn_supp \
${WPA_DISTDIR}/src/crypto
 
 PROG=  wpa_supplicant
___
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: r230292 - head/share/man/man9

2012-01-17 Thread Kevin Lo
Author: kevlo
Date: Wed Jan 18 02:29:11 2012
New Revision: 230292
URL: http://svn.freebsd.org/changeset/base/230292

Log:
  NOOBJ is long time dead
  
  Reviewed by:  kib

Modified:
  head/share/man/man9/namei.9

Modified: head/share/man/man9/namei.9
==
--- head/share/man/man9/namei.9 Wed Jan 18 02:27:09 2012(r230291)
+++ head/share/man/man9/namei.9 Wed Jan 18 02:29:11 2012(r230292)
@@ -196,10 +196,6 @@ With this flag,
 will follow the symbolic link if the last part
 of the path supplied is a symbolic link (i.e., it will return a vnode
 for whatever the link points at, instead for the link itself).
-.It Dv NOOBJ
-Do not call
-.Fn vfs_object_create
-for the returned vnode, even though it meets required criteria for VM support.
 .It Dv NOFOLLOW
 Do not follow symbolic links (pseudo).
 This flag is not looked for by the actual code, which looks for
___
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: r230291 - head/share/man/man9

2012-01-17 Thread Kevin Lo
Author: kevlo
Date: Wed Jan 18 02:27:09 2012
New Revision: 230291
URL: http://svn.freebsd.org/changeset/base/230291

Log:
  vfs_object_create() function is obsolete. Use vnode_create_vobject()
  to create the backing object.
  
  Reviewed by:  kib

Modified:
  head/share/man/man9/vnode.9

Modified: head/share/man/man9/vnode.9
==
--- head/share/man/man9/vnode.9 Tue Jan 17 22:42:54 2012(r230290)
+++ head/share/man/man9/vnode.9 Wed Jan 18 02:27:09 2012(r230291)
@@ -119,13 +119,13 @@ No type.
 .It Dv VREG
 A regular file; may be with or without VM object backing.
 If you want to make sure this get a backing object, call
-.Xr vfs_object_create 9 .
+.Fn vnode_create_vobject .
 .It Dv VDIR
 A directory.
 .It Dv VBLK
 A block device; may be with or without VM object backing.
 If you want to make sure this get a backing object, call
-.Xr vfs_object_create 9 .
+.Fn vnode_create_vobject .
 .It Dv VCHR
 A character device.
 .It Dv VLNK
___
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: r230201 - head/lib/libc/gen

2012-01-17 Thread David Xu

On 2012/1/17 22:57, John Baldwin wrote:

On Monday, January 16, 2012 1:15:14 am David Xu wrote:

Author: davidxu
Date: Mon Jan 16 06:15:14 2012
New Revision: 230201
URL: http://svn.freebsd.org/changeset/base/230201

Log:
   Insert read memory barriers.

I think using atomic_load_acq() on sem->nwaiters would be clearer as it would
indicate which variable you need to ensure is read after other operations.  In
general I think raw rmb/wmb usage should be avoided when possible as it is
does not describe the programmer's intent as well.


Yes, I had considered that I may use atomic_load_acq(), but at that time,
I thought it emits a bus locking, right ? so I just picked up rmb() which
only affects current cpu. maybe atomic_load_acq() does same thing with 
rmb() ?

it is still unclear to me.

Regards,
David Xu
___
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: r230279 - head/usr.sbin/ypserv

2012-01-17 Thread Eitan Adler
On Tue, Jan 17, 2012 at 3:39 PM, Hiroki Sato  wrote:
> Author: hrs
> Date: Tue Jan 17 20:39:33 2012
> New Revision: 230279
> URL: http://svn.freebsd.org/changeset/base/230279
>
> Log:
>  Revert changes in r228790.  It prevented the ypserv daemon from working with
>  with multiple socktypes.

I was at work and unable to do this earlier which is I was so brief
before. I will be be certain to test better next time.

Thanks for handling it!

-- 
Eitan Adler
___
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: r230265 - head/sys/contrib/pf/net

2012-01-17 Thread Ermal Luçi
2012/1/17 Gleb Smirnoff 

> On Tue, Jan 17, 2012 at 05:48:10PM +0100, Ermal Lu?i wrote:
> E> Maybe it does not hurt in general to keep the V_
> E> Some work was done to add it, no?!
>
> The V_ has been left under __FreeBSD__.
>
> E> On Tue, Jan 17, 2012 at 1:14 PM, Gleb Smirnoff 
> wrote:
> E>
> E> > Author: glebius
> E> > Date: Tue Jan 17 12:14:26 2012
> E> > New Revision: 230265
> E> > URL: http://svn.freebsd.org/changeset/base/230265
> E> >
> E> > Log:
> E> >  Allocate our mbuf with m_get2().
> E> >
> E> > Modified:
> E> >  head/sys/contrib/pf/net/if_pfsync.c
> E> >
> E> > Modified: head/sys/contrib/pf/net/if_pfsync.c
> E> >
> E> >
> ==
> E> > --- head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:13:36 2012
> E> >  (r230264)
> E> > +++ head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:14:26 2012
> E> >  (r230265)
> E> > @@ -2121,9 +2121,6 @@ pfsync_sendout(void)
> E> >  #ifdef notyet
> E> >struct tdb *t;
> E> >  #endif
> E> > -#ifdef __FreeBSD__
> E> > -   size_t pktlen;
> E> > -#endif
> E> >int offset;
> E> >int q, count = 0;
> E> >
> E> > @@ -2145,44 +2142,33 @@ pfsync_sendout(void)
> E> >return;
> E> >}
> E> >
> E> > -   MGETHDR(m, M_DONTWAIT, MT_DATA);
> E> > -   if (m == NULL) {
> E> >  #ifdef __FreeBSD__
> E> > +   m = m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr +
> sc->sc_len);
> E> > +   if (m == NULL) {
> E> >sc->sc_ifp->if_oerrors++;
> E> > +   V_pfsyncstats.pfsyncs_onomem++;
> E> > +   return;
> E> > +   }
> E> >  #else
> E> > +   MGETHDR(m, M_DONTWAIT, MT_DATA);
> E> > +   if (m == NULL) {
> E> >sc->sc_if.if_oerrors++;
> E> > -#endif
> E> > -   V_pfsyncstats.pfsyncs_onomem++;
> E> > +   pfsyncstats.pfsyncs_onomem++;
>
^^
What about this?


> E> >pfsync_drop(sc);
> E> >return;
> E> >}
> E> >
> E> > -#ifdef __FreeBSD__
> E> > -   pktlen = max_linkhdr + sc->sc_len;
> E> > -   if (pktlen > MHLEN) {
> E> > -   /* Find the right pool to allocate from. */
> E> > -   /* XXX: This is ugly. */
> E> > -   m_cljget(m, M_DONTWAIT, pktlen <= MCLBYTES ? MCLBYTES
> :
> E> > -#if MJUMPAGESIZE != MCLBYTES
> E> > -   pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE :
> E> > -#endif
> E> > -   pktlen <= MJUM9BYTES ? MJUM9BYTES :
> MJUM16BYTES);
> E> > -#else
> E> >if (max_linkhdr + sc->sc_len > MHLEN) {
> E> >MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len);
> E> > -#endif
> E> >if (!ISSET(m->m_flags, M_EXT)) {
> E> >m_free(m);
> E> > -#ifdef __FreeBSD__
> E> > -   sc->sc_ifp->if_oerrors++;
> E> > -#else
> E> >sc->sc_if.if_oerrors++;
> E> > -#endif
> E> > -   V_pfsyncstats.pfsyncs_onomem++;
> E> > +   pfsyncstats.pfsyncs_onomem++;
>
^^^
What about this?


> E> >pfsync_drop(sc);
> E> >return;
> E> >}
> E> >}
> E> > +#endif
> E> >m->m_data += max_linkhdr;
> E> >m->m_len = m->m_pkthdr.len = sc->sc_len;
> E> >
> E> >
> E>
> E>
> E> --
> E> Ermal
>
> --
> Totus tuus, Glebius.
>



-- 
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: r230289 - head/sbin/growfs

2012-01-17 Thread Ed Schouten
Author: ed
Date: Tue Jan 17 22:19:35 2012
New Revision: 230289
URL: http://svn.freebsd.org/changeset/base/230289

Log:
  Allow growfs to be built with GCC 4.7 and -Werror.
  
  The dp1 variable is only used when FSIRAND is defined. Just place the
  variable behind #ifdefs entirely.

Modified:
  head/sbin/growfs/growfs.c

Modified: head/sbin/growfs/growfs.c
==
--- head/sbin/growfs/growfs.c   Tue Jan 17 22:17:11 2012(r230288)
+++ head/sbin/growfs/growfs.c   Tue Jan 17 22:19:35 2012(r230289)
@@ -374,7 +374,9 @@ initcg(int cylno, time_t modtime, int fs
static caddr_t iobuf;
long blkno, start;
ufs2_daddr_t i, cbase, dmax;
+#ifdef FSIRAND
struct ufs1_dinode *dp1;
+#endif
struct csum *cs;
uint d, dupper, dlower;
 
@@ -452,8 +454,8 @@ initcg(int cylno, time_t modtime, int fs
bzero(iobuf, sblock.fs_bsize);
for (i = 0; i < sblock.fs_ipg / INOPF(&sblock);
 i += sblock.fs_frag) {
-   dp1 = (struct ufs1_dinode *)(void *)iobuf;
 #ifdef FSIRAND
+   dp1 = (struct ufs1_dinode *)(void *)iobuf;
for (j = 0; j < INOPB(&sblock); j++) {
dp1->di_gen = random();
dp1++;
___
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: r230288 - head/share/man/man4

2012-01-17 Thread Pyun YongHyeon
Author: yongari
Date: Tue Jan 17 22:17:11 2012
New Revision: 230288
URL: http://svn.freebsd.org/changeset/base/230288

Log:
  Document dev.bge.%d.msi_disable tunable.

Modified:
  head/share/man/man4/bge.4

Modified: head/share/man/man4/bge.4
==
--- head/share/man/man4/bge.4   Tue Jan 17 22:17:10 2012(r230287)
+++ head/share/man/man4/bge.4   Tue Jan 17 22:17:11 2012(r230288)
@@ -31,7 +31,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 2, 2011
+.Dd January 17, 2012
 .Dt BGE 4
 .Os
 .Sh NAME
@@ -188,7 +188,7 @@ SysKonnect SK-9D21 (10/100/1000baseTX)
 SysKonnect SK-9D41 (1000baseSX)
 .El
 .Sh LOADER TUNABLES
-The following tunable can be set at the
+The following tunables can be set at the
 .Xr loader 8
 prompt before booting the kernel, or stored in
 .Xr loader.conf 5 .
@@ -197,6 +197,9 @@ prompt before booting the kernel, or sto
 Allow the ASF feature for cooperating with IPMI.
 Can cause system lockup problems on a small number of systems.
 Enabled by default.
+.It Va dev.bge.%d.msi_disable
+Non-zero value disables MSI support on the Ethernet hardware.
+The default value is 0.
 .El
 .Sh SYSCTL VARIABLES
 The following variables are available as both
___
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: r230287 - head/bin/ps

2012-01-17 Thread Ed Schouten
Author: ed
Date: Tue Jan 17 22:17:10 2012
New Revision: 230287
URL: http://svn.freebsd.org/changeset/base/230287

Log:
  Remove unused variables.
  
  Simply annotate the function parameters with __unused, instead of adding
  the ve-variables. This makes the code build with GCC 4.7 and -Werror.

Modified:
  head/bin/ps/print.c

Modified: head/bin/ps/print.c
==
--- head/bin/ps/print.c Tue Jan 17 22:15:33 2012(r230286)
+++ head/bin/ps/print.c Tue Jan 17 22:17:10 2012(r230287)
@@ -99,10 +99,8 @@ printheader(void)
 char *
 arguments(KINFO *k, VARENT *ve)
 {
-   VAR *v;
char *vis_args;
 
-   v = ve->var;
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
@@ -116,10 +114,8 @@ arguments(KINFO *k, VARENT *ve)
 char *
 command(KINFO *k, VARENT *ve)
 {
-   VAR *v;
char *vis_args, *vis_env, *str;
 
-   v = ve->var;
if (cflag) {
/* If it is the last field, then don't pad */
if (STAILQ_NEXT(ve, next_ve) == NULL) {
@@ -172,10 +168,8 @@ command(KINFO *k, VARENT *ve)
 char *
 ucomm(KINFO *k, VARENT *ve)
 {
-   VAR *v;
char *str;
 
-   v = ve->var;
if (STAILQ_NEXT(ve, next_ve) == NULL) { /* last field, don't pad */
asprintf(&str, "%s%s%s%s",
k->ki_d.prefix ? k->ki_d.prefix : "",
@@ -192,12 +186,10 @@ ucomm(KINFO *k, VARENT *ve)
 }
 
 char *
-tdnam(KINFO *k, VARENT *ve)
+tdnam(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
char *str;
 
-   v = ve->var;
if (showthreads && k->ki_p->ki_numthreads > 1)
str = strdup(k->ki_p->ki_tdname);
else
@@ -207,28 +199,24 @@ tdnam(KINFO *k, VARENT *ve)
 }
 
 char *
-logname(KINFO *k, VARENT *ve)
+logname(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
 
-   v = ve->var;
if (*k->ki_p->ki_login == '\0')
return (NULL);
return (strdup(k->ki_p->ki_login));
 }
 
 char *
-state(KINFO *k, VARENT *ve)
+state(KINFO *k, VARENT *ve __unused)
 {
int flag, tdflags;
char *cp, *buf;
-   VAR *v;
 
buf = malloc(16);
if (buf == NULL)
errx(1, "malloc failed");
 
-   v = ve->var;
flag = k->ki_p->ki_flag;
tdflags = k->ki_p->ki_tdflags;  /* XXXKSE */
cp = buf;
@@ -294,72 +282,58 @@ state(KINFO *k, VARENT *ve)
 #definescalepri(x) ((x) - PZERO)
 
 char *
-pri(KINFO *k, VARENT *ve)
+pri(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
char *str;
 
-   v = ve->var;
asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_level));
return (str);
 }
 
 char *
-upr(KINFO *k, VARENT *ve)
+upr(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
char *str;
 
-   v = ve->var;
asprintf(&str, "%d", scalepri(k->ki_p->ki_pri.pri_user));
return (str);
 }
 #undef scalepri
 
 char *
-uname(KINFO *k, VARENT *ve)
+uname(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
 
-   v = ve->var;
return (strdup(user_from_uid(k->ki_p->ki_uid, 0)));
 }
 
 char *
-egroupname(KINFO *k, VARENT *ve)
+egroupname(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
 
-   v = ve->var;
return (strdup(group_from_gid(k->ki_p->ki_groups[0], 0)));
 }
 
 char *
-rgroupname(KINFO *k, VARENT *ve)
+rgroupname(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
 
-   v = ve->var;
return (strdup(group_from_gid(k->ki_p->ki_rgid, 0)));
 }
 
 char *
-runame(KINFO *k, VARENT *ve)
+runame(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
 
-   v = ve->var;
return (strdup(user_from_uid(k->ki_p->ki_ruid, 0)));
 }
 
 char *
-tdev(KINFO *k, VARENT *ve)
+tdev(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
dev_t dev;
char *str;
 
-   v = ve->var;
dev = k->ki_p->ki_tdev;
if (dev == NODEV)
str = strdup("-");
@@ -370,13 +344,11 @@ tdev(KINFO *k, VARENT *ve)
 }
 
 char *
-tname(KINFO *k, VARENT *ve)
+tname(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
dev_t dev;
char *ttname, *str;
 
-   v = ve->var;
dev = k->ki_p->ki_tdev;
if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
str = strdup("- ");
@@ -394,13 +366,11 @@ tname(KINFO *k, VARENT *ve)
 }
 
 char *
-longtname(KINFO *k, VARENT *ve)
+longtname(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
dev_t dev;
const char *ttname;
 
-   v = ve->var;
dev = k->ki_p->ki_tdev;
if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL)
ttname = "-";
@@ -409,9 +379,8 @@ longtname(KINFO *k, VARENT *ve)
 }
 
 char *
-started(KINFO *k, VARENT *ve)
+started(KINFO *k, VARENT *ve __unused)
 {
-   VAR *v;
time_t then;
struct tm *tp;
  

svn commit: r230286 - head/sys/dev/bge

2012-01-17 Thread Pyun YongHyeon
Author: yongari
Date: Tue Jan 17 22:15:33 2012
New Revision: 230286
URL: http://svn.freebsd.org/changeset/base/230286

Log:
  Introduce a tunable that disables use of MSI.
  Non-zero value will use INTx.

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Tue Jan 17 22:09:33 2012(r230285)
+++ head/sys/dev/bge/if_bge.c   Tue Jan 17 22:15:33 2012(r230286)
@@ -2745,6 +2745,9 @@ bge_can_use_msi(struct bge_softc *sc)
 {
int can_use_msi = 0;
 
+   if (sc->bge_msi_disable != 0)
+   return (0);
+
/* Disable MSI for polling(4). */
 #ifdef DEVICE_POLLING
return (0);
@@ -5627,6 +5630,12 @@ bge_add_sysctls(struct bge_softc *sc)
"Number of fragmented TX buffers of a frame allowed before "
"forced collapsing");
 
+   sc->bge_msi_disable = 0;
+   snprintf(tn, sizeof(tn), "dev.bge.%d.msi_disable", unit);
+   TUNABLE_INT_FETCH(tn, &sc->bge_msi_disable);
+   SYSCTL_ADD_INT(ctx, children, OID_AUTO, "msi_disable",
+   CTLFLAG_RD, &sc->bge_msi_disable, 0, "Disable MSI");
+
/*
 * It seems all Broadcom controllers have a bug that can generate UDP
 * datagrams with checksum value 0 when TX UDP checksum offloading is

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hTue Jan 17 22:09:33 2012
(r230285)
+++ head/sys/dev/bge/if_bgereg.hTue Jan 17 22:15:33 2012
(r230286)
@@ -2864,6 +2864,7 @@ struct bge_softc {
int bge_timer;
int bge_forced_collapse;
int bge_forced_udpcsum;
+   int bge_msi_disable;
int bge_csum_features;
struct callout  bge_stat_ch;
uint32_tbge_rx_discards;
___
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: r230281 - in head/libexec/rtld-elf: amd64 i386

2012-01-17 Thread Ed Schouten
Author: ed
Date: Tue Jan 17 21:55:20 2012
New Revision: 230281
URL: http://svn.freebsd.org/changeset/base/230281

Log:
  Remove unneeded dtv variable.
  
  It is only assigned and not used at all. The object files stay identical
  when the variables are removed.
  
  Approved by:  kib

Modified:
  head/libexec/rtld-elf/amd64/reloc.c
  head/libexec/rtld-elf/i386/reloc.c

Modified: head/libexec/rtld-elf/amd64/reloc.c
==
--- head/libexec/rtld-elf/amd64/reloc.c Tue Jan 17 20:56:12 2012
(r230280)
+++ head/libexec/rtld-elf/amd64/reloc.c Tue Jan 17 21:55:20 2012
(r230281)
@@ -487,10 +487,8 @@ allocate_initial_tls(Obj_Entry *objs)
 void *__tls_get_addr(tls_index *ti)
 {
 Elf_Addr** segbase;
-Elf_Addr* dtv;
 
 __asm __volatile("movq %%fs:0, %0" : "=r" (segbase));
-dtv = segbase[1];
 
 return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset);
 }

Modified: head/libexec/rtld-elf/i386/reloc.c
==
--- head/libexec/rtld-elf/i386/reloc.c  Tue Jan 17 20:56:12 2012
(r230280)
+++ head/libexec/rtld-elf/i386/reloc.c  Tue Jan 17 21:55:20 2012
(r230281)
@@ -444,10 +444,8 @@ __attribute__((__regparm__(1)))
 void *___tls_get_addr(tls_index *ti)
 {
 Elf_Addr** segbase;
-Elf_Addr* dtv;
 
 __asm __volatile("movl %%gs:0, %0" : "=r" (segbase));
-dtv = segbase[1];
 
 return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset);
 }
@@ -456,10 +454,8 @@ void *___tls_get_addr(tls_index *ti)
 void *__tls_get_addr(tls_index *ti)
 {
 Elf_Addr** segbase;
-Elf_Addr* dtv;
 
 __asm __volatile("movl %%gs:0, %0" : "=r" (segbase));
-dtv = segbase[1];
 
 return tls_get_addr_common(&segbase[1], ti->ti_module, ti->ti_offset);
 }
___
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: r228790 - in head/usr.sbin: fwcontrol newsyslog ypserv

2012-01-17 Thread Eitan Adler
On Tue, Jan 17, 2012 at 3:57 PM, Hiroki Sato  wrote:
>  I suspects you did not test ypserv after this change.  Freeing the
>  pointer sname at the end of create_service() is completely wrong and
>  probably people get the following error message when invoking ypserv:
>
>  getaddrinfo(): servname not supported for ai_socktype

Already on my list of things to fix - thanks for the report!


-- 
Eitan Adler
Ports committer
X11, Bugbusting teams
___
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: r228790 - in head/usr.sbin: fwcontrol newsyslog ypserv

2012-01-17 Thread Hiroki Sato
Eitan Adler  wrote
  in <201112212027.pblkrfpk084...@svn.freebsd.org>:

ea> Author: eadler (ports committer)
ea> Date: Wed Dec 21 20:27:41 2011
ea> New Revision: 228790
ea> URL: http://svn.freebsd.org/changeset/base/228790
ea>
ea> Log:
ea>   - Remove extraneous null ptr deref checks
ea>   - Fix memory leak
ea>
ea>   Submitted by: Slono Slono 
ea>   Approved by:  jhb
ea>   MFC after:1 week
ea>
ea> Modified:
ea>   head/usr.sbin/fwcontrol/fwcontrol.c
ea>   head/usr.sbin/newsyslog/newsyslog.c
ea>   head/usr.sbin/ypserv/yp_main.c

 I suspects you did not test ypserv after this change.  Freeing the
 pointer sname at the end of create_service() is completely wrong and
 probably people get the following error message when invoking ypserv:

  getaddrinfo(): servname not supported for ai_socktype

-- Hiroki


pgpa3Lywevy6A.pgp
Description: PGP signature


svn commit: r230279 - head/usr.sbin/ypserv

2012-01-17 Thread Hiroki Sato
Author: hrs
Date: Tue Jan 17 20:39:33 2012
New Revision: 230279
URL: http://svn.freebsd.org/changeset/base/230279

Log:
  Revert changes in r228790.  It prevented the ypserv daemon from working with
  with multiple socktypes.

Modified:
  head/usr.sbin/ypserv/yp_main.c

Modified: head/usr.sbin/ypserv/yp_main.c
==
--- head/usr.sbin/ypserv/yp_main.c  Tue Jan 17 20:22:10 2012
(r230278)
+++ head/usr.sbin/ypserv/yp_main.c  Tue Jan 17 20:39:33 2012
(r230279)
@@ -256,7 +256,6 @@ create_service(const int sock, const str
const struct __rpc_sockinfo *si)
 {
int error;
-   char *sname;
 
SVCXPRT *transp;
struct addrinfo hints, *res, *res0;
@@ -264,7 +263,6 @@ create_service(const int sock, const str
struct bindaddrlistent *blep;
struct netbuf svcaddr;
 
-   sname = NULL;
SLIST_INIT(&sle_head);
memset(&hints, 0, sizeof(hints));
memset(&svcaddr, 0, sizeof(svcaddr));
@@ -344,6 +342,7 @@ create_service(const int sock, const str
if (strncmp("0", servname, 1) == 0) {
struct sockaddr *sap;
socklen_t slen;
+   char *sname;
 
sname = malloc(NI_MAXSERV);
if (sname == NULL) {
@@ -444,7 +443,6 @@ create_service(const int sock, const str
}
/* XXX: ignore error intentionally */
rpcb_set(YPPROG, YPVERS, nconf, &svcaddr);
-   free(sname);
freeaddrinfo(res0);
return 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: r230277 - head/sys/sys

2012-01-17 Thread Ed Schouten
* Ed Schouten , 20120117 21:21:
> Don't expose __generic() when not using C++.

d'oh! I mean the opposite. Don't expose __generic() when using C++.

-- 
 Ed Schouten 
 WWW: http://80386.nl/


pgpr5swLoYMJB.pgp
Description: PGP signature


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

2012-01-17 Thread John Baldwin
On Tuesday, January 17, 2012 2:22:26 pm Scott Long wrote:
> On Jan 17, 2012, at 8:08 AM, John Baldwin wrote:
> > On Sunday, January 15, 2012 6:32:43 pm Colin Percival wrote:
> >> On 01/15/12 15:28, John Baldwin wrote:
> >>> On 1/15/12 2:09 AM, Eitan Adler wrote:
>  Log:
>   - Fix undefined behavior when device_get_name is null
>   - Make error message more informative
> >>> 
> >>> The in-kernel printf(9) always prints "(null)" for %s when the pointer is 
> >>> NULL,
> >>> so that wasn't undefined behavior.  Printing out the driver name is a 
> >>> useful
> >>> change, but the "(unknown)" bits are just noise as it isn't clear that
> >>> "(unknown)" is substantially better than "(null)".
> >> 
> >> I think the change from "(null)" to "(unknown)" is useful, since when I see
> >> "(null)" printed my immediate thought is "looks like there's a bug I need 
> >> to
> >> track down here".
> > 
> > The entire printf is "there's a bug I need to track down here".  (null)
> > explicitly tells me that device_get_name() is NULL when looking at the 
> > printf
> > to see what it means.  Having it be (unknown) tells me the same exact thing,
> > but only after I've parsed an extra 2-3 lines of code to figure out what
> > (unknown) stands for.
> > 
> 
> I like that change.  "null" is ambiguous for those who aren't intimately 
> familiar with the bus code.

Bruce suggested in another e-mail that the entire printf should be using
device_printf() instead which would also use 'unknown', but spelled slightly
differently (and consistent with other device messages).

-- 
John Baldwin
___
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: r230278 - head/include

2012-01-17 Thread Ed Schouten
Author: ed
Date: Tue Jan 17 20:22:10 2012
New Revision: 230278
URL: http://svn.freebsd.org/changeset/base/230278

Log:
  Only use the static assertion when __generic is available.
  
  Reported by:  tijl

Modified:
  head/include/complex.h

Modified: head/include/complex.h
==
--- head/include/complex.h  Tue Jan 17 20:21:31 2012(r230277)
+++ head/include/complex.h  Tue Jan 17 20:22:10 2012(r230278)
@@ -36,6 +36,9 @@
 #define_Complex__complex__
 #endif
 #define_Complex_I  ((float _Complex)1.0i)
+#endif
+
+#ifdef __generic
 _Static_assert(__generic(_Complex_I, float _Complex, 1, 0),
 "_Complex_I must be of type float _Complex");
 #endif
___
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: r230277 - head/sys/sys

2012-01-17 Thread Ed Schouten
Author: ed
Date: Tue Jan 17 20:21:31 2012
New Revision: 230277
URL: http://svn.freebsd.org/changeset/base/230277

Log:
  Don't expose __generic() when not using C++.
  
  According to the GCC documentation, the constructs used to implement
   are only available in C mode. They only cause breakage when
  used used with g++.
  
  Reported by:  tijl

Modified:
  head/sys/sys/cdefs.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hTue Jan 17 19:36:53 2012(r230276)
+++ head/sys/sys/cdefs.hTue Jan 17 20:21:31 2012(r230277)
@@ -260,7 +260,7 @@
 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
 #define__generic(expr, t, yes, no) 
\
_Generic(expr, t: yes, default: no)
-#elif __GNUC_PREREQ__(3, 1)
+#elif __GNUC_PREREQ__(3, 1) && !defined(__cplusplus)
 #define__generic(expr, t, yes, no) 
\
__builtin_choose_expr(  \
__builtin_types_compatible_p(__typeof(expr), t), yes, no)
___
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: r230125 - head/sys/kern

2012-01-17 Thread Scott Long
On Jan 17, 2012, at 8:08 AM, John Baldwin wrote:
> On Sunday, January 15, 2012 6:32:43 pm Colin Percival wrote:
>> On 01/15/12 15:28, John Baldwin wrote:
>>> On 1/15/12 2:09 AM, Eitan Adler wrote:
 Log:
  - Fix undefined behavior when device_get_name is null
  - Make error message more informative
>>> 
>>> The in-kernel printf(9) always prints "(null)" for %s when the pointer is 
>>> NULL,
>>> so that wasn't undefined behavior.  Printing out the driver name is a useful
>>> change, but the "(unknown)" bits are just noise as it isn't clear that
>>> "(unknown)" is substantially better than "(null)".
>> 
>> I think the change from "(null)" to "(unknown)" is useful, since when I see
>> "(null)" printed my immediate thought is "looks like there's a bug I need to
>> track down here".
> 
> The entire printf is "there's a bug I need to track down here".  (null)
> explicitly tells me that device_get_name() is NULL when looking at the printf
> to see what it means.  Having it be (unknown) tells me the same exact thing,
> but only after I've parsed an extra 2-3 lines of code to figure out what
> (unknown) stands for.
> 

I like that change.  "null" is ambiguous for those who aren't intimately 
familiar with the bus code.

Scott


___
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: r230276 - head/sys/dev/re

2012-01-17 Thread Pyun YongHyeon
Author: yongari
Date: Tue Jan 17 19:36:53 2012
New Revision: 230276
URL: http://svn.freebsd.org/changeset/base/230276

Log:
  Free allocated jumbo buffers when controller is stopped.

Modified:
  head/sys/dev/re/if_re.c

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Tue Jan 17 19:31:03 2012(r230275)
+++ head/sys/dev/re/if_re.c Tue Jan 17 19:36:53 2012(r230276)
@@ -3558,7 +3558,6 @@ re_stop(struct rl_softc *sc)
}
 
/* Free the TX list buffers. */
-
for (i = 0; i < sc->rl_ldata.rl_tx_desc_cnt; i++) {
txd = &sc->rl_ldata.rl_tx_desc[i];
if (txd->tx_m != NULL) {
@@ -3572,7 +3571,6 @@ re_stop(struct rl_softc *sc)
}
 
/* Free the RX list buffers. */
-
for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) {
rxd = &sc->rl_ldata.rl_rx_desc[i];
if (rxd->rx_m != NULL) {
@@ -3584,6 +3582,20 @@ re_stop(struct rl_softc *sc)
rxd->rx_m = NULL;
}
}
+
+   if ((sc->rl_flags & RL_FLAG_JUMBOV2) != 0) {
+   for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) {
+   rxd = &sc->rl_ldata.rl_jrx_desc[i];
+   if (rxd->rx_m != NULL) {
+   bus_dmamap_sync(sc->rl_ldata.rl_jrx_mtag,
+   rxd->rx_dmamap, BUS_DMASYNC_POSTREAD);
+   bus_dmamap_unload(sc->rl_ldata.rl_jrx_mtag,
+   rxd->rx_dmamap);
+   m_freem(rxd->rx_m);
+   rxd->rx_m = 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: r230275 - head/sys/dev/re

2012-01-17 Thread Pyun YongHyeon
Author: yongari
Date: Tue Jan 17 19:31:03 2012
New Revision: 230275
URL: http://svn.freebsd.org/changeset/base/230275

Log:
  Use a RX DMA tag to free loaded RX DMA maps.
  Previously it used a TX DMA tag.

Modified:
  head/sys/dev/re/if_re.c

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Tue Jan 17 18:54:50 2012(r230274)
+++ head/sys/dev/re/if_re.c Tue Jan 17 19:31:03 2012(r230275)
@@ -3576,7 +3576,7 @@ re_stop(struct rl_softc *sc)
for (i = 0; i < sc->rl_ldata.rl_rx_desc_cnt; i++) {
rxd = &sc->rl_ldata.rl_rx_desc[i];
if (rxd->rx_m != NULL) {
-   bus_dmamap_sync(sc->rl_ldata.rl_tx_mtag,
+   bus_dmamap_sync(sc->rl_ldata.rl_rx_mtag,
rxd->rx_dmamap, BUS_DMASYNC_POSTREAD);
bus_dmamap_unload(sc->rl_ldata.rl_rx_mtag,
rxd->rx_dmamap);
___
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: r230125 - head/sys/kern

2012-01-17 Thread Doug Barton
On 01/17/2012 10:48, John Baldwin wrote:
> On Tuesday, January 17, 2012 12:29:06 pm Andriy Gapon wrote:
>> on 17/01/2012 19:12 Eitan Adler said the following:
>>> To me seeing "(null)" from the output of printf indicates "There is a
>>> bug here, printf should never be given a NULL argument.".
>>> However, given that it isn't undefined here, and the objections I've
>>> received I will revert this part of the change when I get home.
>>
>> Would this be worth the hassle now that the change is already committed?
> 
> Probably not, though at some point if the printf is reworked for some other
> reason it could be removed then.  I don't think we need to add more special
> case handling for NULL string pointers passed to kernel printf in the future,
> however.

If it needs to be changed, it should be done sooner than later. It's not
as if we're carving the bits out of stone after all. :)



-- 

It's always a long day; 86400 doesn't fit into a short.

Breadth of IT experience, and depth of knowledge in the DNS.
Yours for the right price.  :)  http://SupersetSolutions.com/

___
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: r230125 - head/sys/kern

2012-01-17 Thread John Baldwin
On Tuesday, January 17, 2012 12:29:06 pm Andriy Gapon wrote:
> on 17/01/2012 19:12 Eitan Adler said the following:
> > To me seeing "(null)" from the output of printf indicates "There is a
> > bug here, printf should never be given a NULL argument.".
> > However, given that it isn't undefined here, and the objections I've
> > received I will revert this part of the change when I get home.
> 
> Would this be worth the hassle now that the change is already committed?

Probably not, though at some point if the printf is reworked for some other
reason it could be removed then.  I don't think we need to add more special
case handling for NULL string pointers passed to kernel printf in the future,
however.

-- 
John Baldwin
___
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: r230273 - head/sys/modules/wtap

2012-01-17 Thread Adrian Chadd
Author: adrian
Date: Tue Jan 17 18:20:34 2012
New Revision: 230273
URL: http://svn.freebsd.org/changeset/base/230273

Log:
  Tidy-up.

Modified:
  head/sys/modules/wtap/Makefile

Modified: head/sys/modules/wtap/Makefile
==
--- head/sys/modules/wtap/Makefile  Tue Jan 17 18:10:25 2012
(r230272)
+++ head/sys/modules/wtap/Makefile  Tue Jan 17 18:20:34 2012
(r230273)
@@ -1,11 +1,11 @@
 # $FreeBSD$
 
-.PATH: ${.CURDIR}/../../dev/wtap
 
 # Declare Name of kernel module
 KMOD   =  wtap
 
 # Enumerate Source files for kernel module
+.PATH: ${.CURDIR}/../../dev/wtap
 SRCS   =  if_wtap_module.c if_wtap.c if_medium.c
 
 .PATH: ${.CURDIR}/../../dev/wtap/wtap_hal
___
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: r230272 - head/sys/netgraph

2012-01-17 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jan 17 18:10:25 2012
New Revision: 230272
URL: http://svn.freebsd.org/changeset/base/230272

Log:
  The newhook method can be called in ISR context at
  certain circumstances, so better use M_NOWAIT in it.

Modified:
  head/sys/netgraph/ng_tag.c

Modified: head/sys/netgraph/ng_tag.c
==
--- head/sys/netgraph/ng_tag.c  Tue Jan 17 18:05:13 2012(r230271)
+++ head/sys/netgraph/ng_tag.c  Tue Jan 17 18:10:25 2012(r230272)
@@ -303,8 +303,9 @@ ng_tag_newhook(node_p node, hook_p hook,
int error;
 
/* Create hook private structure. */
-   hip = malloc(sizeof(*hip), M_NETGRAPH_TAG, M_WAITOK | M_ZERO);
-   /* M_WAITOK can't return NULL. */
+   hip = malloc(sizeof(*hip), M_NETGRAPH_TAG, M_NOWAIT | M_ZERO);
+   if (hip == NULL)
+   return (ENOMEM);
NG_HOOK_SET_PRIVATE(hook, hip);
 
/*
___
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: r230265 - head/sys/contrib/pf/net

2012-01-17 Thread Gleb Smirnoff
On Tue, Jan 17, 2012 at 05:48:10PM +0100, Ermal Lu?i wrote:
E> Maybe it does not hurt in general to keep the V_
E> Some work was done to add it, no?!

The V_ has been left under __FreeBSD__.

E> On Tue, Jan 17, 2012 at 1:14 PM, Gleb Smirnoff  wrote:
E> 
E> > Author: glebius
E> > Date: Tue Jan 17 12:14:26 2012
E> > New Revision: 230265
E> > URL: http://svn.freebsd.org/changeset/base/230265
E> >
E> > Log:
E> >  Allocate our mbuf with m_get2().
E> >
E> > Modified:
E> >  head/sys/contrib/pf/net/if_pfsync.c
E> >
E> > Modified: head/sys/contrib/pf/net/if_pfsync.c
E> >
E> > 
==
E> > --- head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:13:36 2012
E> >  (r230264)
E> > +++ head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:14:26 2012
E> >  (r230265)
E> > @@ -2121,9 +2121,6 @@ pfsync_sendout(void)
E> >  #ifdef notyet
E> >struct tdb *t;
E> >  #endif
E> > -#ifdef __FreeBSD__
E> > -   size_t pktlen;
E> > -#endif
E> >int offset;
E> >int q, count = 0;
E> >
E> > @@ -2145,44 +2142,33 @@ pfsync_sendout(void)
E> >return;
E> >}
E> >
E> > -   MGETHDR(m, M_DONTWAIT, MT_DATA);
E> > -   if (m == NULL) {
E> >  #ifdef __FreeBSD__
E> > +   m = m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr + sc->sc_len);
E> > +   if (m == NULL) {
E> >sc->sc_ifp->if_oerrors++;
E> > +   V_pfsyncstats.pfsyncs_onomem++;
E> > +   return;
E> > +   }
E> >  #else
E> > +   MGETHDR(m, M_DONTWAIT, MT_DATA);
E> > +   if (m == NULL) {
E> >sc->sc_if.if_oerrors++;
E> > -#endif
E> > -   V_pfsyncstats.pfsyncs_onomem++;
E> > +   pfsyncstats.pfsyncs_onomem++;
E> >pfsync_drop(sc);
E> >return;
E> >}
E> >
E> > -#ifdef __FreeBSD__
E> > -   pktlen = max_linkhdr + sc->sc_len;
E> > -   if (pktlen > MHLEN) {
E> > -   /* Find the right pool to allocate from. */
E> > -   /* XXX: This is ugly. */
E> > -   m_cljget(m, M_DONTWAIT, pktlen <= MCLBYTES ? MCLBYTES :
E> > -#if MJUMPAGESIZE != MCLBYTES
E> > -   pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE :
E> > -#endif
E> > -   pktlen <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES);
E> > -#else
E> >if (max_linkhdr + sc->sc_len > MHLEN) {
E> >MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len);
E> > -#endif
E> >if (!ISSET(m->m_flags, M_EXT)) {
E> >m_free(m);
E> > -#ifdef __FreeBSD__
E> > -   sc->sc_ifp->if_oerrors++;
E> > -#else
E> >sc->sc_if.if_oerrors++;
E> > -#endif
E> > -   V_pfsyncstats.pfsyncs_onomem++;
E> > +   pfsyncstats.pfsyncs_onomem++;
E> >pfsync_drop(sc);
E> >return;
E> >}
E> >}
E> > +#endif
E> >m->m_data += max_linkhdr;
E> >m->m_len = m->m_pkthdr.len = sc->sc_len;
E> >
E> >
E> 
E> 
E> -- 
E> Ermal

-- 
Totus tuus, Glebius.
___
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: r230252 - head/sys/fs/tmpfs

2012-01-17 Thread Jaakko Heinonen
On 2012-01-17, Kevin Lo wrote:
>   Return EOPNOTSUPP since we only support update mounts for NFS export.
>   
> @@ -150,8 +150,12 @@ tmpfs_mount(struct mount *mp)
>   return (EINVAL);
>  
>   if (mp->mnt_flag & MNT_UPDATE) {
> + /*
> +  * Only support update mounts for NFS export.
> +  */
>   if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0))
>   return (0);
> + return (EOPNOTSUPP);
>   }

This doesn't look correct. As long as the option list includes the
"export" option, all options are accepted. An example:

# mount -u -o ro /mnt
mount: tmpfs : Operation not supported
# mount -u -o ro,export /mnt
#

-- 
Jaakko
___
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: r230125 - head/sys/kern

2012-01-17 Thread Andriy Gapon
on 17/01/2012 19:12 Eitan Adler said the following:
> To me seeing "(null)" from the output of printf indicates "There is a
> bug here, printf should never be given a NULL argument.".
> However, given that it isn't undefined here, and the objections I've
> received I will revert this part of the change when I get home.

Would this be worth the hassle now that the change is already committed?

-- 
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: r230025 - head/contrib/compiler-rt/lib/sparc64

2012-01-17 Thread Marius Strobl
On Tue, Jan 17, 2012 at 03:55:05PM +0100, Ed Schouten wrote:
> Hi Marius,
> 
> * Marius Strobl , 20120113 01:00:
> > Uhm, these are V8-specific, for V9 the C compiler frame size should
> > be 192 instead of 64 and the function alignment should be 32 instead
> > of 4 bytes (at least with GCC and US1-optimizations enabled as we
> > default to on sparc64), see . However, given that
> > these functions only seem to obtain new register window for
> > debugging purposes you probably alternatively could just remove
> > the saves and the corresponding restores completely.
> 
> Any comments on the attached patch?
> 

Index: divmod.m4
===
--- divmod.m4   (revision 230265)
+++ divmod.m4   (working copy)
@@ -235,7 +236,6 @@
 got_result:
tst SIGN
bge 1f
-   restore
! answer < 0
retl! leaf-routine return
 ifelse( ANSWER, `quotient',

Sorry, on closer inspection you cannot just litteraly remove the
restore in this case. The problem is that both bge and retl are
delayed control-transfer instructions and the restore is done in
the delay slot of the bge, which means it's actually execetuted
before the branch (in FreeBSD source we usually mark this via an
additional space character before the instruction in a delay slot
so it's easier to spot). If you just remove the restore retl is
now in the delay slot of bge, which gives wrong behavior. You
therefore either need to replace it with a nop or you can actually
take advantage of the delay slots like done in the attached patch
(untested).

Marius

Index: divmod.m4
===
--- divmod.m4	(revision 230267)
+++ divmod.m4	(working copy)
@@ -59,9 +59,6 @@ define(SC,`%g2')
 
 #include "../assembly.h"
 
-.text
-	.align 4
-
 define(DEVELOP_QUOTIENT_BITS,
 `	!depth $1, accumulated bits $2
 	bl	L.$1.eval(TWOSUPN+$2)
@@ -84,12 +81,14 @@ L.$1.eval(TWOSUPN+$2):
 	ifelse( $1, 1, `9:')
 ')
 ifelse( ANSWER, `quotient', `
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__udivsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	b	divide
 	mov	0,SIGN			! result always nonnegative
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__divsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	orcc	divisor,dividend,%g0	! are either dividend or divisor negative
 	bge	divide			! if not, skip this junk
 	xor	divisor,dividend,SIGN	! record sign of result in sign of SIGN
@@ -104,12 +103,14 @@ DEFINE_COMPILERRT_FUNCTION(__divsi3)
 	neg	dividend
 	! FALL THROUGH
 ',`
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__umodsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	b	divide
 	mov	0,SIGN			! result always nonnegative
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__modsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	orcc	divisor,dividend,%g0	! are either dividend or divisor negative
 	bge	divide			! if not, skip this junk
 	mov	dividend,SIGN		! record sign of result in sign of SIGN
@@ -184,8 +185,8 @@ do_single_div:
 	nop
 	sub	R,V,R
 	mov	1,Q
-	b	end_single_divloop
-	nop
+	b,a	end_single_divloop
+	! EMPTY
 single_divloop:
 	sll	Q,1,Q
 	bl	1f
@@ -202,8 +203,8 @@ single_divloop:
 		deccc	SC
 		bge	single_divloop
 		tst	R
-		b	end_regular_divide
-		nop
+		b,a	end_regular_divide
+		! EMPTY
 
 not_really_big:
 1:
@@ -224,9 +225,8 @@ end_regular_divide:
 	deccc	ITER
 	bge	divloop
 	tst	R
-	bge	got_result
-	nop
-	! non-restoring fixup here
+	bl,a	got_result
+	! non-restoring fixup if remainder < 0, otherwise annulled
 ifelse( ANSWER, `quotient',
 `	dec	Q
 ',`	add	R,divisor,R
@@ -234,13 +234,11 @@ ifelse( ANSWER, `quotient',
 
 got_result:
 	tst	SIGN
-	bge	1f
-	restore
-	! answer < 0
-	retl! leaf-routine return
+	bl,a	1f
+	! negate for answer < 0, otherwise annulled
 ifelse( ANSWER, `quotient',
-`	neg	%o2,%o0			! quotient <- -Q
-',`	neg	%o3,%o0 		! remainder <- -R
+`	neg	%o2,%o2			! Q <- -Q
+',`	neg	%o3,%o3 		! R <- -R
 ')
 1:
 	retl! leaf-routine return
___
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: r230125 - head/sys/kern

2012-01-17 Thread Eitan Adler
On Tue, Jan 17, 2012 at 10:08 AM, John Baldwin  wrote:
> On Sunday, January 15, 2012 6:32:43 pm Colin Percival wrote:
>> On 01/15/12 15:28, John Baldwin wrote:
>> > On 1/15/12 2:09 AM, Eitan Adler wrote:
>> >> Log:
>> >>    - Fix undefined behavior when device_get_name is null
>> >>    - Make error message more informative
>> >
>> > The in-kernel printf(9) always prints "(null)" for %s when the pointer is 
>> > NULL,
>> > so that wasn't undefined behavior.  Printing out the driver name is a 
>> > useful
>> > change, but the "(unknown)" bits are just noise as it isn't clear that
>> > "(unknown)" is substantially better than "(null)".
>>
>> I think the change from "(null)" to "(unknown)" is useful, since when I see
>> "(null)" printed my immediate thought is "looks like there's a bug I need to
>> track down here".
>
> The entire printf is "there's a bug I need to track down here".  (null)
> explicitly tells me that device_get_name() is NULL when looking at the printf
> to see what it means.  Having it be (unknown) tells me the same exact thing,
> but only after I've parsed an extra 2-3 lines of code to figure out what
> (unknown) stands for.

To me seeing "(null)" from the output of printf indicates "There is a
bug here, printf should never be given a NULL argument.".
However, given that it isn't undefined here, and the objections I've
received I will revert this part of the change when I get home.


-- 
Eitan Adler
Ports committer
X11, Bugbusting teams
___
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: r230270 - in head/sys: amd64/include i386/include

2012-01-17 Thread Konstantin Belousov
Author: kib
Date: Tue Jan 17 17:07:13 2012
New Revision: 230270
URL: http://svn.freebsd.org/changeset/base/230270

Log:
  Add definitions for the FPU extended state header, legacy extended
  state and AVX state.
  
  MFC after:1 week

Modified:
  head/sys/amd64/include/fpu.h
  head/sys/i386/include/npx.h

Modified: head/sys/amd64/include/fpu.h
==
--- head/sys/amd64/include/fpu.hTue Jan 17 16:53:41 2012
(r230269)
+++ head/sys/amd64/include/fpu.hTue Jan 17 17:07:13 2012
(r230270)
@@ -78,6 +78,28 @@ struct  savefpu {
uint8_t sv_pad[96];
 } __aligned(16);
 
+struct xstate_hdr {
+   uint64_t xstate_bv;
+   uint8_t xstate_rsrv0[16];
+   uint8_t xstate_rsrv[40];
+};
+
+struct savefpu_xstate {
+   struct xstate_hdr sx_hd;
+   struct ymmacc   sx_ymm[16];
+};
+
+struct savefpu_ymm {
+   struct  envxmm  sv_env;
+   struct {
+   struct fpacc87  fp_acc;
+   int8_t  fp_pad[6];  /* padding */
+   } sv_fp[8];
+   struct xmmacc   sv_xmm[16];
+   uint8_t sv_pad[96];
+   struct savefpu_xstate sv_xstate;
+} __aligned(64);
+
 #ifdef _KERNEL
 struct fpu_kern_ctx {
struct savefpu hwstate;

Modified: head/sys/i386/include/npx.h
==
--- head/sys/i386/include/npx.h Tue Jan 17 16:53:41 2012(r230269)
+++ head/sys/i386/include/npx.h Tue Jan 17 17:07:13 2012(r230270)
@@ -101,6 +101,11 @@ struct  xmmacc {
u_char  xmm_bytes[16];
 };
 
+/* Contents of the upper 16 bytes of each AVX extended accumulator */
+struct  ymmacc {
+   uint8_t  ymm_bytes[16];
+};
+
 struct  savexmm {
struct  envxmm  sv_env;
struct {
@@ -116,6 +121,28 @@ union  savefpu {
struct  savexmm sv_xmm;
 };
 
+struct xstate_hdr {
+   uint64_t xstate_bv;
+   uint8_t xstate_rsrv0[16];
+   uint8_t xstate_rsrv[40];
+};
+
+struct savexmm_xstate {
+   struct xstate_hdr sx_hd;
+   struct ymmacc   sx_ymm[16];
+};
+
+struct savexmm_ymm {
+   struct  envxmm  sv_env;
+   struct {
+   struct fpacc87  fp_acc;
+   int8_t  fp_pad[6];  /* padding */
+   } sv_fp[8];
+   struct xmmacc   sv_xmm[16];
+   uint8_t sv_pad[96];
+   struct savexmm_xstate sv_xstate;
+} __aligned(64);
+
 /*
  * The hardware default control word for i387's and later coprocessors is
  * 0x37F, giving:
___
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: r230269 - head/sys/amd64/include

2012-01-17 Thread Konstantin Belousov
Author: kib
Date: Tue Jan 17 16:53:41 2012
New Revision: 230269
URL: http://svn.freebsd.org/changeset/base/230269

Log:
  Modernize the fpusave structures definitions by using uint*_t types.
  
  MFC after:1 week

Modified:
  head/sys/amd64/include/fpu.h

Modified: head/sys/amd64/include/fpu.h
==
--- head/sys/amd64/include/fpu.hTue Jan 17 16:20:50 2012
(r230268)
+++ head/sys/amd64/include/fpu.hTue Jan 17 16:53:41 2012
(r230269)
@@ -43,34 +43,39 @@
 
 /* Contents of each x87 floating point accumulator */
 struct fpacc87 {
-   u_char  fp_bytes[10];
+   uint8_t fp_bytes[10];
 };
 
 /* Contents of each SSE extended accumulator */
 struct  xmmacc {
-   u_char  xmm_bytes[16];
+   uint8_t xmm_bytes[16];
+};
+
+/* Contents of the upper 16 bytes of each AVX extended accumulator */
+struct  ymmacc {
+   uint8_t  ymm_bytes[16];
 };
 
 struct  envxmm {
-   u_int16_t   en_cw;  /* control word (16bits) */
-   u_int16_t   en_sw;  /* status word (16bits) */
-   u_int8_ten_tw;  /* tag word (8bits) */
-   u_int8_ten_zero;
-   u_int16_t   en_opcode;  /* opcode last executed (11 bits ) */
-   u_int64_t   en_rip; /* floating point instruction pointer */
-   u_int64_t   en_rdp; /* floating operand pointer */
-   u_int32_t   en_mxcsr;   /* SSE sontorol/status register */
-   u_int32_t   en_mxcsr_mask;  /* valid bits in mxcsr */
+   uint16_ten_cw;  /* control word (16bits) */
+   uint16_ten_sw;  /* status word (16bits) */
+   uint8_t en_tw;  /* tag word (8bits) */
+   uint8_t en_zero;
+   uint16_ten_opcode;  /* opcode last executed (11 bits ) */
+   uint64_ten_rip; /* floating point instruction pointer */
+   uint64_ten_rdp; /* floating operand pointer */
+   uint32_ten_mxcsr;   /* SSE sontorol/status register */
+   uint32_ten_mxcsr_mask;  /* valid bits in mxcsr */
 };
 
 struct  savefpu {
struct  envxmm  sv_env;
struct {
struct fpacc87  fp_acc;
-   u_char  fp_pad[6];  /* padding */
+   uint8_t fp_pad[6];  /* padding */
} sv_fp[8];
struct xmmacc   sv_xmm[16];
-   u_char sv_pad[96];
+   uint8_t sv_pad[96];
 } __aligned(16);
 
 #ifdef _KERNEL
___
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: r230265 - head/sys/contrib/pf/net

2012-01-17 Thread Ermal Luçi
Maybe it does not hurt in general to keep the V_

Some work was done to add it, no?!

On Tue, Jan 17, 2012 at 1:14 PM, Gleb Smirnoff  wrote:

> Author: glebius
> Date: Tue Jan 17 12:14:26 2012
> New Revision: 230265
> URL: http://svn.freebsd.org/changeset/base/230265
>
> Log:
>  Allocate our mbuf with m_get2().
>
> Modified:
>  head/sys/contrib/pf/net/if_pfsync.c
>
> Modified: head/sys/contrib/pf/net/if_pfsync.c
>
> ==
> --- head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:13:36 2012
>  (r230264)
> +++ head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:14:26 2012
>  (r230265)
> @@ -2121,9 +2121,6 @@ pfsync_sendout(void)
>  #ifdef notyet
>struct tdb *t;
>  #endif
> -#ifdef __FreeBSD__
> -   size_t pktlen;
> -#endif
>int offset;
>int q, count = 0;
>
> @@ -2145,44 +2142,33 @@ pfsync_sendout(void)
>return;
>}
>
> -   MGETHDR(m, M_DONTWAIT, MT_DATA);
> -   if (m == NULL) {
>  #ifdef __FreeBSD__
> +   m = m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr + sc->sc_len);
> +   if (m == NULL) {
>sc->sc_ifp->if_oerrors++;
> +   V_pfsyncstats.pfsyncs_onomem++;
> +   return;
> +   }
>  #else
> +   MGETHDR(m, M_DONTWAIT, MT_DATA);
> +   if (m == NULL) {
>sc->sc_if.if_oerrors++;
> -#endif
> -   V_pfsyncstats.pfsyncs_onomem++;
> +   pfsyncstats.pfsyncs_onomem++;
>pfsync_drop(sc);
>return;
>}
>
> -#ifdef __FreeBSD__
> -   pktlen = max_linkhdr + sc->sc_len;
> -   if (pktlen > MHLEN) {
> -   /* Find the right pool to allocate from. */
> -   /* XXX: This is ugly. */
> -   m_cljget(m, M_DONTWAIT, pktlen <= MCLBYTES ? MCLBYTES :
> -#if MJUMPAGESIZE != MCLBYTES
> -   pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE :
> -#endif
> -   pktlen <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES);
> -#else
>if (max_linkhdr + sc->sc_len > MHLEN) {
>MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len);
> -#endif
>if (!ISSET(m->m_flags, M_EXT)) {
>m_free(m);
> -#ifdef __FreeBSD__
> -   sc->sc_ifp->if_oerrors++;
> -#else
>sc->sc_if.if_oerrors++;
> -#endif
> -   V_pfsyncstats.pfsyncs_onomem++;
> +   pfsyncstats.pfsyncs_onomem++;
>pfsync_drop(sc);
>return;
>}
>}
> +#endif
>m->m_data += max_linkhdr;
>m->m_len = m->m_pkthdr.len = sc->sc_len;
>
>


-- 
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: r230268 - head/sys/kern

2012-01-17 Thread Alan Cox
Author: alc
Date: Tue Jan 17 16:20:50 2012
New Revision: 230268
URL: http://svn.freebsd.org/changeset/base/230268

Log:
  Explain why it is safe to unlock the vnode.
  
  Requested by: kib

Modified:
  head/sys/kern/imgact_elf.c

Modified: head/sys/kern/imgact_elf.c
==
--- head/sys/kern/imgact_elf.c  Tue Jan 17 15:20:41 2012(r230267)
+++ head/sys/kern/imgact_elf.c  Tue Jan 17 16:20:50 2012(r230268)
@@ -800,6 +800,9 @@ __CONCAT(exec_, __elfN(imgact))(struct i
 * than zero.  Consequently, the vnode lock is not needed by vrele().
 * However, in cases where the vnode lock is external, such as nullfs,
 * v_usecount may become zero.
+*
+* The VV_TEXT flag prevents modifications to the executable while
+* the vnode is unlocked.
 */
VOP_UNLOCK(imgp->vp, 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: r230208 - head/sys/fs/tmpfs

2012-01-17 Thread John Baldwin
On Tuesday, January 17, 2012 9:50:15 am John Baldwin wrote:
> On Monday, January 16, 2012 5:25:23 am Kevin Lo wrote:
> > Author: kevlo
> > Date: Mon Jan 16 10:25:22 2012
> > New Revision: 230208
> > URL: http://svn.freebsd.org/changeset/base/230208
> > 
> > Log:
> >   Add nfs export support to tmpfs(5)
> >   
> >   Reviewed by:  kib
> > 
> > Modified:
> >   head/sys/fs/tmpfs/tmpfs_vfsops.c
> > 
> > Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
> > 
> ==
> > --- head/sys/fs/tmpfs/tmpfs_vfsops.cMon Jan 16 09:53:24 2012
> > (r230207)
> > +++ head/sys/fs/tmpfs/tmpfs_vfsops.cMon Jan 16 10:25:22 2012
> > (r230208)
> > @@ -150,10 +150,8 @@ tmpfs_mount(struct mount *mp)
> > return (EINVAL);
> >  
> > if (mp->mnt_flag & MNT_UPDATE) {
> > -   /* XXX: There is no support yet to update file system
> > -* settings.  Should be added. */
> > -
> > -   return EOPNOTSUPP;
> > +   if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0))
> > +   return (0);
> > }
> 
> Is it supposed to fall through if the 'export' option isn't in the list 
> during 
> an update mount?

Nevermind, was supposed to have deleted this from my pending send queue before
it went out.  This was fixed in a subsequent commit.

-- 
John Baldwin
___
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: r230267 - head/include

2012-01-17 Thread David Chisnall
Author: theraven
Date: Tue Jan 17 15:20:41 2012
New Revision: 230267
URL: http://svn.freebsd.org/changeset/base/230267

Log:
  Fix clang atomic to use for atomic_is_lock_free().
  
  Reviewed by:  ed
  Approved by:  dim (mentor)

Modified:
  head/include/stdatomic.h

Modified: head/include/stdatomic.h
==
--- head/include/stdatomic.hTue Jan 17 13:52:04 2012(r230266)
+++ head/include/stdatomic.hTue Jan 17 15:20:41 2012(r230267)
@@ -118,7 +118,7 @@ enum memory_order {
 
 #if defined(__CLANG_ATOMICS)
 #defineatomic_is_lock_free(obj) \
-   __atomic_is_lock_free(obj)
+   __atomic_is_lock_free(sizeof(obj))
 #elif defined(__GNUC_ATOMICS)
 #defineatomic_is_lock_free(obj) \
__atomic_is_lock_free(sizeof((obj)->__val))
___
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: r230125 - head/sys/kern

2012-01-17 Thread John Baldwin
On Sunday, January 15, 2012 6:32:43 pm Colin Percival wrote:
> On 01/15/12 15:28, John Baldwin wrote:
> > On 1/15/12 2:09 AM, Eitan Adler wrote:
> >> Log:
> >>- Fix undefined behavior when device_get_name is null
> >>- Make error message more informative
> > 
> > The in-kernel printf(9) always prints "(null)" for %s when the pointer is 
> > NULL,
> > so that wasn't undefined behavior.  Printing out the driver name is a useful
> > change, but the "(unknown)" bits are just noise as it isn't clear that
> > "(unknown)" is substantially better than "(null)".
> 
> I think the change from "(null)" to "(unknown)" is useful, since when I see
> "(null)" printed my immediate thought is "looks like there's a bug I need to
> track down here".

The entire printf is "there's a bug I need to track down here".  (null)
explicitly tells me that device_get_name() is NULL when looking at the printf
to see what it means.  Having it be (unknown) tells me the same exact thing,
but only after I've parsed an extra 2-3 lines of code to figure out what
(unknown) stands for.

-- 
John Baldwin
___
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: r230201 - head/lib/libc/gen

2012-01-17 Thread John Baldwin
On Monday, January 16, 2012 1:15:14 am David Xu wrote:
> Author: davidxu
> Date: Mon Jan 16 06:15:14 2012
> New Revision: 230201
> URL: http://svn.freebsd.org/changeset/base/230201
> 
> Log:
>   Insert read memory barriers.

I think using atomic_load_acq() on sem->nwaiters would be clearer as it would
indicate which variable you need to ensure is read after other operations.  In
general I think raw rmb/wmb usage should be avoided when possible as it is 
does not describe the programmer's intent as well.

-- 
John Baldwin
___
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: r230208 - head/sys/fs/tmpfs

2012-01-17 Thread John Baldwin
On Monday, January 16, 2012 5:25:23 am Kevin Lo wrote:
> Author: kevlo
> Date: Mon Jan 16 10:25:22 2012
> New Revision: 230208
> URL: http://svn.freebsd.org/changeset/base/230208
> 
> Log:
>   Add nfs export support to tmpfs(5)
>   
>   Reviewed by:kib
> 
> Modified:
>   head/sys/fs/tmpfs/tmpfs_vfsops.c
> 
> Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
> 
==
> --- head/sys/fs/tmpfs/tmpfs_vfsops.c  Mon Jan 16 09:53:24 2012
> (r230207)
> +++ head/sys/fs/tmpfs/tmpfs_vfsops.c  Mon Jan 16 10:25:22 2012
> (r230208)
> @@ -150,10 +150,8 @@ tmpfs_mount(struct mount *mp)
>   return (EINVAL);
>  
>   if (mp->mnt_flag & MNT_UPDATE) {
> - /* XXX: There is no support yet to update file system
> -  * settings.  Should be added. */
> -
> - return EOPNOTSUPP;
> + if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0))
> + return (0);
>   }

Is it supposed to fall through if the 'export' option isn't in the list during 
an update mount?

-- 
John Baldwin
___
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: r230025 - head/contrib/compiler-rt/lib/sparc64

2012-01-17 Thread Ed Schouten
Hi Marius,

* Marius Strobl , 20120113 01:00:
> Uhm, these are V8-specific, for V9 the C compiler frame size should
> be 192 instead of 64 and the function alignment should be 32 instead
> of 4 bytes (at least with GCC and US1-optimizations enabled as we
> default to on sparc64), see . However, given that
> these functions only seem to obtain new register window for
> debugging purposes you probably alternatively could just remove
> the saves and the corresponding restores completely.

Any comments on the attached patch?

Thanks,
-- 
 Ed Schouten 
 WWW: http://80386.nl/
Index: modsi3.S
===
--- modsi3.S	(revision 230265)
+++ modsi3.S	(working copy)
@@ -47,13 +47,13 @@
  */
 #include "../assembly.h"
 .text
-	.align 4
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__umodsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	b	divide
 	mov	0,%g3			! result always nonnegative
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__modsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	orcc	%o1,%o0,%g0	! are either %o0 or %o1 negative
 	bge	divide			! if not, skip this junk
 	mov	%o0,%g3		! record sign of result in sign of %g3
@@ -324,7 +324,6 @@
 got_result:
 	tst	%g3
 	bge	1f
-	restore
 	! answer < 0
 	retl! leaf-routine return
 	neg	%o3,%o0 		! remainder <- -%o3
Index: divmod.m4
===
--- divmod.m4	(revision 230265)
+++ divmod.m4	(working copy)
@@ -59,9 +59,6 @@
 
 #include "../assembly.h"
 
-.text
-	.align 4
-
 define(DEVELOP_QUOTIENT_BITS,
 `	!depth $1, accumulated bits $2
 	bl	L.$1.eval(TWOSUPN+$2)
@@ -84,12 +81,14 @@
 	ifelse( $1, 1, `9:')
 ')
 ifelse( ANSWER, `quotient', `
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__udivsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	b	divide
 	mov	0,SIGN			! result always nonnegative
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__divsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	orcc	divisor,dividend,%g0	! are either dividend or divisor negative
 	bge	divide			! if not, skip this junk
 	xor	divisor,dividend,SIGN	! record sign of result in sign of SIGN
@@ -104,12 +103,14 @@
 	neg	dividend
 	! FALL THROUGH
 ',`
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__umodsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	b	divide
 	mov	0,SIGN			! result always nonnegative
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__modsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	orcc	divisor,dividend,%g0	! are either dividend or divisor negative
 	bge	divide			! if not, skip this junk
 	mov	dividend,SIGN		! record sign of result in sign of SIGN
@@ -235,7 +236,6 @@
 got_result:
 	tst	SIGN
 	bge	1f
-	restore
 	! answer < 0
 	retl! leaf-routine return
 ifelse( ANSWER, `quotient',
Index: divsi3.S
===
--- divsi3.S	(revision 230265)
+++ divsi3.S	(working copy)
@@ -47,13 +47,13 @@
  */
 #include "../assembly.h"
 .text
-	.align 4
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__udivsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	b	divide
 	mov	0,%g3			! result always nonnegative
+.text
+	.align 32
 DEFINE_COMPILERRT_FUNCTION(__divsi3)
-	save	%sp,-64,%sp		! do this for debugging
 	orcc	%o1,%o0,%g0	! are either %o0 or %o1 negative
 	bge	divide			! if not, skip this junk
 	xor	%o1,%o0,%g3	! record sign of result in sign of %g3
@@ -324,7 +324,6 @@
 got_result:
 	tst	%g3
 	bge	1f
-	restore
 	! answer < 0
 	retl! leaf-routine return
 	neg	%o2,%o0			! quotient <- -%o2


pgpXBg9l9u3gY.pgp
Description: PGP signature


Re: svn commit: r230264 - head/sys/sys

2012-01-17 Thread Andre Oppermann

On 17.01.2012 13:16, Gleb Smirnoff wrote:

On Tue, Jan 17, 2012 at 12:13:37PM +, Gleb Smirnoff wrote:
T>  Author: glebius
T>  Date: Tue Jan 17 12:13:36 2012
T>  New Revision: 230264
T>  URL: http://svn.freebsd.org/changeset/base/230264
T>
T>  Log:
T>Provide a function m_get2() that allocates a minimal mbuf that
T>would fit specified size. Returned mbuf may be a single mbuf,
T>an mbuf with a cluster from packet zone, or an mbuf with jumbo
T>cluster of sufficient size.

I am open to discussion on bikeshed color^W^W a better name for
this function.


We already have m_getm2() which does the same for mbuf chains.


I utilized it in pfsync, however there are several other places where
it can be used instead of handrolled "if else if else" constructs.


Handrolled mbuf allocation isn't good.  Should be all in one place.

--
Andre
___
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: r230262 - head/sys/amd64/include

2012-01-17 Thread Bruce Evans

On Tue, 17 Jan 2012, Konstantin Belousov wrote:


Log:
 Implement xsetbv(), xsave() and xrstor() providing C access to the
 similarly named CPU instructions.


Please don't add to the unsorting in this file.


Modified: head/sys/amd64/include/cpufunc.h
==
--- head/sys/amd64/include/cpufunc.hTue Jan 17 07:23:43 2012
(r230261)
+++ head/sys/amd64/include/cpufunc.hTue Jan 17 07:30:36 2012
(r230262)
#else /* !(__GNUCLIKE_ASM && __CC_SUPPORTS___INLINE) */

int breakpoint(void);
@@ -733,6 +768,9 @@ u_int   rgs(void);
voidwbinvd(void);
voidwrite_rflags(u_int rf);
voidwrmsr(u_int msr, uint64_t newval);
+void   xsetbv(uint32_t reg, uint64_t val);
+void   xsave(char *addr, uint64_t mask);
+void   xrstor(char *addr, uint64_t mask);


This matches the order of the inlines, and w < x, but e > a and s > r.



#endif  /* __GNUCLIKE_ASM && __CC_SUPPORTS___INLINE */


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: r230264 - head/sys/sys

2012-01-17 Thread Gleb Smirnoff
On Tue, Jan 17, 2012 at 12:13:37PM +, Gleb Smirnoff wrote:
T> Author: glebius
T> Date: Tue Jan 17 12:13:36 2012
T> New Revision: 230264
T> URL: http://svn.freebsd.org/changeset/base/230264
T> 
T> Log:
T>   Provide a function m_get2() that allocates a minimal mbuf that
T>   would fit specified size. Returned mbuf may be a single mbuf,
T>   an mbuf with a cluster from packet zone, or an mbuf with jumbo
T>   cluster of sufficient size.

I am open to discussion on bikeshed color^W^W a better name for
this function.

I utilized it in pfsync, however there are several other places where
it can be used instead of handrolled "if else if else" constructs.

-- 
Totus tuus, Glebius.
___
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: r230265 - head/sys/contrib/pf/net

2012-01-17 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jan 17 12:14:26 2012
New Revision: 230265
URL: http://svn.freebsd.org/changeset/base/230265

Log:
  Allocate our mbuf with m_get2().

Modified:
  head/sys/contrib/pf/net/if_pfsync.c

Modified: head/sys/contrib/pf/net/if_pfsync.c
==
--- head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:13:36 2012
(r230264)
+++ head/sys/contrib/pf/net/if_pfsync.c Tue Jan 17 12:14:26 2012
(r230265)
@@ -2121,9 +2121,6 @@ pfsync_sendout(void)
 #ifdef notyet
struct tdb *t;
 #endif
-#ifdef __FreeBSD__
-   size_t pktlen;
-#endif
int offset;
int q, count = 0;
 
@@ -2145,44 +2142,33 @@ pfsync_sendout(void)
return;
}
 
-   MGETHDR(m, M_DONTWAIT, MT_DATA);
-   if (m == NULL) {
 #ifdef __FreeBSD__
+   m = m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr + sc->sc_len);
+   if (m == NULL) {
sc->sc_ifp->if_oerrors++;
+   V_pfsyncstats.pfsyncs_onomem++;
+   return;
+   }
 #else
+   MGETHDR(m, M_DONTWAIT, MT_DATA);
+   if (m == NULL) {
sc->sc_if.if_oerrors++;
-#endif
-   V_pfsyncstats.pfsyncs_onomem++;
+   pfsyncstats.pfsyncs_onomem++;
pfsync_drop(sc);
return;
}
 
-#ifdef __FreeBSD__
-   pktlen = max_linkhdr + sc->sc_len;
-   if (pktlen > MHLEN) {
-   /* Find the right pool to allocate from. */
-   /* XXX: This is ugly. */
-   m_cljget(m, M_DONTWAIT, pktlen <= MCLBYTES ? MCLBYTES :
-#if MJUMPAGESIZE != MCLBYTES
-   pktlen <= MJUMPAGESIZE ? MJUMPAGESIZE :
-#endif
-   pktlen <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES);
-#else
if (max_linkhdr + sc->sc_len > MHLEN) {
MCLGETI(m, M_DONTWAIT, NULL, max_linkhdr + sc->sc_len);
-#endif
if (!ISSET(m->m_flags, M_EXT)) {
m_free(m);
-#ifdef __FreeBSD__
-   sc->sc_ifp->if_oerrors++;
-#else
sc->sc_if.if_oerrors++;
-#endif
-   V_pfsyncstats.pfsyncs_onomem++;
+   pfsyncstats.pfsyncs_onomem++;
pfsync_drop(sc);
return;
}
}
+#endif
m->m_data += max_linkhdr;
m->m_len = m->m_pkthdr.len = sc->sc_len;
 
___
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: r230264 - head/sys/sys

2012-01-17 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jan 17 12:13:36 2012
New Revision: 230264
URL: http://svn.freebsd.org/changeset/base/230264

Log:
  Provide a function m_get2() that allocates a minimal mbuf that
  would fit specified size. Returned mbuf may be a single mbuf,
  an mbuf with a cluster from packet zone, or an mbuf with jumbo
  cluster of sufficient size.

Modified:
  head/sys/sys/mbuf.h

Modified: head/sys/sys/mbuf.h
==
--- head/sys/sys/mbuf.h Tue Jan 17 11:04:58 2012(r230263)
+++ head/sys/sys/mbuf.h Tue Jan 17 12:13:36 2012(r230264)
@@ -398,6 +398,8 @@ extern uma_zone_t   zone_ext_refcnt;
 
 static __inline struct mbuf*m_getcl(int how, short type, int flags);
 static __inline struct mbuf*m_get(int how, short type);
+static __inline struct mbuf*m_get2(int how, short type, int flags,
+   int size);
 static __inline struct mbuf*m_gethdr(int how, short type);
 static __inline struct mbuf*m_getjcl(int how, short type, int flags,
int size);
@@ -544,6 +546,52 @@ m_getcl(int how, short type, int flags)
 }
 
 /*
+ * m_get2() allocates minimum mbuf that would fit "size" argument.
+ *
+ * XXX: This is rather large, should be real function maybe.
+ */
+static __inline struct mbuf *
+m_get2(int how, short type, int flags, int size)
+{
+   struct mb_args args;
+   struct mbuf *m, *n;
+   uma_zone_t zone;
+
+   args.flags = flags;
+   args.type = type;
+
+   if (size <= MHLEN || (size <= MLEN && (flags & M_PKTHDR) == 0))
+   return ((struct mbuf *)(uma_zalloc_arg(zone_mbuf, &args, how)));
+   if (size <= MCLBYTES)
+   return ((struct mbuf *)(uma_zalloc_arg(zone_pack, &args, how)));
+
+   if (size > MJUM16BYTES)
+   return (NULL);
+
+   m = uma_zalloc_arg(zone_mbuf, &args, how);
+   if (m == NULL)
+   return (NULL);
+
+#if MJUMPAGESIZE != MCLBYTES
+   if (size <= MJUMPAGESIZE)
+   zone = zone_jumbop;
+   else
+#endif
+   if (size <= MJUM9BYTES)
+   zone = zone_jumbo9;
+   else
+   zone = zone_jumbo16;
+
+   n = uma_zalloc_arg(zone, m, how);
+   if (n == NULL) {
+   uma_zfree(zone_mbuf, m);
+   return (NULL);
+   }
+
+   return (m);
+}
+
+/*
  * m_getjcl() returns an mbuf with a cluster of the specified size attached.
  * For size it takes MCLBYTES, MJUMPAGESIZE, MJUM9BYTES, MJUM16BYTES.
  *
___
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: r230037 - head/lib/libutil

2012-01-17 Thread Bruce Evans

On Mon, 16 Jan 2012, Pawel Jakub Dawidek wrote:


On Mon, Jan 16, 2012 at 11:14:32AM -0600, Guy Helmer wrote:

I've pasted the diff below that I think captures the majority of the issues you have 
brought up. I have not attempted to tackle the property.3/properties.3 issues, nor 
the objections to the prefixes that I think would take considerably more effort to 
resolve -- I wanted to concentrate on the issues that can be isolated to libutil. I 
hope the diff was pasted OK, especially WRT  characters.


The patch looks mostly good, one nit mentioned below and also one
question for Bruce.


+/* Flags for hexdump(3) */
+/* Flags for humanize_number(3) flags */
+/* Flags for humanize_number(3) scale */
+/* return values from realhostname() */
+/* Flags for pw_scan() */
+/* Return values from uu_lock() */


All those sentences are missing period and one doesn't start with
capital letter.


I decided not to worry about the termination since it was fairly consistent
in the file.  The most recent commit fixed these, but made all the others
inconsistent:

% /* for properties.c */
% /* Avoid pulling in all the include files for no need */
% #ifdef _STDIO_H_  /* avoid adding new includes */

This is now the only comment to the right of code.  Comments to the
right of ifdefs are especially hard format nicely
(the normal comment indentation to 32 or 40 columns doesn't work
well; I normally use a single space; the above indents to 24 columns),
so the should be avoided.  The same treatment is used for 3 other includes,
but there is no comment for the others.  The simplest fix is to remove
this comment.  Otherwise, put a meta-comment about them all somewhere.
It's hard to place this so that it clearly covers them all, but anywhere
is better than to the right of 1 of their ifdefs.

% /* fparseln(3) */

This is also missing the new, otherwise (too) uniform wording
"Flags for..."


I noticed also one more inconsistency:

struct kinfo_file *
kinfo_getfile(pid_t _pid, int *_cntp);
struct passwd
*pw_dup(const struct passwd *_pw);

Sometimes * is on the same line as function type and sometimes it is in
the line below. Former is definiately better.


Indded.


Guy, feel free to commit what you got now with those sentences fixed and
I'll do one iterration. It is taking way too long and I'm sure you are
bored by now:) We don't want to scare you off:)


+struct pidfh *
+   pidfile_open(const char *_path, mode_t _mode, pid_t *_pidptr);


Bruce, is this your suggestion?


Yes.


This somehow looks weird too me. What I
use and I think it is in general more widely used across FreeBSD is
simply:

struct pidfh *pidfile_open(const char *_path, mode_t _mode, pid_t *_pidptr);

when the type exceeds one tab, but the line fits into 80 chars or:

struct pidfh *pidfile_open(const char *_path, mode_t _mode, pid_t *_pidptr,
int _some_other_argument);

when line exceeds 80 chars.


Very important headers like  often use the style of lining
up all function names.  This can from 4.4BSD (was even in FreeBSD-1
so probably in Net/2) so I consider it Normal.  I think this is easier
to read.  But it is harder to write and maintain, so only very important
headers should do it (same for leaving an extra column for '* before
function names').  libutil.h isn't important, but it already did this
in many cases (including by you for humanize_number() :-), so I said
to do it for all cases.  A middle way would be to use the fancy
formatting only when line splitting is needed to avoid long lines
anyway:
- short prototypes: never split
- slightly longer prototypes: split at function name provided this requires
  only 2 lines
- even longer prototypes: split after a comma in parameter list provided this
  requires only 2 lines
- very long prototypes: split after at function name and take more than 3
  lines no matter how it is split (might take 1 extra for this)
But this would be even harder to write and maintain.


Especially this one looks very strange:

properties
properties_read(int _fd);



`properties' is weird because it doesn't look like a type.

indent(1) and maybe smart editors don't even understand the minimal
facy formatting in .  That's what I mean by "hard to write
and maintain".  Especially for the fancier formattings of very long
prototypes which need careful fancy formatting most, it's too hard
to produce and reproduce with a simple editor or formatting utility.
FreeBSD indent(1) still doesn't even understand prototypes, but it
manages to usually not mess up simple ones.  It actually makes a
big mess of , starting with the first __dead2:

% __BEGIN_DECLS
% void 
% abort(void)__dead2;

%   int abs(int)__pure2;
%   int atexit(void (*) (void));
%   double atof(const char *);

After removing the __dead2 and the __pure2, it gets a bit further:

% __BEGIN_DECLS
% void  abort(void);
% int   abs (int);
% int   atexit(void (*) (void));
% doubleatof(const char *);
% int   atoi(const char 

Re: svn commit: r230037 - head/lib/libutil

2012-01-17 Thread Bruce Evans

On Mon, 16 Jan 2012, Guy Helmer wrote:


On Jan 14, 2012, at 3:02 PM, Bruce Evans wrote:
...
I've pasted the diff below that I think captures the majority of the issues you have 
brought up. I have not attempted to tackle the property.3/properties.3 issues, nor 
the objections to the prefixes that I think would take considerably more effort to 
resolve -- I wanted to concentrate on the issues that can be isolated to libutil. I 
hope the diff was pasted OK, especially WRT  characters.


I see you committed it.  It is mostly OK, but as usual a pre-commit review
would have been useful.


Index: lib/libutil/libutil.h
===
--- lib/libutil/libutil.h   (revision 230221)
+++ lib/libutil/libutil.h   (working copy)
+/* Flags for hexdump(3) */
#define HD_COLUMN_MASK  0xff
#define HD_DELIM_MASK   0xff00
#define HD_OMIT_COUNT   (1 << 16)
#define HD_OMIT_HEX (1 << 17)
#define HD_OMIT_CHARS   (1 << 18)

+/* Flags for humanize_number(3) flags */


The double "flags" is meaningful but hard to parse.


+#defineHN_DECIMAL  0x01
+#defineHN_NOSPACE  0x02
+#defineHN_B0x04
+#defineHN_DIVISOR_1000 0x08
+#defineHN_IEC_PREFIXES 0x10
+
+/* Flags for humanize_number(3) scale */


It is only after reading this that the double "flags" starts making
sense.  Add " parameter" to the end of each to make more sense.  Then
omit the first "Flags " to make even more sense.  Then consider adding
some punctuation.  Then add "Values" where "Flags" was.  The first
"Flags" was only a paraphrase of "`flags' parameter".  This is most
useful when the parameter's name is not `flags', and only works then
there is only 1 parameter that takes flags.  This results in:

/* Values for humanize_number(3)'s `flags' parameter */
/* Values for humanize_number(3)'s `scale' parameter */

Perhaps you can abbreviate this a bit.  "Values " is mostly tautologous
but seems to improve readability.


+/* return values from realhostname() */


This one is not capitalized.


+/* Return values from uu_lock() */
+#defineUU_LOCK_INUSE   1
+#defineUU_LOCK_OK  0
+#defineUU_LOCK_OPEN_ERR-1
+#defineUU_LOCK_READ_ERR-2
+#defineUU_LOCK_CREAT_ERR   -3
+#defineUU_LOCK_WRITE_ERR   -4
+#defineUU_LOCK_LINK_ERR-5
+#defineUU_LOCK_TRY_ERR -6
+#defineUU_LOCK_OWNER_ERR   -7


Er, the parentheses were not redundant for -N, since -N consists of 2
tokens.  I just tried to find an example of why they are needed in
, but could only find historical and contrived examples:
- before C90, they were necessary to prevent - -1 becoming --1.  Code
  like -UU_LOCK_OPEN_ERR isn't necessarily an error.  For a non-flag
  macro FOO, -FOO just isn't an error, so FOO needed to be parenthesized
  it it was a negative integer.
- now, 1(-1) is a syntax error, but 1-1 is not.  Code like
  1 UU_LOCK_OPEN_ERR should be a syntax error, but isn't if the macro
  expands to -1.  This is unimportant compared with -FOO working, since
  the parentheses only give detection of an error.

Parentheses are necessary for casts in macros even for C90 and later,
since if FOO is defined as (long)1 then the useful expression
`sizeof FOO' is the syntax error `sizeof(long) 1'.

To avoid avoid worrying about this, expression-like macros should
always be parenthesized iff they have more than 1 token.

When worrying about this, you look at the C operator precedence table
and notice that parentheses don't have the highest precedence, since they
share precedence with some other operators.  So there must be some magic
for parenthesizing macros to be sufficient.

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"