]> granicus.if.org Git - zfs/commitdiff
Add highbit func,
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Thu, 6 Mar 2008 23:12:55 +0000 (23:12 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Thu, 6 Mar 2008 23:12:55 +0000 (23:12 +0000)
Add sloopy atomic declaration which will need to be fixed (eventually)
Fill out more of the Solaris VM hooks
Adjust the create_thread function

git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@26 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

include/sys/kstat.h
include/sys/sysmacros.h
include/sys/thread.h
include/sys/vmsystm.h
modules/spl/spl-generic.c
modules/spl/spl-thread.c
modules/splat/splat-thread.c

index dea7987f5c56ff3087a2b1f0ca24f3309ccbee85..0b6ce0583e3c12e86d987aa6762c551a2b445e6e 100644 (file)
@@ -131,7 +131,21 @@ kstat_delete(kstat_t *ksp)
 }
 
 /* FIXME - NONE OF THIS IS ATOMIC, IT SHOULD BE.  For the moment this is
- * OK since it is only used for the noncritical kstat counters */
+ * OK since it is only used for the noncritical kstat counters, and we
+ * are only doing testing on x86_86 platform where the entire counter
+ * will be updated with one instruction. */
+static __inline__ void
+atomic_inc_64(volatile uint64_t *target)
+{
+       (*target)++;
+}
+
+static __inline__ void
+atomic_dec_64(volatile uint64_t *target)
+{
+       (*target)--;
+}
+
 static __inline__ uint64_t
 atomic_add_64(volatile uint64_t *target, uint64_t delta)
 {
index 65070d858f5a05e07b1bce9587f536891a8b9d69..1927a060db5aedd2484149ee62e73ef117629770 100644 (file)
@@ -64,7 +64,7 @@ extern "C" {
 #define bzero(ptr,size)                 memset(ptr,0,size)
 #define bcopy(src,dest,size)            memcpy(dest,src,size)
 #define ASSERT(x)                       BUG_ON(!(x))
-#define VERIFY(x)
+#define VERIFY(x)                      ASSERT(x)
 
 #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \
        const TYPE __left = (TYPE)(LEFT);        \
@@ -103,10 +103,12 @@ extern "C" {
 #endif  /* DTRACE_PROBE4 */
 #define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i)        ((void)0)
 
-/* Missing globals
- */
+/* Missing globals */
 extern int p0;
 
+/* Missing misc functions */
+extern int highbit(unsigned long i);
+
 #define makedevice(maj,min) makedev(maj,min)
 
 /* XXX - Borrowed from zfs project libsolcompat/include/sys/sysmacros.h */
index d1009ab6d8c7713012f07dd930caa361b8830d2f..4532aee5bbbdf2e8adf4034d48a69816eccc1751 100644 (file)
@@ -31,14 +31,9 @@ extern "C" {
 #define thread_exit()                  __thread_exit()
 #define curthread                      get_current()
 
-/* We just need a valid type to pass around, it's unused */
-typedef struct proc_s {
-       int foo;
-} proc_t;
-
 extern kthread_t *__thread_create(caddr_t stk, size_t  stksize,
                             void (*proc)(void *), void *args,
-                            size_t len, proc_t *pp, int state,
+                            size_t len, int *pp, int state,
                             pri_t pri);
 extern void __thread_exit(void);
 
index 5d1c385b0ebbaac1041d34d7ecba3fddedf07ce0..e66872f0c0218eace74682da71a500fefb2de8b9 100644 (file)
@@ -4,5 +4,39 @@
 #include <linux/mm.h>
 
 #define physmem                                num_physpages
+#define ptob(pages)                    (pages * PAGE_SIZE)
+#define membar_producer()              smp_wmb()
+
+#if 0
+/* The approximate total number of free pages */
+#define freemem                                0
+
+/* The average number of free pages over the last 5 seconds */
+#define avefree                                0
+
+/* The average number of free pages over the last 30 seconds */
+#define avefree30                      0
+
+/* A guess as to how much memory has been promised to
+ * processes but not yet allocated */
+#define deficit                                0
+
+/* A guess as to how many page are needed to satisfy
+ * stalled page creation requests */
+#define needfree                       0
+
+/* A bootlean the controls the setting of deficit */
+#define desperate
+
+/* When free memory is above this limit, no paging or swapping is done */
+#define lotsfree                       0
+
+/* When free memory is above this limit, swapping is not performed */
+#define desfree                                0
+
+/* Threshold for many low memory tests, e.g. swapping is
+ * more active below this limit */
+#define minfree                                0
+#endif
 
 #endif /* SPL_VMSYSTM_H */
index 60bebfdc47bf85094b5b5e2c2e3ae4371d499ee9..1f982f8bdcca1388b4d201318c64948ead732545 100644 (file)
@@ -8,6 +8,37 @@
 int p0 = 0;
 EXPORT_SYMBOL(p0);
 
+int
+highbit(unsigned long i)
+{
+        register int h = 1;
+
+        if (i == 0)
+                return (0);
+#if BITS_PER_LONG == 64
+        if (i & 0xffffffff00000000ul) {
+                h += 32; i >>= 32;
+        }
+#endif
+        if (i & 0xffff0000) {
+                h += 16; i >>= 16;
+        }
+        if (i & 0xff00) {
+                h += 8; i >>= 8;
+        }
+        if (i & 0xf0) {
+                h += 4; i >>= 4;
+        }
+        if (i & 0xc) {
+                h += 2; i >>= 2;
+        }
+        if (i & 0x2) {
+                h += 1;
+        }
+        return (h);
+}
+EXPORT_SYMBOL(highbit);
+
 static int __init spl_init(void)
 {
         printk(KERN_INFO "spl: Loaded Solaris Porting Layer v%s\n", VERSION);
index 40b1b316f6b899536673860ef417100ecb46e51f..e6dca2300ea4a88f22a49def5ef98dc918952770 100644 (file)
@@ -60,7 +60,7 @@ EXPORT_SYMBOL(__thread_exit);
  * style callers likely never check for... since it can't fail. */
 kthread_t *
 __thread_create(caddr_t stk, size_t  stksize, void (*proc)(void *),
-               void *args, size_t len, proc_t *pp, int state, pri_t pri)
+               void *args, size_t len, int *pp, int state, pri_t pri)
 {
        thread_priv_t tp;
        DEFINE_WAIT(wait);
index aff18cd5f64a4401da6e3f469fdcb2f433c698a9..dec251efe744d19968bb467ab0ae23f81efcf68b 100644 (file)
@@ -51,7 +51,7 @@ splat_thread_test1(struct file *file, void *arg)
        spin_lock(&tp.tp_lock);
 
        thr = (kthread_t *)thread_create(NULL, 0, splat_thread_work, &tp, 0,
-                                        (proc_t *) &p0, TS_RUN, minclsyspri);
+                                        &p0, TS_RUN, minclsyspri);
        /* Must never fail under Solaris, but we check anyway so we can
         * report an error when this impossible thing happens */
        if (thr == NULL) {