Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2019069rwb; Thu, 29 Sep 2022 05:21:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6HNskqK35Yq73KtDGtXtwQtlw5z5XOoFy5lgf+wi0b2pCaWRxck4SBncbeskwWJHtkrWlw X-Received: by 2002:a65:6e82:0:b0:41a:9b73:f0e6 with SMTP id bm2-20020a656e82000000b0041a9b73f0e6mr2779701pgb.371.1664454074882; Thu, 29 Sep 2022 05:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664454074; cv=none; d=google.com; s=arc-20160816; b=zjaPFUV2Q2/nC2gHC3rtjhJIbVLXKTMaGsZFVbEEIeQnVX36x3+ieU3gGeVLNYa3HO SgxVdr08cHD/j/lzf9gfE5D8sQHbGNQ8YqacwfBbQ6NCIFVdB0Qp8IeMKoVeLZwKBbUx +gyi2UAVIjMjWsW2faQE2c2lPjnJJYLStru/ozzWND87jQEeEL2EexAgc+r8ofv+PEYg BQiQo9vl/37/7GvcOJsIhsYc30UmMNKMLgwD9ZByglbUZuhGXwIfbWPFiJb3d9ozslTf agKHFud8FIljV3IYllQ5o9ewWtRJyAyCIj8V1p3UIOk6unA9lYz8yjWh3XxlC3AQDbo/ G4/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=xlKGV7zI8yovT8Qjaw1ezWS3Z9lVHmoWfs71GWUdoy4=; b=gcs8S5dO74096g7mufrz7bj6oECKTq2gQrIar/aJzDacoZnNenkbxZ5QflLMnkGie8 gHFQbQaiDcU9tDcVr4QW8g2CqOicQFSmRXyeWyd22NB5DczxMylda968b0HulQeFdDWt 7+xSsyvcYqFkbHg0UQSuwJBrVtMGJqIxmsZMtmxwaFeKy0M5Q6roqQ4wTrxmpolMHgGz rVYXuv8cyqcrf5M1Oduxky4qlSmPxqLLO8SSGKXjfqeU2FcKu75vcm+RkOyFIxrbB7f2 s4PwGvZE8GMCz3B1FlH3LmiwQ5uMaCk+SQDp+rtA7d6w8j9uCjcfIK5MhlLeA2zPD+UM E0tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XPuGtjI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d18-20020a170903231200b00175284c8e9dsi10272332plh.199.2022.09.29.05.21.01; Thu, 29 Sep 2022 05:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XPuGtjI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235262AbiI2Lei (ORCPT + 99 others); Thu, 29 Sep 2022 07:34:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234916AbiI2Leg (ORCPT ); Thu, 29 Sep 2022 07:34:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A138248 for ; Thu, 29 Sep 2022 04:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664451271; 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=xlKGV7zI8yovT8Qjaw1ezWS3Z9lVHmoWfs71GWUdoy4=; b=XPuGtjI+uWbWYDDeNtt21VO/oybFUOHidW5all2oCrbj/Nd1Nsq2CV1TYyuKFGsIXFCYKG GuvKq/KD4fiR8T0zeRQ3sjXxyJoEbh2b7e5pAMQdipmSjBK9eOcMSPgpFpM+N8SS0v5lXg WPyIKOeDnee+207fYEWEFGJCZH+huFE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-434-pQaDUFMyPUelI1FKIZiPIw-1; Thu, 29 Sep 2022 07:34:28 -0400 X-MC-Unique: pQaDUFMyPUelI1FKIZiPIw-1 Received: by mail-wm1-f71.google.com with SMTP id 14-20020a05600c228e00b003b4d065282dso344130wmf.8 for ; Thu, 29 Sep 2022 04:34:27 -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:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=xlKGV7zI8yovT8Qjaw1ezWS3Z9lVHmoWfs71GWUdoy4=; b=J5IYdwT5lClW4f2Yr3QuN+30hiIZayNeboRE+Yu3n9GqR7dGDRwtSEZZp1iU+jxgEh Gk/XwYmOIKs/O4in7l+TxkSB0j5qCGfAh1O+Ke3qr8OWMg9Aqq0IBQMTzEvDgp61J82Y 1GbS7KU1aEdxWnVfpK6tugnYbdU/eDGZvLxI8SYU11K2i3I9tjArS7M0ENraTH7s6fVl MG3WmT9poWQU6UDsvQ0gaV0MeL6lgP8cgpMKEiKXUn5EjgurgrlpCMDmgBXS47bLyXrO eFuERT19/MBAq0VWK5L2f4iaQsNP/ISxMJewbpaXMOIOo7f0y/VEjWv7AGeMq7Evwp3o 2lpw== X-Gm-Message-State: ACrzQf0sjYGV1JUobJqByu5XiyeaDLeuL0Y78VEXRJHrBecdQakvElFD idZz593ggZq0cK1SbpByDd/mUv5YsOd6Ak9oghB85hgFSKR+R07mRSoEPO8hP8dXqFXC0hmZ14s BFqEcOsSN+1g8o+MfeFPl4oFz X-Received: by 2002:a05:6000:86:b0:228:db07:24bc with SMTP id m6-20020a056000008600b00228db0724bcmr1903601wrx.204.1664451266818; Thu, 29 Sep 2022 04:34:26 -0700 (PDT) X-Received: by 2002:a05:6000:86:b0:228:db07:24bc with SMTP id m6-20020a056000008600b00228db0724bcmr1903572wrx.204.1664451266401; Thu, 29 Sep 2022 04:34:26 -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 q17-20020adff511000000b002253fd19a6asm8219675wro.18.2022.09.29.04.34.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Sep 2022 04:34:25 -0700 (PDT) Message-ID: <889909f6-f2db-f34a-0305-eb8500dd5453@redhat.com> Date: Thu, 29 Sep 2022 13:34:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH 0/3] ksm: fix incorrect count of merged pages when enabling use_zero_pages Content-Language: en-US To: Claudio Imbrenda , xu.xin.sc@gmail.com Cc: akpm@linux-foundation.org, imbrenda@linux.vnet.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, xu xin References: <20220929025206.280970-1-xu.xin16@zte.com.cn> <20220929124242.60ef57ee@p-imbrenda> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220929124242.60ef57ee@p-imbrenda> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.09.22 12:42, Claudio Imbrenda wrote: > On Thu, 29 Sep 2022 02:52:06 +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 >> 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's because those pages are not shared between different processes. They are probably the most shared pages between processes in the kernel. They are simply not KSM pages, that's what makes accounting tricky here. > >> 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). > > why? > > do you need to know how many untouched zero pages a process has? > > does it make a difference if the zero page is really untouched or if it > was touched in the past but it is now zero? I'd also like to understand the rationale. Is it about estimating memory demands when each and every shared page could get unshared? -- Thanks, David / dhildenb