Add highbit func,

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
This commit is contained in:
behlendo 2008-03-06 23:12:55 +00:00
parent a713518f5d
commit 77b1fe8fa8
7 changed files with 88 additions and 12 deletions

View 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)
{

View 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 */

View 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);

View 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 */

View 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);

View 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);

View 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) {