From patchwork Thu Jul 10 21:53:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 4528551 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 201339F3B4 for ; Thu, 10 Jul 2014 23:34:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63B5B2011D for ; Thu, 10 Jul 2014 23:34:07 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 83E7D201B4 for ; Thu, 10 Jul 2014 23:34:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 891CC6E7B0; Thu, 10 Jul 2014 16:33:24 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 4AD5C6E01B for ; Thu, 10 Jul 2014 14:53:39 -0700 (PDT) Received: by mail-wg0-f42.google.com with SMTP id l18so187538wgh.25 for ; Thu, 10 Jul 2014 14:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Et6CeacQ+ZXUDSUWOeTDPDr4eyTKfiO4mVnCBYMb8XU=; b=CMUS5o6RY3bYZfpA0u3558Wmswa3yPV6NNo9g/y5s72eHKWSv0xB1N0eRekv4YxlE3 YeCZB/j7yqXH9vmKwnl7rmP4xmmQoJLZ5vCUvOffLo4NaJQalBv0GnJATMQKQWhFUqb7 LuNyGfRVmMEH1mjDqHxLEEVnXt24f/o4VI40PDjf9v4nA8y2PcZ4VAk/3g/Q74bcqAaP Y0EZPF+jtursgR/Jxbo3evkolrG+is6TXNkwutmklkTiNRCu/g/crjVCUs5M2V3HY3yc 47hbzELIh7ct6nYCTAV+vlcYa4jzVV/BM5E2LGrMrSc94BRw5NDz6eBkZPYoBLY1BsUD I0EQ== X-Received: by 10.194.1.164 with SMTP id 4mr59628675wjn.17.1405029217111; Thu, 10 Jul 2014 14:53:37 -0700 (PDT) Received: from localhost.localdomain ([77.127.59.49]) by mx.google.com with ESMTPSA id 10sm835823wjx.26.2014.07.10.14.53.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jul 2014 14:53:36 -0700 (PDT) From: Oded Gabbay X-Google-Original-From: Oded Gabbay To: Andrew Morton Subject: [PATCH 28/83] mm: Change timing of notification to IOMMUs about a page to be invalidated Date: Fri, 11 Jul 2014 00:53:26 +0300 Message-Id: <1405029208-6703-1-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Thu, 10 Jul 2014 16:33:12 -0700 Cc: Andrew Lewycky , Hugh Dickins , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jianyu Zhan , linux-mm , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Alex Deucher , Naoya Horiguchi , Cyrill Gorcunov , Joonsoo Kim , "Kirill A. Shutemov" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Lewycky This patch changes the location of the mmu_notifier_invalidate_page function call inside try_to_unmap_one. The mmu_notifier_invalidate_page function call tells the IOMMU that a pgae should be invalidated. The location is changed from after releasing the physical page to before releasing the physical page. This change should prevent the bug that would occur in the (rare) case where the GPU attempts to access a page while the CPU attempts to swap out that page (or discard it if it is not dirty). Signed-off-by: Andrew Lewycky Signed-off-by: Oded Gabbay --- mm/rmap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/rmap.c b/mm/rmap.c index 196cd0c..73d4c3d 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1231,13 +1231,17 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma, } else dec_mm_counter(mm, MM_FILEPAGES); + pte_unmap_unlock(pte, ptl); + + mmu_notifier_invalidate_page(vma, address, event); + page_remove_rmap(page); page_cache_release(page); + return ret; + out_unmap: pte_unmap_unlock(pte, ptl); - if (ret != SWAP_FAIL && !(flags & TTU_MUNLOCK)) - mmu_notifier_invalidate_page(vma, address, event); out: return ret;