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 BF455C433EF for ; Fri, 17 Dec 2021 21:17:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B2A16B007B; Fri, 17 Dec 2021 16:17:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 45F326B007D; Fri, 17 Dec 2021 16:17:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 300B26B007E; Fri, 17 Dec 2021 16:17:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id 229BD6B007B for ; Fri, 17 Dec 2021 16:17:33 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DA886180E1E4C for ; Fri, 17 Dec 2021 21:17:22 +0000 (UTC) X-FDA: 78928547124.30.91647FA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf31.hostedemail.com (Postfix) with ESMTP id 28CD020031 for ; Fri, 17 Dec 2021 21:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639775841; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q8mMbbXNNFkQCye2i+vJ7bGpp5qprCcUMSqt2cqb7yI=; b=e3x5lhiB6Y1eulJ02+yUJN/LL1dvU8a1riRwvu7yV0KbUVOMsqXNAEvdSo/KB/xVzNZF8v 7kz0ehkTtakoMEn7Ghm9raUK+v/plKAWfN26pA5c4yhTTNUkk0xKCBa1diRhnEe6LOwZ+Z cfGdcgIJ/ahalWXe9Gxrv+nm15i1kOw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-492-3n74jLetMgWAQJrJaKPjWg-1; Fri, 17 Dec 2021 16:17:18 -0500 X-MC-Unique: 3n74jLetMgWAQJrJaKPjWg-1 Received: by mail-wm1-f70.google.com with SMTP id 138-20020a1c0090000000b00338bb803204so1258204wma.1 for ; Fri, 17 Dec 2021 13:17:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=Q8mMbbXNNFkQCye2i+vJ7bGpp5qprCcUMSqt2cqb7yI=; b=A+hyoBpLlBJRJ9yfLVJQod9op/98LsJC1a21XCgty+ct3IHqdh5wuWsW2pauzE9sns qQt/U0jz3mhXWNrwGR6vBtSEihtee3yYIrZYi+NFN3qVXKvaeqMls3ft5BFAh3ifNwUa A5QQ4GrlCrTD+r9s5wafkRFO0clbjqQS/4dkubCpYuPZrOqhl02gqlZFHltXlkAIPfa6 YwMU7bnVbkrtSM2VoWCX6ZX+S6RC2wfcFofwN6Y/uXGSUb+DLl9fdxtDzJ+PYyWu8ihs 69Sd2zSol4UklNOmVtlP5E8fVZuzUv7z2iq2Hx7S1w6h0X/LeF3C/nwCuBDajmV13L2g iFXA== X-Gm-Message-State: AOAM532fC0+p2RQKUCJrJLA6+b7podKHQb6ZuC8UcLlNogeGhdFRz8r2 E502SEET9RciTdAlz1w0FvlZfgdinKienUFfqMWpoABhu/w6MdaCN1C1VHlCdqxxI0RXYJ8ObSk CJJd3a6WWpeo= X-Received: by 2002:adf:ce84:: with SMTP id r4mr4060406wrn.131.1639775837479; Fri, 17 Dec 2021 13:17:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyHFjtfUP+UrzLUR48hxKqEKlGEluE4bUcCBZtUym2XEAAEZjLDhDIAoq52AL8Giwi/+zzjw== X-Received: by 2002:adf:ce84:: with SMTP id r4mr4060376wrn.131.1639775837280; Fri, 17 Dec 2021 13:17:17 -0800 (PST) Received: from [192.168.3.132] (p4ff234b8.dip0.t-ipconnect.de. [79.242.52.184]) by smtp.gmail.com with ESMTPSA id m3sm1977816wms.25.2021.12.17.13.17.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Dec 2021 13:17:16 -0800 (PST) Message-ID: <4bc68a26-5924-4766-2e6a-b18a523a2621@redhat.com> Date: Fri, 17 Dec 2021 22:17:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: Linus Torvalds , Jason Gunthorpe Cc: Linux Kernel Mailing List , Andrew Morton , Hugh Dickins , David Rientjes , Shakeel Butt , John Hubbard , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Vlastimil Babka , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" References: <20211217113049.23850-1-david@redhat.com> <20211217113049.23850-7-david@redhat.com> <54c492d7-ddcd-dcd0-7209-efb2847adf7c@redhat.com> <20211217204705.GF6385@nvidia.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb) In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 28CD020031 X-Stat-Signature: pwx89zc5yyqb4eq1fftdd7z5kqmh6rgr Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e3x5lhiB; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf31.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam11 X-HE-Tag: 1639775833-84410 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 17.12.21 21:56, Linus Torvalds wrote: > On Fri, Dec 17, 2021 at 12:47 PM Jason Gunthorpe wrote: >> >> To remind all, the GUP users, like RDMA, VFIO use >> FOLL_FORCE|FOLL_WRITE to get a 'r/o pin' specifically because of the >> COW breaking the coherence. In these case 'r/o pin' does not mean >> "snapshot the data", but its only a promise not to write to the pages >> and still desires coherence with the memory map. >> >> Eg in RDMA we know of apps asking for a R/O pin of something in .bss >> then filling that something with data finally doing the actual >> DMA. Breaking COW after pin breaks those apps. > > I agree. > I agree that breaking COW after a pin should never be done. Therefore, break the COW before the pin -> unsharing as implemented here. > And my argument is that those kinds of things that ask for a R/O pin > are broken, and should just make sure to use the shared pins. And trigger a write fault although they are just reading. To me this is just a band aid instead of eventually ... ... > What's the downside of just doing this properly? Doing it properly by fixing GUP and not the COW logic. GUP and COW are just incompatible and we should unshare early. Honestly, the memory corruptions we can trigger in user space due to the current COW logic *especially* with FOLL_WRITE users such O_DIRECT, io_uring or vfio are not a joke anymore. (again, link in the cover letter) -- Thanks, David / dhildenb