From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrea Arcangeli Subject: Re: [RFC PATCH 0/4] Restore change_pte optimization to its former glory Date: Mon, 11 Feb 2019 15:02:00 -0500 Message-ID: <20190211200200.GA30128@redhat.com> References: <20190131183706.20980-1-jglisse@redhat.com> <20190201235738.GA12463@redhat.com> <20190211190931.GA3908@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peter Xu , 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 To: Jerome Glisse Return-path: Content-Disposition: inline In-Reply-To: <20190211190931.GA3908@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Mon, Feb 11, 2019 at 02:09:31PM -0500, Jerome Glisse wrote: > Yeah, between do you have any good workload for me to test this ? I > was thinking of running few same VM and having KSM work on them. Is > there some way to trigger KVM to fork ? As the other case is breaking > COW after fork. KVM can fork on guest pci-hotplug events or network init to run host scripts and re-init the signals before doing the exec, but it won't move the needle because all guest memory registered in the MMU notifier is set as MADV_DONTFORK... so fork() is a noop unless qemu is also modified not to call MADV_DONTFORK. Calling if (!fork()) exit(0) from a timer at regular intervals during qemu runtime after turning off MADV_DONTFORK in qemu would allow to exercise fork against the KVM MMU Notifier methods. The optimized change_pte code in copy-on-write code is the same post-fork or post-KSM merge and fork() itself doesn't use change_pte while KSM does, so with regard to change_pte it should already provide a good test coverage to test with only KSM without fork(). It'll cover the read-write -> readonly transition with same PFN (write_protect_page), the read-only to read-only changing PFN (replace_page) as well as the readonly -> read-write transition changing PFN (wp_page_copy) all three optimized with change_pte. Fork would not leverage change_pte for the first two cases.