linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: cgel.zte@gmail.com
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	mhocko@suse.com, vbabka@suse.cz, minchan@kernel.org,
	oleksandr@redhat.com, xu xin <xu.xin16@zte.com.cn>
Subject: [PATCH linux-next] mm/madvise: allow KSM hints for process_madvise
Date: Fri,  1 Jul 2022 08:43:23 +0000	[thread overview]
Message-ID: <20220701084323.1261361-1-xu.xin16@zte.com.cn> (raw)

From: xu xin <xu.xin16@zte.com.cn>

The benefits of doing this are obvious because using madvise in user code
is the only current way to enable KSM, which is inconvenient for those
compiled app without marking MERGEABLE wanting to enable KSM.

Since we already have the syscall of process_madvise(), then reusing the
interface to allow external KSM hints is more acceptable [1].

Although this patch was released by Oleksandr Natalenko, but it was
unfortunately terminated without any conclusions because there was debate
on whether it should use signal_pending() to check the target task besides
the task of current() when calling unmerge_ksm_pages of other task [2].

I think it's unneeded to check the target task. For example, when we set
the klob /sys/kernel/mm/ksm/run from 1 to 2,
unmerge_and_remove_all_rmap_items() doesn't use signal_pending() to check
all other target tasks either.

I hope this patch can get attention again.

[1] https://lore.kernel.org/lkml/YoOrdh85+AqJH8w1@dhcp22.suse.cz/
[2] https://lore.kernel.org/lkml/2a66abd8-4103-f11b-06d1-07762667eee6@suse.cz/

Signed-off-by: Oleksandr Natalenko <oleksandr@redhat.com>
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
 mm/madvise.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mm/madvise.c b/mm/madvise.c
index 851fa4e134bc..df915531ad9f 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1173,6 +1173,10 @@ process_madvise_behavior_valid(int behavior)
 	case MADV_COLD:
 	case MADV_PAGEOUT:
 	case MADV_WILLNEED:
+#ifdef CONFIG_KSM
+	case MADV_MERGEABLE:
+	case MADV_UNMERGEABLE:
+#endif
 		return true;
 	default:
 		return false;
-- 
2.25.1



             reply	other threads:[~2022-07-01  8:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01  8:43 cgel.zte [this message]
2022-07-01  9:11 ` Michal Hocko
2022-07-01 10:32   ` David Hildenbrand
2022-07-01 10:50     ` David Hildenbrand
2022-07-01 12:02       ` Michal Hocko
2022-07-01 12:09         ` David Hildenbrand
2022-07-01 12:36           ` Michal Hocko
2022-07-01 12:39             ` David Hildenbrand
2022-07-01 13:19               ` Michal Hocko
2022-07-01 19:12                 ` David Hildenbrand
2022-07-04  6:48                   ` Michal Hocko
2022-07-04  7:29                     ` CGEL
2022-07-04  8:40                       ` Michal Hocko
2022-07-04  9:35                         ` David Hildenbrand
2022-07-04  8:13           ` CGEL
2022-07-04  9:30             ` David Hildenbrand

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=20220701084323.1261361-1-xu.xin16@zte.com.cn \
    --to=cgel.zte@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=oleksandr@redhat.com \
    --cc=vbabka@suse.cz \
    --cc=xu.xin16@zte.com.cn \
    /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