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]
Date:   Fri, 13 May 2022 06:50:31 +0000
From:   CGEL <cgel.zte@...il.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     akpm@...ux-foundation.org, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org, corbet@....net,
        xu xin <xu.xin16@....com.cn>,
        Yang Yang <yang.yang29@....com.cn>,
        Ran Xiaokai <ran.xiaokai@....com.cn>,
        wangyong <wang.yong12@....com.cn>,
        Yunkai Zhang <zhang.yunkai@....com.cn>
Subject: Re: [PATCH v6] mm/ksm: introduce ksm_force for each process

On Thu, May 12, 2022 at 10:07:09PM +0100, Matthew Wilcox wrote:
> On Tue, May 10, 2022 at 12:22:42PM +0000, cgel.zte@...il.com wrote:
> > +++ b/Documentation/admin-guide/mm/ksm.rst
> > @@ -32,7 +32,7 @@ are swapped back in: ksmd must rediscover their identity and merge again).
> >  Controlling KSM with madvise
> >  ============================
> >  
> > -KSM only operates on those areas of address space which an application
> > +KSM can operates on those areas of address space which an application
> 
> "can operate on"
>
Thanks.

> > +			 * Force anonymous pages of this mm to be involved in KSM merging
> > +			 * without explicitly calling madvise.
> > +			 */
> > +			if (!test_bit(MMF_VM_MERGEABLE, &mm->flags))
> > +				err = __ksm_enter(mm);
> > +			if (!err)
> > +				mm->ksm_force = force;
> > +		}
> > +
> > +		mmap_write_unlock(mm);
> > +	}
> 
> There's a much simpler patch hiding inside this complicated one.
> 
> 	if (force) {
> 		set_bit(MMF_VM_MERGEABLE, &mm->flags));
> 		for each VMA
> 			set VM_MERGEABLE;
> 		err = __ksm_enter(mm);
> 	} else {
> 		clear_bit(MMF_VM_MERGEABLE, &mm->flags));
> 		for each VMA
> 			clear VM_MERGEABLE;
> 	}
> 
> ... and all the extra complications you added go away.

Sorry, but I don't think that is a better way of implementation, although it
is simpler. It overrides the intention of code ifself which is
unrecoverable. For example, if a program which madvise just a part of VMAs
(not all) as MERGEABLE then its ksm_force is turned on, and subsequently
it ksm_force is turned off again, the "madvised MERGEBLE" cannot be
recoverd.
===========================================================================
I have a idea: can we refer to the interface of THP? Substitute ksm_force
with ksm_enabled and give three values to it:

1) always: force all anonymous VMAs of this process to be scanned.

2) madvise: the default state, unless user code call madvise, don't
scan this process.

3) never: never be involed in KSM.
===========================================================================

How about this?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