Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2210929pxk; Mon, 14 Sep 2020 07:30:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSB89VL/TTu+joecvlrBWNrDsfUITqDO/vnAHo2w4FohGdoYQv2wUuSoONlp+PVc4i8Ptf X-Received: by 2002:a17:906:2b06:: with SMTP id a6mr14937260ejg.209.1600093804140; Mon, 14 Sep 2020 07:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600093804; cv=none; d=google.com; s=arc-20160816; b=JRvzntA4V43XtBHjgbTtuwWppCDdAU49x7QYb/ZOrtiN2z6ny+c9bDVoHU+3eDOdwB nLNxu7dRemgfawGDpHFtkriL5NSdKQiWbsou2hm1B7RMOYl3/dgpffLHfqC8enBpIxjj +KVU7JGRFKqapt8F9LonsByf5Bc/H0fGNnizukeBsPEGikEdEgeRpzLta1lFRkxiX1ZO XSDfq+ExylrJqRdi2FW3KReUEyoWG8DKn0/MaAC37bK7rum8YaLkem9hHctEitkjLXdg 7/tSyhDykAcJET5cKVkgqK63F2tWX0t0BNK17UQir7Nc5j8TI8FBCqU5MEk2eELGTpgx +NYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vbjdsDyKQAMF1IWmc/SZZDWufYvYJBspJjcAsQFTx5Q=; b=Dhr2UlWDay5K+2TzeiAhOiLqo3ukXysHqied0jTQj7Nq2aWD9p08AiLLuCLqzRJFnq D9DodbbXhtme061etWYZJXh2OFpTtluGzkZVG+riScdoC/hrGmzEYJkWkfU/rpnitfH8 OqiPDK9uwIiqQhqSFPh8OXh4rMKxJRNBWJoU9aMxGje5wIUTpuEeXHIw+6VqpJabGrVF TUuzFQ4OV4y+HCmyGX/pkRF+tlHFmgXC1asqHX7lhRBRhqfzn6GdDcXNTfVmiEYX49bg HTb4h6Bq9S7HMWGySLZu0Yt85j6aRpr0bGF/k04NWDL+F/7nqPYt7xc4VDgPpHV7pv0w uYEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BtXCbegd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bu26si7203655edb.135.2020.09.14.07.29.41; Mon, 14 Sep 2020 07:30:04 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=BtXCbegd; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbgINO26 (ORCPT + 99 others); Mon, 14 Sep 2020 10:28:58 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:27821 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726691AbgINO1g (ORCPT ); Mon, 14 Sep 2020 10:27:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600093656; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vbjdsDyKQAMF1IWmc/SZZDWufYvYJBspJjcAsQFTx5Q=; b=BtXCbegd6IwT5htQft0w8ybQ7+3W0EPlcuzWUk12kVUGH91Tzq2sf9gb7tQJ7mM/HoLzL6 nOpJji58SIqlpGVDrFa9QllobeSz4KtLCjIsxnZOAqtw0zZhUjPrppErTdooJ3DFmWot7a jBbMd5om6fI9ZojzoSXtfcX2rRvr8H0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-5t0SsAqaPrOI2e9_LMXynA-1; Mon, 14 Sep 2020 10:27:34 -0400 X-MC-Unique: 5t0SsAqaPrOI2e9_LMXynA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F180518B9F40; Mon, 14 Sep 2020 14:27:31 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.40.192.129]) by smtp.corp.redhat.com (Postfix) with SMTP id 267A860C0F; Mon, 14 Sep 2020 14:27:24 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 14 Sep 2020 16:27:31 +0200 (CEST) Date: Mon, 14 Sep 2020 16:27:24 +0200 From: Oleg Nesterov To: Peter Xu Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Maya B . Gokhale" , Linus Torvalds , Yang Shi , Marty Mcfadden , Kirill Shutemov , Jann Horn , Jan Kara , Kirill Tkhai , Andrea Arcangeli , Christoph Hellwig , Andrew Morton Subject: Re: [PATCH 3/4] mm/gup: Remove enfornced COW mechanism Message-ID: <20200914142722.GA21906@redhat.com> References: <20200821234958.7896-1-peterx@redhat.com> <20200821234958.7896-4-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200821234958.7896-4-peterx@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/21, Peter Xu wrote: > > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -381,22 +381,13 @@ static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address, > } > > /* > - * FOLL_FORCE or a forced COW break can write even to unwritable pte's, > - * but only after we've gone through a COW cycle and they are dirty. > + * FOLL_FORCE can write to even unwritable pte's, but only > + * after we've gone through a COW cycle and they are dirty. > */ > static inline bool can_follow_write_pte(pte_t pte, unsigned int flags) > { > - return pte_write(pte) || ((flags & FOLL_COW) && pte_dirty(pte)); > -} > - > -/* > - * A (separate) COW fault might break the page the other way and > - * get_user_pages() would return the page from what is now the wrong > - * VM. So we need to force a COW break at GUP time even for reads. > - */ > -static inline bool should_force_cow_break(struct vm_area_struct *vma, unsigned int flags) > -{ > - return is_cow_mapping(vma->vm_flags) && (flags & (FOLL_GET | FOLL_PIN)); > + return pte_write(pte) || > + ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte)); Do we really need to add the FOLL_FORCE check back? Afaics, FOLL_COW is only possible if FOLL_FORCE was set. Oleg.