[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20121222160228.GB18082@redhat.com>
Date: Sat, 22 Dec 2012 17:02:28 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Anton Arapov <anton@...hat.com>
Cc: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
LKML <linux-kernel@...r.kernel.org>,
Josh Stone <jistone@...hat.com>,
Frank Eigler <fche@...hat.com>,
Anithra P Janakiraman <anithra@...ux.vnet.ibm.com>
Subject: Re: [RFC PATCH 2/6] uretprobes: trampoline implementation
On 12/21, Anton Arapov wrote:
>
> +static unsigned long xol_get_trampoline_slot(void)
> +{
> + struct xol_area *area;
> + unsigned long offset;
> + void *vaddr;
> + uprobe_opcode_t bp_insn = UPROBE_SWBP_INSN;
> +
> + area = get_xol_area(current->mm);
> + if (!area) {
> + area = xol_alloc_area();
> + if (!area)
> + return 0;
> + }
> +
> + if (!area->rp_trampoline_vaddr)
> + area->rp_trampoline_vaddr = xol_take_insn_slot(area);
> +
> + /*
> + * Initialize the slot if rp_trampoline_vaddr points to valid
> + * instruction slot.
> + */
> + if (unlikely(!area->rp_trampoline_vaddr))
> + return 0;
> +
> + offset = area->rp_trampoline_vaddr & ~PAGE_MASK;
> + vaddr = kmap_atomic(area->page);
> + memcpy(vaddr + offset, &bp_insn, UPROBE_SWBP_INSN_SIZE);
> + kunmap_atomic(vaddr);
> +
> + return area->rp_trampoline_vaddr;
> +}
Oh, this should be unified with xol_get_insn_slot(), we certainly do not
want to copy-and-paste it.
Or. Perhaps even better, do not add this helper at all. xol_alloc_area()
could reserve the first slot/bit for trampoline. And note that in this
case we do not need xol_area->rp_trampoline_vaddr, it is always equal
to xol_area->vaddr.
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists