[SSI] openssi/kernel/include/asm-x86_64 atomic.h, 1.2, 1.3 desc.h, 1.1, 1.2 fcntl.h, 1.2, 1.3 mman.h, 1.2, 1.3 semaphore.h, 1.2, 1.3 system.h, 1.1, 1.2 uaccess.h, 1.2, 1.3

John Hughes <[email protected]> Mon, 15 Feb 2010 16:51:42 +0000
Newsgroups gmane.linux.cluster.ssic.cvs
Message-ID <[email protected]>
Update of /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv29261/include/asm-x86_64

Modified Files:
      Tag: OPENSSI-DEBIAN
	atomic.h desc.h fcntl.h mman.h semaphore.h system.h uaccess.h 
Log Message:
Patch VANILLA x86_64 files for OpenSSI

Index: atomic.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64/atomic.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- atomic.h	15 Feb 2010 16:48:43 -0000	1.2
+++ atomic.h	15 Feb 2010 16:51:39 -0000	1.3
@@ -378,4 +378,20 @@
 #define smp_mb__before_atomic_inc()	barrier()
 #define smp_mb__after_atomic_inc()	barrier()
 
+#ifdef __HAVE_ARCH_CMPXCHG
+
+static __inline__ int atomic_test_and_add(int i, atomic_t *v)
+{
+	int o, n;
+	do {
+		o = atomic_read(v);
+		if (o <= 0)
+			return 0;
+		n = o + i;
+	} while (cmpxchg((volatile int *)v, o, n) != o);
+	return 1;
+}
+
+#endif
+
 #endif

Index: mman.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64/mman.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mman.h	15 Feb 2010 16:48:43 -0000	1.2
+++ mman.h	15 Feb 2010 16:51:39 -0000	1.3
@@ -23,6 +23,10 @@
 #define MAP_NORESERVE	0x4000		/* don't check for reservations */
 #define MAP_POPULATE	0x8000		/* populate (prefault) pagetables */
 #define MAP_NONBLOCK	0x10000		/* do not block on IO */
+#ifdef CONFIG_SSI
+#define MAP_MIGRATE     0x40000         /* mapping that should be taken to the remote node */
+#endif
+
 
 #define MS_ASYNC	1		/* sync memory asynchronously */
 #define MS_INVALIDATE	2		/* invalidate the caches */

Index: fcntl.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64/fcntl.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- fcntl.h	15 Feb 2010 16:48:43 -0000	1.2
+++ fcntl.h	15 Feb 2010 16:51:39 -0000	1.3
@@ -22,6 +22,10 @@
 #define O_NOFOLLOW	0400000 /* don't follow links */
 #define O_NOATIME	01000000
 
+#ifdef CONFIG_SSI
+#define O_NOOPEN       02000000 /* don't call open op */
+#endif
+
 #define F_DUPFD		0	/* dup */
 #define F_GETFD		1	/* get close_on_exec */
 #define F_SETFD		2	/* set/clear close_on_exec */

Index: system.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64/system.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- system.h	13 Feb 2010 13:46:39 -0000	1.1
+++ system.h	15 Feb 2010 16:51:39 -0000	1.2
@@ -70,6 +70,12 @@
 		".previous"			\
 		: :"r" (value), "r" (0))
 
