Re: [PATCH v4 3.0-rc2-tip 2/22] 2: uprobes: Breakground page replacement.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/14, Srikar Dronamraju wrote:
>
> > > +static int write_opcode(struct task_struct *tsk, struct uprobe * uprobe,
> > > +			unsigned long vaddr, uprobe_opcode_t opcode)
> > > +{
> > > +	struct page *old_page, *new_page;
> > > +	void *vaddr_old, *vaddr_new;
> > > +	struct vm_area_struct *vma;
> > > +	unsigned long addr;
> > > +	int ret;
> > > +
> > > +	/* Read the page with vaddr into memory */
> > > +	ret = get_user_pages(tsk, tsk->mm, vaddr, 1, 1, 1, &old_page, &vma);
> >
> > Sorry if this was already discussed... But why we are using FOLL_WRITE here?
> > We are not going to write into this page, and this provokes the unnecessary
> > cow, no?
>
> Yes, We are not going to write to the page returned by get_user_pages
> but a copy of that page.

Yes I see. But the page returned by get_user_pages(write => 1) is already
a cow'ed copy (this mapping should be read-only).

> The idea was if we cow the page then we dont
> need to cow it at the replace_page time

Yes, replace_page() shouldn't cow.

> and since get_user_pages knows
> the right way to cow the page, we dont have to write another routine to
> cow the page.

Confused. write_opcode() allocs another page and does memcpy. This is
correct, but I don't understand the first cow.

> I am still not clear on your concern.

Probably I missed something... but could you please explain why we can't

	- ret = get_user_pages(tsk, tsk->mm, vaddr, 1, 1, 1, &old_page, &vma);
	+ ret = get_user_pages(tsk, tsk->mm, vaddr, 1, 0, 0, &old_page, &vma);

?

> > Also. This is called under down_read(mmap_sem), can't we race with
> > access_process_vm() modifying the same memory?
>
> Yes, we could be racing with access_process_vm on the same memory.
>
> Do we have any other option other than making write_opcode/read_opcode
> being called under down_write(mmap_sem)?

I dunno. Probably we can simply ignore this issue, there are other ways
to modify this memory.

Oleg.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  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@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]