Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1591676pxb; Thu, 4 Feb 2021 17:53:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/594mC5OpVcqxPyG1Rs2dVbngTmEKasXzzxe1layYkg6TCfl+VRtEgODWkgY1ikrggq2/ X-Received: by 2002:a17:906:1e87:: with SMTP id e7mr1836133ejj.322.1612490030619; Thu, 04 Feb 2021 17:53:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612490030; cv=none; d=google.com; s=arc-20160816; b=vGvWlCarvsM1ChlFy20k1+o3DhslKDFn3ufJiwwQXrna97Pv58qy0MYLHb2edwifXc /MuEQSmBJYa4/GU08JFESffeodliZ9djOnB+1VIOmlwgVnBz6i8CyfY6iYjN2Hz2LezU KlrPK3lL7XTU/WIgv4vTfq7JQOL41rSfPfA5AcW825oBGUFZS/kHDa4w8LgsU/ddoa3r +nrcjITYi7hs1Nxlh38GWS5zGDfqT1nDZTTARDB/FYZarVzZl3euWNna7TtiHzp8YFjc qABRP4im2kv7BTTyguIeFbZAheyk1n6/14ALHWJVit5gr7cktG9pRZAsj8mp9ZNFjNSl 1Kyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DJBAqOJIb2bK546eUomBLziWNsQdl9+DyYJ9LvCcAEY=; b=IvUiyCUvvpE43VM6RJoofP81ApryQhDPgmAwG66vwvznSp5PeqAOjpJo97iKajnv45 gL9NhDbw+ukP2zFcaSA6N+tbbblsUZl8cQmTmptP+NQyuQjcRTttR37y/jppe29xlI1L IFOfDgp5QOMHNSionSLtI70XGItwK42am0wgeoA9nbdPGwHFZbJD8ljsbeUqsxL8reyY iY5+/UZlIPCRhnk7DPnnjMJ9HXIzpl1IHup3nUSMrpAkNQb9AwLgpJ0fHbTaEkeuml/F hKYZYdq4A4WQypYhJfL0TGlTJUAnFk14NH78ZB2boZqwtlXR+Z+d3rG4ec6gPPbI6bDy UoQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=AdIuNlaA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si4143874edb.606.2021.02.04.17.53.26; Thu, 04 Feb 2021 17:53:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=AdIuNlaA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229766AbhBDXUm (ORCPT + 99 others); Thu, 4 Feb 2021 18:20:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbhBDXUm (ORCPT ); Thu, 4 Feb 2021 18:20:42 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D0DCC0613D6 for ; Thu, 4 Feb 2021 15:20:02 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id a19so5228695qka.2 for ; Thu, 04 Feb 2021 15:20:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DJBAqOJIb2bK546eUomBLziWNsQdl9+DyYJ9LvCcAEY=; b=AdIuNlaAznLEic3h7nb6J5UFmUhLlTmFIx+P7W/VVAZIy6uKnlhP7k2mfFDbwo3Beo P3xT9UnKKOFe653iZY0vneLQtqYiAB4CoiDE8PGB9RoEiIcqgYA9Qn2FziXJRLPxM5G4 pZzyxg+xHsnPJRieFBz/YmgbZEE8D/oKFB1Wdx3gtN2K3tXD15xfbD9qYnmC02LnM8Rc QYFzYI1XtQnGCCMHoYouo0f+Ee3fSPX3CFOnFU51gUBz+cfeBx3NypC0lgXLF12jBqJe 4jXye5GtoDJHsiughq6M+xkqhyTJVygv+h50azgg43fTfOK93pvFktxCgYmT0btZe11T +65w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DJBAqOJIb2bK546eUomBLziWNsQdl9+DyYJ9LvCcAEY=; b=ZuwcjMuuorUTeFrmFEm/qWdSyaKed/77erLAgZ7nesEU8H9+j593rObX9Y1V/DQkMA BM7odOvws71rczXD1C7rEdUWWNGgiM02Ty1NStQjFW5AYEQU/67Im0OIPwrKS9mfjSU5 b7kuXjTlTOwDSlpL/nmOmJQZyu0i/FAJ+8I7r+F6VIV/9pWyGqWJl9Z57WaawcZEqcmc AoNuH+SrfJXEUNDf/28cmwgTxgD3zmF0bK8TetbQgKjexITsVcCek+31OlDxw6PLxNY1 50moQUKiiPlILow1J1dXSLCuSxvbwtbOgDCxOWUks32DODTMEd0QyMbDbI8izQ3hOZhc MfZA== X-Gm-Message-State: AOAM530319JdrsWL411VGzfUA76fbQsqPEdnEcPan1iaBN3sDelBu3SN ZNdqtuNIxGV60Jh3Nh6BqA0Jeg== X-Received: by 2002:a05:620a:898:: with SMTP id b24mr1643689qka.269.1612480801680; Thu, 04 Feb 2021 15:20:01 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id z20sm6266353qki.93.2021.02.04.15.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 15:20:01 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1l7nuq-003e2a-NM; Thu, 04 Feb 2021 19:20:00 -0400 Date: Thu, 4 Feb 2021 19:20:00 -0400 From: Jason Gunthorpe To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kirill Shutemov , Wei Zhang , Mike Rapoport , Matthew Wilcox , Miaohe Lin , Andrea Arcangeli , Gal Pressman , Jan Kara , Jann Horn , Andrew Morton , Kirill Tkhai , Linus Torvalds , Mike Kravetz , David Gibson , Christoph Hellwig Subject: Re: [PATCH v2 3/4] mm: Introduce page_needs_cow_for_dma() for deciding whether cow Message-ID: <20210204232000.GG4718@ziepe.ca> References: <20210204145033.136755-1-peterx@redhat.com> <20210204145033.136755-4-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210204145033.136755-4-peterx@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 04, 2021 at 09:50:32AM -0500, Peter Xu wrote: > We've got quite a few places (pte, pmd, pud) that explicitly checked against > whether we should break the cow right now during fork(). It's easier to > provide a helper, especially before we work the same thing on hugetlbfs. > > Since we'll reference is_cow_mapping() in mm.h, move it there too. Actually it > suites mm.h more since internal.h is mm/ only, but mm.h is exported to the > whole kernel. With that we should expect another patch to use is_cow_mapping() > whenever we can across the kernel since we do use it quite a lot but it's > always done with raw code against VM_* flags. > > Signed-off-by: Peter Xu > include/linux/mm.h | 21 +++++++++++++++++++++ > mm/huge_memory.c | 8 ++------ > mm/internal.h | 5 ----- > mm/memory.c | 7 +------ > 4 files changed, 24 insertions(+), 17 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index ecdf8a8cd6ae..6ea20721d349 100644 > +++ b/include/linux/mm.h > @@ -1291,6 +1291,27 @@ static inline bool page_maybe_dma_pinned(struct page *page) > GUP_PIN_COUNTING_BIAS; > } > > +static inline bool is_cow_mapping(vm_flags_t flags) > +{ It feels a bit more logical to pass in a struct vm_area_struct *' here? Jason