+/*
+ * Save a segment register away
+ */
+#define savesegment(seg, value) \
+	asm volatile("movw %%" #seg ",%0":"=m" (value))
+
 #define set_debug(value,register) \
                 __asm__("movq %0,%%db" #register  \
 		: /* no output */ \

Index: desc.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64/desc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- desc.h	13 Feb 2010 13:46:39 -0000	1.1
+++ desc.h	15 Feb 2010 16:51:39 -0000	1.2
@@ -212,6 +212,10 @@
 
 extern struct desc_ptr idt_descr;
 
+#ifdef CONFIG_SSI
+extern int copy_ldt(mm_context_t *new, mm_context_t *old);
+#endif
+
 #endif /* !__ASSEMBLY__ */
 
 #endif

Index: uaccess.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64/uaccess.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- uaccess.h	15 Feb 2010 16:48:43 -0000	1.2
+++ uaccess.h	15 Feb 2010 16:51:40 -0000	1.3
@@ -101,7 +101,7 @@
 		:"rbx")
 
 /* Careful: we have to cast the result to the type of the pointer for sign reasons */
-#define get_user(x,ptr)							\
+#define get_user_lcl(x,ptr)						\
 ({	unsigned long __val_gu;						\
 	int __ret_gu; 							\
 	__chk_user_ptr(ptr);						\
@@ -129,12 +129,12 @@
 		:"0" (ptr),"d" (x)					\
 		:"rbx")
 
-#define put_user(x,ptr)							\
+#define put_user_lcl(x,ptr)							\
   __put_user_check((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
-#define __get_user(x,ptr) \
+#define __get_user_lcl(x,ptr) \
   __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
-#define __put_user(x,ptr) \
+#define __put_user_lcl(x,ptr) \
   __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
 
 #define __get_user_unaligned __get_user
@@ -242,11 +242,12 @@
 /* Handles exceptions in both to and from, but doesn't do access_ok */
 extern unsigned long copy_user_generic(void *to, const void *from, unsigned len); 
 
-extern unsigned long copy_to_user(void __user *to, const void *from, unsigned len); 
-extern unsigned long copy_from_user(void *to, const void __user *from, unsigned len); 
+extern unsigned long copy_to_user_lcl(void __user *to, const void *from, unsigned len); 
+extern unsigned long copy_from_user_lcl(void *to, const void __user *from, unsigned len); 
+/* SSI_FIXMEL: What to do for this? */
 extern unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len); 
 
-static inline int __copy_from_user(void *dst, const void __user *src, unsigned size) 
+static inline int __copy_from_user_lcl(void *dst, const void __user *src, unsigned size) 
 { 
        int ret = 0;
 	if (!__builtin_constant_p(size))
@@ -275,7 +276,7 @@
 	}
 }	
 
-static inline int __copy_to_user(void __user *dst, const void *src, unsigned size) 
+static inline int __copy_to_user_lcl(void __user *dst, const void *src, unsigned size) 
 { 
        int ret = 0;
 	if (!__builtin_constant_p(size))
@@ -347,14 +348,19 @@
 	}
 }	
 
-long strncpy_from_user(char *dst, const char __user *src, long count);
-long __strncpy_from_user(char *dst, const char __user *src, long count);
-long strnlen_user(const char __user *str, long n);
-long strlen_user(const char __user *str);
-unsigned long clear_user(void __user *mem, unsigned long len);
-unsigned long __clear_user(void __user *mem, unsigned long len);
+long strncpy_from_user_lcl(char *dst, const char __user *src, long count);
+long __strncpy_from_user_lcl(char *dst, const char __user *src, long count);
+long strnlen_user_lcl(const char __user *str, long n);
+long strlen_user_lcl(const char __user *str);
+unsigned long clear_user_lcl(void __user *mem, unsigned long len);
+unsigned long __clear_user_lcl(void __user *mem, unsigned long len);
+
+#define __copy_to_user_inatomic_lcl __copy_to_user_lcl
+#define __copy_from_user_inatomic_lcl __copy_from_user_lcl
 
 #define __copy_to_user_inatomic __copy_to_user
 #define __copy_from_user_inatomic __copy_from_user
 
+#include <cluster/ssi/rcopy_uaccess.h>
+
 #endif /* __X86_64_UACCESS_H */

Index: semaphore.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/asm-x86_64/semaphore.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- semaphore.h	15 Feb 2010 16:48:43 -0000	1.2
+++ semaphore.h	15 Feb 2010 16:51:39 -0000	1.3
@@ -42,19 +42,53 @@
 #include <linux/wait.h>
 #include <linux/rwsem.h>
 #include <linux/stringify.h>
+#ifdef CONFIG_SSI
+#include <asm/current.h>
+#endif
 
 struct semaphore {
 	atomic_t count;
 	int sleepers;
+#ifdef CONFIG_SSI
+	void *owner;
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+/* Support recursive non-interruptible acquired sempahore. This is needed
+ * for OpenSSI CFS client@server because in those code paths
+ * the VM revisits -eg. generic_file_writev() on memory pressure.	-Roger
+ */
+	void *flusher;
+#endif
+#endif
 	wait_queue_head_t wait;
 };
 
+#ifdef CONFIG_SSI
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
 #define __SEMAPHORE_INITIALIZER(name, n)				\
 {									\
 	.count		= ATOMIC_INIT(n),				\
 	.sleepers	= 0,						\
+	.owner		= NULL,						\
+	.flusher	= NULL,						\
 	.wait		= __WAIT_QUEUE_HEAD_INITIALIZER((name).wait)	\
 }
+#else
+#define __SEMAPHORE_INITIALIZER(name, n)                                \
+{                                                                       \
+	.count          = ATOMIC_INIT(n),                               \
+	.sleepers       = 0,                                            \
+	.owner          = NULL,                                         \
+	.wait           = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait)    \
+}
+#endif
+#else
+#define __SEMAPHORE_INITIALIZER(name, n)				\
+{									\
+	.count		= ATOMIC_INIT(n),				\
+	.sleepers	= 0,						\
+	.wait		= __WAIT_QUEUE_HEAD_INITIALIZER((name).wait)	\
+}
+#endif
 
 #define __MUTEX_INITIALIZER(name) \
 	__SEMAPHORE_INITIALIZER(name,1)
