linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux-mm <linux-mm@kvack.org>, Ingo Molnar <mingo@elte.hu>,
	Andi Kleen <andi@firstfloor.org>,
	Christoph Hellwig <hch@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Roland McGrath <roland@hack.frob.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Arnaldo Carvalho de Melo <acme@infradead.org>,
	Anton Arapov <anton@redhat.com>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Jim Keniston <jkenisto@linux.vnet.ibm.com>,
	Stephen Wilson <wilsons@start.ca>
Subject: [PATCH 5/5] uprobes: remove the uprobes_xol_area code
Date: Mon, 28 Nov 2011 20:07:46 +0100	[thread overview]
Message-ID: <20111128190746.GF4602@redhat.com> (raw)
In-Reply-To: <20111128190614.GA4602@redhat.com>

Remove the no longer needed uprobes_xol_area code.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 include/linux/mm_types.h |    1 -
 include/linux/uprobes.h  |   24 ------
 kernel/fork.c            |    2 -
 kernel/uprobes.c         |  198 ----------------------------------------------
 4 files changed, 0 insertions(+), 225 deletions(-)

diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 2595c9c..b3f1ece 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -392,7 +392,6 @@ struct mm_struct {
 #endif
 #ifdef CONFIG_UPROBES
 	atomic_t mm_uprobes_count;
-	struct uprobes_xol_area *uprobes_xol_area;
 #endif
 };
 
diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index bb59a66..4f92272 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -100,26 +100,6 @@ struct uprobe_task {
 	struct uprobe *active_uprobe;
 };
 
-/*
- * On a breakpoint hit, thread contests for a slot.  It free the
- * slot after singlestep.  Only definite number of slots are
- * allocated.
- */
-
-struct uprobes_xol_area {
-	wait_queue_head_t wq;	/* if all slots are busy */
-	atomic_t slot_count;	/* currently in use slots */
-	unsigned long *bitmap;	/* 0 = free slot */
-	struct page *page;
-
-	/*
-	 * We keep the vma's vm_start rather than a pointer to the vma
-	 * itself.  The probed process or a naughty kernel module could make
-	 * the vma go away, and we must handle that reasonably gracefully.
-	 */
-	unsigned long vaddr;		/* Page(s) of instruction slots */
-};
-
 #ifdef CONFIG_UPROBES
 extern int __weak set_bkpt(struct mm_struct *mm, struct uprobe *uprobe,
 							unsigned long vaddr);
