Re: [PATCH v3 0/10] Uprobes v3

From: Srikar Dronamraju
Date: Thu May 13 2010 - 08:07:52 EST


>
> Hrmm, you could do something like the above and use write_protect_page()
> along with that lock_page() you do to sync against concurrent faults. It
> won't be the fastest code around but it should work I guess.

Okay, thanks for the code.

>
> Something like try_to_merge_one_page() in the KSM code:
>
> write_opcode(struct mm_struct *mm, unsigned long address, void *insn,
> int len)
> {
> down_read(mm->mmap_sem);

[ snipped]
>
> kunmap_atomic(vaddr_new);
> kunmap_atomic(vaddr_old);
>
> /* XXX: frob mlock state */

I think you are referring to mlock_vma_page() and munlock_vma_page that
we have in try_to_merge_one_page(). However mlock_vma_page and
munlock_vma_page are not exposed outside mm as they are declared inside
mm/internal.h. So do you suggest moving the declarations out of
mm/internal.h or have a wrapper function defined in mm/ that could be
used by both KSM and uprobes.

>
> /* flip pages, do_wp_page() will fail pte_same() and bail */
> err = replace_page(vma, new_page, old_page, orig_pte)
> if (err) goto fail_more;
>
> /* we're done, let 'em rip */
> unlock_page(old_page);
> put_page(old_page);
>
> return;
>
> fail:
> /* XXX: fixup stuff */
> }
>
> Note that this can fail for fun reasons like O_DIRECT IO, but that
> should be very rare indeed on text pages.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/