From patchwork Sat Oct 13 00:24:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Arcangeli X-Patchwork-Id: 10639759 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 7478417E1 for ; Sat, 13 Oct 2018 00:24:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65D772BAFF for ; Sat, 13 Oct 2018 00:24:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59AE82BB04; Sat, 13 Oct 2018 00:24:37 +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 E57FB2BAFF for ; Sat, 13 Oct 2018 00:24:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1F6C6B029D; Fri, 12 Oct 2018 20:24:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 92C736B0298; Fri, 12 Oct 2018 20:24:33 -0400 (EDT) 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 758416B029C; Fri, 12 Oct 2018 20:24:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 3C7886B0298 for ; Fri, 12 Oct 2018 20:24:33 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id d200-v6so13244490qkc.22 for ; Fri, 12 Oct 2018 17:24:33 -0700 (PDT) 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; bh=RJnUg25d+eLor5UPrJN+kZQntXCyQ0/TA0GnjYU5GcE=; b=IdyHqm4pC8saEha3ukRLHXfGsVfS+KpVR6+ZVbe2OGGGSI9JtK1S/o0iWP9C9NH/Rs WthTdrG/1nVQ3cQ/qbAHeRWDDSwTt9k6CF0X+0qIix8pth2/c01IWEFZweVUi5mb3wz1 xbzeyuqYq/6t/t1YW0WbpOBKoPKbrK9Bw37iprKzpysNCr+Mp9m1WhhlKb5VF2/3JBcj 3CCQtyJezc4TpVVFpVvrwhycRz4W2dfT+nW6s7JbiRpSA+/L618TCGNiRe4kuw5lMkoo 1/HuCW/yn+X7RcFmzBQLbBrXRfke0vkKEbpZRIHFwQgXGpq5M9ukvQZZM7DdTFTR3HuZ z8zw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: ABuFfoj0+cmWJ7yfQYY4O8ixx0vxdn9zQGHwFfY72ZAO/LlR8Sq7mYba hI3x7nSBnVwM2fTd7WwKNfdctqQF+ncoHdAjoALQ0Nypz9p5dNIseVkSFA0H+ZO8RQ4ZFqdYMnY jyM4J7EWZ+XvbAVDm9tCnqe26piF7h8VTAxWuhT+4pKkOedvd1TSt254wHO2u/kxbRQ== X-Received: by 2002:a0c:db91:: with SMTP id m17mr8085639qvk.166.1539390273002; Fri, 12 Oct 2018 17:24:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV609LWrN8nK+r99NvQDTJgdTq8j8yC2mL0BgOp3S9dfHzbpm7dPz/qUcJLdscPdMwuzU4FXa X-Received: by 2002:a0c:db91:: with SMTP id m17mr8085621qvk.166.1539390272408; Fri, 12 Oct 2018 17:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539390272; cv=none; d=google.com; s=arc-20160816; b=XSYehwQYoJhditfFNqVV++I4v5oEaLe1oX/mmHvXN/sLQMyPwg4tN0s964QvarnvK/ VEMQMFhQGGNifhdKuV51Jq0eXojqUf3b1IAPCyI4pjJ+6yp7z3QsqdFUge09ps1kS7Kl mFu1LulEi6N2vyBRrHGKUtCgicpy0biDfSmCpEgBbYXy9OJr7zbPp45OokxRuY9J9PrW h3dHS/VESA14fuUvwjLCcWRCO2xYjqYfApUjPMIwhqHcx8FLmPVZUo5h2uVzmZeYVEA3 At0L9zyBvSRN53S18jsWNhdLFEF/pIw3r6qiaOagRTwaebtnZLq5M0Jv6Ad75wkg/oum vSZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=RJnUg25d+eLor5UPrJN+kZQntXCyQ0/TA0GnjYU5GcE=; b=ZeinSwlyForA6CK+fVV4mUDEHyO8hQk8BlqrQUhKb5BEWOZbhPa/JPAu/80KzD75jV AHKhUXhbl3LPUpWLF3NB75eULwlEnJVr9S0mP4hvVEufXUjttA2tjVIJhhVZF5WLnLZI o2oKNM8+koJqn4mgSACZ/EeePcydbuVy79yLB7UAn7Ds6hvbIuKlsh2sFFgOlnsPGpTO V/qaiQulpkCP19KQXNL8KzTcPWQj0KSbNUsl0Dr+QsH6VEIpAJF4yW97gEAbWEwoFiXL gZnfNCkhtdva1ARP5sdqe6dSZkj09+JztLkwOrDUYid9jPhTZxK81Rjs7QxTFo24kKPG Sy8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@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 w2-v6si2409311qte.137.2018.10.12.17.24.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:24:32 -0700 (PDT) Received-SPF: pass (google.com: domain of aarcange@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 aarcange@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=aarcange@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8476E4628E; Sat, 13 Oct 2018 00:24:31 +0000 (UTC) Received: from sky.random (ovpn-120-22.rdu2.redhat.com [10.10.120.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CDAA1001F3D; Sat, 13 Oct 2018 00:24:31 +0000 (UTC) From: Andrea Arcangeli To: linux-mm@kvack.org Cc: Aaron Tomlin , Mel Gorman , Jerome Glisse , "Kirill A. Shutemov" , Andrew Morton Subject: [PATCH 3/3] mm: thp: relocate flush_cache_range() in migrate_misplaced_transhuge_page() Date: Fri, 12 Oct 2018 20:24:30 -0400 Message-Id: <20181013002430.698-4-aarcange@redhat.com> In-Reply-To: <20181013002430.698-1-aarcange@redhat.com> References: <20181013002430.698-1-aarcange@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 13 Oct 2018 00:24:31 +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 There should be no cache left by the time we overwrite the old transhuge pmd with the new one. It's already too late to flush through the virtual address because we already copied the page data to the new physical address. So flush the cache before the data copy. Also delete the "end" variable to shutoff a "unused variable" warning on x86 where flush_cache_range() is a noop. Signed-off-by: Andrea Arcangeli Acked-by: Kirill A. Shutemov --- mm/migrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index c9e9b7db8b6d..9bf5fe9a1008 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2019,7 +2019,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, struct page *new_page = NULL; int page_lru = page_is_file_cache(page); unsigned long start = address & HPAGE_PMD_MASK; - unsigned long end = start + HPAGE_PMD_SIZE; /* * Rate-limit the amount of data that is being migrated to a node. @@ -2050,6 +2049,8 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, /* anon mapping, we can simply copy page->mapping to the new page: */ new_page->mapping = page->mapping; new_page->index = page->index; + /* flush the cache before copying using the kernel virtual address */ + flush_cache_range(vma, start, end + HPAGE_PMD_SIZE); migrate_page_copy(new_page, page); WARN_ON(PageLRU(new_page)); @@ -2087,7 +2088,6 @@ int migrate_misplaced_transhuge_page(struct mm_struct *mm, * new page and page_add_new_anon_rmap guarantee the copy is * visible before the pagetable update. */ - flush_cache_range(vma, start, end); page_add_anon_rmap(new_page, vma, start, true); /* * At this point the pmd is numa/protnone (i.e. non present)