From: Wu Fengguang <wfg@mail.ustc.edu.cn>
To: Hui Zhu <teawater@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH for vm-scalability] usemem: Add code for touch-alloc
Date: Sat, 10 Apr 2021 09:05:32 +0800 [thread overview]
Message-ID: <20210410010532.GA339619@wfg-e595> (raw)
In-Reply-To: <20210408134255.12330-1-teawater@gmail.com>
Applied, thanks!
On Thu, Apr 08, 2021 at 09:42:55PM +0800, Hui Zhu wrote:
>Add code for touch-alloc.
>And Change read memory to write memory to avoid use the zero-page for
>reads in do_anonymous_page.
>
>Signed-off-by: Hui Zhu <teawater@gmail.com>
>---
> usemem.c | 34 ++++++++++++++++++++++------------
> 1 file changed, 22 insertions(+), 12 deletions(-)
>
>diff --git a/usemem.c b/usemem.c
>index e2c46ec..5b90aae 100644
>--- a/usemem.c
>+++ b/usemem.c
>@@ -329,6 +329,18 @@ void detach(void)
> }
> }
>
>+unsigned long do_access(unsigned long *p, unsigned long idx, int read)
>+{
>+ volatile unsigned long *vp = p;
>+
>+ if (read)
>+ return vp[idx]; /* read data */
>+ else {
>+ vp[idx] = idx; /* write data */
>+ return 0;
>+ }
>+}
>+
> unsigned long * allocate(unsigned long bytes)
> {
> unsigned long *p;
>@@ -355,6 +367,14 @@ unsigned long * allocate(unsigned long bytes)
> p = (unsigned long *)ALIGN((unsigned long)p, pagesize - 1);
> }
>
>+ if (opt_touch_alloc) {
>+ unsigned long i;
>+ unsigned long m = bytes / sizeof(*p);
>+
>+ for (i = 0; i < m; i += 1)
>+ do_access(p, i, 0);
>+ }
>+
> return p;
> }
>
>@@ -436,18 +456,6 @@ void shm_unlock(int seg_id)
> shmctl(seg_id, SHM_UNLOCK, NULL);
> }
>
>-unsigned long do_access(unsigned long *p, unsigned long idx, int read)
>-{
>- volatile unsigned long *vp = p;
>-
>- if (read)
>- return vp[idx]; /* read data */
>- else {
>- vp[idx] = idx; /* write data */
>- return 0;
>- }
>-}
>-
> #define NSEC_PER_SEC (1UL * 1000 * 1000 * 1000)
>
> long nsec_sub(long nsec1, long nsec2)
>@@ -953,6 +961,8 @@ int main(int argc, char *argv[])
> opt_punch_holes = 1;
> } else if (strcmp(opts[opt_index].name, "init-time") == 0) {
> opt_init_time = 1;
>+ } else if (strcmp(opts[opt_index].name, "touch-alloc") == 0) {
>+ opt_touch_alloc = 1;
> } else
> usage(1);
> break;
>--
>2.17.1
>
prev parent reply other threads:[~2021-04-10 1:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-08 13:42 [PATCH for vm-scalability] usemem: Add code for touch-alloc Hui Zhu
2021-04-10 1:05 ` Wu Fengguang [this message]
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=20210410010532.GA339619@wfg-e595 \
--to=wfg@mail.ustc.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=teawater@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.