Skip to contentSkip to conversation

uprobes: tmpfs support

GIT PULL Oleg Nesterov 3 participants 4 messages Jun 2, 2014

lore
Share & tools
lore
#0 lore raw

Ingo, please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc uprobes/core

Based on tip:perf/uprobes

Usually I try to accumulate more changes before I ask to pull, but v3.15 is close and it would be nice to merge the tmpfs fix too. Plus a purely cosmetic change I promised to do when we discussed the x86 changes.

Oleg Nesterov (3):

      uprobes: Shift ->readpage check from __copy_insn() to uprobe_register()
      uprobes: Teach copy_insn() to support tmpfs
      uprobes/x86: Rename arch_uprobe->def to ->dflt, minor comment updates
 arch/x86/include/asm/uprobes.h |    2 +-
 arch/x86/kernel/uprobes.c      |   37 ++++++++++++++++++-------------------
 kernel/events/uprobes.c        |   17 +++++++++++------
 3 files changed, 30 insertions(+), 26 deletions(-)
#1 lore raw
Quoted 5 lines · Oleg Nesterov

Ingo, please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc uprobes/core

Based on tip:perf/uprobes

Eww, adding tmpfs-specific code to uprobes screams layering violation.

Hugh, what is the problem with implementing ->readpage for tmpfs again?

#2 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Oleg Nesterov

Ingo, please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc uprobes/core

Based on tip:perf/uprobes

Eww, adding tmpfs-specific code to uprobes screams layering violation.

Hugh, what is the problem with implementing ->readpage for tmpfs again?

The problem is that ->readpage invites the caller to allocate a page of their choice for pagecache, and then pass it down to the filesystem to fill and use thereafter.

There are several ways in which that does not suit tmpfs, 3 spring to mind:
1. the page may already be in memory, but currently in swapcache not in
filecache: tmpfs knows how to manage that, the ->readpage caller does not
2. there may be a NUMA mempolicy applied to that file, which would choose to allocate the page differently: tmpfs knows about that, caller does not
3. (handy side-effect) it happens to disable use of tmpfs file as swapfile

It was a great relief when tmpfs could finally jettison its ->readpage back in v3.1 (though if you press me, I could admit to some remaining embarrassments). I certainly do not want it back.

Just think of tmpfs as a layering violation itself (memory as backing! no wonder it has peculiar demands on the allocation of its backing) and we're all good - there's a variety of ways in which the generic code already happens to accommodate it (many PageSwapBacked tests, or the mapping_cap_account_dirty/writeback tests, for example).

IIRC, you were in on the discussion of shmem_read_mapping_page() when we introduced it: Oleg is simply adding a call to it to fix a uprobes bug. That the name explicitly mentions shmem instead of concealing it, is not necessarily a bad thing.

Hugh

#3 lore raw
In reply to Christoph Hellwig
Quoted 11 lines · Christoph Hellwig
Quoted 5 lines · Oleg Nesterov

Ingo, please pull from

git://git.kernel.org/pub/scm/linux/kernel/git/oleg/misc uprobes/core

Based on tip:perf/uprobes

Eww, adding tmpfs-specific code to uprobes screams layering violation.

Hugh, what is the problem with implementing ->readpage for tmpfs again?

I leave this to you and Hugh.

But I hope you are not arguing with this patch, it is very simple and we do want to support tmpfs. If tmpfs has ->readpage again we can revert this patch.

BTW. Is it safe to pass file == NULL to read_mapping_page() and ->readpage()? Last time I tried to check this looked safe but this is not documented. We need to call read_mapping_page() from uprobe_register() but it doesn't have "struct file *" and thus we need to delay arch_uprobe_analyze_insn() until we find the first mapping, too bad.

And why read_mapping_page() has "void *data" but not "struct file *file"...

Oleg.