public inbox for [email protected]
 help / color / mirror / Atom feed
From: CGEL <[email protected]>
To: Matthew Wilcox <[email protected]>
Cc: [email protected], [email protected],
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected], [email protected],
	[email protected], [email protected]
Subject: Re: [PATCH v5] mm/ksm: introduce ksm_force for each process
Date: Mon, 9 May 2022 06:57:33 +0000	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On Sun, May 08, 2022 at 07:03:36PM +0100, Matthew Wilcox wrote:
> On Sun, May 08, 2022 at 09:27:10AM +0000, [email protected] wrote:
> > If ksm_force is set to 0, cancel the feature of ksm_force of this
> > process and unmerge those merged pages belonging to VMAs which is not
> > madvised as MADV_MERGEABLE of this process, but leave MADV_MERGEABLE
> > areas merged.
> 
> Is that actually a useful feature?  Otherwise, we could simply turn
> on/off the existing MMF_VM_MERGEABLE flag instead of introducing this
> new bool.
> 
I think this will be very useful for those apps which are very likely to
cause Same Pages in memory and users and operators are not willing to
modified the source codes for any reasons.

Besides, simply turning of/off the existing MMF_VM_MERGEABLE flag may be
not feasible because madvise will also turn on the MMF_VM_MERGEABLE
flag.

I think the following suggestions is good, and I will resend a patch.
> > +Controlling KSM with procfs
> > +===========================
> > +
> > +KSM can also operate on anonymous areas of address space of those processes's
> > +knob ``/proc/<pid>/ksm_force`` is on, even if app codes doesn't call madvise()
> > +explicitly to advise specific areas as MADV_MERGEABLE.
> > +
> > +You can set ksm_force to 1 to force all anonymous and qualified VMAs of
> > +this process to be involved in KSM scanning. But It is effective only when the
> > +klob of ``/sys/kernel/mm/ksm/run`` is set as 1.
> 
> I think that last sentence doesn't really add any value.
> 
> > +	memset(buffer, 0, sizeof(buffer));
> > +	if (count > sizeof(buffer) - 1)
> > +		count = sizeof(buffer) - 1;
> > +	if (copy_from_user(buffer, buf, count)) {
> > +		err = -EFAULT;
> > +		goto out_return;
> 
> This feels a bit unnecessary.  Just 'return -EFAULT' here.
> 
> > +	}
> > +
> > +	err = kstrtoint(strstrip(buffer), 0, &force);
> > +
> > +	if (err)
> > +		goto out_return;
> 
> 'return err'
> 
> > +	if (force != 0 && force != 1) {
> > +		err = -EINVAL;
> > +		goto out_return;
> 
> 'return -EINVAL'
> 
> > +	}
> > +
> > +	task = get_proc_task(file_inode(file));
> > +	if (!task) {
> > +		err = -ESRCH;
> > +		goto out_return;
> 
> 'return -ESRCH'



  reply	other threads:[~2022-05-09  6:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07  5:47 [PATCH v3] mm/ksm: introduce ksm_force for each process cgel.zte
2022-05-07 17:59 ` Andrew Morton
2022-05-08  9:14   ` [PATCH v4] " cgel.zte
2022-05-08  9:27   ` [PATCH v5] " cgel.zte
2022-05-08 18:03     ` Matthew Wilcox
2022-05-09  6:57       ` CGEL [this message]
2022-05-09 15:40         ` Matthew Wilcox
2022-05-10  2:23           ` CGEL
2022-05-10 20:10     ` Ammar Faizi
2022-05-10 20:30       ` Andrew Morton
2022-05-11  7:58         ` Ammar Faizi
2022-05-12  7:03           ` [PATCH v7] " cgel.zte
2022-05-12 20:41             ` 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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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