From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4FDEC433FE for ; Mon, 10 Oct 2022 09:24:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E7CB6B0071; Mon, 10 Oct 2022 05:24:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 297236B0073; Mon, 10 Oct 2022 05:24:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 111B7900002; Mon, 10 Oct 2022 05:24:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EA8F16B0071 for ; Mon, 10 Oct 2022 05:24:29 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 956D3160D57 for ; Mon, 10 Oct 2022 09:24:29 +0000 (UTC) X-FDA: 80004504258.24.5E9689F Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf03.hostedemail.com (Postfix) with ESMTP id 98EC52001C for ; Mon, 10 Oct 2022 09:24:28 +0000 (UTC) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29A9GNX1029490; Mon, 10 Oct 2022 09:24:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=Hl2tgLNm5lg6VuSf7qo6KRUTP5SpNvEJuGFzq+31vvU=; b=Hx8KInzwt224qXVYuHos+x95vB6xdJuwSsMa/ssp7pw+mY2kzhAikNpcnz9t8zhzR5Zl 7K7OyeV6rpfcxO80vE7PuG8NQtttRuoVRPJE4Tv6Riyj6hd77yYN8h9Wysi4natN0Sna mB5BrdbX4RH4qDfpKgDdgtgN8kUm9cti6RPy1RZR+PtbcLOq6yG3En5UXGrIw50NhCJU mD8uATxGbFY6/oJyRyufMTPnCo1HXrqpUeLpvvX/7V0drfq534tDZJvaz63Yzd6kJenv L03eCOOVQTec+TQ+R563x3elAKV8P/ctWetSi0z37WiT/41fTUA166tjTCN2kiy6cz/D zA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k3k7v6dq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Oct 2022 09:24:27 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29A8mJ3R020230; Mon, 10 Oct 2022 09:24:27 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3k3k7v6djf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Oct 2022 09:24:26 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29A9KR99029021; Mon, 10 Oct 2022 09:24:17 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3k30u9aj7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Oct 2022 09:24:17 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29A9OFq960752272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Oct 2022 09:24:15 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 64A464C046; Mon, 10 Oct 2022 09:24:15 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FEDE4C040; Mon, 10 Oct 2022 09:24:15 +0000 (GMT) Received: from p-imbrenda (unknown [9.152.224.242]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 10 Oct 2022 09:24:15 +0000 (GMT) Date: Mon, 10 Oct 2022 11:24:13 +0200 From: Claudio Imbrenda To: xu.xin.sc@gmail.com Cc: akpm@linux-foundation.org, ran.xiaokai@zte.com.cn, yang.yang29@zte.com.cn, jiang.xuexin@zte.com.cn, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xu xin Subject: Re: [PATCH v2 0/5] ksm: support tracking KSM-placed zero-pages Message-ID: <20221010112413.219dc989@p-imbrenda> In-Reply-To: <20221009021816.315205-1-xu.xin16@zte.com.cn> References: <20221009021816.315205-1-xu.xin16@zte.com.cn> Organization: IBM X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-redhat-linux-gnu) Content-Type: text/plain; charset=US-ASCII X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: hqGr5RA2tO08WTSR8-F74aiZE3fP-9Ht X-Proofpoint-GUID: XYvKMfVOoHr7rSfJkFfp6_i-at8BfPfm Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-10-07_04,2022-10-07_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 bulkscore=0 mlxlogscore=628 mlxscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 clxscore=1011 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210100055 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665393869; a=rsa-sha256; cv=none; b=sQLL8UUQGOWL5bpCNfDFGY4alomkjOcbOlAB5Z5jO41k8MxSLm1bCD24/od9nP05IeiMH8 V2FsQj5QV5Q4HMxRl9r5bDck2+tF7+fFK+c0wf+amuvfm+gp1PKwujo8mh/B5t9ddBcyTj fVp7FqoyS82GZdjnovtqRRmMcjEO1eY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Hx8KInzw; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf03.hostedemail.com: domain of imbrenda@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=imbrenda@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665393869; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Hl2tgLNm5lg6VuSf7qo6KRUTP5SpNvEJuGFzq+31vvU=; b=Vf4uA6RlhNW9OCQSrhd8G2gb26AhokiDyeERj5dov5f6DL1cKAroI2A+U1ocyT+O48wARO emUHG4U4pSM1x8jCr9QQzLemWqSxKVGxJYzgptxJqzC7DFiFM0LLCQxGPz969WJs8PfJJS If/VMpHJDn52ZBM39VyB4GL67MASjIY= X-Stat-Signature: 4yfbehh1zps74egqswkitg5xk7a9c1ib X-Rspamd-Queue-Id: 98EC52001C Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Hx8KInzw; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf03.hostedemail.com: domain of imbrenda@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=imbrenda@linux.ibm.com X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1665393868-420090 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, 9 Oct 2022 02:18:16 +0000 xu.xin.sc@gmail.com wrote: > From: xu xin > > Before enabling use_zero_pages by setting /sys/kernel/mm/ksm/ > use_zero_pages to 1, pages_sharing of KSM is basically accurate. But > when enabling use_zero_pages, all empty pages that are merged with > kernel zero page are not counted in pages_sharing or pages_shared. > That is because these empty pages are merged with zero-pages then no > longer managed by KSM, which leads to two issues at least: > > 1) MADV_UNMERGEABLE and other ways to trigger unsharing will *not* > unshare the shared zeropage as placed by KSM (which is against the > MADV_UNMERGEABLE documentation at least); see the link: > https://lore.kernel.org/lkml/4a3daba6-18f9-d252-697c-197f65578c44@redhat.com/ > > 2) we cannot know how many pages are zero pages placed by KSM when > enabling use_zero_pages, which leads to KSM not being transparent > with all actual merged pages by KSM. > > With the patch series, we can unshare zero-pages(KSM-placed) accurately > and count ksm zero pages. why are you trying so hard to fix something that is not broken? can't you just avoid using use_zero_pages? why is it so important to know how many zero pages have been merged? and why do you want to unmerge them? the important thing is that the sysadmin knows how much memory would be needed to do the unmerge, and that information is already there. > > --- > v1->v2: > > [patch 4/5] fix build warning, mm/ksm.c:550, misleading indentation; statement > 'rmap_item->mm->ksm_zero_pages_sharing--;' is not part of the previous 'if'. > > > > *** BLURB HERE *** > > xu xin (5): > ksm: abstract the function try_to_get_old_rmap_item > ksm: support unsharing zero pages placed by KSM > ksm: count all zero pages placed by KSM > ksm: count zero pages for each process > ksm: add zero_pages_sharing documentation > > Documentation/admin-guide/mm/ksm.rst | 10 +- > fs/proc/base.c | 1 + > include/linux/mm_types.h | 7 +- > mm/ksm.c | 177 +++++++++++++++++++++------ > 4 files changed, 157 insertions(+), 38 deletions(-) >