From 9b56fdb458b014bdda974b43a3e59721032898bb Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 2 Nov 2007 16:43:10 +0100 Subject: [PATCH 1/4] lguest: make async_hcall() static async_hcall() can become static. Signed-off-by: Adrian Bunk Signed-off-by: Rusty Russell --- arch/x86/lguest/boot.c | 26 +++++++++++++------------- include/asm-x86/lguest_hcall.h | 3 --- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index a55b0902f9d3d0..e6023b86f31d34 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c @@ -113,17 +113,6 @@ static void lguest_leave_lazy_mode(void) hcall(LHCALL_FLUSH_ASYNC, 0, 0, 0); } -static void lazy_hcall(unsigned long call, - unsigned long arg1, - unsigned long arg2, - unsigned long arg3) -{ - if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) - hcall(call, arg1, arg2, arg3); - else - async_hcall(call, arg1, arg2, arg3); -} - /* async_hcall() is pretty simple: I'm quite proud of it really. We have a * ring buffer of stored hypercalls which the Host will run though next time we * do a normal hypercall. Each entry in the ring has 4 slots for the hypercall @@ -134,8 +123,8 @@ static void lazy_hcall(unsigned long call, * full and we just make the hypercall directly. This has the nice side * effect of causing the Host to run all the stored calls in the ring buffer * which empties it for next time! */ -void async_hcall(unsigned long call, - unsigned long arg1, unsigned long arg2, unsigned long arg3) +static void async_hcall(unsigned long call, unsigned long arg1, + unsigned long arg2, unsigned long arg3) { /* Note: This code assumes we're uniprocessor. */ static unsigned int next_call; @@ -161,6 +150,17 @@ void async_hcall(unsigned long call, } local_irq_restore(flags); } + +static void lazy_hcall(unsigned long call, + unsigned long arg1, + unsigned long arg2, + unsigned long arg3) +{ + if (paravirt_get_lazy_mode() == PARAVIRT_LAZY_NONE) + hcall(call, arg1, arg2, arg3); + else + async_hcall(call, arg1, arg2, arg3); +} /*:*/ /*G:033 diff --git a/include/asm-x86/lguest_hcall.h b/include/asm-x86/lguest_hcall.h index 9c5092b6aa9f29..2091779e91fbe4 100644 --- a/include/asm-x86/lguest_hcall.h +++ b/include/asm-x86/lguest_hcall.h @@ -54,9 +54,6 @@ hcall(unsigned long call, } /*:*/ -void async_hcall(unsigned long call, - unsigned long arg1, unsigned long arg2, unsigned long arg3); - /* Can't use our min() macro here: needs to be a constant */ #define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32) From 02c3530da6b926b31f89ba589da72eca49557edd Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 2 Nov 2007 16:43:28 +0100 Subject: [PATCH 2/4] unexport access_process_vm This patch removes the no longer used EXPORT_SYMBOL_GPL(access_process_vm). Signed-off-by: Adrian Bunk Signed-off-by: Rusty Russell --- mm/memory.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index eefd5b68bc42d7..9791e4786843f4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2748,4 +2748,3 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in return buf - old_buf; } -EXPORT_SYMBOL_GPL(access_process_vm); From fad23fc78b959dae89768e523c3a6f5edb83bbe9 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 2 Nov 2007 16:43:22 +0100 Subject: [PATCH 3/4] kernel/futex.c: make 3 functions static The following functions can now become static again: - get_futex_key() - get_futex_key_refs() - drop_futex_key_refs() Signed-off-by: Adrian Bunk Signed-off-by: Rusty Russell --- include/linux/futex.h | 4 ---- kernel/futex.c | 11 ++++------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/include/linux/futex.h b/include/linux/futex.h index 99650353adfaeb..92d420fe03f817 100644 --- a/include/linux/futex.h +++ b/include/linux/futex.h @@ -149,10 +149,6 @@ union futex_key { int offset; } both; }; -int get_futex_key(u32 __user *uaddr, struct rw_semaphore *shared, - union futex_key *key); -void get_futex_key_refs(union futex_key *key); -void drop_futex_key_refs(union futex_key *key); #ifdef CONFIG_FUTEX extern void exit_robust_list(struct task_struct *curr); diff --git a/kernel/futex.c b/kernel/futex.c index 32710451dc20ea..9dc591ab681a92 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -181,8 +181,8 @@ static inline int match_futex(union futex_key *key1, union futex_key *key2) * For other futexes, it points to ¤t->mm->mmap_sem and * caller must have taken the reader lock. but NOT any spinlocks. */ -int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, - union futex_key *key) +static int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, + union futex_key *key) { unsigned long address = (unsigned long)uaddr; struct mm_struct *mm = current->mm; @@ -268,14 +268,13 @@ int get_futex_key(u32 __user *uaddr, struct rw_semaphore *fshared, } return err; } -EXPORT_SYMBOL_GPL(get_futex_key); /* * Take a reference to the resource addressed by a key. * Can be called while holding spinlocks. * */ -inline void get_futex_key_refs(union futex_key *key) +static void get_futex_key_refs(union futex_key *key) { if (key->both.ptr == 0) return; @@ -288,13 +287,12 @@ inline void get_futex_key_refs(union futex_key *key) break; } } -EXPORT_SYMBOL_GPL(get_futex_key_refs); /* * Drop a reference to the resource addressed by a key. * The hash bucket spinlock must not be held. */ -void drop_futex_key_refs(union futex_key *key) +static void drop_futex_key_refs(union futex_key *key) { if (!key->both.ptr) return; @@ -307,7 +305,6 @@ void drop_futex_key_refs(union futex_key *key) break; } } -EXPORT_SYMBOL_GPL(drop_futex_key_refs); static u32 cmpxchg_futex_value_locked(u32 __user *uaddr, u32 uval, u32 newval) { From 633872b980f55f40a5e7de374f26970e41e2137b Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Nov 2007 21:55:57 +1100 Subject: [PATCH 4/4] lguest: tidy up documentation After Adrian Bunk's "make async_hcall static" moved things around, update comments to match (aka "make Guest"). Signed-off-by: Rusty Russell --- arch/x86/lguest/boot.c | 43 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index e6023b86f31d34..92c56117eae5ed 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c @@ -93,27 +93,7 @@ struct lguest_data lguest_data = { }; static cycle_t clock_base; -/*G:035 Notice the lazy_hcall() above, rather than hcall(). This is our first - * real optimization trick! - * - * When lazy_mode is set, it means we're allowed to defer all hypercalls and do - * them as a batch when lazy_mode is eventually turned off. Because hypercalls - * are reasonably expensive, batching them up makes sense. For example, a - * large munmap might update dozens of page table entries: that code calls - * paravirt_enter_lazy_mmu(), does the dozen updates, then calls - * lguest_leave_lazy_mode(). - * - * So, when we're in lazy mode, we call async_hypercall() to store the call for - * future processing. When lazy mode is turned off we issue a hypercall to - * flush the stored calls. - */ -static void lguest_leave_lazy_mode(void) -{ - paravirt_leave_lazy(paravirt_get_lazy_mode()); - hcall(LHCALL_FLUSH_ASYNC, 0, 0, 0); -} - -/* async_hcall() is pretty simple: I'm quite proud of it really. We have a +/*G:037 async_hcall() is pretty simple: I'm quite proud of it really. We have a * ring buffer of stored hypercalls which the Host will run though next time we * do a normal hypercall. Each entry in the ring has 4 slots for the hypercall * arguments, and a "hcall_status" word which is 0 if the call is ready to go, @@ -151,6 +131,18 @@ static void async_hcall(unsigned long call, unsigned long arg1, local_irq_restore(flags); } +/*G:035 Notice the lazy_hcall() above, rather than hcall(). This is our first + * real optimization trick! + * + * When lazy_mode is set, it means we're allowed to defer all hypercalls and do + * them as a batch when lazy_mode is eventually turned off. Because hypercalls + * are reasonably expensive, batching them up makes sense. For example, a + * large munmap might update dozens of page table entries: that code calls + * paravirt_enter_lazy_mmu(), does the dozen updates, then calls + * lguest_leave_lazy_mode(). + * + * So, when we're in lazy mode, we call async_hcall() to store the call for + * future processing. */ static void lazy_hcall(unsigned long call, unsigned long arg1, unsigned long arg2, @@ -161,7 +153,14 @@ static void lazy_hcall(unsigned long call, else async_hcall(call, arg1, arg2, arg3); } -/*:*/ + +/* When lazy mode is turned off reset the per-cpu lazy mode variable and then + * issue a hypercall to flush any stored calls. */ +static void lguest_leave_lazy_mode(void) +{ + paravirt_leave_lazy(paravirt_get_lazy_mode()); + hcall(LHCALL_FLUSH_ASYNC, 0, 0, 0); +} /*G:033 * After that diversion we return to our first native-instruction