Re: svn commit: r285336 - in head/sys: netipsec opencrypto

2015-07-10 Thread Matthew D. Fuller
On Thu, Jul 09, 2015 at 06:16:36PM + I heard the voice of
George V. Neville-Neil, and lo! it spake thus:
> New Revision: 285336
> URL: https://svnweb.freebsd.org/changeset/base/285336
> 
> Log:
>   Add support for AES modes to IPSec.  These modes work both in software only
>   mode and with hardware support on systems that have AESNI instructions.

With (apparently) this change, I can trigger a panic at will by
running

% geli onetime -e AES-XTS -d /dev/ada0s1

My best guess is that it comes from

> -#define RIJNDAEL128_BLOCK_LEN16
> +#define  AES_MIN_BLOCK_LEN   1

> - RIJNDAEL128_BLOCK_LEN, 8, 32, 64,
> + AES_MIN_BLOCK_LEN, AES_XTS_IV_LEN, AES_XTS_MIN_KEY, AES_XTS_MAX_KEY,

changing that first arg from 16 to 1.  It seems to be avoided with the
following patch:

--8K

Index: sys/opencrypto/xform.c
===
--- sys/opencrypto/xform.c  (revision 285365)
+++ sys/opencrypto/xform.c  (working copy)
@@ -257,7 +257,7 @@
 
 struct enc_xform enc_xform_aes_xts = {
CRYPTO_AES_XTS, "AES-XTS",
-   AES_MIN_BLOCK_LEN, AES_XTS_IV_LEN, AES_XTS_MIN_KEY, AES_XTS_MAX_KEY,
+   AES_BLOCK_LEN, AES_XTS_IV_LEN, AES_XTS_MIN_KEY, AES_XTS_MAX_KEY,
aes_xts_encrypt,
aes_xts_decrypt,
aes_xts_setkey,

--8K

at least in a little testing here.  If that's the actual fix, some of
the other MIN_BLOCK_LEN changes in GCM and GMAC are probably suspect
too.


(I also wonder why AES-ICM is still using the RIJNDAEL128 #defines;
shouldn't it be using the AES's too?  But that's cosmtic...)


-- 
Matthew Fuller (MF4839)   |  fulle...@over-yonder.net
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
   On the Internet, nobody can hear you scream.
___
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: r285381 - head/share/man/man9

2015-07-10 Thread John-Mark Gurney
Author: jmg
Date: Sat Jul 11 04:20:56 2015
New Revision: 285381
URL: https://svnweb.freebsd.org/changeset/base/285381

Log:
  some additional improvements to the documentation...
  
  Sponsored by: Netflix, Inc.

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

Modified: head/share/man/man9/crypto.9
==
--- head/share/man/man9/crypto.9Sat Jul 11 03:57:36 2015
(r285380)
+++ head/share/man/man9/crypto.9Sat Jul 11 04:20:56 2015
(r285381)
@@ -17,7 +17,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 8, 2015
+.Dd July 10, 2015
 .Dt CRYPTO 9
 .Os
 .Sh NAME
@@ -40,6 +40,8 @@
 .Ft void
 .Fn crypto_kdone "struct cryptkop *"
 .Ft int
+.Fn crypto_find_driver "const char *"
+.Ft int
 .Fn crypto_newsession "uint64_t *" "struct cryptoini *" int
 .Ft int
 .Fn crypto_freesession uint64_t
@@ -157,15 +159,28 @@ was a fatal error in verifying the argum
 For session initialization and teardown there is no callback mechanism used.
 .Pp
 The
+.Fn crypto_find_driver
+function may be called to return the specific id of the provided name.
+If the specified driver could not be found, the returned id is -1.
+.Pp
+The
 .Fn crypto_newsession
 routine is called by consumers of cryptographic services (such as the
 .Xr ipsec 4
 stack) that wish to establish a new session with the framework.
-On success, the first argument will contain the Session Identifier (SID).
 The second argument contains all the necessary information for
 the driver to establish the session.
-The third argument indicates whether a
-hardware driver (1) should be used or not (0).
+The third argument is either a specific driver id, or one or both
+of
+.Dv CRYPTOCAP_F_HARDWARE ,
+to select hardware devices,
+or
+.Dv CRYPTOCAP_F_SOFTWARE ,
+to select software devices.
+If both are specified, a hardware device will be returned
+before a software device will be.
+On success, the value pointed to by the first argument will be the
+Session IDentifier (SID).
 The various fields in the
 .Vt cryptoini
 structure are:
___
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: r285366 - in head: lib/libmd sys/crypto/sha2

2015-07-10 Thread John-Mark Gurney
Author: jmg
Date: Sat Jul 11 03:12:34 2015
New Revision: 285366
URL: https://svnweb.freebsd.org/changeset/base/285366

Log:
  Complete the move that was started w/ r263218..  For some reason I
  didn't delete the files, so that means we need to bring the changes in
  r282726 to the correct files..
  
  make tinderbox completed with this patch...

Deleted:
  head/lib/libmd/sha256.h
  head/lib/libmd/sha256c.c
Modified:
  head/sys/crypto/sha2/sha256.h
  head/sys/crypto/sha2/sha256c.c

Modified: head/sys/crypto/sha2/sha256.h
==
--- head/sys/crypto/sha2/sha256.h   Fri Jul 10 22:10:00 2015
(r285365)
+++ head/sys/crypto/sha2/sha256.h   Sat Jul 11 03:12:34 2015
(r285366)
@@ -40,6 +40,38 @@ typedef struct SHA256Context {
 } SHA256_CTX;
 
 __BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#ifndef SHA256_Init
+#define SHA256_Init_libmd_SHA256_Init
+#endif
+#ifndef SHA256_Update
+#define SHA256_Update  _libmd_SHA256_Update
+#endif
+#ifndef SHA256_Final
+#define SHA256_Final   _libmd_SHA256_Final
+#endif
+#ifndef SHA256_End
+#define SHA256_End _libmd_SHA256_End
+#endif
+#ifndef SHA256_File
+#define SHA256_File_libmd_SHA256_File
+#endif
+#ifndef SHA256_FileChunk
+#define SHA256_FileChunk   _libmd_SHA256_FileChunk
+#endif
+#ifndef SHA256_Data
+#define SHA256_Data_libmd_SHA256_Data
+#endif
+
+#ifndef SHA256_Transform
+#define SHA256_Transform   _libmd_SHA256_Transform
+#endif
+#ifndef SHA256_version
+#define SHA256_version _libmd_SHA256_version
+#endif
+
 void   SHA256_Init(SHA256_CTX *);
 void   SHA256_Update(SHA256_CTX *, const void *, size_t);
 void   SHA256_Final(unsigned char [32], SHA256_CTX *);

Modified: head/sys/crypto/sha2/sha256c.c
==
--- head/sys/crypto/sha2/sha256c.c  Fri Jul 10 22:10:00 2015
(r285365)
+++ head/sys/crypto/sha2/sha256c.c  Sat Jul 11 03:12:34 2015
(r285366)
@@ -299,3 +299,18 @@ SHA256_Final(unsigned char digest[32], S
/* Clear the context state */
memset((void *)ctx, 0, sizeof(*ctx));
 }
+
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+   activated in the context of compiling these sources for internal
+   use in libcrypt.
+ */
+#undef SHA256_Init
+__weak_reference(_libmd_SHA256_Init, SHA256_Init);
+#undef SHA256_Update
+__weak_reference(_libmd_SHA256_Update, SHA256_Update);
+#undef SHA256_Final
+__weak_reference(_libmd_SHA256_Final, SHA256_Final);
+#undef SHA256_Transform
+__weak_reference(_libmd_SHA256_Transform, SHA256_Transform);
+#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: r285363 - head/sys/geom/eli

2015-07-10 Thread Pawel Jakub Dawidek
Author: pjd
Date: Fri Jul 10 19:27:19 2015
New Revision: 285363
URL: https://svnweb.freebsd.org/changeset/base/285363

Log:
  Spoil even can happen for some time now even on providers opened exclusively
  (on the media change event). Update GELI to handle that situation.
  
  PR:   201185
  Submitted by: Matthew D. Fuller

Modified:
  head/sys/geom/eli/g_eli.c

Modified: head/sys/geom/eli/g_eli.c
==
--- head/sys/geom/eli/g_eli.c   Fri Jul 10 19:24:36 2015(r285362)
+++ head/sys/geom/eli/g_eli.c   Fri Jul 10 19:27:19 2015(r285363)
@@ -730,10 +730,10 @@ g_eli_create(struct gctl_req *req, struc
sc = malloc(sizeof(*sc), M_ELI, M_WAITOK | M_ZERO);
gp->start = g_eli_start;
/*
-* Spoiling cannot happen actually, because we keep provider open for
-* writing all the time or provider is read-only.
+* Spoiling can happen even though we have the provider open
+* exclusively, e.g. through media change events.
 */
-   gp->spoiled = g_eli_orphan_spoil_assert;
+   gp->spoiled = g_eli_orphan;
gp->orphan = g_eli_orphan;
gp->dumpconf = g_eli_dumpconf;
/*
___
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: r285362 - head/sys/netpfil/ipfw

2015-07-10 Thread Luigi Rizzo
Author: luigi
Date: Fri Jul 10 19:24:36 2015
New Revision: 285362
URL: https://svnweb.freebsd.org/changeset/base/285362

Log:
  assorted algorithmic fixes from Paolo Valente (one of my qfq coauthors):
  - use 1ULL to avoid shift truncations
  - recompute the sum of weight dynamically to provide better fairness
  - fix an erroneous constant in the computation of the slot
  - preserve timestamp correctness when the old timestamp is stale.

Modified:
  head/sys/netpfil/ipfw/dn_sched_qfq.c

Modified: head/sys/netpfil/ipfw/dn_sched_qfq.c
==
--- head/sys/netpfil/ipfw/dn_sched_qfq.cFri Jul 10 19:18:49 2015
(r285361)
+++ head/sys/netpfil/ipfw/dn_sched_qfq.cFri Jul 10 19:24:36 2015
(r285362)
@@ -172,8 +172,6 @@ for the scheduler: bitmaps and bucket li
 
 #defineQFQ_MAX_WEIGHT  (1lmax);
cl->grp = &q->groups[i];
q->wsum += w;
+   q->iwsum = ONE_FP / q->wsum; /* XXX note theory */
// XXX cl->S = q->V; ?
-   // XXX compute q->i_wsum
return 0;
 }
 
@@ -325,6 +324,8 @@ qfq_free_queue(struct dn_queue *_q)
struct qfq_class *cl = (struct qfq_class *)_q;
if (cl->inv_w) {
q->wsum -= ONE_FP/cl->inv_w;
+   if (q->wsum != 0)
+   q->iwsum = ONE_FP / q->wsum;
cl->inv_w = 0; /* reset weight to avoid run twice */
}
return 0;
@@ -408,7 +409,8 @@ qfq_make_eligible(struct qfq_sched *q, u
old_vslot = old_V >> QFQ_MIN_SLOT_SHIFT;
 
if (vslot != old_vslot) {
-   mask = (2UL << (__fls(vslot ^ old_vslot))) - 1;
+   /* should be 1ULL not 2ULL */
+   mask = (1ULL << (__fls(vslot ^ old_vslot))) - 1;
qfq_move_groups(q, mask, IR, ER);
qfq_move_groups(q, mask, IB, EB);
}
@@ -557,7 +559,7 @@ qfq_dequeue(struct dn_sch_inst *si)
}
NO(q->queued--;)
old_V = q->V;
-   q->V += (uint64_t)m->m_pkthdr.len * IWSUM;
+   q->V += (uint64_t)m->m_pkthdr.len * q->iwsum;
ND("m is %p F 0x%llx V now 0x%llx", m, cl->F, q->V);
 
if (qfq_update_class(q, grp, cl)) {
@@ -612,7 +614,7 @@ qfq_update_start(struct qfq_sched *q, st
int slot_shift = cl->grp->slot_shift;
 
roundedF = qfq_round_down(cl->F, slot_shift);
-   limit = qfq_round_down(q->V, slot_shift) + (1UL << slot_shift);
+   limit = qfq_round_down(q->V, slot_shift) + (1ULL << slot_shift);
 
if (!qfq_gt(cl->F, q->V) || qfq_gt(roundedF, limit)) {
/* timestamp was stale */
@@ -620,7 +622,11 @@ qfq_update_start(struct qfq_sched *q, st
if (mask) {
struct qfq_group *next = qfq_ffs(q, mask);
if (qfq_gt(roundedF, next->F)) {
-   cl->S = next->F;
+   /* from pv 
71261956973ba9e0637848a5adb4a5819b4bae83 */
+   if (qfq_gt(limit, next->F))
+   cl->S = next->F;
+   else /* preserve timestamp correctness */
+   cl->S = limit;
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"


svn commit: r285361 - head/sys/netpfil/ipfw

2015-07-10 Thread Luigi Rizzo
Author: luigi
Date: Fri Jul 10 19:18:49 2015
New Revision: 285361
URL: https://svnweb.freebsd.org/changeset/base/285361

Log:
  one more warning suppression when compiling the test code in userspace.

Modified:
  head/sys/netpfil/ipfw/dn_heap.c

Modified: head/sys/netpfil/ipfw/dn_heap.c
==
--- head/sys/netpfil/ipfw/dn_heap.c Fri Jul 10 18:10:40 2015
(r285360)
+++ head/sys/netpfil/ipfw/dn_heap.c Fri Jul 10 19:18:49 2015
(r285361)
@@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$");
 #include  "dn_heap.h"
 #define log(x, arg...) fprintf(stderr, ## arg)
 #define panic(x...)fprintf(stderr, ## x), exit(1)
-#define MALLOC_DEFINE(a, b, c)
+#define MALLOC_DEFINE(a, b, c) volatile int __dummy__ ## a 
__attribute__((__unused__))
 static void *my_malloc(int s) {return malloc(s); }
 static void my_free(void *p) { free(p); }
 #define malloc(s, t, w)my_malloc(s)
___
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: r285282 - head/sys/vm

2015-07-10 Thread Alan Cox
On 07/10/2015 13:49, hiren panchasara wrote:
> On 07/09/15 at 06:13P, Alan Cox wrote:
>> On Jul 8, 2015, at 1:29 PM, hiren panchasara  wrote:
>>
>>> On 07/08/15 at 05:46P, Alan Cox wrote:
 Author: alc
 Date: Wed Jul  8 17:45:59 2015
 New Revision: 285282
 URL: https://svnweb.freebsd.org/changeset/base/285282

 Log:
  The intention of r254304 was to scan the active queue continuously.
  However, I've observed the active queue scan stopping when there are
  frequent free page shortages and the inactive queue is steadily refilled
  by other mechanisms, such as the sequential access heuristic in vm_fault()
  or madvise(2). 
>>> What would be the actual downside/effect of this scenario? i.e. What goes
>>> wrong when active queue scan stops and what would I see/observe on a
>>> system when the problem is going on - is what I want to understand.
>>>
>>
>> Basically, pages that haven?t been used recently get stuck in the active 
>> queue.  Consequently, they are never reclaimed and repurposed to hold newly 
>> accessed data.  Instead, more recently used pages from the inactive queue 
>> are reclaimed.  Effectively, this reduces the amount of physical memory that 
>> is available for caching file data, and so the system (likely) performs more 
>> I/O operations than it would have with the stuck pages problem corrected.
>>
> Thanks. So it seems now there is an enforced number of min pages that
> *must* be scanned which is proportional to the time of last scan.


That is correct.


  To remedy this problem, record the time of the last active
  queue scan, and always scan a number of pages proportional to the time
  since the last scan, regardless of whether that last scan was a
  timeout-triggered ("pass == 0") or free-page-shortage-triggered ("pass >
  0") scan.

  Also, on a timeout-triggered scan, allow a full scan of the active queue
  when the system is short of inactive pages.

  Reviewed by:  kib
  MFC after:6 weeks
  Sponsored by: EMC / Isilon Storage Division
>>> [skip]
>>>
>>> Thanks in advance.
>>> Cheers,
>>> Hiren
>>

___
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: r285282 - head/sys/vm

2015-07-10 Thread hiren panchasara
On 07/09/15 at 06:13P, Alan Cox wrote:
> 
> On Jul 8, 2015, at 1:29 PM, hiren panchasara  wrote:
> 
> > On 07/08/15 at 05:46P, Alan Cox wrote:
> >> Author: alc
> >> Date: Wed Jul  8 17:45:59 2015
> >> New Revision: 285282
> >> URL: https://svnweb.freebsd.org/changeset/base/285282
> >> 
> >> Log:
> >>  The intention of r254304 was to scan the active queue continuously.
> >>  However, I've observed the active queue scan stopping when there are
> >>  frequent free page shortages and the inactive queue is steadily refilled
> >>  by other mechanisms, such as the sequential access heuristic in vm_fault()
> >>  or madvise(2). 
> > 
> > What would be the actual downside/effect of this scenario? i.e. What goes
> > wrong when active queue scan stops and what would I see/observe on a
> > system when the problem is going on - is what I want to understand.
> > 
> 
> 
> Basically, pages that haven?t been used recently get stuck in the active 
> queue.  Consequently, they are never reclaimed and repurposed to hold newly 
> accessed data.  Instead, more recently used pages from the inactive queue are 
> reclaimed.  Effectively, this reduces the amount of physical memory that is 
> available for caching file data, and so the system (likely) performs more I/O 
> operations than it would have with the stuck pages problem corrected.
>

Thanks. So it seems now there is an enforced number of min pages that
*must* be scanned which is proportional to the time of last scan.

Cheers,
Hiren
> 
> >>  To remedy this problem, record the time of the last active
> >>  queue scan, and always scan a number of pages proportional to the time
> >>  since the last scan, regardless of whether that last scan was a
> >>  timeout-triggered ("pass == 0") or free-page-shortage-triggered ("pass >
> >>  0") scan.
> >> 
> >>  Also, on a timeout-triggered scan, allow a full scan of the active queue
> >>  when the system is short of inactive pages.
> >> 
> >>  Reviewed by:  kib
> >>  MFC after:6 weeks
> >>  Sponsored by: EMC / Isilon Storage Division
> > 
> > [skip]
> > 
> > Thanks in advance.
> > Cheers,
> > Hiren
> 
> 


pgpsAze1hvTDI.pgp
Description: PGP signature


Re: svn commit: r285349 - in head/sys: dev/cxgbe dev/e1000 dev/ixgbe dev/netmap dev/re net

2015-07-10 Thread Patrick Kelsey
Thanks for the update, Luigi!  For the record, the exclusive open was Juli
Mallett's idea for the solutions you mention - I was just the first +1.

-Patrick

On Fri, Jul 10, 2015 at 1:51 AM, Luigi Rizzo  wrote:

> Author: luigi
> Date: Fri Jul 10 05:51:36 2015
> New Revision: 285349
> URL: https://svnweb.freebsd.org/changeset/base/285349
>
> Log:
>   Sync netmap sources with the version in our private tree.
>   This commit contains large contributions from Giuseppe Lettieri and
>   Stefano Garzarella, is partly supported by grants from Verisign and
> Cisco,
>   and brings in the following:
>
>   - fix zerocopy monitor ports and introduce copying monitor ports
> (the latter are lower performance but give access to all traffic
> in parallel with the application)
>
>   - exclusive open mode, useful to implement solutions that recover
> from crashes of the main netmap client (suggested by Patrick Kelsey)
>
>   - revised memory allocator in preparation for the 'passthrough mode'
> (ptnetmap) recently presented at bsdcan. ptnetmap is described in
>   S. Garzarella, G. Lettieri, L. Rizzo;
>   Virtual device passthrough for high speed VM networking,
>   ACM/IEEE ANCS 2015, Oakland (CA) May 2015
>   http://info.iet.unipi.it/~luigi/research.html
>
>   - fix rx CRC handing on ixl
>
>   - add module dependencies for netmap when building drivers as modules
>
>   - minor simplifications to device-specific routines (*txsync, *rxsync)
>
>   - general code cleanup (remove unused variables, introduce macros
> to access rings and remove duplicate code,
>
>   Applications do not need to be recompiled, unless of course
>   they want to use the new features (monitors and exclusive open).
>
>   Those willing to try this code on stable/10 can just update the
>   sys/dev/netmap/*, sys/net/netmap* with the version in HEAD
>   and apply the small patches to individual device drivers.
>
>   MFC after:1 month
>   Sponsored by: (partly) Verisign, Cisco
>
> Modified:
>   head/sys/dev/cxgbe/t4_main.c
>   head/sys/dev/cxgbe/t4_netmap.c
>   head/sys/dev/e1000/if_em.c
>   head/sys/dev/e1000/if_igb.c
>   head/sys/dev/e1000/if_lem.c
>   head/sys/dev/ixgbe/if_ix.c
>   head/sys/dev/netmap/if_em_netmap.h
>   head/sys/dev/netmap/if_igb_netmap.h
>   head/sys/dev/netmap/if_ixl_netmap.h
>   head/sys/dev/netmap/if_lem_netmap.h
>   head/sys/dev/netmap/if_re_netmap.h
>   head/sys/dev/netmap/if_vtnet_netmap.h
>   head/sys/dev/netmap/ixgbe_netmap.h
>   head/sys/dev/netmap/netmap.c
>   head/sys/dev/netmap/netmap_freebsd.c
>   head/sys/dev/netmap/netmap_generic.c
>   head/sys/dev/netmap/netmap_kern.h
>   head/sys/dev/netmap/netmap_mem2.c
>   head/sys/dev/netmap/netmap_mem2.h
>   head/sys/dev/netmap/netmap_monitor.c
>   head/sys/dev/netmap/netmap_pipe.c
>   head/sys/dev/netmap/netmap_vale.c
>   head/sys/dev/re/if_re.c
>   head/sys/net/netmap.h
>   head/sys/net/netmap_user.h
>
> Modified: head/sys/dev/cxgbe/t4_main.c
>
> ==
> --- head/sys/dev/cxgbe/t4_main.cFri Jul 10 05:07:18 2015
> (r285348)
> +++ head/sys/dev/cxgbe/t4_main.cFri Jul 10 05:51:36 2015
> (r285349)
> @@ -8533,10 +8533,17 @@ static devclass_t cxgbe_devclass, cxl_de
>  DRIVER_MODULE(t4nex, pci, t4_driver, t4_devclass, mod_event, 0);
>  MODULE_VERSION(t4nex, 1);
>  MODULE_DEPEND(t4nex, firmware, 1, 1, 1);
> +#ifdef DEV_NETMAP
> +MODULE_DEPEND(t4nex, netmap, 1, 1, 1);
> +#endif /* DEV_NETMAP */
> +
>
>  DRIVER_MODULE(t5nex, pci, t5_driver, t5_devclass, mod_event, 0);
>  MODULE_VERSION(t5nex, 1);
>  MODULE_DEPEND(t5nex, firmware, 1, 1, 1);
> +#ifdef DEV_NETMAP
> +MODULE_DEPEND(t5nex, netmap, 1, 1, 1);
> +#endif /* DEV_NETMAP */
>
>  DRIVER_MODULE(cxgbe, t4nex, cxgbe_driver, cxgbe_devclass, 0, 0);
>  MODULE_VERSION(cxgbe, 1);
>
> Modified: head/sys/dev/cxgbe/t4_netmap.c
>
> ==
> --- head/sys/dev/cxgbe/t4_netmap.c  Fri Jul 10 05:07:18 2015
> (r285348)
> +++ head/sys/dev/cxgbe/t4_netmap.c  Fri Jul 10 05:51:36 2015
> (r285349)
> @@ -917,8 +917,6 @@ cxgbe_netmap_txsync(struct netmap_kring
> kring->nr_hwtail -= kring->nkr_num_slots;
> }
>
> -   nm_txsync_finalize(kring);
> -
> return (0);
>  }
>
> @@ -931,7 +929,7 @@ cxgbe_netmap_rxsync(struct netmap_kring
> struct port_info *pi = ifp->if_softc;
> struct adapter *sc = pi->adapter;
> struct sge_nm_rxq *nm_rxq = &sc->sge.nm_rxq[pi->first_nm_rxq +
> kring->ring_id];
> -   u_int const head = nm_rxsync_prologue(kring);
> +   u_int const head = kring->rhead;
> u_int n;
> int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags &
> NKR_PENDINTR;
>
> @@ -993,8 +991,6 @@ cxgbe_netmap_rxsync(struct netmap_kring
> }
> }
>
> -   nm_rxsync_finalize(kring);
> -
> return (0);
>  }
>
>
> Modified: head/sys/dev

svn commit: r285360 - head/sys/netpfil/ipfw/test

2015-07-10 Thread Luigi Rizzo
Author: luigi
Date: Fri Jul 10 18:10:40 2015
New Revision: 285360
URL: https://svnweb.freebsd.org/changeset/base/285360

Log:
  add code to compute fairness indexes;
  cleanups to remove compile warnings.

Modified:
  head/sys/netpfil/ipfw/test/dn_test.h
  head/sys/netpfil/ipfw/test/main.c

Modified: head/sys/netpfil/ipfw/test/dn_test.h
==
--- head/sys/netpfil/ipfw/test/dn_test.hFri Jul 10 16:05:24 2015
(r285359)
+++ head/sys/netpfil/ipfw/test/dn_test.hFri Jul 10 18:10:40 2015
(r285360)
@@ -30,9 +30,13 @@ extern int debug;
 
 
 #ifndef offsetof
-#define offsetof(t,m) (int)((&((t *)0L)->m))
+#define offsetof(t,m) (int)(intptr_t)((&((t *)0L)->m))
 #endif
 
+#if defined(__APPLE__) // XXX osx
+typedef unsigned int u_int;
+#endif /* osx */
+
 #include 
 
 /* prevent include of other system headers */
@@ -85,6 +89,11 @@ struct dn_flow {
uint64_t tot_bytes;
uint32_t flow_id;
struct list_head h; /* used by the generator */
+
+   /* bytes served by the flow since the last backlog time */
+   uint64_t bytes;
+   /* bytes served by the system at the last backlog time  */
+   uint64_t sch_bytes;
 };
 
 struct dn_link {
@@ -103,7 +112,7 @@ struct mbuf {
void *cfg;  /* config args */
 };
 
-#define MALLOC_DECLARE(x)
+#define MALLOC_DECLARE(x)  extern volatile int __dummy__ ## x
 #define KASSERT(x, y)  do { if (!(x)) printf y ; exit(0); } while (0)
 struct ipfw_flow_id {
 };

Modified: head/sys/netpfil/ipfw/test/main.c
==
--- head/sys/netpfil/ipfw/test/main.c   Fri Jul 10 16:05:24 2015
(r285359)
+++ head/sys/netpfil/ipfw/test/main.c   Fri Jul 10 18:10:40 2015
(r285360)
@@ -75,6 +75,9 @@ struct cfg_s {
 #define BACKLOG30
uint32_tllmask;
struct list_head ll[BACKLOG + 10];
+
+   double *q_wfi;  /* (byte) Worst-case Fair Index of the flows  */
+   double wfi; /* (byte) Worst-case Fair Index of the system */
 };
 
 /* FI2Q and Q2FI converts from flow_id to dn_queue and back.
@@ -145,6 +148,39 @@ dequeue(struct cfg_s *c)
return m;
 }
 
+static void
+gnet_stats_enq(struct cfg_s *c, struct mbuf *mb)
+{
+   struct dn_sch_inst *si = c->si;
+   struct dn_queue *_q = FI2Q(c, mb->flow_id);
+
+   if (_q->ni.length == 1) {
+   _q->ni.bytes = 0;
+   _q->ni.sch_bytes = si->ni.bytes;
+   }
+}
+
+static void
+gnet_stats_deq(struct cfg_s *c, struct mbuf *mb)
+{
+   struct dn_sch_inst *si = c->si;
+   struct dn_queue *_q = FI2Q(c, mb->flow_id);
+   int len = mb->m_pkthdr.len;
+
+   _q->ni.bytes += len;
+   si->ni.bytes += len;
+
+   if (_q->ni.length == 0) {
+   double bytes = (double)_q->ni.bytes;
+   double sch_bytes = (double)si->ni.bytes - _q->ni.sch_bytes;
+   double weight = (double)_q->fs->fs.par[0] / c->wsum;
+   double wfi = sch_bytes * weight - bytes;
+
+   if (c->q_wfi[mb->flow_id] < wfi)
+   c->q_wfi[mb->flow_id] = wfi;
+   }
+}
+
 static int
 mainloop(struct cfg_s *c)
 {
@@ -164,6 +200,7 @@ mainloop(struct cfg_s *c)
} else {
ND("enqueue ok");
c->pending++;
+   gnet_stats_enq(c, m);
}
}
if (c->can_dequeue) {
@@ -172,6 +209,7 @@ mainloop(struct cfg_s *c)
c->pending--;
drop(c, m);
c->drop--;  /* compensate */
+   gnet_stats_deq(c, m);
}
}
}
@@ -187,7 +225,8 @@ dump(struct cfg_s *c)
 
for (i=0; i < c->flows; i++) {
q = FI2Q(c, i);
-   DX(1, "queue %4d tot %10lld", i, q->ni.tot_bytes);
+   DX(1, "queue %4d tot %10llu", i,
+   (unsigned long long)q->ni.tot_bytes);
}
DX(1, "done %d loops\n", c->loops);
return 0;
@@ -373,6 +412,9 @@ init(struct cfg_s *c)
extern moduledata_t *_g_dn_wf2qp;
extern moduledata_t *_g_dn_rr;
extern moduledata_t *_g_dn_qfq;
+#ifdef WITH_QFQP
+   extern moduledata_t *_g_dn_qfqp;
+#endif
 #ifdef WITH_KPS
extern moduledata_t *_g_dn_kps;
 #endif
@@ -384,6 +426,11 @@ init(struct cfg_s *c)
mod = _g_dn_fifo;
else if (!strcmp(av[1], "qfq"))
mod = _g_dn_qfq;
+#ifdef WITH_QFQP
+   else if (!strcmp(av[1], "qfq+") ||
+   !strcmp(av[1], "qfqp") )
+   mod = _g_dn_qfqp;
+#endi

svn commit: r285359 - head/sys/dev/netmap

2015-07-10 Thread Luigi Rizzo
Author: luigi
Date: Fri Jul 10 16:05:24 2015
New Revision: 285359
URL: https://svnweb.freebsd.org/changeset/base/285359

Log:
  staticize functions only used in netmap.c
  (detected by jenkins run with gcc 4.9)
  
  Update documentation on the use of netmap_priv_d,
  rename the refcount and use the same structure in
  FreeBSD and linux
  
  No functional changes.

Modified:
  head/sys/dev/netmap/netmap.c
  head/sys/dev/netmap/netmap_freebsd.c
  head/sys/dev/netmap/netmap_kern.h
  head/sys/dev/netmap/netmap_vale.c

Modified: head/sys/dev/netmap/netmap.c
==
--- head/sys/dev/netmap/netmap.cFri Jul 10 14:39:46 2015
(r285358)
+++ head/sys/dev/netmap/netmap.cFri Jul 10 16:05:24 2015
(r285359)
@@ -726,6 +726,9 @@ netmap_update_config(struct netmap_adapt
return 1;
 }
 
+static void netmap_txsync_to_host(struct netmap_adapter *na);
+static int netmap_rxsync_from_host(struct netmap_adapter *na, struct thread 
*td, void *pwait);
+
 /* kring->nm_sync callback for the host tx ring */
 static int
 netmap_txsync_to_host_compat(struct netmap_kring *kring, int flags)
@@ -959,11 +962,12 @@ nm_si_user(struct netmap_priv_d *priv, e
 }
 
 /*
- * Destructor of the netmap_priv_d, called when the fd has
- * no active open() and mmap().
- * Undo all the things done by NIOCREGIF.
+ * Destructor of the netmap_priv_d, called when the fd is closed
+ * Action: undo all the things done by NIOCREGIF,
+ * On FreeBSD we need to track whether there are active mmap()s,
+ * and we use np_active_mmaps for that. On linux, the field is always 0.
+ * Return: 1 if we can free priv, 0 otherwise.
  *
- * returns 1 if this is the last instance and we can free priv
  */
 /* call with NMG_LOCK held */
 int
@@ -971,17 +975,13 @@ netmap_dtor_locked(struct netmap_priv_d 
 {
struct netmap_adapter *na = priv->np_na;
 
-#ifdef __FreeBSD__
-   /*
-* np_refcount is the number of active mmaps on
-* this file descriptor
-*/
-   if (--priv->np_refcount > 0) {
+   /* number of active mmaps on this fd (FreeBSD only) */
+   if (--priv->np_refs > 0) {
return 0;
}
-#endif /* __FreeBSD__ */
+
if (!na) {
-   return 1; //XXX is it correct?
+   return 1; //XXX is it correct?
}
netmap_do_unregif(priv);
netmap_adapter_put(na);
@@ -1139,7 +1139,7 @@ netmap_sw_to_nic(struct netmap_adapter *
  * can be among multiple user threads erroneously calling
  * this routine concurrently.
  */
-void
+static void
 netmap_txsync_to_host(struct netmap_adapter *na)
 {
struct netmap_kring *kring = &na->tx_rings[na->num_tx_rings];
@@ -1177,7 +1177,7 @@ netmap_txsync_to_host(struct netmap_adap
  * returns the number of packets delivered to tx queues in
  * transparent mode, or a negative value if error
  */
-int
+static int
 netmap_rxsync_from_host(struct netmap_adapter *na, struct thread *td, void 
*pwait)
 {
struct netmap_kring *kring = &na->rx_rings[na->num_rx_rings];

Modified: head/sys/dev/netmap/netmap_freebsd.c
==
--- head/sys/dev/netmap/netmap_freebsd.cFri Jul 10 14:39:46 2015
(r285358)
+++ head/sys/dev/netmap/netmap_freebsd.cFri Jul 10 16:05:24 2015
(r285359)
@@ -576,7 +576,7 @@ netmap_mmap_single(struct cdev *cdev, vm
goto err_unlock;
}
vmh->priv = priv;
-   priv->np_refcount++;
+   priv->np_refs++;
NMG_UNLOCK();
 
obj = cdev_pager_allocate(vmh, OBJT_DEVICE,
@@ -593,7 +593,7 @@ netmap_mmap_single(struct cdev *cdev, vm
 
 err_deref:
NMG_LOCK();
-   priv->np_refcount--;
+   priv->np_refs--;
 err_unlock:
NMG_UNLOCK();
 // err:
@@ -602,14 +602,14 @@ err_unlock:
 }
 
 /*
- * netmap_close() is called on every close(), but we do not need to do
- * anything at that moment, since the process may have other open file
- * descriptors for /dev/netmap. Instead, we pass netmap_dtor() to
+ * On FreeBSD the close routine is only called on the last close on
+ * the device (/dev/netmap) so we cannot do anything useful.
+ * To track close() on individual file descriptors we pass netmap_dtor() to
  * devfs_set_cdevpriv() on open(). The FreeBSD kernel will call the destructor
  * when the last fd pointing to the device is closed. 
  *
- * Unfortunately, FreeBSD does not automatically track active mmap()s on an fd,
- * so we have to track them by ourselvesi (see above). The result is that
+ * Note that FreeBSD does not even munmap() on close() so we also have
+ * to track mmap() ourselves, and postpone the call to
  * netmap_dtor() is called when the process has no open fds and no active
  * memory maps on /dev/netmap, as in linux.
  */
@@ -634,19 +634,15 @@ netmap_open(struct cdev *dev, int oflags
(void)devtype;
(void)td;
 
-   // XXX wait or nowai

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

2015-07-10 Thread Ed Schouten
Author: ed
Date: Fri Jul 10 14:39:46 2015
New Revision: 285358
URL: https://svnweb.freebsd.org/changeset/base/285358

Log:
  Add missing const keyword to kern_sigaction()'s 'act' parameter.
  
  This structure is not modified by the function. Also add const to
  sigact_flag_test(), as it is called by kern_sigaction().

Modified:
  head/sys/kern/kern_sig.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/kern/kern_sig.c
==
--- head/sys/kern/kern_sig.cFri Jul 10 13:54:03 2015(r285357)
+++ head/sys/kern/kern_sig.cFri Jul 10 14:39:46 2015(r285358)
@@ -628,7 +628,7 @@ sig_ffs(sigset_t *set)
 }
 
 static bool
-sigact_flag_test(struct sigaction *act, int flag)
+sigact_flag_test(const struct sigaction *act, int flag)
 {
 
/*
@@ -648,11 +648,8 @@ sigact_flag_test(struct sigaction *act, 
  * osigaction
  */
 int
-kern_sigaction(td, sig, act, oact, flags)
-   struct thread *td;
-   register int sig;
-   struct sigaction *act, *oact;
-   int flags;
+kern_sigaction(struct thread *td, int sig, const struct sigaction *act,
+struct sigaction *oact, int flags)
 {
struct sigacts *ps;
struct proc *p = td->td_proc;

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Fri Jul 10 13:54:03 2015(r285357)
+++ head/sys/sys/syscallsubr.h  Fri Jul 10 14:39:46 2015(r285358)
@@ -207,7 +207,7 @@ int kern_shmat(struct thread *td, int sh
int shmflg);
 intkern_shmctl(struct thread *td, int shmid, int cmd, void *buf,
size_t *bufsz);
-intkern_sigaction(struct thread *td, int sig, struct sigaction *act,
+intkern_sigaction(struct thread *td, int sig, const struct sigaction *act,
struct sigaction *oact, int flags);
 intkern_sigaltstack(struct thread *td, stack_t *ss, stack_t *oss);
 intkern_sigprocmask(struct thread *td, int how,
___
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: r285357 - in head/sys: kern sys

2015-07-10 Thread Mateusz Guzik
Author: mjg
Date: Fri Jul 10 13:54:03 2015
New Revision: 285357
URL: https://svnweb.freebsd.org/changeset/base/285357

Log:
  fd: further cleanup of kern_dup
  
  - make mode enum start from 0 so that the assertion covers all cases [1]
  - rename prefix _CLOEXEC flag with _FLAG
  - postpone fhold on the old file descriptor, which eliminates the need to 
fdrop
in error cases.
  - fixup FDDUP_FCNTL check missed in the previous commit
  
  This removes 'fp == oldfde->fde_file' assertion which had little value. 
kern_dup
  only calls fd-related functions which cannot drop the lock or a whole lot of
  races would be introduced.
  
  Noted by: kib [1]

Modified:
  head/sys/kern/kern_descrip.c
  head/sys/sys/filedesc.h

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Jul 10 11:01:30 2015
(r285356)
+++ head/sys/kern/kern_descrip.cFri Jul 10 13:54:03 2015
(r285357)
@@ -224,7 +224,6 @@ fd_last_used(struct filedesc *fdp, int s
return (-1);
 }
 
-#ifdef INVARIANTS
 static int
 fdisused(struct filedesc *fdp, int fd)
 {
@@ -234,7 +233,6 @@ fdisused(struct filedesc *fdp, int fd)
 
return ((fdp->fd_map[NDSLOT(fd)] & NDBIT(fd)) != 0);
 }
-#endif
 
 /*
  * Mark a file descriptor as used.
@@ -486,7 +484,7 @@ kern_fcntl(struct thread *td, int fd, in
 
case F_DUPFD_CLOEXEC:
tmp = arg;
-   error = kern_dup(td, FDDUP_FCNTL, FDDUP_CLOEXEC, fd, tmp);
+   error = kern_dup(td, FDDUP_FCNTL, FDDUP_FLAG_CLOEXEC, fd, tmp);
break;
 
case F_DUP2FD:
@@ -496,7 +494,7 @@ kern_fcntl(struct thread *td, int fd, in
 
case F_DUP2FD_CLOEXEC:
tmp = arg;
-   error = kern_dup(td, FDDUP_FIXED, FDDUP_CLOEXEC, fd, tmp);
+   error = kern_dup(td, FDDUP_FIXED, FDDUP_FLAG_CLOEXEC, fd, tmp);
break;
 
case F_GETFD:
@@ -794,14 +792,13 @@ kern_dup(struct thread *td, u_int mode, 
struct filedesc *fdp;
struct filedescent *oldfde, *newfde;
struct proc *p;
-   struct file *fp;
struct file *delfp;
int error, maxfd;
 
p = td->td_proc;
fdp = p->p_fd;
 
-   MPASS((flags & ~(FDDUP_CLOEXEC)) == 0);
+   MPASS((flags & ~(FDDUP_FLAG_CLOEXEC)) == 0);
MPASS(mode < FDDUP_LASTMODE);
 
/*
@@ -812,26 +809,23 @@ kern_dup(struct thread *td, u_int mode, 
if (old < 0)
return (EBADF);
if (new < 0)
-   return (flags & FDDUP_FCNTL ? EINVAL : EBADF);
+   return (mode == FDDUP_FCNTL ? EINVAL : EBADF);
maxfd = getmaxfd(td);
if (new >= maxfd)
-   return (flags & FDDUP_FCNTL ? EINVAL : EBADF);
+   return (mode == FDDUP_FCNTL ? EINVAL : EBADF);
 
FILEDESC_XLOCK(fdp);
if (fget_locked(fdp, old) == NULL) {
FILEDESC_XUNLOCK(fdp);
return (EBADF);
}
-   oldfde = &fdp->fd_ofiles[old];
if ((mode == FDDUP_FIXED || mode == FDDUP_MUSTREPLACE) && old == new) {
td->td_retval[0] = new;
-   if (flags & FDDUP_CLOEXEC)
+   if (flags & FDDUP_FLAG_CLOEXEC)
fdp->fd_ofiles[new].fde_flags |= UF_EXCLOSE;
FILEDESC_XUNLOCK(fdp);
return (0);
}
-   fp = oldfde->fde_file;
-   fhold(fp);
 
/*
 * If the caller specified a file descriptor, make sure the file
@@ -843,20 +837,15 @@ kern_dup(struct thread *td, u_int mode, 
case FDDUP_FCNTL:
if ((error = fdalloc(td, new, &new)) != 0) {
FILEDESC_XUNLOCK(fdp);
-   fdrop(fp, td);
return (error);
}
-   newfde = &fdp->fd_ofiles[new];
break;
case FDDUP_MUSTREPLACE:
/* Target file descriptor must exist. */
-   if (new >= fdp->fd_nfiles ||
-   fdp->fd_ofiles[new].fde_file == NULL) {
+   if (fget_locked(fdp, new) == NULL) {
FILEDESC_XUNLOCK(fdp);
-   fdrop(fp, td);
return (EBADF);
}
-   newfde = &fdp->fd_ofiles[new];
break;
case FDDUP_FIXED:
if (new >= fdp->fd_nfiles) {
@@ -875,28 +864,24 @@ kern_dup(struct thread *td, u_int mode, 
PROC_UNLOCK(p);
if (error != 0) {
FILEDESC_XUNLOCK(fdp);
-   fdrop(fp, td);
return (EMFILE);
}
}
 #endif
fdgrowtable_exp(fdp, new + 1);
-   oldfde = &fdp->fd_ofiles[old];
}

Re: svn commit: r285356 - in head/sys: compat/cloudabi kern sys

2015-07-10 Thread Mateusz Guzik
On Fri, Jul 10, 2015 at 02:10:50PM +0300, Konstantin Belousov wrote:
> On Fri, Jul 10, 2015 at 11:01:31AM +, Mateusz Guzik wrote:
> > Author: mjg
> > Date: Fri Jul 10 11:01:30 2015
> > New Revision: 285356
> > URL: https://svnweb.freebsd.org/changeset/base/285356
> > 
> > Log:
> >   fd: split kern_dup flags argument into actual flags and a mode
> >   
> >   Tidy up the code inside to switch on the mode.
> 
> > +   MPASS(mode < FDDUP_LASTMODE);
> Since you started the FDDUP_ modes enum from 1, this assert does not fully
> validate the mode.  Am I wrong ?
> 

Oops, correct. There is no problem starting with 0, so I'll just change
the enum. Thanks.

> > +/* Operation types for kern_dup(). */
> > +enum {
> > +   FDDUP_NORMAL = 0x01,/* dup() behavior. */
> > +   FDDUP_FCNTL,/* fcntl()-style errors. */
> > +   FDDUP_FIXED,/* Force fixed allocation. */
> > +   FDDUP_MUSTREPLACE,  /* Target must exist. */
> > +   FDDUP_LASTMODE,
> > +};
> > +
> >  /* Flags for kern_dup(). */
> > -#defineFDDUP_FIXED 0x1 /* Force fixed allocation. */
> > -#defineFDDUP_FCNTL 0x2 /* fcntl()-style errors. */
> > -#defineFDDUP_CLOEXEC   0x4 /* Atomically set FD_CLOEXEC. */
> > -#defineFDDUP_MUSTREPLACE   0x8 /* Target must exist. */
> > +#defineFDDUP_CLOEXEC   0x1 /* Atomically set FD_CLOEXEC. */
> 
> Consider using different prefixes for mode/flags ?

I only came up with FDDUP_FLAG_CLOEXEC which is quite verbose, but may
be acceptable. I definitely want to avoid re-using O_CLOEXEC.

-- 
Mateusz Guzik 
___
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: r285356 - in head/sys: compat/cloudabi kern sys

2015-07-10 Thread Konstantin Belousov
On Fri, Jul 10, 2015 at 11:01:31AM +, Mateusz Guzik wrote:
> Author: mjg
> Date: Fri Jul 10 11:01:30 2015
> New Revision: 285356
> URL: https://svnweb.freebsd.org/changeset/base/285356
> 
> Log:
>   fd: split kern_dup flags argument into actual flags and a mode
>   
>   Tidy up the code inside to switch on the mode.

> +   MPASS(mode < FDDUP_LASTMODE);
Since you started the FDDUP_ modes enum from 1, this assert does not fully
validate the mode.  Am I wrong ?

> +/* Operation types for kern_dup(). */
> +enum {
> + FDDUP_NORMAL = 0x01,/* dup() behavior. */
> + FDDUP_FCNTL,/* fcntl()-style errors. */
> + FDDUP_FIXED,/* Force fixed allocation. */
> + FDDUP_MUSTREPLACE,  /* Target must exist. */
> + FDDUP_LASTMODE,
> +};
> +
>  /* Flags for kern_dup(). */
> -#define  FDDUP_FIXED 0x1 /* Force fixed allocation. */
> -#define  FDDUP_FCNTL 0x2 /* fcntl()-style errors. */
> -#define  FDDUP_CLOEXEC   0x4 /* Atomically set FD_CLOEXEC. */
> -#define  FDDUP_MUSTREPLACE   0x8 /* Target must exist. */
> +#define  FDDUP_CLOEXEC   0x1 /* Atomically set FD_CLOEXEC. */

Consider using different prefixes for mode/flags ?
___
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: r285356 - in head/sys: compat/cloudabi kern sys

2015-07-10 Thread Mateusz Guzik
Author: mjg
Date: Fri Jul 10 11:01:30 2015
New Revision: 285356
URL: https://svnweb.freebsd.org/changeset/base/285356

Log:
  fd: split kern_dup flags argument into actual flags and a mode
  
  Tidy up the code inside to switch on the mode.

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c
  head/sys/kern/kern_descrip.c
  head/sys/sys/filedesc.h
  head/sys/sys/syscallsubr.h

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Fri Jul 10 09:20:13 2015
(r285355)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Fri Jul 10 11:01:30 2015
(r285356)
@@ -97,7 +97,7 @@ cloudabi_sys_fd_replace(struct thread *t
 * clear the return value, as this system call yields no return
 * value.
 */
-   error = kern_dup(td, FDDUP_MUSTREPLACE, uap->from, uap->to);
+   error = kern_dup(td, FDDUP_MUSTREPLACE, 0, uap->from, uap->to);
td->td_retval[0] = 0;
return (error);
 }

Modified: head/sys/kern/kern_descrip.c
==
--- head/sys/kern/kern_descrip.cFri Jul 10 09:20:13 2015
(r285355)
+++ head/sys/kern/kern_descrip.cFri Jul 10 11:01:30 2015
(r285356)
@@ -355,7 +355,7 @@ int
 sys_dup2(struct thread *td, struct dup2_args *uap)
 {
 
-   return (kern_dup(td, FDDUP_FIXED, (int)uap->from, (int)uap->to));
+   return (kern_dup(td, FDDUP_FIXED, 0, (int)uap->from, (int)uap->to));
 }
 
 /*
@@ -371,7 +371,7 @@ int
 sys_dup(struct thread *td, struct dup_args *uap)
 {
 
-   return (kern_dup(td, 0, (int)uap->fd, 0));
+   return (kern_dup(td, FDDUP_NORMAL, 0, (int)uap->fd, 0));
 }
 
 /*
@@ -481,22 +481,22 @@ kern_fcntl(struct thread *td, int fd, in
switch (cmd) {
case F_DUPFD:
tmp = arg;
-   error = kern_dup(td, FDDUP_FCNTL, fd, tmp);
+   error = kern_dup(td, FDDUP_FCNTL, 0, fd, tmp);
break;
 
case F_DUPFD_CLOEXEC:
tmp = arg;
-   error = kern_dup(td, FDDUP_FCNTL | FDDUP_CLOEXEC, fd, tmp);
+   error = kern_dup(td, FDDUP_FCNTL, FDDUP_CLOEXEC, fd, tmp);
break;
 
case F_DUP2FD:
tmp = arg;
-   error = kern_dup(td, FDDUP_FIXED, fd, tmp);
+   error = kern_dup(td, FDDUP_FIXED, 0, fd, tmp);
break;
 
case F_DUP2FD_CLOEXEC:
tmp = arg;
-   error = kern_dup(td, FDDUP_FIXED | FDDUP_CLOEXEC, fd, tmp);
+   error = kern_dup(td, FDDUP_FIXED, FDDUP_CLOEXEC, fd, tmp);
break;
 
case F_GETFD:
@@ -789,7 +789,7 @@ getmaxfd(struct thread *td)
  * Common code for dup, dup2, fcntl(F_DUPFD) and fcntl(F_DUP2FD).
  */
 int
-kern_dup(struct thread *td, int flags, int old, int new)
+kern_dup(struct thread *td, u_int mode, int flags, int old, int new)
 {
struct filedesc *fdp;
struct filedescent *oldfde, *newfde;
@@ -801,10 +801,8 @@ kern_dup(struct thread *td, int flags, i
p = td->td_proc;
fdp = p->p_fd;
 
-   MPASS((flags & ~(FDDUP_FIXED | FDDUP_FCNTL | FDDUP_CLOEXEC |
-   FDDUP_MUSTREPLACE)) == 0);
-   MPASS((flags & (FDDUP_FIXED | FDDUP_MUSTREPLACE)) !=
-   (FDDUP_FIXED | FDDUP_MUSTREPLACE));
+   MPASS((flags & ~(FDDUP_CLOEXEC)) == 0);
+   MPASS(mode < FDDUP_LASTMODE);
 
/*
 * Verify we have a valid descriptor to dup from and possibly to
@@ -825,7 +823,7 @@ kern_dup(struct thread *td, int flags, i
return (EBADF);
}
oldfde = &fdp->fd_ofiles[old];
-   if (flags & (FDDUP_FIXED | FDDUP_MUSTREPLACE) && old == new) {
+   if ((mode == FDDUP_FIXED || mode == FDDUP_MUSTREPLACE) && old == new) {
td->td_retval[0] = new;
if (flags & FDDUP_CLOEXEC)
fdp->fd_ofiles[new].fde_flags |= UF_EXCLOSE;
@@ -840,7 +838,17 @@ kern_dup(struct thread *td, int flags, i
 * table is large enough to hold it, and grab it.  Otherwise, just
 * allocate a new descriptor the usual way.
 */
-   if (flags & FDDUP_MUSTREPLACE) {
+   switch (mode) {
+   case FDDUP_NORMAL:
+   case FDDUP_FCNTL:
+   if ((error = fdalloc(td, new, &new)) != 0) {
+   FILEDESC_XUNLOCK(fdp);
+   fdrop(fp, td);
+   return (error);
+   }
+   newfde = &fdp->fd_ofiles[new];
+   break;
+   case FDDUP_MUSTREPLACE:
/* Target file descriptor must exist. */
if (new >= fdp->fd_nfiles ||
fdp->fd_ofiles[new].fde_file == NULL) {
@@ -849,7 +857,8 @@ kern_dup(struct thread *td, int flags, i
return (EBADF);
}
newfde = &fdp->fd_ofiles[new];
-   } else if (

svn commit: r285355 - head/sys/i386/isa

2015-07-10 Thread Konstantin Belousov
Author: kib
Date: Fri Jul 10 09:20:13 2015
New Revision: 285355
URL: https://svnweb.freebsd.org/changeset/base/285355

Log:
  Convert between abridged (from FXSAVE) and unabridged (from FSAVE)
  versions of the x87 tags.  The conversion is naive, used abridged tag
  is converted to valid unabridged, without additional checks for zero
  and special values.
  
  Noted by: bde
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/i386/isa/npx.c

Modified: head/sys/i386/isa/npx.c
==
--- head/sys/i386/isa/npx.c Fri Jul 10 09:15:06 2015(r285354)
+++ head/sys/i386/isa/npx.c Fri Jul 10 09:20:13 2015(r285355)
@@ -1173,16 +1173,20 @@ npx_fill_fpregs_xmm1(struct savexmm *sv_
/* FPU control/status */
penv_87->en_cw = penv_xmm->en_cw;
penv_87->en_sw = penv_xmm->en_sw;
-   penv_87->en_tw = penv_xmm->en_tw;
penv_87->en_fip = penv_xmm->en_fip;
penv_87->en_fcs = penv_xmm->en_fcs;
penv_87->en_opcode = penv_xmm->en_opcode;
penv_87->en_foo = penv_xmm->en_foo;
penv_87->en_fos = penv_xmm->en_fos;
 
-   /* FPU registers */
-   for (i = 0; i < 8; ++i)
+   /* FPU registers and tags */
+   penv_87->en_tw = 0x;
+   for (i = 0; i < 8; ++i) {
sv_87->sv_ac[i] = sv_xmm->sv_fp[i].fp_acc;
+   if ((penv_xmm->en_tw & (1 << i)) != 0)
+   /* zero and special are set as valid */
+   penv_87->en_tw &= ~(3 << i);
+   }
 }
 
 void
@@ -1206,16 +1210,19 @@ npx_set_fpregs_xmm(struct save87 *sv_87,
/* FPU control/status */
penv_xmm->en_cw = penv_87->en_cw;
penv_xmm->en_sw = penv_87->en_sw;
-   penv_xmm->en_tw = penv_87->en_tw;
penv_xmm->en_fip = penv_87->en_fip;
penv_xmm->en_fcs = penv_87->en_fcs;
penv_xmm->en_opcode = penv_87->en_opcode;
penv_xmm->en_foo = penv_87->en_foo;
penv_xmm->en_fos = penv_87->en_fos;
 
-   /* FPU registers */
-   for (i = 0; i < 8; ++i)
+   /* FPU registers and tags */
+   penv_xmm->en_tw = 0;
+   for (i = 0; i < 8; ++i) {
sv_xmm->sv_fp[i].fp_acc = sv_87->sv_ac[i];
+   if ((penv_87->en_tw && (3 << i)) != (3 << i))
+   penv_xmm->en_tw |= 1 << i;
+   }
 }
 #endif /* CPU_ENABLE_SSE */
 
___
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: r285354 - head/sys/i386/include

2015-07-10 Thread Konstantin Belousov
Author: kib
Date: Fri Jul 10 09:15:06 2015
New Revision: 285354
URL: https://svnweb.freebsd.org/changeset/base/285354

Log:
  Duplicate the copyright from the i386/i386/machdep.c into
  i386/include/frame.h after a code was moved from machdep.c to frame.h
  in r284925.
  
  Use include guards style similar to other guards.
  
  Noted by: bde
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/i386/include/frame.h

Modified: head/sys/i386/include/frame.h
==
--- head/sys/i386/include/frame.h   Fri Jul 10 08:54:12 2015
(r285353)
+++ head/sys/i386/include/frame.h   Fri Jul 10 09:15:06 2015
(r285354)
@@ -1,14 +1,44 @@
 /*-
- * This file is in the public domain.
+ * Copyright (c) 2003 Peter Wemm.
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 4. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
  */
-/* $FreeBSD$ */
 
-#include 
+#ifndef _I386_FRAME_H_
+#define_I386_FRAME_H_
 
-#ifndef __I386_FRAME_H__
-#define__i386_FRAME_H__
+#include 
 
 #defineCS_SECURE(cs)   (ISPL(cs) == SEL_UPL)
 #defineEFL_SECURE(ef, oef) ef) ^ (oef)) & ~PSL_USERCHANGE) == 
0)
 
-#endif
+#endif /* _I386_FRAME_H_ */
___
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: r285353 - head/sys/kern

2015-07-10 Thread Konstantin Belousov
Author: kib
Date: Fri Jul 10 08:54:12 2015
New Revision: 285353
URL: https://svnweb.freebsd.org/changeset/base/285353

Log:
  Change the mb() use in the sched_ult tdq_notify() and sched_idletd()
  to more C11-ish atomic_thread_fence_seq_cst().
  
  Note that on PowerPC, which currently uses lwsync for mb(), the change
  actually fixes the missed store/load barrier, intended by r271604 [*].
  
  Reviewed by:  alc
  Noted by: alc [*]
  Sponsored by: The FreeBSD Foundation
  MFC after:3 weeks

Modified:
  head/sys/kern/sched_ule.c

Modified: head/sys/kern/sched_ule.c
==
--- head/sys/kern/sched_ule.c   Fri Jul 10 08:36:22 2015(r285352)
+++ head/sys/kern/sched_ule.c   Fri Jul 10 08:54:12 2015(r285353)
@@ -1057,7 +1057,7 @@ tdq_notify(struct tdq *tdq, struct threa
 * globally visible before we read tdq_cpu_idle.  Idle thread
 * accesses both of them without locks, and the order is important.
 */
-   mb();
+   atomic_thread_fence_seq_cst();
 
if (TD_IS_IDLETHREAD(ctd)) {
/*
@@ -2667,7 +2667,7 @@ sched_idletd(void *dummy)
 * before cpu_idle() read tdq_load.  The order is important
 * to avoid race with tdq_notify.
 */
-   mb();
+   atomic_thread_fence_seq_cst();
cpu_idle(switchcnt * 4 > sched_idlespinthresh);
tdq->tdq_cpu_idle = 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"


svn commit: r285352 - in head/lib/libc: aarch64 aarch64/gen tests/sys

2015-07-10 Thread Andrew Turner
Author: andrew
Date: Fri Jul 10 08:36:22 2015
New Revision: 285352
URL: https://svnweb.freebsd.org/changeset/base/285352

Log:
  Add support for makecontext. This supports up to 8 arguments as this
  simplifies the code, these can be passed in registers.
  
  Obtained from:ABT Systems Ltd
  Sponsored by: The FreeBSD Foundation

Added:
  head/lib/libc/aarch64/gen/_ctx_start.S   (contents, props changed)
  head/lib/libc/aarch64/gen/makecontext.c   (contents, props changed)
Modified:
  head/lib/libc/aarch64/Symbol.map
  head/lib/libc/aarch64/gen/Makefile.inc
  head/lib/libc/tests/sys/Makefile

Modified: head/lib/libc/aarch64/Symbol.map
==
--- head/lib/libc/aarch64/Symbol.mapFri Jul 10 07:13:14 2015
(r285351)
+++ head/lib/libc/aarch64/Symbol.mapFri Jul 10 08:36:22 2015
(r285352)
@@ -28,6 +28,7 @@ FBSD_1.0 {
vfork;
brk;
sbrk;
+   makecontext;
 };
 
 FBSDprivate_1.0 {
@@ -35,4 +36,5 @@ FBSDprivate_1.0 {
_end;
curbrk;
minbrk;
+   __makecontext;
 };

Modified: head/lib/libc/aarch64/gen/Makefile.inc
==
--- head/lib/libc/aarch64/gen/Makefile.inc  Fri Jul 10 07:13:14 2015
(r285351)
+++ head/lib/libc/aarch64/gen/Makefile.inc  Fri Jul 10 08:36:22 2015
(r285352)
@@ -1,10 +1,12 @@
 # $FreeBSD$
 
-SRCS+= fabs.S \
+SRCS+= _ctx_start.S \
+   fabs.S \
flt_rounds.c \
fpgetmask.c \
fpsetmask.c \
ldexp.c \
+   makecontext.c \
_setjmp.S \
_set_tp.c \
setjmp.S \

Added: head/lib/libc/aarch64/gen/_ctx_start.S
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/aarch64/gen/_ctx_start.S  Fri Jul 10 08:36:22 2015
(r285352)
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+ENTRY(_ctx_start)
+   blr x19 /* Call func from makecontext */
+   mov x0, x20 /* Load ucp saved in makecontext */
+   bl  _C_LABEL(ctx_done)
+   bl  _C_LABEL(abort)
+END(_ctx_start)

Added: head/lib/libc/aarch64/gen/makecontext.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/aarch64/gen/makecontext.c Fri Jul 10 08:36:22 2015
(r285352)
@@ -0,0 +1,86 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Andrew Turner under
+ * sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+

svn commit: r285351 - head/sys/dev/virtio/network

2015-07-10 Thread Luigi Rizzo
Author: luigi
Date: Fri Jul 10 07:13:14 2015
New Revision: 285351
URL: https://svnweb.freebsd.org/changeset/base/285351

Log:
  add netmap dependency when compiled as a module

Modified:
  head/sys/dev/virtio/network/if_vtnet.c

Modified: head/sys/dev/virtio/network/if_vtnet.c
==
--- head/sys/dev/virtio/network/if_vtnet.c  Fri Jul 10 06:47:14 2015
(r285350)
+++ head/sys/dev/virtio/network/if_vtnet.c  Fri Jul 10 07:13:14 2015
(r285351)
@@ -304,6 +304,9 @@ DRIVER_MODULE(vtnet, virtio_pci, vtnet_d
 vtnet_modevent, 0);
 MODULE_VERSION(vtnet, 1);
 MODULE_DEPEND(vtnet, virtio, 1, 1, 1);
+#ifdef DEV_NETMAP
+MODULE_DEPEND(vtnet, netmap, 1, 1, 1);
+#endif /* DEV_NETMAP */
 
 static int
 vtnet_modevent(module_t mod, int type, void *unused)
___
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"