Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3062544imj; Mon, 18 Feb 2019 18:52:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IbArNvWAl8bhzoNsJ1VEtd2jy5co1ZzlTvWwzELYxORjdRezlu3aQoZ+Log5jOb+pRhVMzt X-Received: by 2002:a63:ec48:: with SMTP id r8mr25862090pgj.50.1550544756140; Mon, 18 Feb 2019 18:52:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550544756; cv=none; d=google.com; s=arc-20160816; b=hNnVRguuFXSdLkNLkE5rkh5353YfstkfdwQkZSmQAlWG0b8DekGR9jOuNb6vpkHF8H XT5dvGdhaBOJxuK4ZoY0tx50qvE/z5FeTYYgqdJPWSs3svdLA4S5SRICUKI8HEB08RyY e2fPXFyvt6jT9m9x8ENlkIB6Wyv7AsSyGwv2OUAb4TWF1DLcIh4NblxDRbNFMBOzxmPu 5u1ei/di7oovRNjLAsDNQNuz4XDx8Egic3QSj1YOyYSvGfPXiVUfRyrCg7l8VUHcXPsY snC+EEzcUpKG7MHcJ3JsjlRlSrL2GQAtBUTqdjy698s8Y9vMbh6jBIyv81cmWLSEc1PV Ud1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8g77xX5XEbc9w1ZQ+UBUoak3MQ0n9Lq3RW4jOi+9K7s=; b=vn19MNYsRpJ0Jllb/5fPc7TJxONT3FMDYArW9QDbM/v1bJS1qkz/Up1nIZ4OM/e6M5 hfftMzgb01zIBQNwtrvvCTwssx0Zg2l7dbv0Wj/o9EblrcYl0Kf1g697O3V04LyLZOnU jLkAK6lI1BR2aZgHS6Ck6ugbHIJ3kIyh1LorY201vG8RnaDnHfUXEHOYecHE0ZwRERSv Nk//wGhoI+LY8kVpYTRweNECGFpVPEtrnbtKnAjBkA/F8z8j+Q50WZrQdaMY7Qz8pn99 yARjvy2Kojd9qUB3v664qogIOr/CDNW4FZ7c/AYcGhfkabeFX9tmc92ZZfje5/NpFFgw mvlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si6460481pll.75.2019.02.18.18.52.21; Mon, 18 Feb 2019 18:52:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbfBSChJ (ORCPT + 99 others); Mon, 18 Feb 2019 21:37:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55118 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbfBSChI (ORCPT ); Mon, 18 Feb 2019 21:37:08 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 572CBBDFA; Tue, 19 Feb 2019 02:37:08 +0000 (UTC) Received: from xz-x1 (dhcp-14-116.nay.redhat.com [10.66.14.116]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C3515D706; Tue, 19 Feb 2019 02:37:03 +0000 (UTC) Date: Tue, 19 Feb 2019 10:37:01 +0800 From: Peter Xu To: Andrea Arcangeli Cc: Jerome Glisse , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andrew Morton , Matthew Wilcox , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Michal Hocko , kvm@vger.kernel.org Subject: Re: [RFC PATCH 0/4] Restore change_pte optimization to its former glory Message-ID: <20190219023701.GA3223@xz-x1> References: <20190131183706.20980-1-jglisse@redhat.com> <20190201235738.GA12463@redhat.com> <20190211190931.GA3908@redhat.com> <20190211200200.GA30128@redhat.com> <20190218160411.GA3142@redhat.com> <20190218174505.GD30645@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190218174505.GD30645@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 19 Feb 2019 02:37:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 18, 2019 at 12:45:05PM -0500, Andrea Arcangeli wrote: > On Mon, Feb 18, 2019 at 11:04:13AM -0500, Jerome Glisse wrote: > > So i run 2 exact same VMs side by side (copy of same COW image) and > > built the same kernel tree inside each (that is the only important > > workload that exist ;)) but the change_pte did not have any impact: > > > > before mean {real: 1358.250977, user: 16650.880859, sys: 839.199524, npages: 76855.390625} > > before stdev {real: 6.744010, user: 108.863762, sys: 6.840437, npages: 1868.071899} > > after mean {real: 1357.833740, user: 16685.849609, sys: 839.646973, npages: 76210.601562} > > after stdev {real: 5.124797, user: 78.469360, sys: 7.009164, npages: 2468.017578} > > without mean {real: 1358.501343, user: 16674.478516, sys: 837.791992, npages: 76225.203125} > > without stdev {real: 5.541104, user: 97.998367, sys: 6.715869, npages: 1682.392578} > > > > Above is time taken by make inside each VM for all yes config. npages > > is the number of page shared reported on the host at the end of the > > build. > > Did you set /sys/kernel/mm/ksm/sleep_millisecs to 0? > > It would also help to remove the checksum check from mm/ksm.c: > > - if (rmap_item->oldchecksum != checksum) { > - rmap_item->oldchecksum = checksum; > - return; > - } > > One way or another, /sys/kernel/mm/ksm/pages_shared and/or > pages_sharing need to change significantly to be sure we're exercising > the COW/merging code that uses change_pte. KSM is smart enough to > merge only not frequently changing pages, and with the default KSM > code this probably works too well for a kernel build. Would it also make sense to track how many pages are really affected by change_pte (say, in kvm_set_pte_rmapp, count avaliable SPTEs that are correctly rebuilt)? I'm thinking even if many pages are merged by KSM it's still possible that these pages are not actively shadowed by KVM MMU, meanwhile change_pte should only affect actively shadowed SPTEs. In other words, IMHO we might not be able to observe obvious performance differeneces if the pages we are accessing are not merged by KSM. In our case (building the kernel), IIUC the mostly possible shared pages are system image pages, however when building the kernel I'm thinking whether these pages will be frequently accesses, and whether this could lead to similar performance numbers. Thanks, -- Peter Xu