Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp6020845rwe; Tue, 18 Apr 2023 15:33:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bIRKIUKF1ENzsXSN2UnaJT3XNeUPrCVs7b+Mc8ZyN1Au4ESgdpMivGx4xBxrYxU6K3kgie X-Received: by 2002:a05:6a20:9f98:b0:e5:58e6:be37 with SMTP id mm24-20020a056a209f9800b000e558e6be37mr820337pzb.61.1681857190218; Tue, 18 Apr 2023 15:33:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681857190; cv=none; d=google.com; s=arc-20160816; b=uS1MKoCKPEH2D3YKMU9hRIaDt202hhm8UzxqPZ3fj5kOt6RYilWbtA8GAaVcJ4UFup 6+B6n/kAW5MkPaBZ0L6h1DgL6/vQRsMgNNwgRJoLKbVYsfpfmSWaYT/gkGC27AIfvN99 AFIdbQnNbksyJihZ2nnOshurz11uNu3mgJGuCYmPUB07D4MRKyWO1WcrTD30HN59sYjF s6o8l8PW+ncYAwCL4lxoOi52yZn4MVSMoFvlKsz3cL4geZO/8Je7Mx1kF3tRWHWGNRuS kFdRvgzkR/T1sOaajwoNYasJJa6VzD0w4uQGoXTWe7HcB3C8C3yMxmbEsfWKme9VvBbj pNxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=DlT9rcJDo4TXGeTD4p8dkZMtxuGVxrlx46N9rOSauCU=; b=XNqRHgMax2fbOMNCegbdK6N5dgBwK4c9fmeg0by9e2jkNN57taJ8jdXesQzqVX9mWF Tc/PBwpjYwCcNzu7DRXRgZGO9kJUclkxMfWT/r9OKu64JJvUDUPpvchVUwbiF2Z6en48 RC71NRbHd7Se6fGXKlujeg6VZ/XfmqwMQ1IzcAhme4X/0UJPd9jxOwfT48P8vkdK11iY irQ+TtxeKYAtl2Qa7jkUqhV5WFxuuW9NGbuqJv5WH7tYxpmRy9RecXvf/ziF6lavLYqJ Fqf02J+yYpBnbSjaW8zb7v+nON5MBj35EFzAxJS4Qt/iJmnIRrTaZeuQ1kufSN24yfAl qoog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=o4yUqM6o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c1-20020a654201000000b0050ac7d1b32asi14739491pgq.603.2023.04.18.15.32.23; Tue, 18 Apr 2023 15:33:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=o4yUqM6o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232693AbjDRWVN (ORCPT + 99 others); Tue, 18 Apr 2023 18:21:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232455AbjDRWVM (ORCPT ); Tue, 18 Apr 2023 18:21:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 565298A58 for ; Tue, 18 Apr 2023 15:21:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E819463416 for ; Tue, 18 Apr 2023 22:21:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0967EC433D2; Tue, 18 Apr 2023 22:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1681856470; bh=PTrG+mr+PdluSGweJxje7TrtnEwJCDyxTOe2OFhcWXc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=o4yUqM6oVUNoacmu1wWtJ75bIma2UAQusUEEfSQDbnr8ycc7zG7TyurxZtbnKeUDL TBk0m9j3yOEq3SCIomqxKpY32xsyvhbqkrPwe5VQlKv+E3aJwxLOpEBLAV6uR+bF11 YU8vax5sSMXE2DBHdiUybWcvepUPAxhbNcBwPx+Q= Date: Tue, 18 Apr 2023 15:21:09 -0700 From: Andrew Morton To: Matthew Wilcox Cc: Vishal Moola , Peng Zhang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, mike.kravetz@oracle.com, sidhartha.kumar@oracle.com, muchun.song@linux.dev, wangkefeng.wang@huawei.com, sunnanyong@huawei.com Subject: Re: [PATCH v5 3/6] userfaultfd: convert copy_huge_page_from_user() to copy_folio_from_user() Message-Id: <20230418152109.32a90ebecc905ae60e2d072f@linux-foundation.org> In-Reply-To: References: <20230331093937.945725-1-zhangpeng362@huawei.com> <20230331093937.945725-4-zhangpeng362@huawei.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 11 Apr 2023 04:40:17 +0100 Matthew Wilcox wrote: > On Thu, Apr 06, 2023 at 07:28:44PM -0700, Vishal Moola wrote: > > > - flush_dcache_page(subpage); > > > - > > > cond_resched(); > > > } > > > + flush_dcache_folio(dst_folio); > > > return ret_val; > > > } > > > > Moving the flush_dcache_page() outside the loop to be > > flush_dcache_folio() changes the behavior of the function. > > > > Initially, if it fails to copy the entire page, the function breaks out > > of the loop and returns the number of unwritten bytes without > > flushing the page from the cache. Now if it fails, it will still flush > > out the page it failed on, as well as any later pages it may not > > have gotten to yet. > > I'm not sure this is worth worrying about. Failing to copy the entire > folio is unlikely, and if we do, flushing the entire folio instead of just > a few pages in it is harmless. Plus I have patches which significantly > optiise flush_dcache_folio() over flush_dcache_page() (for the majority > of architectures) and so I think this change is actually beneficial in > the long term. Thanks, I'll send the series in for the next merge window as-is. If others remain unhappy with the flushing issue, please propose something during the next -rc cycle.