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 X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19645C433E0 for ; Thu, 4 Feb 2021 17:55:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 61B7764E0F for ; Thu, 4 Feb 2021 17:55:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61B7764E0F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A39A96B0005; Thu, 4 Feb 2021 12:55:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EA4F6B0006; Thu, 4 Feb 2021 12:55:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9030B6B006E; Thu, 4 Feb 2021 12:55:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0076.hostedemail.com [216.40.44.76]) by kanga.kvack.org (Postfix) with ESMTP id 7865A6B0005 for ; Thu, 4 Feb 2021 12:55:38 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BAAA63631 for ; Thu, 4 Feb 2021 17:55:37 +0000 (UTC) X-FDA: 77781337914.19.can88_080bebc275de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 5C9A61AD1B0 for ; Thu, 4 Feb 2021 17:55:37 +0000 (UTC) X-HE-Tag: can88_080bebc275de X-Filterd-Recvd-Size: 4825 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 17:55:36 +0000 (UTC) Received: by mail-lf1-f45.google.com with SMTP id b2so5913302lfq.0 for ; Thu, 04 Feb 2021 09:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=voNiwPhzeLAZNHX2oRQL59Hxy42wWXI9DL6jmHv2mf0=; b=NUI9thqKSFpWLW3nPn6698yvI2J++NtLklBNQ+xHDuLU0hK9vHDTLtOsI88z5efBKG 8uCbzqHIDFL7NCjPcpmxpKuVrzdrJkALf3jaBFQky7nr8k1jo5+j5RhC3jzu3Fehs4lq k6G5sz9oPMVP3kBQajQ0ZaZP5M53dDdKmwQsU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=voNiwPhzeLAZNHX2oRQL59Hxy42wWXI9DL6jmHv2mf0=; b=cVznc7WJ8kM4Ra92NR884jE7fp7tkoz+W6FwEK0le7xnO6L7s+Sl/S05vMNgpl3vhz jaLhu+4QJOUyoUX8QXHOXrz3tRr0qqllWY5mPvJjDfqQEd5BP9P2HTgTu0LDeIVj8Gxz AjwmgIRCFqK4MBuft2VxqmZ+vhwSRau7xERWlElwtf32czMB1n7CVc2beu4chP5LWOES hRylSWwyeyw1iNZDykvCkIHWSNrtKC53Uz0SUPJkWCUc/sQaoR6uPN1nXTPL/zYWQF6t 1iBdiHk1xqVUGdjFiEwCVocCtlGdObPTjlENk1uZrYKrbLiFbSLkLM1vrdQVfZaWdq2A ROjQ== X-Gm-Message-State: AOAM533tbB6/QbnRiMqj+xvupmC+H2RmsIF6ZMIOYSVT6wbYmAbjowGZ WCVEVab/TLthkL4CRp5XUVT8nWiKgcqYsw== X-Google-Smtp-Source: ABdhPJxHKKxTMnm0p/Pa2Bm7h3soUl8PU1jMDz23GgITNRH0mwK03MzdfAvPXo8jVzXB/x9e0XGEDQ== X-Received: by 2002:a19:2383:: with SMTP id j125mr271912lfj.217.1612461334753; Thu, 04 Feb 2021 09:55:34 -0800 (PST) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id 8sm693313lfq.103.2021.02.04.09.55.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 04 Feb 2021 09:55:33 -0800 (PST) Received: by mail-lf1-f42.google.com with SMTP id h7so5861908lfc.6 for ; Thu, 04 Feb 2021 09:55:33 -0800 (PST) X-Received: by 2002:a19:8186:: with SMTP id c128mr273214lfd.377.1612461332734; Thu, 04 Feb 2021 09:55:32 -0800 (PST) MIME-Version: 1.0 References: <20210204145033.136755-1-peterx@redhat.com> <20210204145033.136755-4-peterx@redhat.com> In-Reply-To: <20210204145033.136755-4-peterx@redhat.com> From: Linus Torvalds Date: Thu, 4 Feb 2021 09:54:37 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 3/4] mm: Introduce page_needs_cow_for_dma() for deciding whether cow To: Peter Xu Cc: Linux-MM , Linux Kernel Mailing List , Kirill Shutemov , Wei Zhang , Mike Rapoport , Matthew Wilcox , Miaohe Lin , Andrea Arcangeli , Gal Pressman , Jan Kara , Jann Horn , Andrew Morton , Kirill Tkhai , Mike Kravetz , Jason Gunthorpe , David Gibson , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" 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 Thu, Feb 4, 2021 at 6:50 AM Peter Xu wrote: > > --- a/include/linux/mm.h > +++ 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) > +{ > + return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE; > +} Oh, and I just realized: moving this to means that this patch could/should also get rid of - manual copy of this in mm/hugetlb.c: cow = (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE; - private #define for the same thing in fs/proc/task_mmu.c #define is_cow_mapping(flags) (((flags) & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE) - manual copy in drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c: bool is_cow_mapping = (vma->vm_flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE; I guess it could be a later cleanup patch too, but maybe best done in this series just to not forget about it. Linus