@@ -131,7 +111,6 @@ extern int register_uprobe(struct inode *inode, loff_t offset,
 extern void unregister_uprobe(struct inode *inode, loff_t offset,
 				struct uprobe_consumer *consumer);
 extern void free_uprobe_utask(struct task_struct *tsk);
-extern void free_uprobes_xol_area(struct mm_struct *mm);
 extern int mmap_uprobe(struct vm_area_struct *vma);
 extern void munmap_uprobe(struct vm_area_struct *vma);
 extern unsigned long __weak get_uprobe_bkpt_addr(struct pt_regs *regs);
@@ -174,8 +153,5 @@ static inline unsigned long get_uprobe_bkpt_addr(struct pt_regs *regs)
 static inline void free_uprobe_utask(struct task_struct *tsk)
 {
 }
-static inline void free_uprobes_xol_area(struct mm_struct *mm)
-{
-}
 #endif /* CONFIG_UPROBES */
 #endif	/* _LINUX_UPROBES_H */
diff --git a/kernel/fork.c b/kernel/fork.c
index 166ee1b..a6b1757 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -553,7 +553,6 @@ void mmput(struct mm_struct *mm)
 	might_sleep();
 
 	if (atomic_dec_and_test(&mm->mm_users)) {
-		free_uprobes_xol_area(mm);
 		exit_aio(mm);
 		ksm_exit(mm);
 		khugepaged_exit(mm); /* must run before exit_mmap */
@@ -742,7 +741,6 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
 #endif
 #ifdef CONFIG_UPROBES
 	atomic_set(&mm->mm_uprobes_count, 0);
-	mm->uprobes_xol_area = NULL;
 #endif
 
 	if (!mm_init(mm, tsk))
diff --git a/kernel/uprobes.c b/kernel/uprobes.c
index c9e2f65..aaab607 100644
--- a/kernel/uprobes.c
+++ b/kernel/uprobes.c
@@ -33,9 +33,6 @@
 #include <linux/kdebug.h>	/* notifier mechanism */
 #include <linux/uprobes.h>
 
-#define UINSNS_PER_PAGE	(PAGE_SIZE/UPROBES_XOL_SLOT_BYTES)
-#define MAX_UPROBES_XOL_SLOTS UINSNS_PER_PAGE
-
 static bulkref_t uprobes_srcu;
 static struct rb_root uprobes_tree = RB_ROOT;
 static DEFINE_SPINLOCK(uprobes_treelock);	/* serialize rbtree access */
@@ -1062,201 +1059,6 @@ void munmap_uprobe(struct vm_area_struct *vma)
 	return;
 }
 
-/* Slot allocation for XOL */
-static int xol_add_vma(struct uprobes_xol_area *area)
-{
-	struct mm_struct *mm;
-	int ret;
-
-	area->page = alloc_page(GFP_HIGHUSER);
-	if (!area->page)
-		return -ENOMEM;
-
-	mm = current->mm;
-	down_write(&mm->mmap_sem);
-	ret = -EALREADY;
-	if (mm->uprobes_xol_area)
-		goto fail;
-
-	ret = -ENOMEM;
-
-	/* Try to map as high as possible, this is only a hint. */
-	area->vaddr = get_unmapped_area(NULL, TASK_SIZE - PAGE_SIZE,
-							PAGE_SIZE, 0, 0);
-	if (area->vaddr & ~PAGE_MASK) {
-		ret = area->vaddr;
-		goto fail;
-	}
-
-	ret = install_special_mapping(mm, area->vaddr, PAGE_SIZE,
-				VM_EXEC|VM_MAYEXEC|VM_DONTCOPY|VM_IO,
-				&area->page);
-	if (ret)
-		goto fail;
-
-	smp_wmb();	/* pairs with get_uprobes_xol_area() */
-	mm->uprobes_xol_area = area;
-	ret = 0;
-
-fail:
-	up_write(&mm->mmap_sem);
-	if (ret)
-		__free_page(area->page);
-
-	return ret;
-}
-
-static struct uprobes_xol_area *get_uprobes_xol_area(struct mm_struct *mm)
-{
-	struct uprobes_xol_area *area = mm->uprobes_xol_area;
-	smp_read_barrier_depends();/* pairs with wmb in xol_add_vma() */
-	return area;
-}
-
-/*
- * xol_alloc_area - Allocate process's uprobes_xol_area.
- * This area will be used for storing instructions for execution out of
- * line.
- *
- * Returns the allocated area or NULL.
- */
-static struct uprobes_xol_area *xol_alloc_area(void)
-{
-	struct uprobes_xol_area *area;
-
-	area = kzalloc(sizeof(*area), GFP_KERNEL);
-	if (unlikely(!area))
-		return NULL;
-
-	area->bitmap = kzalloc(BITS_TO_LONGS(UINSNS_PER_PAGE) * sizeof(long),
-								GFP_KERNEL);
-
-	if (!area->bitmap)
-		goto fail;
-
-	init_waitqueue_head(&area->wq);
-	if (!xol_add_vma(area))
-		return area;
-
-fail:
-	kfree(area->bitmap);
-	kfree(area);
-	return get_uprobes_xol_area(current->mm);
-}
-
-/*
- * free_uprobes_xol_area - Free the area allocated for slots.
- */
-void free_uprobes_xol_area(struct mm_struct *mm)
-{
-	struct uprobes_xol_area *area = mm->uprobes_xol_area;
-
-	if (!area)
-		return;
-
-	put_page(area->page);
-	kfree(area->bitmap);
-	kfree(area);
-}
-
-/*
- *  - search for a free slot.
- */
-static unsigned long xol_take_insn_slot(struct uprobes_xol_area *area)
-{
-	unsigned long slot_addr;
-	int slot_nr;
-
-	do {
-		slot_nr = find_first_zero_bit(area->bitmap, UINSNS_PER_PAGE);
-		if (slot_nr < UINSNS_PER_PAGE) {
-			if (!test_and_set_bit(slot_nr, area->bitmap))
-				break;
-
-			slot_nr = UINSNS_PER_PAGE;
-			continue;
-		}
-		wait_event(area->wq,
-			(atomic_read(&area->slot_count) < UINSNS_PER_PAGE));
-	} while (slot_nr >= UINSNS_PER_PAGE);
-
-	slot_addr = area->vaddr + (slot_nr * UPROBES_XOL_SLOT_BYTES);
-	atomic_inc(&area->slot_count);
-	return slot_addr;
-}
-
-/*
- * xol_get_insn_slot - If was not allocated a slot, then
- * allocate a slot.
- * Returns the allocated slot address or 0.
- */
-static unsigned long xol_get_insn_slot(struct uprobe *uprobe,
-					unsigned long slot_addr)
-{
-	struct uprobes_xol_area *area;
-	unsigned long offset;
-	void *vaddr;
-
-	area = get_uprobes_xol_area(current->mm);
-	if (!area) {
-		area = xol_alloc_area();
-		if (!area)
-			return 0;
-	}
-	current->utask->xol_vaddr = xol_take_insn_slot(area);
-
-	/*
-	 * Initialize the slot if xol_vaddr points to valid
-	 * instruction slot.
-	 */
-	if (unlikely(!current->utask->xol_vaddr))
-		return 0;
-
-	current->utask->vaddr = slot_addr;
-	offset = current->utask->xol_vaddr & ~PAGE_MASK;
-	vaddr = kmap_atomic(area->page);
-	memcpy(vaddr + offset, uprobe->insn, MAX_UINSN_BYTES);
-	kunmap_atomic(vaddr);
-	return current->utask->xol_vaddr;
-}
-
-/*
- * xol_free_insn_slot - If slot was earlier allocated by
- * @xol_get_insn_slot(), make the slot available for
- * subsequent requests.
- */
-static void xol_free_insn_slot(struct task_struct *tsk)
-{
-	struct uprobes_xol_area *area;
-	unsigned long vma_end;
-	unsigned long slot_addr;
-
-	if (!tsk->mm || !tsk->mm->uprobes_xol_area || !tsk->utask)
-		return;
-
-	slot_addr = tsk->utask->xol_vaddr;
-
-	if (unlikely(!slot_addr || IS_ERR_VALUE(slot_addr)))
-		return;
-
-	area = tsk->mm->uprobes_xol_area;
-	vma_end = area->vaddr + PAGE_SIZE;
-	if (area->vaddr <= slot_addr && slot_addr < vma_end) {
-		int slot_nr;
-		unsigned long offset = slot_addr - area->vaddr;
-
-		slot_nr = offset / UPROBES_XOL_SLOT_BYTES;
-		if (slot_nr >= UINSNS_PER_PAGE)
-			return;
-
-		clear_bit(slot_nr, area->bitmap);
-		atomic_dec(&area->slot_count);
-		if (waitqueue_active(&area->wq))
-			wake_up(&area->wq);
-		tsk->utask->xol_vaddr = 0;
-	}
-}
-
 /**
  * get_uprobe_bkpt_addr - compute address of bkpt given post-bkpt regs
  * @regs: Reflects the saved state of the task after it has hit a breakpoint
-- 
1.5.5.1


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2011-11-28 19:12 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-18 11:06 [PATCH v7 3.2-rc2 0/30] uprobes patchset with perf probe support Srikar Dronamraju
2011-11-18 11:06 ` [PATCH v7 3.2-rc2 1/30] uprobes: Auxillary routines to insert, find, delete uprobes Srikar Dronamraju
2011-11-23 18:23   ` Peter Zijlstra
2011-11-18 11:07 ` [PATCH v7 3.2-rc2 2/30] uprobes: Allow multiple consumers for an uprobe Srikar Dronamraju
2011-11-18 11:07 ` [PATCH v7 3.2-rc2 3/30] uprobes: register/unregister probes Srikar Dronamraju
2011-11-23 16:09   ` Peter Zijlstra
2011-11-23 16:11     ` Peter Zijlstra
2011-11-24 14:39     ` Srikar Dronamraju
2011-11-23 16:22   ` Peter Zijlstra
2011-11-23 16:27   ` Peter Zijlstra
2011-11-23 16:35   ` Peter Zijlstra
2011-11-28 15:29   ` Peter Zijlstra
2011-11-29  7:48     ` Srikar Dronamraju
2011-11-29 10:52       ` Peter Zijlstra
2011-12-01 13:41         ` Srikar Dronamraju
2011-12-01 13:20   ` Peter Zijlstra
2011-11-18 11:07 ` [PATCH v7 3.2-rc2 4/30] uprobes: Define hooks for mmap/munmap Srikar Dronamraju
2011-11-23 17:13   ` Peter Zijlstra
2011-11-23 18:10   ` Peter Zijlstra
2011-11-24 13:47     ` Srikar Dronamraju
2011-11-24 14:13       ` Peter Zijlstra
2011-11-24 14:25         ` Srikar Dronamraju
2011-11-28 14:59       ` Peter Zijlstra
2011-11-29  8:33         ` Srikar Dronamraju
2011-11-29 11:48           ` Peter Zijlstra
2011-11-29 15:05             ` Peter Zijlstra
2011-11-30  5:50               ` Srikar Dronamraju
2011-11-29 16:22             ` Srikar Dronamraju
2011-11-30 12:25               ` Peter Zijlstra
2011-12-01  5:40                 ` Srikar Dronamraju
2011-12-01 11:36                   ` Peter Zijlstra
2011-12-01 13:24                     ` Srikar Dronamraju
2011-11-30  5:30           ` Srikar Dronamraju
2011-11-23 18:15   ` Peter Zijlstra
2011-11-23 19:50     ` Steven Rostedt
2011-11-24 13:37     ` Srikar Dronamraju
2011-11-24 13:47       ` Peter Zijlstra
2011-11-18 11:07 ` [PATCH v7 3.2-rc2 5/30] uprobes: copy of the original instruction Srikar Dronamraju
2011-11-23 18:26   ` Peter Zijlstra
2011-11-23 18:40   ` Peter Zijlstra
2011-11-23 19:49     ` Steven Rostedt
2011-11-23 20:52       ` Peter Zijlstra
2011-11-24 12:50     ` Srikar Dronamraju
2011-11-28 14:23   ` Peter Zijlstra
2011-11-18 11:07 ` [PATCH v7 3.2-rc2 6/30] uprobes: define fixups Srikar Dronamraju
2011-11-18 11:07 ` [PATCH v7 3.2-rc2 7/30] uprobes: uprobes arch info Srikar Dronamraju
2011-11-18 11:08 ` [PATCH v7 3.2-rc2 8/30] x86: analyze instruction and determine fixups Srikar Dronamraju
2011-11-30 18:57   ` Oleg Nesterov
2011-12-01  5:52     ` Srikar Dronamraju
2011-11-18 11:08 ` [PATCH v7 3.2-rc2 9/30] uprobes: Background page replacement Srikar Dronamraju
2011-11-25 14:29   ` Peter Zijlstra
2011-11-25 14:54   ` Peter Zijlstra
2011-11-26  2:25     ` Srikar Dronamraju
2011-11-28 14:13   ` Peter Zijlstra
2011-11-29  7:49     ` Srikar Dronamraju
2011-11-28 15:01   ` Peter Zijlstra
2011-11-18 11:08 ` [PATCH v7 3.2-rc2 10/30] x86: Set instruction pointer Srikar Dronamraju
2011-11-18 11:08 ` [PATCH v7 3.2-rc2 11/30] x86: Introduce TIF_UPROBE FLAG Srikar Dronamraju
2011-11-18 11:09 ` [PATCH v7 3.2-rc2 12/30] uprobes: Handle breakpoint and Singlestep Srikar Dronamraju
2011-11-25 15:24   ` Peter Zijlstra
2011-11-26  2:22     ` Srikar Dronamraju
2011-11-18 11:09 ` [PATCH v7 3.2-rc2 13/30] x86: define a x86 specific exception notifier Srikar Dronamraju
2011-11-18 11:09 ` [PATCH v7 3.2-rc2 14/30] uprobe: register " Srikar Dronamraju
2011-11-18 11:09 ` [PATCH v7 3.2-rc2 15/30] x86: Define x86_64 specific uprobe_task_arch_info structure Srikar Dronamraju
2011-11-18 11:09 ` [PATCH v7 3.2-rc2 16/30] uprobes: Introduce " Srikar Dronamraju
2011-11-18 11:09 ` [PATCH v7 3.2-rc2 17/30] x86: arch specific hooks for pre/post singlestep handling Srikar Dronamraju
2011-11-18 11:10 ` [PATCH v7 3.2-rc2 18/30] uprobes: slot allocation Srikar Dronamraju
2011-11-18 11:10 ` [PATCH v7 3.2-rc2 19/30] tracing: modify is_delete, is_return from ints to bool Srikar Dronamraju
2011-11-23 19:24   ` Steven Rostedt
2011-11-18 11:10 ` [PATCH v7 3.2-rc2 20/30] tracing: Extract out common code for kprobes/uprobes traceevents Srikar Dronamraju
2011-11-23 19:32   ` Steven Rostedt
2011-11-24 13:12     ` Srikar Dronamraju
2011-11-18 11:10 ` [PATCH v7 3.2-rc2 21/30] tracing: uprobes trace_event interface Srikar Dronamraju
2011-11-18 11:10 ` [PATCH v7 3.2-rc2 22/30] perf: rename target_module to target Srikar Dronamraju
2011-11-18 11:11 ` [PATCH v7 3.2-rc2 23/30] perf: perf interface for uprobes Srikar Dronamraju
2011-11-18 11:11 ` [PATCH v7 3.2-rc2 24/30] perf: show possible probes in a given executable file or library Srikar Dronamraju
2011-11-18 11:11 ` [PATCH v7 3.2-rc2 25/30] uprobes: call post_xol() unconditionally Srikar Dronamraju
2011-11-18 11:11 ` [PATCH v7 3.2-rc2 26/30] uprobes: introduce uprobe_deny_signal() Srikar Dronamraju
2011-11-18 11:12 ` [PATCH v7 3.2-rc2 27/30] uprobes: x86: introduce xol_was_trapped() Srikar Dronamraju
2011-11-18 11:12 ` [PATCH v7 3.2-rc2 28/30] uprobes: introduce UTASK_SSTEP_TRAPPED logic Srikar Dronamraju
2011-11-18 11:12 ` [PATCH v7 3.2-rc2 29/30] uprobes: Introduce uprobe flags Srikar Dronamraju
2011-11-18 11:12 ` [PATCH v7 3.2-rc2 30/30] x86: skip singlestep where possible Srikar Dronamraju
2011-11-22  5:03 ` [PATCH v7 3.2-rc2 0/30] uprobes patchset with perf probe support Srikar Dronamraju
2011-11-22 14:49   ` Stephen Rothwell
2011-11-23 13:20     ` Srikar Dronamraju
2011-11-23 13:38       ` Stephen Rothwell
2011-11-28 19:06 ` [PATCH RFC 0/5] uprobes: kill xol vma Oleg Nesterov
2011-11-28 19:06   ` [PATCH 1/5] uprobes: kill pre_ssout(), introduce set_xol_ip() Oleg Nesterov
2011-11-28 19:06   ` [PATCH 2/5] uprobes: introduce uprobe_switch_to() Oleg Nesterov
2011-11-28 19:53     ` Peter Zijlstra
2011-11-29 17:18       ` Oleg Nesterov
2011-11-30 12:11         ` Peter Zijlstra
2011-11-30 17:10           ` Oleg Nesterov
2011-11-28 19:07   ` [PATCH 3/5] uprobes: introduce uprobe_xol_slots[NR_CPUS] Oleg Nesterov
2011-11-28 19:48     ` Peter Zijlstra
2011-11-28 19:52       ` Peter Zijlstra
2011-11-29 18:24     ` Oleg Nesterov
2011-11-28 19:07   ` [PATCH 4/5] uprobes: teach set_xol_ip() to use uprobe_xol_slots[] Oleg Nesterov
2011-11-28 19:07   ` Oleg Nesterov [this message]
2011-11-28 19:57   ` [PATCH RFC 0/5] uprobes: kill xol vma Peter Zijlstra
2011-11-29 10:30   ` Srikar Dronamraju
2011-11-29 18:26     ` Oleg Nesterov
2011-11-30 16:15       ` Andi Kleen
2011-11-30 16:20         ` Peter Zijlstra
2011-11-30 18:47           ` Oleg Nesterov
2011-12-12 17:30   ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111128190746.GF4602@redhat.com \
    --to=oleg@redhat.com \
    --cc=acme@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=ananth@in.ibm.com \
    --cc=andi@firstfloor.org \
    --cc=anton@redhat.com \
    --cc=hch@infradead.org \
    --cc=jkenisto@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=roland@hack.frob.com \
    --cc=rostedt@goodmis.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=wilsons@start.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).