From patchwork Mon Oct 15 20:23:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Arcangeli X-Patchwork-Id: 10642435 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 31A6D15E2 for ; Mon, 15 Oct 2018 20:23:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20AE728909 for ; Mon, 15 Oct 2018 20:23:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 109B2289CB; Mon, 15 Oct 2018 20:23:18 +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 CFD2728909 for ; Mon, 15 Oct 2018 20:23:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2C1B6B0003; Mon, 15 Oct 2018 16:23:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DB3E66B0005; Mon, 15 Oct 2018 16:23:14 -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 C55EE6B0006; Mon, 15 Oct 2018 16:23:14 -0400 (EDT) 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 970F16B0003 for ; Mon, 15 Oct 2018 16:23:14 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id n1-v6so21777163qtb.17 for ; Mon, 15 Oct 2018 13:23:14 -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=w3SfSMu341dMz27AGEWE8i4/xhoNbX4Nmsmcy+Fdf7w=; b=qSsihXbJ0ttsUYYPIBF8zz2RNjwfNV3oIX4wV+YDRcXwmE2nn49nvAtLGb54C2ArjZ 4jODA4Qwaoe1pLCDpGfz7xBWowsy6ohN5AUa1kD8KPwGq47jqZX7kyze/8KVME1kMuEw fcsfaIaiEzK0XX/2Nh37rdFKGIeXutKNYKNjzm4jm1WRxEKCHHabQzXHtbxql64slfvr 6t4iJGJpu9qzCEHO66F3D3twbBpAeNqbIFjONTh7JAi0jBYdGY/ypPZptpYCffPgBOn0 lKxmf3sK85S9aG1IxMjuqVDSlJCSpOhUN6GWoO55geAaLxtv5XTvGvNYmX8AdWXcAyRg nxHg== 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: ABuFfohOzWAJOZibCh7M19f/zXAyXb1jPlmkASF9sSokPiFsmCxqjg7z rDgqQsAjTQ8X8SSixfHXBuqbwFRqtLHk2a19KJme7gsYcxOpsyoq3VNO/8EjolqpcvURe3Qj3QK XLUq6TdmdDIBpHs5A1Tr6y8tPHr87Ac5NGEiG7RBSYshKvJ6wvNvcFFE8LOUclard8w== X-Received: by 2002:ac8:21b6:: with SMTP id 51-v6mr18089113qty.122.1539634994295; Mon, 15 Oct 2018 13:23:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Y9tRhQgEVB8paiSTlfyKWv5f/OVl3y0DRtDTn5zAZ0358lqeYKRVVX/eVB9FcpgrscpgB X-Received: by 2002:ac8:21b6:: with SMTP id 51-v6mr18089077qty.122.1539634993600; Mon, 15 Oct 2018 13:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539634993; cv=none; d=google.com; s=arc-20160816; b=OPgdrkpuiybKqYe72ya4iIFFvzXFXuWriObqBonnGV56iBLLv+6cRn8NiY9PZWwqjZ wNC9QMdIMFnqs0Ln9pwoD+3I4+6fPgkTek4I2eX/fLopyEKqGifJOaJY7Gws/gTvy74c a78U+87eXp9Ez8tOJVRqc668OGXdRQ09145Y+l0l+SA8O/6U/qYordXEjbt8LOVdtojx N4blw4kembYXLep5TvedC5MGuKg4DEa3LKlrAAGSKK0wUudMP2lUaUKPOlMyhhEOy0E4 IlflCs+0pR5cnlnt0GYVAydXzaMODL6nDQS16kxSeXsFuzpUkZ0GzKhXSu4cA7LvHV8K hD5g== 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=w3SfSMu341dMz27AGEWE8i4/xhoNbX4Nmsmcy+Fdf7w=; b=yVJaaHRMVYl7q5pDDUuNke5LoqryJQtV/adUYamMbMFU2uvE0dN46KRZkSeFlyhHSC O+sxT4pZ9cL8h4e1xtd4pfALkODyrzIbsDlsh9FYdsmgJNTTeDuxUtFUNiHky7aCCUEN HwTdfIOGmHd9G3MhNpBNPY516bFSUmKC4AGMCDahIK5dJayJ6+bvJp9A+4uBRoVeRChC FaeLvk6f/Fq3bOSr2vB0WZmFjS2kKrFzkKGxJY8z56soMBPBrlIVy0L8w5DB9nku/y4G 2XhXfGxYshqbbA0RR9CT3RvEDQpW5zE1x0bPPD2sf8PFk97cRhYncwh2CNgX/xDDqmH+ Lj+Q== 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 p93si2467971qva.126.2018.10.15.13.23.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 13:23:13 -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-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 80D9783F46; Mon, 15 Oct 2018 20:23:12 +0000 (UTC) Received: from sky.random (ovpn-120-12.rdu2.redhat.com [10.10.120.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30E2A768A1; Mon, 15 Oct 2018 20:23:12 +0000 (UTC) From: Andrea Arcangeli To: linux-mm@kvack.org Cc: Aaron Tomlin , Mel Gorman , Jerome Glisse , "Kirill A. Shutemov" , Andrew Morton Subject: [PATCH 1/1] mm: thp: relocate flush_cache_range() in migrate_misplaced_transhuge_page() Date: Mon, 15 Oct 2018 16:23:11 -0400 Message-Id: <20181015202311.7209-1-aarcange@redhat.com> In-Reply-To: <20181013002430.698-4-aarcange@redhat.com> References: <20181013002430.698-4-aarcange@redhat.com> 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.27]); Mon, 15 Oct 2018 20:23:12 +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 --- mm/migrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index c9e9b7db8b6d..8afb41167641 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, start + 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)