From: Andrew Morton <akpm@linux-foundation.org>
To: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
Cc: linux-mm@kvack.org, borntraeger@de.ibm.com, hughd@google.com,
aarcange@redhat.com, chrisw@sous-sol.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] mm/ksm: improve deduplication of zero pages with colouring
Date: Thu, 19 Jan 2017 15:33:24 -0800 [thread overview]
Message-ID: <20170119153324.69cd6ba29704b02040412ec6@linux-foundation.org> (raw)
In-Reply-To: <1484850953-23941-1-git-send-email-imbrenda@linux.vnet.ibm.com>
On Thu, 19 Jan 2017 19:35:53 +0100 Claudio Imbrenda <imbrenda@linux.vnet.ibm.com> wrote:
> Some architectures have a set of zero pages (coloured zero pages)
> instead of only one zero page, in order to improve the cache
> performance. In those cases, the kernel samepage merger (KSM) would
> merge all the allocated pages that happen to be filled with zeroes to
> the same deduplicated page, thus losing all the advantages of coloured
> zero pages.
>
> This behaviour is noticeable when a process accesses large arrays of
> allocated pages containing zeroes. A test I conducted on s390 shows
> that there is a speed penalty when KSM merges such pages, compared to
> not merging them or using actual zero pages from the start without
> breaking the COW.
>
> This patch fixes this behaviour. When coloured zero pages are present,
> the checksum of a zero page is calculated during initialisation, and
> compared with the checksum of the current canditate during merging. In
> case of a match, the normal merging routine is used to merge the page
> with the correct coloured zero page, which ensures the candidate page
> is checked to be equal to the target zero page.
>
> A sysfs entry is also added to toggle this behaviour, since it can
> potentially introduce performance regressions, especially on
> architectures without coloured zero pages. The default value is
> disabled, for backwards compatibility.
>
> With this patch, the performance with KSM is the same as with non
> COW-broken actual zero pages, which is also the same as without KSM.
>
> ...
>
> @@ -2233,6 +2267,28 @@ static ssize_t merge_across_nodes_store(struct kobject *kobj,
> KSM_ATTR(merge_across_nodes);
> #endif
>
> +static ssize_t use_zero_pages_show(struct kobject *kobj,
> + struct kobj_attribute *attr, char *buf)
> +{
> + return sprintf(buf, "%u\n", ksm_use_zero_pages);
> +}
> +static ssize_t use_zero_pages_store(struct kobject *kobj,
> + struct kobj_attribute *attr,
> + const char *buf, size_t count)
> +{
> + int err;
> + bool value;
> +
> + err = kstrtobool(buf, &value);
> + if (err)
> + return -EINVAL;
> +
> + ksm_use_zero_pages = value;
> +
> + return count;
> +}
> +KSM_ATTR(use_zero_pages);
Please send along an update for Documentation/vm/ksm.txt? Be sure that
it fully explains "since it can potentially introduce performance
regressions", so our users are able to understand whether or not they
should use this.
--
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>
prev parent reply other threads:[~2017-01-19 23:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 18:35 Claudio Imbrenda
2017-01-19 22:11 ` Andrea Arcangeli
2017-01-19 23:33 ` Andrew Morton [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=20170119153324.69cd6ba29704b02040412ec6@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=aarcange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=chrisw@sous-sol.org \
--cc=hughd@google.com \
--cc=imbrenda@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox