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 F05CFC43219 for ; Thu, 29 Sep 2022 09:21:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B7018D0001; Thu, 29 Sep 2022 05:21:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73EB36B0074; Thu, 29 Sep 2022 05:21:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DF298D0001; Thu, 29 Sep 2022 05:21:53 -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 483CA6B0073 for ; Thu, 29 Sep 2022 05:21:53 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1181E121285 for ; Thu, 29 Sep 2022 09:21:53 +0000 (UTC) X-FDA: 79964580906.21.97EFB93 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id B044720009 for ; Thu, 29 Sep 2022 09:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664443311; h=from:from: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; bh=Ke0PkvjcwfbH75Zmmd3mgZq6jo8h9BqrU/07q+LRkYI=; b=XA/bkDER3SX2gZk8VU8yoNP3fG8Ls2ukL+UWdtk9MLxQveND+45xHSP+2MO19jFAGwleVz GRNVI9HbNwmKzruyqamgNCRCKkSeaTjwBgDwIfgkgz3yOLs36ROVm+8mLJ4yo0QPWbnHU8 zwW5QxskoV1eOR6BUga8jn4vBoqha40= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-510-ieqVOWaUO3C7JH-By3JTlw-1; Thu, 29 Sep 2022 05:21:47 -0400 X-MC-Unique: ieqVOWaUO3C7JH-By3JTlw-1 Received: by mail-wr1-f70.google.com with SMTP id v22-20020adf8b56000000b0022af189148bso285304wra.22 for ; Thu, 29 Sep 2022 02:21:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=Ke0PkvjcwfbH75Zmmd3mgZq6jo8h9BqrU/07q+LRkYI=; b=7Xgp7/emL9e0QDrwjmE+Lr1oUApMLuIy15O8FLPXP1hG0tfLT+I0qbxCaDcgy5Vuxa szjnXlkbUiD++DtQzB9l15+zVqN02uvi2+N9dJcJgQENsaa2gn4NF/w52e5T8ENqg15m bOh77TJvTyJovo8tez8R0atHmu6l7YXDOwcWYcKwKLHq0N12wY7zmuGkGx1uJn0UtAHh kSJAG9xoRjeyL9mUkX379SkZU+s5dIzfjzyKrAqcf7LXag8edfnahf+ixs32U7FuI+QD izmgeM/pwfTHNrxJqDzjoqJdBb6/LMgH1mO0cQTSwrUu+RVTkGvfdh8RcYPFJfqiHBB5 G+Vw== X-Gm-Message-State: ACrzQf08Hpmv6/U2cO0UiN4i/KkXgv6klGOBjh4pRwkqHEJHsXECIP+w I5SVK3/4exRnVeZfhuR4qO/k3gEVs1SDm0pYAwbPKuT2jaQa0mfQEgYGVKhEIQaKCujVj3Wjs4N DvuCd0qwmOFA= X-Received: by 2002:a5d:47a4:0:b0:226:e547:b602 with SMTP id 4-20020a5d47a4000000b00226e547b602mr1496490wrb.406.1664443305971; Thu, 29 Sep 2022 02:21:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4W8pTVLJPBhavUN+i/fs2ek3WbmQXvJhXnU8ufO/u7+71wdQ9GOSYUjyfC2+fmt79Yw1fqeg== X-Received: by 2002:a5d:47a4:0:b0:226:e547:b602 with SMTP id 4-20020a5d47a4000000b00226e547b602mr1496478wrb.406.1664443305696; Thu, 29 Sep 2022 02:21:45 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:ce00:b5d:2b28:1eb5:9245? (p200300cbc705ce000b5d2b281eb59245.dip0.t-ipconnect.de. [2003:cb:c705:ce00:b5d:2b28:1eb5:9245]) by smtp.gmail.com with ESMTPSA id i1-20020a5d4381000000b002205cbc1c74sm6118043wrq.101.2022.09.29.02.21.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Sep 2022 02:21:45 -0700 (PDT) Message-ID: <4a3daba6-18f9-d252-697c-197f65578c44@redhat.com> Date: Thu, 29 Sep 2022 11:21:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 To: xu.xin.sc@gmail.com, akpm@linux-foundation.org, imbrenda@linux.vnet.ibm.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, xu xin References: <20220929025206.280970-1-xu.xin16@zte.com.cn> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 0/3] ksm: fix incorrect count of merged pages when enabling use_zero_pages In-Reply-To: <20220929025206.280970-1-xu.xin16@zte.com.cn> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XA/bkDER"; spf=pass (imf03.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664443312; a=rsa-sha256; cv=none; b=em9bj50x02wsnDKAFYHFR1NTxD8DNqDM41PNS78KmOwoesrEeooAnQO74XfjklpUxEnw0M YBxXswDhDmd/GVqLwTkhpTxuYJ2Bq7ezlewYcNMm5m0+bIwjtKgpAYJCLARq3S4k5iof0Y saPqQsKe2y6axHMv6+ajDGathO4WMU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664443312; 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=Ke0PkvjcwfbH75Zmmd3mgZq6jo8h9BqrU/07q+LRkYI=; b=xAIpViBeE5XgPbCgaFSJgeAFHbHguWgXUS/3aqCfK7H/aec4FyYnuvyw66s/cttNqdG+9v bu9QwFnBLr4dllXsmaxr0jDhOKtxKgW/GE+c8gVLohV+dYpXnl7gR1XO076O5R7C35qlU5 DFkDhAEpSBiJ52OnVP2aazD25kkJc6E= Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XA/bkDER"; spf=pass (imf03.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: 8mx3i7jhcuptoqo3wkiy6aruubf74o1d X-Rspamd-Queue-Id: B044720009 X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1664443311-500028 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 29.09.22 04:52, 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 > after 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 the rmap_items of these ksm zero pages are not > appended to The Stable Tree of KSM. > > We need to add the count of empty pages to let users know how many empty > pages are merged with kernel zero page(s). > > Please see the subsequent patches for details. Just raising the topic here because it's related to the KSM usage of the shared zero-page: 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). It will only unshare actual KSM pages. We might not want want to blindly unshare all shared zeropages in applicable VMAs ... using a dedicated shared zero (KSM) page -- instead of the generic zero page -- might be one way to handle this cleaner. Would that also fix some of the issues you describe above? -- Thanks, David / dhildenb