From patchwork Thu Jan 31 18:37:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10791163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3CC5139A for ; Thu, 31 Jan 2019 18:37:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96ED4310F5 for ; Thu, 31 Jan 2019 18:37:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8790231111; Thu, 31 Jan 2019 18:37:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F8C310F5 for ; Thu, 31 Jan 2019 18:37:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B08E8E0003; Thu, 31 Jan 2019 13:37:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 337D58E0001; Thu, 31 Jan 2019 13:37:19 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AD238E0003; Thu, 31 Jan 2019 13:37:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id E3E578E0001 for ; Thu, 31 Jan 2019 13:37:18 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id j125so4138926qke.12 for ; Thu, 31 Jan 2019 10:37:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=c0x0Lso80FVkCqQKmxH25r61rYDEF6XogwD4uXvVoWY=; b=ZQz+tYFhWXq4Lg7ii3JFL+jSTjRij1sLKyEcBs+dKVopB5851Ba8HudAhtjxJifgWB +xvfAWEzHnxuHKz2/LNnD1NChdpZEc3W2CSgUdlpENYEetRR6JlPNaU5scfFW7zO7ETd dmdRQ1wsBeyQW0H8xu4hwxfWSWXDhcpCd0pka3KjCST0QQrhkywRJ77Ey8w/wfq0hwjF wQrdQMZzWUNWiC5dMoc2CvvfzowJyuJfQvUPN0dFiWWvICbvYzPYc2PlLHQNf0M0c/21 slezEqthhB79h8x6an9QGC6LyMQy38yxxbnnAxsiPhMMw/jPAKbduPA8TPP2a9Ghb8H/ Vj/Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukeIqnkQ3R64biDyXw5BGOGBmn9A6k6kOVm7e7tB7V5ia6xh9yiq gVmo9sleRGeaca7ntt7oMyrD8HGAeO6ea6sMGL/B5dcjDPygDaSiN6jP73HQ2KWGeVUnyH24zIp mqggKqbe+IkmwEPCn0qj3OKlmZc5QiW73CfQ4EH42YeLlOlMY7/8EOlydxDFN2tTFRQ== X-Received: by 2002:ac8:2bd4:: with SMTP id n20mr35066030qtn.172.1548959838702; Thu, 31 Jan 2019 10:37:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN5oWm3B4uLnjRquynyW0gQMPB2zfgI7nCeMDCLmm/xFC9no8URLwTG1z2RdFikp8OBBXypI X-Received: by 2002:ac8:2bd4:: with SMTP id n20mr35066007qtn.172.1548959838265; Thu, 31 Jan 2019 10:37:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548959838; cv=none; d=google.com; s=arc-20160816; b=OjfAYcp+Ss2vvJ4unq5F+r5kjylKCvqlk9JgVxHxjhHypphfjcEXi5Q5PLIlJhYTls ii7dBxTvIvseEjTE473LDIx/e4fuaQPCPAk4pbkYypYLteYaOwbxTnB1Ax2mhK2fIGuX HXdcC3cGmKvlDQCZnlwjcg8jiexFixzov4AlmgRRwOnraIp9vE8jx8nUcuO4K2zaBtAb U+WWmcd2SU/oEKL6FUB9SL+4jFjD8WIK71MdHWZ1rrqxHOpCrb8kEVNQktepS3UBMhAc ARZuh9KQO6hSgbn3oOF20xhQMMuvZphemEF9zkr17eAxmDKHHukFfjhRlZkqt/VxK9qh z6Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=c0x0Lso80FVkCqQKmxH25r61rYDEF6XogwD4uXvVoWY=; b=tfI8gxM+Fb4nt1ddYZnUykZ2KEQYLQzzZgCi50/2wjPO479kxerogjKco1qHHbtnNX ptBtfq3QE3jDkDopINZni1ixET3Pvr/kRN5n8jrjrwuSjsMQ64fxEEezZICP6VOoxNX2 y6D6GIyGlRFycIbJAWkxozep8YjIfaHPXOeAghaMfTA4uCvDdbuGZY7LlOGp5qpS9NgD o4CLEIaYsglbmrJqyw0U5VwT5nj4ymEhit1UxSDhCQxKnmMkrumgQWpnWi1LHiaClBSO /BwyXEo8RiUG4/SOrTXUdeXSAIqIco1dx/f/vYE2YsuRGGkPIGnuXl8XNBw5yN4d65xn VQYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l7si3433153qth.251.2019.01.31.10.37.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:37:18 -0800 (PST) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 540FCAC613; Thu, 31 Jan 2019 18:37:17 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0C9F17F7D; Thu, 31 Jan 2019 18:37:15 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , Peter Xu , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andrew Morton , Matthew Wilcox , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Michal Hocko , kvm@vger.kernel.org Subject: [RFC PATCH 1/4] uprobes: use set_pte_at() not set_pte_at_notify() Date: Thu, 31 Jan 2019 13:37:03 -0500 Message-Id: <20190131183706.20980-2-jglisse@redhat.com> In-Reply-To: <20190131183706.20980-1-jglisse@redhat.com> References: <20190131183706.20980-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 31 Jan 2019 18:37:17 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse Using set_pte_at_notify() trigger useless calls to change_pte() so just use set_pte_at() instead. The reason is that set_pte_at_notify() should only be use when going from either a read and write pte to read only pte with same pfn, or from read only to read and write with a different pfn. The set_pte_at_notify() was use because __replace_page() code came from the mm/ksm.c code in which the above rules are valid. Signed-off-by: Jérôme Glisse Cc: Andrea Arcangeli Cc: Peter Xu Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Andrew Morton Cc: Matthew Wilcox Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Michal Hocko Cc: kvm@vger.kernel.org --- kernel/events/uprobes.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 87e76a1dc758..a4807b1edd7f 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -207,8 +207,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, flush_cache_page(vma, addr, pte_pfn(*pvmw.pte)); ptep_clear_flush_notify(vma, addr, pvmw.pte); - set_pte_at_notify(mm, addr, pvmw.pte, - mk_pte(new_page, vma->vm_page_prot)); + set_pte_at(mm, addr, pvmw.pte, mk_pte(new_page, vma->vm_page_prot)); page_remove_rmap(old_page, false); if (!page_mapped(old_page)) From patchwork Thu Jan 31 18:37:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10791165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BAE191E for ; Thu, 31 Jan 2019 18:37:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12979310F5 for ; Thu, 31 Jan 2019 18:37:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05F9A31111; Thu, 31 Jan 2019 18:37:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96630310F5 for ; Thu, 31 Jan 2019 18:37:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E8698E0004; Thu, 31 Jan 2019 13:37:20 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 24A408E0001; Thu, 31 Jan 2019 13:37:20 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EB578E0004; Thu, 31 Jan 2019 13:37:19 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id CF97F8E0001 for ; Thu, 31 Jan 2019 13:37:19 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id n50so4681948qtb.9 for ; Thu, 31 Jan 2019 10:37:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kXqLfs1BKp0kzy9udszLKBSqjJnqMxtry13bQ0e2bt8=; b=VD7CPTUbQZwoe/6C6M58onbZGXw+sVwyjl869HKiRbaShnQAyF/rkEbsZZ/uAgDHFw d9b0uX9WzTebh0kG19fyKc2G/17XwM3ksbu4UyEa7xRgohflPLB9MVf4xiNWWg00U/0e eRJl+8r7bVzlL9uYKcKeQmiZiG3A2Tw9JDSrq27b40rUyckuzt87bS0d0fJQzefBZ7bx qi9uPG74jHy+CENYHMcbWlZ1ccQPQlpShi7Y034I8ZF83dLdetaniQ5npwr78C/q8FLA xnh79PHIn1VfFg0yQsLG3FiU5j6mvCEXyqR2SlIKNYFCXm8AiTpsHcigBZGnF+M06K1b TWNg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukdeFRKq6tWdK+BArcvLizSCV8XHtpdigoSu5sqfp4Oz8CY3FabJ 7AoY6RFSCfzkAXAYXjsT2AoiYKkK+9nghU7TyZZ37ld272YAh5jZoqD+AHR0Y8B3lIPrhTTSJKH J56/tmH+j5k/pEYwDNLjttOY/ow2ULpzko+b/w4L//H9nTPGVrfWlu4Taw1Fw/vpDcA== X-Received: by 2002:a0c:b527:: with SMTP id d39mr33813356qve.201.1548959839625; Thu, 31 Jan 2019 10:37:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN6aZV+mdzMQN6JdSlGoG0iDsn7Mq5dSJP16dNNQ7l8jI3JH1LPCmu6cSamnpjijm7CuId1i X-Received: by 2002:a0c:b527:: with SMTP id d39mr33813336qve.201.1548959839203; Thu, 31 Jan 2019 10:37:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548959839; cv=none; d=google.com; s=arc-20160816; b=H2QZ2V86KTj77DC0tuZjDEaF8xu5Zn/GDiauLi3gKOJGhwEs6MewKduLXSJfX4eEVr rCiRrzDyCvZKuPJzsYiJTxH6+sde92RAsOUdWFjg6ljM0Cxk58OT7Xtbsu0/jVyC/xBK /LfoVXeykevxz0t7AF7jYWpv27zGbQXzD1ICvgggi4HpNM2C6WGa8N/jwysbHuP5aE9v HvU8zw6uwB3rVnZ7FHV9IfyfBPfFlFSj8jxcrAtpA6DO6SU50Ax/5A542kZKUwc5uQiM WOtGTPGKMmFJqLL9D6gbxXCRkKT61ccYASGPFsHHNqMcv3oSsdZYEbZtIhj1UPgXwkWi jX9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=kXqLfs1BKp0kzy9udszLKBSqjJnqMxtry13bQ0e2bt8=; b=Ns/S1vOe7rXX3JVVl40wa4BRIlMsVXryLxYD756FM1HuXerFXcULvqFfxP45rAftcO U0f1gc2H6DcvlfBdY/Qf2AAAzMwTh4E0h+7M20xq1as5tcbJP2KVfbnUnKsQTU+G75Vy c+TzkyRd2oDswAR/eGbZ4xzW1osuLdvUDQPwYKsiWIZKsK3EwiVpsgcCOPCMeVIBnZ5X 39h530aCDqcJ8MbVaOmIruJyYcvCW0a9/eUv44M6i4Gqcs1F2k6nda3O11Qf+sYMFwg1 Kn15iCJEqvVUvEhdcD0IHuiOUMK4qbrA1ghtVF9Y8x48zTJQKp580pWEY820uHUbkORG QO7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id e16si1800838qtr.3.2019.01.31.10.37.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:37:19 -0800 (PST) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B0E99090D; Thu, 31 Jan 2019 18:37:18 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6934718506; Thu, 31 Jan 2019 18:37:17 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , Peter Xu , Andrew Morton , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org Subject: [RFC PATCH 2/4] mm/mmu_notifier: use unsigned for event field in range struct Date: Thu, 31 Jan 2019 13:37:04 -0500 Message-Id: <20190131183706.20980-3-jglisse@redhat.com> In-Reply-To: <20190131183706.20980-1-jglisse@redhat.com> References: <20190131183706.20980-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 31 Jan 2019 18:37:18 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse Use unsigned for event field in range struct so that we can also set flags with the event. This patch change the field and introduce the helper. Signed-off-by: Jérôme Glisse Cc: Andrea Arcangeli Cc: Peter Xu Cc: Andrew Morton Cc: Paolo Bonzini Cc: Radim Krčmář Cc: kvm@vger.kernel.org --- include/linux/mmu_notifier.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index be873c431886..d7a35975c2bd 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -6,6 +6,7 @@ #include #include #include +#include struct mmu_notifier; struct mmu_notifier_ops; @@ -38,8 +39,11 @@ enum mmu_notifier_event { MMU_NOTIFY_PROTECTION_VMA, MMU_NOTIFY_PROTECTION_PAGE, MMU_NOTIFY_SOFT_DIRTY, + MMU_NOTIFY_EVENT_MAX }; +#define MMU_NOTIFIER_EVENT_BITS order_base_2(MMU_NOTIFY_EVENT_MAX) + #ifdef CONFIG_MMU_NOTIFIER /* @@ -60,7 +64,7 @@ struct mmu_notifier_range { struct mm_struct *mm; unsigned long start; unsigned long end; - enum mmu_notifier_event event; + unsigned event; bool blockable; }; @@ -352,7 +356,7 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) static inline void mmu_notifier_range_init(struct mmu_notifier_range *range, - enum mmu_notifier_event event, + unsigned event, struct vm_area_struct *vma, struct mm_struct *mm, unsigned long start, From patchwork Thu Jan 31 18:37:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10791167 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82EBA139A for ; Thu, 31 Jan 2019 18:37:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 791E8310AA for ; Thu, 31 Jan 2019 18:37:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D62E3110C; Thu, 31 Jan 2019 18:37:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E04EC310F5 for ; Thu, 31 Jan 2019 18:37:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70EC78E0005; Thu, 31 Jan 2019 13:37:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 66BD78E0001; Thu, 31 Jan 2019 13:37:21 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50DD08E0005; Thu, 31 Jan 2019 13:37:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id 2110D8E0001 for ; Thu, 31 Jan 2019 13:37:21 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id j5so4620858qtk.11 for ; Thu, 31 Jan 2019 10:37:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=u45twQrCqvSrmqG5PGI8ES0fpLyoiBXcBf7TRg10A3c=; b=doTWko/A/1xi1iyrFgHOsjpIJKEpg+4iwX9VYOfPIxDeAl/sEKSc8zyeFAVBk61ZBw veonY5CPfSfMae4mBYnd23a6lQNOyZ6BQx5XO5QpW5i6KQdySIHq8RdHlerk9IHjNZyO LzhnZXwP/2wxA2KUfniFtMHzU596WtCV+GGawzt5ZtxfxN/9EDCEb/1xiLg/SkWUd/Ce 5le6K0nOVdKscwwoNQTCtQFTwfvO+gf04xlKzWPcr3o9ig9C4PoysamornPremezXZtI icg+jiaxtolkDIjxEdSoDdjBojdjWMbxGR6u7rV6Wtp5RC/IDszHlEmOMzPa+Ktj/Uyw j4ng== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukeP4e2AbYE7h2xeA0kLACx8oE1xuaT3UrggzKlLZFd9ZYLfDFnz G7dsLT1EBmbz9mamls8XNzZJuOnCn87h9lvyGRNJeHIK0EqKSNvn+jUpbM5doh+UaD+MmIsG7/U GUrHD7M9w6XOO5CHEW2h6uYDA3y78/L0PUPrgM9/Apj6DZ+0QdbWRqeXYbIOMpD8VyQ== X-Received: by 2002:a37:aa0c:: with SMTP id t12mr32111426qke.358.1548959840902; Thu, 31 Jan 2019 10:37:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6aqcKJI6SDstX/mlWDhUt6iXsi7DtjwZXYlNmVqLqD5Eir6odWI45tudrj4jsdj20UjUkn X-Received: by 2002:a37:aa0c:: with SMTP id t12mr32111407qke.358.1548959840386; Thu, 31 Jan 2019 10:37:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548959840; cv=none; d=google.com; s=arc-20160816; b=YrKoKZCT7V5MURQikMbjL0IXwIBH2MkJEwoQycu1o4ZkG+615twuzIevCfxM9GI09C zsTfzD7aV0umZyT8J13U83do2MjZIA3tKJcyLdodowbNpnzD61pVAt3ht0JvWonTKaM1 0SSPHFeo4hFBv9BNOSB4oV6SesndGr7O0Uzl/jhULMACt65Oh99MjlV+WmBefH9ANmRE 11JL26VbScIYAL4HTDJzy5WNZb2Ji8kobVoAqmYCfrDz2Fg0okr2jRGuk+5yrNMVPZ/d JS6lpYYcHTHlyqIBmJySoKA9o6gnclW8ZvC+C94Ma5OP9UAtJPRIEFUgtDzSwyYEAOau NzFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=u45twQrCqvSrmqG5PGI8ES0fpLyoiBXcBf7TRg10A3c=; b=OVmhCXR7H7Ioaw96QgRhqCzeXCgytrtv6kk73MwUHew/ocuKkIlxLApvX76LFpBpDY LP89+AETmYLSjFQfTsFdvpCM0SehJarxS3uqAdH5c5j32+Sff36cSXZ0V5RTwK4HkG82 0gqjySDajAl16vcJhMJwx8CN3gLI6EyMnMpbcf+IhAb+qIdgWnfp9zxrkBrI5bgbbuqZ FgGc+cTLeP/pIkUI8Tq2o++GsiXl8iRmGQbdYKjMqiMoTbgnN58mRNjV3flq+OMHw2nX xU9IP1iIUXPFFBt95H6wKMlCHHx4dP4ZbrcU811ZwkljrO0eVJVXQKYg1LSSkt2fiDdT 4dZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id l13si67810qvm.104.2019.01.31.10.37.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:37:20 -0800 (PST) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D85489AF1; Thu, 31 Jan 2019 18:37:19 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87A7A18506; Thu, 31 Jan 2019 18:37:18 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , Peter Xu , Andrew Morton , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org Subject: [RFC PATCH 3/4] mm/mmu_notifier: set MMU_NOTIFIER_USE_CHANGE_PTE flag where appropriate Date: Thu, 31 Jan 2019 13:37:05 -0500 Message-Id: <20190131183706.20980-4-jglisse@redhat.com> In-Reply-To: <20190131183706.20980-1-jglisse@redhat.com> References: <20190131183706.20980-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 31 Jan 2019 18:37:19 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse When notifying change for a range use MMU_NOTIFIER_USE_CHANGE_PTE flag for page table update that use set_pte_at_notify() and where the we are going either from read and write to read only with same pfn or read only to read and write with new pfn. Note that set_pte_at_notify() itself should only be use in rare cases ie we do not want to use it when we are updating a significant range of virtual addresses and thus a significant number of pte. Instead for those cases the event provided to mmu notifer invalidate_range_start() callback should be use for optimization. Signed-off-by: Jérôme Glisse Cc: Andrea Arcangeli Cc: Peter Xu Cc: Andrew Morton Cc: Paolo Bonzini Cc: Radim Krčmář Cc: kvm@vger.kernel.org --- include/linux/mmu_notifier.h | 13 +++++++++++++ mm/ksm.c | 6 ++++-- mm/memory.c | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index d7a35975c2bd..0885bf33dc9c 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h @@ -43,6 +43,19 @@ enum mmu_notifier_event { }; #define MMU_NOTIFIER_EVENT_BITS order_base_2(MMU_NOTIFY_EVENT_MAX) +/* + * Set MMU_NOTIFIER_USE_CHANGE_PTE only when the page table it updated with the + * set_pte_at_notify() and when pte is updated from read and write to read only + * with same pfn or from read only to read and write with different pfn. It is + * illegal to set in any other circumstances. + * + * Note that set_pte_at_notify() should not be use outside of the above cases. + * When updating a range in batch (like write protecting a range) it is better + * to rely on invalidate_range_start() and struct mmu_notifier_range to infer + * the kind of update that is happening (as an example you can look at the + * mmu_notifier_range_update_to_read_only() function). + */ +#define MMU_NOTIFIER_USE_CHANGE_PTE (1 << MMU_NOTIFIER_EVENT_BITS) #ifdef CONFIG_MMU_NOTIFIER diff --git a/mm/ksm.c b/mm/ksm.c index 97757c5fa15f..b7fb7b560cc0 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1051,7 +1051,8 @@ static int write_protect_page(struct vm_area_struct *vma, struct page *page, BUG_ON(PageTransCompound(page)); - mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, vma, mm, + mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR | + MMU_NOTIFIER_USE_CHANGE_PTE, vma, mm, pvmw.address, pvmw.address + PAGE_SIZE); mmu_notifier_invalidate_range_start(&range); @@ -1140,7 +1141,8 @@ static int replace_page(struct vm_area_struct *vma, struct page *page, if (!pmd) goto out; - mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, vma, mm, addr, + mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR | + MMU_NOTIFIER_USE_CHANGE_PTE, vma, mm, addr, addr + PAGE_SIZE); mmu_notifier_invalidate_range_start(&range); diff --git a/mm/memory.c b/mm/memory.c index a8c6922526f6..daf4b0f92af8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2275,7 +2275,8 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) __SetPageUptodate(new_page); - mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, vma, mm, + mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR | + MMU_NOTIFIER_USE_CHANGE_PTE, vma, mm, vmf->address & PAGE_MASK, (vmf->address & PAGE_MASK) + PAGE_SIZE); mmu_notifier_invalidate_range_start(&range); From patchwork Thu Jan 31 18:37:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10791171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3BF291E for ; Thu, 31 Jan 2019 18:37:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED102310F5 for ; Thu, 31 Jan 2019 18:37:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E10A031111; Thu, 31 Jan 2019 18:37:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E992310F5 for ; Thu, 31 Jan 2019 18:37:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5ABA48E0006; Thu, 31 Jan 2019 13:37:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 507E98E0001; Thu, 31 Jan 2019 13:37:22 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3ACD88E0006; Thu, 31 Jan 2019 13:37:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id 0A1DD8E0001 for ; Thu, 31 Jan 2019 13:37:22 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id t18so4712571qtj.3 for ; Thu, 31 Jan 2019 10:37:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8tiJVUoyMizFoUbRG/0d46To2uc9w1MUhAWOmZ5Ruc8=; b=rEWlHRiTGKhEu+KG5oS2u4XfBwurbWNPvhFB1ShFEjhazS6KO4Wt4oDIT5U7y+Fct/ dnlbyNdyO3RrCh1pJg/hbXD0071DZYFNATJgJ1aoOZIKliy7b+tvAqzvzKyHs6W4baXH tBa0XDyaDHpo7aPe3agUuSez5tT+cWmkNLsnr6wgwD1VRYlR1f5jCzJODR7FLjkr6Ub1 1V8CdZiA95Oy5xZPEJm7GGNRu9B4qU/8yp9oE0/Xa49ppBCNJ6aEBEeMUtdcyppymPjq Ro7tFuQ5oEUIbvgf7mzXi/2EG0KrzZxT3nCNGnnmjjwKvv1yD/FQXeqysO5SgilOF/l4 OggQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AJcUukeZfavoxxYebcv93JlN8s6CIqIvp01M2zK3x5axvtClPuYmqN6V ojGOmZlGC6rc1fTWd9qH5P+8ePKiiSRRZEkYLm0rANG+vVS2kl918n1H0vYX0o4iA5PwkfgTL6R k2Jx98Ak962iSNQ3RRG8PsBNq0VOinXAcNXFEgUBD5zD0Ekj88rQHM1+LgmRFOEEf+w== X-Received: by 2002:a0c:b786:: with SMTP id l6mr34159889qve.244.1548959841830; Thu, 31 Jan 2019 10:37:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN6nuDUQbrz4HAgGzRjeRlvY0G5+9Ct7BGNaYohaNpa5IIw6LFgOs4FxbZQhEU/rZH6fBEJ/ X-Received: by 2002:a0c:b786:: with SMTP id l6mr34159860qve.244.1548959841376; Thu, 31 Jan 2019 10:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548959841; cv=none; d=google.com; s=arc-20160816; b=WQ/0Kc/fdl8hTRDZhbVCPVN9YMzO9enjYSiIKJDp1YPxQlJZXSXlcKjh6H5Ni9ZxTW o8wIayKr+ZMYLTto2JQUurUUeR5uinqlLHS0GhTIYZ2Mi4IXmsKRusVMg0IpY/zlIkLH YRSXG2HLIqrf7fr0HNz7RV/9IeZsdQgSy4zuQZGDW1zchtM9jjJAy2pF5em0HLGOYPtb 7Nst4pW5ZfxzgaC/HC17kICBpTLpO1dJQSX6NAcQzY4zNYDaePHiC4ri+Y9cYHx7sLtA IxdL1pCYKCMD6u9TMLYGiXmWd55EEQbOwNwVjHQcIfxcSTMDvGEchGh3i38DlieNxwI0 QHtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=8tiJVUoyMizFoUbRG/0d46To2uc9w1MUhAWOmZ5Ruc8=; b=nsI1VpwCPYjMLTU8kq0IBqEPavF4gzrRjZxjfM4RYMGDcIpegNAfI4cPeNCQYyuTtJ noNMNTuZdUfA0C5RCovfvoBVMWsf4ESw1MdbH7ojjUN1qLyVIBm/0WRu6QGY/KhNiZwE 6gfoSRuGn+ybAmhhDTYXCpTIYP0C5nrA13E5H6ZQkBirCAtSMaTqXZXm3rr3C109Woxm quSSoIc0PBLDaQiRJDqhpQ5KMUgfRX9TYfVJsmVCMJNY3jLWJTAtjk1BVMgktlwVPbXT e4NoMbfM+INCgYHsEa7kvmsAEFPC1NdKAKuZsgVSJDu0prG3tbKBjfK/ZXf9MM9Gxz/J ekiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id o5si1654531qta.399.2019.01.31.10.37.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Jan 2019 10:37:21 -0800 (PST) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9F27F3D09; Thu, 31 Jan 2019 18:37:20 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id A757217F7D; Thu, 31 Jan 2019 18:37:19 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Andrea Arcangeli , Peter Xu , Andrew Morton , Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org Subject: [RFC PATCH 4/4] kvm/mmu_notifier: re-enable the change_pte() optimization. Date: Thu, 31 Jan 2019 13:37:06 -0500 Message-Id: <20190131183706.20980-5-jglisse@redhat.com> In-Reply-To: <20190131183706.20980-1-jglisse@redhat.com> References: <20190131183706.20980-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 31 Jan 2019 18:37:20 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse Since changes to mmu notifier the change_pte() optimization was lost for kvm. This re-enable it, when ever a pte is going from read and write to read only with same pfn, or from read only to read and write with different pfn. It is safe to update the secondary MMUs, because the primary MMU pte invalidate must have already happened with a ptep_clear_flush() before set_pte_at_notify() is invoked (and thus before change_pte() callback). Signed-off-by: Jérôme Glisse Cc: Andrea Arcangeli Cc: Peter Xu Cc: Andrew Morton Cc: Paolo Bonzini Cc: Radim Krčmář Cc: kvm@vger.kernel.org --- virt/kvm/kvm_main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5ecea812cb6a..fec155c2d7b8 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -369,6 +369,14 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn, int need_tlb_flush = 0, idx; int ret; + /* + * Nothing to do when MMU_NOTIFIER_USE_CHANGE_PTE is set as it means + * that change_pte() will be call and it is a situation in which we + * allow to only rely on change_pte(). + */ + if (range->event & MMU_NOTIFIER_USE_CHANGE_PTE) + return 0; + idx = srcu_read_lock(&kvm->srcu); spin_lock(&kvm->mmu_lock); /* @@ -398,6 +406,14 @@ static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn, { struct kvm *kvm = mmu_notifier_to_kvm(mn); + /* + * Nothing to do when MMU_NOTIFIER_USE_CHANGE_PTE is set as it means + * that change_pte() will be call and it is a situation in which we + * allow to only rely on change_pte(). + */ + if (range->event & MMU_NOTIFIER_USE_CHANGE_PTE) + return; + spin_lock(&kvm->mmu_lock); /* * This sequence increase will notify the kvm page fault that