[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <dfd4c3ee-bd27-bc33-9b77-f10fac363a7e@linux.vnet.ibm.com>
Date: Thu, 1 Mar 2018 10:55:07 +0530
From: Ravi Bangoria <ravi.bangoria@...ux.vnet.ibm.com>
To: Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
Cc: peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
namhyung@...nel.org, linux-kernel@...r.kernel.org,
rostedt@...dmis.org, mhiramat@...nel.org,
ananth@...ux.vnet.ibm.com, naveen.n.rao@...ux.vnet.ibm.com,
oleg@...hat.com, Ravi Bangoria <ravi.bangoria@...ux.vnet.ibm.com>,
linux-mm@...ck.org, Michal Hocko <mhocko@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [RFC 2/4] Uprobe: Export few functions / data structures
On 02/28/2018 05:54 PM, Srikar Dronamraju wrote:
>> @@ -149,6 +155,11 @@ struct uprobes_state {
>> extern bool arch_uprobe_ignore(struct arch_uprobe *aup, struct pt_regs *regs);
>> extern void arch_uprobe_copy_ixol(struct page *page, unsigned long vaddr,
>> void *src, unsigned long len);
>> +unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset);
>> +void copy_from_page(struct page *page, unsigned long vaddr, void *dst, int len);
>> +void copy_to_page(struct page *page, unsigned long vaddr, const void *src, int len);
>> +struct uprobe_map_info *free_uprobe_map_info(struct uprobe_map_info *info);
>> +
>> #else /* !CONFIG_UPROBES */
> If we have to export the above, we might have to work with mm maintainers and
> see if we can move them there.
Adding
linux-mm@...ck.org
Michal Hocko <mhocko@...nel.org>
Andrew Morton <akpm@...ux-foundation.org>
in the cc.
>> -static inline struct uprobe_map_info *
>> -free_uprobe_map_info(struct uprobe_map_info *info)
>> +struct uprobe_map_info *free_uprobe_map_info(struct uprobe_map_info *info)
>> {
>> struct uprobe_map_info *next = info->next;
>> kfree(info);
>> return next;
>> }
>>
>> -static struct uprobe_map_info *
>> -build_uprobe_map_info(struct address_space *mapping, loff_t offset,
>> - bool is_register)
>> +struct uprobe_map_info *build_uprobe_map_info(struct address_space *mapping,
>> + loff_t offset, bool is_register)
>> {
>> unsigned long pgoff = offset >> PAGE_SHIFT;
>> struct vm_area_struct *vma;
> Instead of exporting, did you look at extending the uprobe consumer with
> ops. i.e if the consumer detects that a probe is a semaphore and exports
> a set of callbacks which can them be called from uprobe
> insertion/deletion time. With such a thing, incrementing/decrementing
> the semaphore and the insertion/deletion of the breakpoint can be done
> at one shot. No?
Yes, we tried that approach as well. Basically, when install_breakpoint() get called,
notify consumer about that. We can either use consumer_filter function or add a
new callback into uprobe_consumer which will get called if install_breakpoint()
succeeds. something like:
if (install_breakpoint()) {
/* Notify consumers right after patching instruction. */
consumer->post_prepare();
}
There are different problem with that approach. install_breakpoint() gets called in
very early stage of binary loading and vma that holds the semaphore won't be
present in the mm yet. I also tried to solve this by creating a task_work in
consumer callback. task_work handler will get called when process virtual memory
map is fully prepared and we are going back to userspace. But it will make design
quite complicated. Also, there is no way to know if mm_struct we got in task_work
handler is _still_ valid.
With unregister also, we first remove the "caller" consumer and then re-patch
original instruction. i.e.
__uprobe_unregister()
{
if (WARN_ON(!consumer_del(uprobe, uc)))
return;
err = register_for_each_vma(uprobe, NULL);
We don't callback "caller" consumer at unregistration.
Our idea is to make changes in core uprobe as less as possible. And IMHO,
exporting build_map_info() helps to simplifies the implementation.
Let me know if I'm missing something.
Thanks for the review,
Ravi
Powered by blists - more mailing lists