@@ -75,6 +109,12 @@
  */
 	atomic_set(&sem->count, val);
 	sem->sleepers = 0;
+#ifdef CONFIG_SSI
+	sem->owner = NULL;
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+	sem->flusher = NULL;
+#endif
+#endif
 	init_waitqueue_head(&sem->wait);
 }
 
@@ -98,6 +138,19 @@
 asmlinkage int  __down_trylock(struct semaphore * sem);
 asmlinkage void __up(struct semaphore * sem);
 
+#ifdef CONFIG_SSI
+static inline int sem_owned(struct semaphore *sem)
+{
+	return (sem->owner == current);
+}
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+static inline int sem_flushing(struct semaphore *sem)
+{
+	return (sem->flusher == current);
+}
+
+#endif
+#endif
 /*
  * This is ugly, but we want the default case to fall through.
  * "__down_failed" is a special asm handler that calls the C
@@ -105,6 +158,12 @@
  */
 static inline void down(struct semaphore * sem)
 {
+#ifdef CONFIG_SSI
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+	if (sem_flushing(sem))
+		return;
+#endif
+#endif
 	might_sleep();
 
 	__asm__ __volatile__(
@@ -119,6 +178,9 @@
 		:"=m" (sem->count)
 		:"D" (sem)
 		:"memory");
+#ifdef CONFIG_SSI
+	sem->owner = current;
+#endif
 }
 
 /*
@@ -144,6 +206,10 @@
 		:"=a" (result), "=m" (sem->count)
 		:"D" (sem)
 		:"memory");
+#ifdef CONFIG_SSI
+	if (result == 0)
+		sem->owner = current;
+#endif
 	return result;
 }
 
@@ -168,6 +234,10 @@
 		:"=a" (result), "=m" (sem->count)
 		:"D" (sem)
 		:"memory","cc");
+#ifdef CONFIG_SSI
+	if (result == 0)
+		sem->owner = current;
+#endif
 	return result;
 }
 
@@ -179,6 +249,13 @@
  */
 static inline void up(struct semaphore * sem)
 {
+#ifdef CONFIG_SSI
+#ifdef CFS_FILE_WRITE_LIVELOCK_FIX
+	if (sem_flushing(sem))
+		return;
+#endif
+	sem->owner = NULL;
+#endif
 	__asm__ __volatile__(
 		"# atomic up operation\n\t"
 		LOCK "incl %0\n\t"     /* ++sem->count */
@@ -192,5 +269,6 @@
 		:"D" (sem)
 		:"memory");
 }
+
 #endif /* __KERNEL__ */
 #endif


------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev