lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120630122919.GB3036@stainedmachine.redhat.com>
Date:	Sat, 30 Jun 2012 14:29:23 +0200
From:	Petr Holasek <pholasek@...hat.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Hugh Dickins <hughd@...gle.com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	Chris Wright <chrisw@...s-sol.org>,
	Izik Eidus <izik.eidus@...ellosystems.com>,
	Rik van Riel <riel@...hat.com>, linux-kernel@...r.kernel.org,
	linux-mm@...ck.org, Anton Arapov <anton@...hat.com>
Subject: Re: [PATCH v2] KSM: numa awareness sysfs knob

On Fri, 29 Jun 2012, Andrew Morton wrote:

> On Fri, 29 Jun 2012 13:49:52 +0200
> Petr Holasek <pholasek@...hat.com> wrote:
> 
> > Introduces new sysfs boolean knob /sys/kernel/mm/ksm/merge_nodes
> > which control merging pages across different numa nodes.
> > When it is set to zero only pages from the same node are merged,
> > otherwise pages from all nodes can be merged together (default behavior).
> > 
> > Typical use-case could be a lot of KVM guests on NUMA machine
> > and cpus from more distant nodes would have significant increase
> > of access latency to the merged ksm page. Sysfs knob was choosen
> > for higher scalability.
> > 
> > Every numa node has its own stable & unstable trees because
> > of faster searching and inserting. Changing of merge_nodes
> > value is possible only when there are not any ksm shared pages in system.
> 
> It would be neat to have a knob which enables KSM for all anon
> mappings.  ie: pretend that MADV_MERGEABLE is always set.  For testing
> coverage purposes.

Interesting idea, I'll try to add it in next release if /sys/kernel/mm/ksm
directory is the right place for such debug knob.

> > --- a/Documentation/vm/ksm.txt
> > +++ b/Documentation/vm/ksm.txt
> > @@ -58,6 +58,12 @@ sleep_millisecs  - how many milliseconds ksmd should sleep before next scan
> >                     e.g. "echo 20 > /sys/kernel/mm/ksm/sleep_millisecs"
> >                     Default: 20 (chosen for demonstration purposes)
> >  
> > +merge_nodes      - specifies if pages from different numa nodes can be merged.
> > +                   When set to 0, ksm merges only pages which physically
> > +                   resides in the memory area of same NUMA node. It brings
> > +                   lower latency to access to shared page.
> > +                   Default: 1
> 
> s/resides/reside/.
> 
> This doc should mention that /sys/kernel/mm/ksm/run should be zeroed to
> alter merge_nodes.  Otherwise confusion will reign.
> 

Oh, forgot to mention it. I'll fix it.

> >
> > ...
> >
> > +static ssize_t merge_nodes_store(struct kobject *kobj,
> > +				   struct kobj_attribute *attr,
> > +				   const char *buf, size_t count)
> > +{
> > +	int err;
> > +	unsigned long knob;
> > +
> > +	err = kstrtoul(buf, 10, &knob);
> > +	if (err)
> > +		return err;
> > +	if (knob > 1)
> > +		return -EINVAL;
> > +
> > +	if (ksm_run & KSM_RUN_MERGE)
> > +		return -EBUSY;
> > +
> > +	mutex_lock(&ksm_thread_mutex);
> > +	if (ksm_merge_nodes != knob) {
> > +		if (ksm_pages_shared > 0)
> > +			return -EBUSY;
> > +		else
> > +			ksm_merge_nodes = knob;
> > +	}
> > +	mutex_unlock(&ksm_thread_mutex);
> > +
> > +	return count;
> > +}
> 
> Seems a bit racy.  Shouldn't the test of ksm_run be inside the locked
> region?
> 

Agreed.

Thanks for your review!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