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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EF3FC433EF for ; Tue, 21 Dec 2021 18:51:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234501AbhLUSvM (ORCPT ); Tue, 21 Dec 2021 13:51:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29506 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241557AbhLUSvL (ORCPT ); Tue, 21 Dec 2021 13:51:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640112671; 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=KdDB4kop2D9Kd7A6GvY14mN9CfVM1HxKMPkAPbonSUY=; b=AOKVuL8+R802LOZcGy2j9fF3Ad1zvk29OQlr338p0+fypnCJ0Y3z/WGsPt2DdMxF4W+eqk Uinz5e+KiCaylG94wj8UYM98wDO1FJgK5zSVLU3SlTfZzicnV4MhgWjWXRHNj4dqrumXJl TI4VogGhGYV//UuP8H6TB/18jBVO9H0= 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-39-DYnjk0U9NcyjuaieclQKOg-1; Tue, 21 Dec 2021 13:51:10 -0500 X-MC-Unique: DYnjk0U9NcyjuaieclQKOg-1 Received: by mail-wm1-f70.google.com with SMTP id e19-20020a05600c4e5300b003458be97976so36634wmq.7 for ; Tue, 21 Dec 2021 10:51:09 -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:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=KdDB4kop2D9Kd7A6GvY14mN9CfVM1HxKMPkAPbonSUY=; b=DU6DqnzBGBd91mmw+ddGTdNOjvdUlN3jGqUqQQYWfS2sGpINeQyy1wctx2K1GTsabF sGImqDZcyCd5NuR1Fe2aioJqTQr/sS4HSrJpwETUZT+6rYPw/PHtE9Z7jZtmAW5HhsZW JdOIE5a/WgAUVAZAx55Jkf0WXrBLwXKAUhwcoKPdMIyDEGqWJbJE0N/NyFkFsJwZSkRy tEQW2cdEuLY6GlCxj0Mln5aTLEe8vESYOPkNgHIX0tvvg6k3Wt41xBxHozKSOjqfcUqO MATwWfd3ShXaANUbBgBVNXQS2OIZrtRCSOYBYRQ/YjMBs/DRDa58Rjp7DqGXMKW3R5Zg ts3Q== X-Gm-Message-State: AOAM530csaW+2G97p2ZBW/vQMuAN23ibWHpshsnlFiGxnP/BDuvkDhRf sEX9dFVv1BoWvfltBk3kwWigLv/N/zzxEoxLcuaIpz6I15wknMaYJjqk/1ysB3bKAGvNfSQTwfm LioA36xKT+9Os/FeAczRx X-Received: by 2002:a05:600c:2295:: with SMTP id 21mr3933031wmf.187.1640112668997; Tue, 21 Dec 2021 10:51:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwM+bksT9Y2Ns9VVTHnMXz/Z2lA+uiCyhoZvC+eiFeXXwvpSu/vBZOkk4sa5iKh/WRsBXorbg== X-Received: by 2002:a05:600c:2295:: with SMTP id 21mr3932994wmf.187.1640112668811; Tue, 21 Dec 2021 10:51:08 -0800 (PST) Received: from [192.168.3.132] (p5b0c64a4.dip0.t-ipconnect.de. [91.12.100.164]) by smtp.gmail.com with ESMTPSA id v6sm3197557wmh.8.2021.12.21.10.51.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Dec 2021 10:51:08 -0800 (PST) Message-ID: Date: Tue, 21 Dec 2021 19:51:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH v1 06/11] mm: support GUP-triggered unsharing via FAULT_FLAG_UNSHARE (!hugetlb) Content-Language: en-US To: Linus Torvalds , Jan Kara Cc: Jason Gunthorpe , Nadav Amit , 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 , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Linux-MM , "open list:KERNEL SELFTEST FRAMEWORK" , "open list:DOCUMENTATION" References: <4D97206A-3B32-4818-9980-8F24BC57E289@vmware.com> <5A7D771C-FF95-465E-95F6-CD249FE28381@vmware.com> <20211221010312.GC1432915@nvidia.com> <900b7d4a-a5dc-5c7b-a374-c4a8cc149232@redhat.com> <20211221180705.GA32603@quack2.suse.cz> From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On 21.12.21 19:30, Linus Torvalds wrote: > On Tue, Dec 21, 2021 at 10:07 AM Jan Kara wrote: >> >> For record we always intended (and still intend) to make O_DIRECT use >> FOLL_PIN. Just it is tricky because some users mix pages pinned with GUP >> and pages acquired through get_page() in a single bio (such as zero page) >> and thus it is non-trivial to do the right thing on IO completion (unpin or >> just put_page). > > Side note: the new "exclusive VM" bit wouldn't _solve_ this issue, but > it might make it much easier to debug and catch. > > If we only set the exclusive VM bit on pages that get mapped into user > space, and we guarantee that GUP only looks up such pages, then we can > also add a debug test to the "unpin" case that the bit is still set. > > And that would catch anybody who ends up using other pages for > unpin(), and you could have a WARN_ON() for it (obviously also trigger > on the page count being too small to unpin). It would also catch if someone would be wrongly dropping the exclusive flag although there are users (pin) relying on the page staying exclusive. > > That way, at least from a kernel debugging and development standpoint > it would make it easy to see "ok, this unpinning got a page that > wasn't pinned" For that purpose the pincount would already kind-off work. Not precise, but at least something ("this page cannot possibly have been pinned"). -- Thanks, David / dhildenb