PATCH: fix regress/sys/kern/extent

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PATCH: fix regress/sys/kern/extent

Theo Buehler
Hiding a lot of <sys/pool.h> from userland breaks the build of the
extent test in regress/sys/kern/extent on amd64.  Additionally, tedu's
added size variable in free(9) breaks the userland macros in
sys/kern/subr_extent.c.  The following patch addresses these two issues.


Index: sys/sys/pool.h
===================================================================
RCS file: /cvs/src/sys/sys/pool.h,v
retrieving revision 1.47
diff -u -p -r1.47 pool.h
--- sys/sys/pool.h      2 Jul 2014 00:23:36 -0000       1.47
+++ sys/sys/pool.h      5 Aug 2014 19:13:24 -0000
@@ -66,7 +66,7 @@ struct kinfo_pool {
        unsigned long   pr_nidle;       /* # of idle pages */
 };

-#if defined(_KERNEL) || defined(_LIBKVM)
+#if defined(_KERNEL) || defined(_LIBKVM) || defined(_EXTENT_TESTING)

 #include <sys/queue.h>
 #include <sys/tree.h>
@@ -158,7 +158,7 @@ struct pool {
                        pr_crange;
 };

-#endif /* _KERNEL || _LIBKVM */
+#endif /* _KERNEL || _LIBKVM || _EXTENT_TESTING */

 #ifdef _KERNEL

Index: sys/kern/subr_extent.c
===================================================================
RCS file: /cvs/src/sys/kern/subr_extent.c,v
retrieving revision 1.51
diff -u -p -r1.51 subr_extent.c
--- sys/kern/subr_extent.c      12 Jul 2014 18:43:32 -0000      1.51
+++ sys/kern/subr_extent.c      5 Aug 2014 19:13:24 -0000
@@ -58,13 +58,13 @@
 #include <string.h>

 #define        malloc(s, t, flags)             malloc(s)
-#define        free(p, t)                      free(p)
+#define        free(p, t, s)                   free(p)
 #define        tsleep(chan, pri, str, timo)    (EWOULDBLOCK)
 #define        wakeup(chan)                    ((void)0)
 #define        pool_get(pool, flags)           malloc((pool)->pr_size, 0, 0)
 #define        pool_init(a, b, c, d, e, f, g)  (a)->pr_size = (b)
 #define        pool_setipl(pool, ipl)          /* nothing */
-#define        pool_put(pool, rp)              free((rp), 0)
+#define        pool_put(pool, rp)              free((rp), 0, 0)
 #define        panic                           printf
 #endif

Reply | Threaded
Open this post in threaded view
|

Re: PATCH: fix regress/sys/kern/extent

Miod Vallat
> Hiding a lot of <sys/pool.h> from userland breaks the build of the
> extent test in regress/sys/kern/extent on amd64.  Additionally, tedu's
> added size variable in free(9) breaks the userland macros in
> sys/kern/subr_extent.c.  The following patch addresses these two issues.

Actually, the extent regress test got broken on 32-bit systems a long
time ago when adding edge cases; the whole test needs to be overhauled
to either be able to output something 32/64-bit agnostic when the region
limit is -1, or to use two expected output files, depending upon the
system the tests are being run on.

Patches to fix this are welcome (-:

Reply | Threaded
Open this post in threaded view
|

Re: PATCH: fix regress/sys/kern/extent

David Gwynne-5
On Tue, Aug 05, 2014 at 08:15:59PM +0000, Miod Vallat wrote:

> > Hiding a lot of <sys/pool.h> from userland breaks the build of the
> > extent test in regress/sys/kern/extent on amd64.  Additionally, tedu's
> > added size variable in free(9) breaks the userland macros in
> > sys/kern/subr_extent.c.  The following patch addresses these two issues.
>
> Actually, the extent regress test got broken on 32-bit systems a long
> time ago when adding edge cases; the whole test needs to be overhauled
> to either be able to output something 32/64-bit agnostic when the region
> limit is -1, or to use two expected output files, depending upon the
> system the tests are being run on.
>
> Patches to fix this are welcome (-:
>

i like this more for the pool/malloc issues.

i am wary of how malloc and pool_get dont handle M_ZERO and PR_ZERO
respectively, but the code doenst use those flags so its ok.

Index: subr_extent.c
===================================================================
RCS file: /cvs/src/sys/kern/subr_extent.c,v
retrieving revision 1.51
diff -u -p -r1.51 subr_extent.c
--- subr_extent.c 12 Jul 2014 18:43:32 -0000 1.51
+++ subr_extent.c 9 Aug 2014 05:18:49 -0000
@@ -49,23 +49,30 @@
  * user-land definitions, so it can fit into a testing harness.
  */
 #include <sys/param.h>
-#include <sys/pool.h>
 #include <sys/extent.h>
 #include <sys/queue.h>
 #include <errno.h>
+#include <err.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
 #define malloc(s, t, flags) malloc(s)
-#define free(p, t) free(p)
+#define free(p, t, s) free(p)
+
 #define tsleep(chan, pri, str, timo) (EWOULDBLOCK)
 #define wakeup(chan) ((void)0)
-#define pool_get(pool, flags) malloc((pool)->pr_size, 0, 0)
-#define pool_init(a, b, c, d, e, f, g) (a)->pr_size = (b)
-#define pool_setipl(pool, ipl) /* nothing */
-#define pool_put(pool, rp) free((rp), 0)
-#define panic printf
+
+struct pool {
+ size_t pr_size;
+};
+
+#define pool_init(a, b, c, d, e, f, g) do { (a)->pr_size = (b); } while (0)
+#define pool_setipl(pp, ipl) /* nothing */
+#define pool_get(pp, flags) malloc((pp)->pr_size, 0, 0)
+#define pool_put(pp, rp) free((rp), 0, 0)
+
+#define panic(...) do { warnx(__VA_ARGS__); abort(); } while (0)
 #endif
 
 #if defined(DIAGNOSTIC) || defined(DDB)