From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Davidlohr Bueso <dbueso@suse.de>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH -next] mm/vmacache: inline vmacache_valid_mm()
Date: Thu, 8 Oct 2015 15:21:15 +0900 [thread overview]
Message-ID: <20151008062115.GA876@swordfish> (raw)
In-Reply-To: <1444277879-22039-1-git-send-email-dave@stgolabs.net>
On (10/07/15 21:17), Davidlohr Bueso wrote:
> This function incurs in very hot paths and merely
> does a few loads for validity check. Lets inline it,
> such that we can save the function call overhead.
>
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
> ---
> mm/vmacache.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmacache.c b/mm/vmacache.c
> index b6e3662..fd09dc9 100644
> --- a/mm/vmacache.c
> +++ b/mm/vmacache.c
> @@ -52,7 +52,7 @@ void vmacache_flush_all(struct mm_struct *mm)
> * Also handle the case where a kernel thread has adopted this mm via use_mm().
> * That kernel thread's vmacache is not applicable to this mm.
> */
> -static bool vmacache_valid_mm(struct mm_struct *mm)
> +static inline bool vmacache_valid_mm(struct mm_struct *mm)
> {
> return current->mm == mm && !(current->flags & PF_KTHREAD);
> }
Seems to be inlined anyway. do you want to inline vmacache_update()?
It looks simple enough (vmacache_valid_mm() is inlined):
void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
{
if (vmacache_valid_mm(newvma->vm_mm))
current->vmacache[VMACACHE_HASH(addr)] = newvma;
}
After moving vmacache_update() and vmacache_valid_mm() to include/linux/vmacache.h
(both `static inline')
./scripts/bloat-o-meter vmlinux.o.old vmlinux.o
add/remove: 0/1 grow/shrink: 1/0 up/down: 22/-54 (-32)
function old new delta
find_vma 97 119 +22
vmacache_update 54 - -54
Something like this, perhaps?
---
include/linux/vmacache.h | 21 ++++++++++++++++++++-
mm/vmacache.c | 20 --------------------
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/include/linux/vmacache.h b/include/linux/vmacache.h
index c3fa0fd4..0ec750b 100644
--- a/include/linux/vmacache.h
+++ b/include/linux/vmacache.h
@@ -15,8 +15,27 @@ static inline void vmacache_flush(struct task_struct *tsk)
memset(tsk->vmacache, 0, sizeof(tsk->vmacache));
}
+/*
+ * This task may be accessing a foreign mm via (for example)
+ * get_user_pages()->find_vma(). The vmacache is task-local and this
+ * task's vmacache pertains to a different mm (ie, its own). There is
+ * nothing we can do here.
+ *
+ * Also handle the case where a kernel thread has adopted this mm via use_mm().
+ * That kernel thread's vmacache is not applicable to this mm.
+ */
+static bool vmacache_valid_mm(struct mm_struct *mm)
+{
+ return current->mm == mm && !(current->flags & PF_KTHREAD);
+}
+
+static inline void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
+{
+ if (vmacache_valid_mm(newvma->vm_mm))
+ current->vmacache[VMACACHE_HASH(addr)] = newvma;
+}
+
extern void vmacache_flush_all(struct mm_struct *mm);
-extern void vmacache_update(unsigned long addr, struct vm_area_struct *newvma);
extern struct vm_area_struct *vmacache_find(struct mm_struct *mm,
unsigned long addr);
diff --git a/mm/vmacache.c b/mm/vmacache.c
index b6e3662..14fec21 100644
--- a/mm/vmacache.c
+++ b/mm/vmacache.c
@@ -43,26 +43,6 @@ void vmacache_flush_all(struct mm_struct *mm)
rcu_read_unlock();
}
-/*
- * This task may be accessing a foreign mm via (for example)
- * get_user_pages()->find_vma(). The vmacache is task-local and this
- * task's vmacache pertains to a different mm (ie, its own). There is
- * nothing we can do here.
- *
- * Also handle the case where a kernel thread has adopted this mm via use_mm().
- * That kernel thread's vmacache is not applicable to this mm.
- */
-static bool vmacache_valid_mm(struct mm_struct *mm)
-{
- return current->mm == mm && !(current->flags & PF_KTHREAD);
-}
-
-void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
-{
- if (vmacache_valid_mm(newvma->vm_mm))
- current->vmacache[VMACACHE_HASH(addr)] = newvma;
-}
-
static bool vmacache_valid(struct mm_struct *mm)
{
struct task_struct *curr;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Davidlohr Bueso <dbueso@suse.de>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH -next] mm/vmacache: inline vmacache_valid_mm()
Date: Thu, 8 Oct 2015 15:21:15 +0900 [thread overview]
Message-ID: <20151008062115.GA876@swordfish> (raw)
In-Reply-To: <1444277879-22039-1-git-send-email-dave@stgolabs.net>
On (10/07/15 21:17), Davidlohr Bueso wrote:
> This function incurs in very hot paths and merely
> does a few loads for validity check. Lets inline it,
> such that we can save the function call overhead.
>
> Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
> ---
> mm/vmacache.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/vmacache.c b/mm/vmacache.c
> index b6e3662..fd09dc9 100644
> --- a/mm/vmacache.c
> +++ b/mm/vmacache.c
> @@ -52,7 +52,7 @@ void vmacache_flush_all(struct mm_struct *mm)
> * Also handle the case where a kernel thread has adopted this mm via use_mm().
> * That kernel thread's vmacache is not applicable to this mm.
> */
> -static bool vmacache_valid_mm(struct mm_struct *mm)
> +static inline bool vmacache_valid_mm(struct mm_struct *mm)
> {
> return current->mm == mm && !(current->flags & PF_KTHREAD);
> }
Seems to be inlined anyway. do you want to inline vmacache_update()?
It looks simple enough (vmacache_valid_mm() is inlined):
void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
{
if (vmacache_valid_mm(newvma->vm_mm))
current->vmacache[VMACACHE_HASH(addr)] = newvma;
}
After moving vmacache_update() and vmacache_valid_mm() to include/linux/vmacache.h
(both `static inline')
./scripts/bloat-o-meter vmlinux.o.old vmlinux.o
add/remove: 0/1 grow/shrink: 1/0 up/down: 22/-54 (-32)
function old new delta
find_vma 97 119 +22
vmacache_update 54 - -54
Something like this, perhaps?
---
include/linux/vmacache.h | 21 ++++++++++++++++++++-
mm/vmacache.c | 20 --------------------
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/include/linux/vmacache.h b/include/linux/vmacache.h
index c3fa0fd4..0ec750b 100644
--- a/include/linux/vmacache.h
+++ b/include/linux/vmacache.h
@@ -15,8 +15,27 @@ static inline void vmacache_flush(struct task_struct *tsk)
memset(tsk->vmacache, 0, sizeof(tsk->vmacache));
}
+/*
+ * This task may be accessing a foreign mm via (for example)
+ * get_user_pages()->find_vma(). The vmacache is task-local and this
+ * task's vmacache pertains to a different mm (ie, its own). There is
+ * nothing we can do here.
+ *
+ * Also handle the case where a kernel thread has adopted this mm via use_mm().
+ * That kernel thread's vmacache is not applicable to this mm.
+ */
+static bool vmacache_valid_mm(struct mm_struct *mm)
+{
+ return current->mm == mm && !(current->flags & PF_KTHREAD);
+}
+
+static inline void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
+{
+ if (vmacache_valid_mm(newvma->vm_mm))
+ current->vmacache[VMACACHE_HASH(addr)] = newvma;
+}
+
extern void vmacache_flush_all(struct mm_struct *mm);
-extern void vmacache_update(unsigned long addr, struct vm_area_struct *newvma);
extern struct vm_area_struct *vmacache_find(struct mm_struct *mm,
unsigned long addr);
diff --git a/mm/vmacache.c b/mm/vmacache.c
index b6e3662..14fec21 100644
--- a/mm/vmacache.c
+++ b/mm/vmacache.c
@@ -43,26 +43,6 @@ void vmacache_flush_all(struct mm_struct *mm)
rcu_read_unlock();
}
-/*
- * This task may be accessing a foreign mm via (for example)
- * get_user_pages()->find_vma(). The vmacache is task-local and this
- * task's vmacache pertains to a different mm (ie, its own). There is
- * nothing we can do here.
- *
- * Also handle the case where a kernel thread has adopted this mm via use_mm().
- * That kernel thread's vmacache is not applicable to this mm.
- */
-static bool vmacache_valid_mm(struct mm_struct *mm)
-{
- return current->mm == mm && !(current->flags & PF_KTHREAD);
-}
-
-void vmacache_update(unsigned long addr, struct vm_area_struct *newvma)
-{
- if (vmacache_valid_mm(newvma->vm_mm))
- current->vmacache[VMACACHE_HASH(addr)] = newvma;
-}
-
static bool vmacache_valid(struct mm_struct *mm)
{
struct task_struct *curr;
next prev parent reply other threads:[~2015-10-08 6:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-08 4:17 [PATCH -next] mm/vmacache: inline vmacache_valid_mm() Davidlohr Bueso
2015-10-08 4:17 ` Davidlohr Bueso
2015-10-08 6:21 ` Sergey Senozhatsky [this message]
2015-10-08 6:21 ` Sergey Senozhatsky
2015-10-08 13:23 ` Davidlohr Bueso
2015-10-08 13:23 ` Davidlohr Bueso
2015-10-08 13:43 ` Sergey Senozhatsky
2015-10-08 13:43 ` Sergey Senozhatsky
2015-10-08 16:55 ` Davidlohr Bueso
2015-10-08 16:55 ` Davidlohr Bueso
2015-10-08 17:32 ` Davidlohr Bueso
2015-10-08 17:32 ` Davidlohr Bueso
2015-10-08 22:15 ` Andrew Morton
2015-10-08 22:15 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151008062115.GA876@swordfish \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.