From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63CD9C433F5 for ; Wed, 2 Feb 2022 13:59:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D55158D00FE; Wed, 2 Feb 2022 08:59:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D01F28D00FA; Wed, 2 Feb 2022 08:59:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF1D38D00FE; Wed, 2 Feb 2022 08:59:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id B27148D00FA for ; Wed, 2 Feb 2022 08:59:06 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 7555B181AF5D8 for ; Wed, 2 Feb 2022 13:59:06 +0000 (UTC) X-FDA: 79097996292.16.E8EDD8E Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf31.hostedemail.com (Postfix) with ESMTP id 5691020005 for ; Wed, 2 Feb 2022 13:59:05 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id g14so61225918ybs.8 for ; Wed, 02 Feb 2022 05:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aWG9s1d/GvbwnTAYal6lRjtSrir89rmlhhFZo56v7xg=; b=0nQIn2NAlIoliEmY6SS6YwYBuiIbHPE+5Apygk3dbZfBoCgVICwMSvt9lX90OuMT9S 6QrtNpPBhvW6Vl0yZw4cHWfyaz0WaHJ0LeTL7B873nyREhUI4pi82laXzphU34F6cujz xsjRgnBHHZYb/CGMqVOwxpRNZ8ChRWryGOXrvZS1FL16+NILZ8x4A6KHaxhsNfCSY+vo culkY6dG8arMD37GC2AGT+NwvcYKA0k3s0d0sdtssSfO/mAHI8XUwbcC/8gkK7+jpM/w 7L1mwjf24KLb13ToS5UztFDh4tGi/fZp1Z+0SamF0syShLYGKe2rIDc9whjazf5VTzNH qcEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aWG9s1d/GvbwnTAYal6lRjtSrir89rmlhhFZo56v7xg=; b=ufGgFIAF0+JKZRimSTDqo1UdF1iXKHgDdsxegsoJZE8RokQYgTUYhQuaS75/VAZx9I XwmLAIRr7Ej04h3VVZXz2MHILeBcbRCLumxlbohmDjfQzFXPRVaD/tISGkxJkY/vx1vq bEeJFlaC9n3Z9cTHoCR35bOgMaR/7P8RKzl3XkZdfNwigqaUJXnJmVPdGV3ueON6a2s1 VwYPbJXq1yPlPrp0U/rry59i2/hiyQvDYmIAvJdW4U5xBNn05CKlMpEbxDvSpVeb5du/ UiygsMiDKg+V5h6/RUF+K0z8fUvkWgNdvSObumlYNFz6PD7PNUAjYso6gbrJ6T2RK0YK 7xJw== X-Gm-Message-State: AOAM53043YcJxoC/OZP8yc2CVP6MD3Xork9uI1RCFh/UCqrDHuwMzKC4 j8VHTe5jxPh1O+9qM8z8QljChXJSXgRHmRstt69xXk1zn+f2uA== X-Google-Smtp-Source: ABdhPJxnAIVW3l9/Qp/Grw4bohejfPa8v/qFOIktxw0zhGzSL9UlCZsT5sNDz0zULIC2JOT6+Dx4DqAbc2IbbSrXlDI= X-Received: by 2002:a25:6b4e:: with SMTP id o14mr30320536ybm.485.1643810344332; Wed, 02 Feb 2022 05:59:04 -0800 (PST) MIME-Version: 1.0 References: <20220131160254.43211-1-songmuchun@bytedance.com> <20220131160254.43211-5-songmuchun@bytedance.com> <14df55c2-cab5-8ff0-5986-fd186c2f60d7@oracle.com> In-Reply-To: <14df55c2-cab5-8ff0-5986-fd186c2f60d7@oracle.com> From: Muchun Song Date: Wed, 2 Feb 2022 21:58:26 +0800 Message-ID: Subject: Re: [PATCH v3 4/5] mm: hugetlb: fix missing cache flush in hugetlb_mcopy_atomic_pte() To: Mike Kravetz Cc: Andrew Morton , zi.yan@cs.rutgers.edu, "Kirill A. Shutemov" , David Rientjes , Lars Persson , Linux Memory Management List , LKML , Xiongchun duan , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5691020005 X-Stat-Signature: 83r5b9eqnj5togihcr5teq4h18wrnc4g Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=0nQIn2NA; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf31.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: nil X-HE-Tag: 1643810345-110988 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: On Wed, Feb 2, 2022 at 6:24 AM Mike Kravetz wrote: > > Cc: Matthew > > On 1/31/22 08:02, Muchun Song wrote: > > folio_copy() will copy the data from one page to the target page, then > > the target page will be mapped to the user space address, which might > > have an alias issue with the kernel address used to copy the data from > > the page to. Fix this issue by flushing dcache but not use > > flush_dcache_folio() since it is not backportable. > > > > Fixes: 8cc5fcbb5be8 ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY") > > Signed-off-by: Muchun Song > > --- > > mm/hugetlb.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index a1baa198519a..f1f1ab31dc8a 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -5804,6 +5804,8 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, > > goto out; > > } > > } else { > > + int i, nr; > > + > > if (vm_shared && > > hugetlbfs_pagecache_present(h, dst_vma, dst_addr)) { > > put_page(*pagep); > > @@ -5819,6 +5821,9 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, > > goto out; > > } > > folio_copy(page_folio(page), page_folio(*pagep)); > > What if we changed that folio_copy() to? > > copy_user_huge_page(page, *pagep, dst_addr, dst_vma, > pages_per_huge_page(h)); > > Seems like that would take care of the flush_dcache_page and it would be > backportable. Agree. I also can replace folio_copy() with copy_user_huge_page(). > > Of course, Matthew may hate the idea. Not sure if there are any plans to > convert copy_user_huge_page to use folio type as it has some special hinting > logic.