Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5795329rwb; Tue, 22 Nov 2022 05:09:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5w/zRfvOSWPZUYgRR4CJg6H6NtEByt2EoE/eQp7YXkm6EMy44dgueAfcUh0+eiSgRIhskr X-Received: by 2002:a63:5d0d:0:b0:43c:6413:322c with SMTP id r13-20020a635d0d000000b0043c6413322cmr8713283pgb.472.1669122550225; Tue, 22 Nov 2022 05:09:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669122550; cv=none; d=google.com; s=arc-20160816; b=sSb8frXMSB//8AvFAAL2wRU1gUT4/g7miUFcoM1cSTeFFiE355QXilDzINbMendMrm r0UCODo5pKEYiV0CM5EEInjEgV1DvszpsV9fpRUOJWFpreJKbjmPqUXV3QXJv5l+J6Yw 5sBPIkMFSThl24LCwZmFjduCoFoBpqhT71UEoBc7JyJTgjJ+IGweYFGk7dIFxYrPsh3u yh9TA0ghlbrX812BZ0a/nZIMy0JvQK6ZWKCdJLDJzfz3hnyoNHSGGRiFeKqBsAw1lKkL Zk3yLcJdUkEfzxDCdJ+Oe3XwJaq9/cvzXleQrEbYgvOJk2E3lpK91DnrH/ONY/lepyjM B4MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=TlBwJNp/jitu4dnjNvCRWCp8vuWXGMZrB45QP9OtTb4=; b=SyjzekqBsaYRB8Y1azqMeVyvXt2fs0ivaYAlV84ryMMTa8HX0wqjiWKj/UGoPeZ4YQ +B0Jo7S1aJnhA81YJLwoCVUFp+vwIG4LLMNeNHFuWaRVNepaYW9dCKdQFsJ4FHS3A1P9 2dLcU0vQ1+6sFWD/za00UQFb0p76hxq2uNJoUtl4oA5v1td4aLWl6b5J/IW55aJRCqPL lM395sMj5xpEfl5CF+bY4porUq2fIZ7nw39lPInx8ucRpO7JbsPBc4QGwJalfo0ybBdj U05wA2PQTObeZ09t8oKQ4MzCPIFPXIxU1BsmI+HLMztNEo7lIRNMTlX5kdSRIMs955e/ zlvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IpzmBLNy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a17090aea9000b00218ad2e9e32si5692865pjz.75.2022.11.22.05.08.58; Tue, 22 Nov 2022 05:09:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IpzmBLNy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231519AbiKVMj7 (ORCPT + 90 others); Tue, 22 Nov 2022 07:39:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232835AbiKVMjq (ORCPT ); Tue, 22 Nov 2022 07:39:46 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 701A85C75E for ; Tue, 22 Nov 2022 04:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669120723; 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=TlBwJNp/jitu4dnjNvCRWCp8vuWXGMZrB45QP9OtTb4=; b=IpzmBLNyACs49jY7lgm++c8lhjtDTgOXfwTpMANdyIWb3BfgSbDCeyxhy1qhFETXdDsd0G An5awmOQ49LKZxGh5izikymF4VR9bXLTXwERrsalSCWWgRSGPg0Pw+ndj60IUPIGdPJpKh EWzeYEpE3ou6yA2Us7yJHfSCe5bm1GU= 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.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-96-b0nCF3xvPYmhRf_P-xM_Wg-1; Tue, 22 Nov 2022 07:38:42 -0500 X-MC-Unique: b0nCF3xvPYmhRf_P-xM_Wg-1 Received: by mail-wm1-f70.google.com with SMTP id c126-20020a1c3584000000b003cfffcf7c1aso8682643wma.0 for ; Tue, 22 Nov 2022 04:38:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TlBwJNp/jitu4dnjNvCRWCp8vuWXGMZrB45QP9OtTb4=; b=GXaxuqe/Nyvhxiyj4tqRnw5d+ouMSzYhHNfJ2SSQ/RB8w8fprnC/Xgr8LoozjCIB1K ovSFY8X4bMCEpk98ZnxQjXuCVEUp7gUs54kP3k3ft+c6E2ILv2NLZQ6XBxZ1JqcdHnYR ziksznBKwTiauLiTG/ONZNxYUrZlgp0Aa3/wPazy74OXZ/ihn5Zfu+6yXd1aXqL/9s+0 AKjj7unRplNvtxj8KL/PgKMsXVoC5bACm4DWA6/iqeZ6QAGiSxRrIgFZC70/gdHvENUk QK0ybu6QP2j+FcpIm7bHgn1K37MfyPnh76zfB3GaoA3EMxKl588qZjmwsf6jYqjChRCk XxWw== X-Gm-Message-State: ANoB5pmnx50cjTDwrJdFb40wQA6STnLCv5Uyw8HjvZ/8VPwfX8Re/7OP I0JQXvt1zJMuD8n5tERCZWOZ+rKK7enEfck/bUd8wsiqJPOlYCGh9UTu1bjKOoweciCnHud3huq M+to5ZuKk7YNUkRV/JRtSU4qN X-Received: by 2002:adf:e844:0:b0:241:bfc9:5975 with SMTP id d4-20020adfe844000000b00241bfc95975mr6721654wrn.605.1669120721068; Tue, 22 Nov 2022 04:38:41 -0800 (PST) X-Received: by 2002:adf:e844:0:b0:241:bfc9:5975 with SMTP id d4-20020adfe844000000b00241bfc95975mr6721629wrn.605.1669120720555; Tue, 22 Nov 2022 04:38:40 -0800 (PST) Received: from ?IPV6:2003:cb:c706:c300:b066:75e3:f1d2:b69b? (p200300cbc706c300b06675e3f1d2b69b.dip0.t-ipconnect.de. [2003:cb:c706:c300:b066:75e3:f1d2:b69b]) by smtp.gmail.com with ESMTPSA id e18-20020a5d5952000000b00236883f2f5csm13821707wri.94.2022.11.22.04.38.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Nov 2022 04:38:40 -0800 (PST) Message-ID: <6ace6cd4-3e13-8ec1-4c2a-49e2e14e81a6@redhat.com> Date: Tue, 22 Nov 2022 13:38:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Content-Language: en-US To: Hans Verkuil , Tomasz Figa , Marek Szyprowski Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, linux-kselftest@vger.kernel.org, Linus Torvalds , Andrew Morton , Jason Gunthorpe , John Hubbard , Peter Xu , Greg Kroah-Hartman , Andrea Arcangeli , Hugh Dickins , Nadav Amit , Vlastimil Babka , Matthew Wilcox , Mike Kravetz , Muchun Song , Lucas Stach , David Airlie , Oded Gabbay , Arnd Bergmann , Mauro Carvalho Chehab References: <20221107161740.144456-1-david@redhat.com> <20221107161740.144456-17-david@redhat.com> <6175d780-3307-854c-448a-8e6c7ad0772c@xs4all.nl> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH RFC 16/19] mm/frame-vector: remove FOLL_FORCE usage In-Reply-To: <6175d780-3307-854c-448a-8e6c7ad0772c@xs4all.nl> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22.11.22 13:25, Hans Verkuil wrote: > Hi Tomasz, David, > > On 11/8/22 05:45, Tomasz Figa wrote: >> Hi David, >> >> On Tue, Nov 8, 2022 at 1:19 AM David Hildenbrand wrote: >>> >>> FOLL_FORCE is really only for debugger access. According to commit >>> 707947247e95 ("media: videobuf2-vmalloc: get_userptr: buffers are always >>> writable"), the pinned pages are always writable. >> >> Actually that patch is only a workaround to temporarily disable >> support for read-only pages as they seemed to suffer from some >> corruption issues in the retrieved user pages. We expect to support >> read-only pages as hardware input after. That said, FOLL_FORCE doesn't >> sound like the right thing even in that case, but I don't know the >> background behind it being added here in the first place. +Hans >> Verkuil +Marek Szyprowski do you happen to remember anything about it? > > I tracked the use of 'force' all the way back to the first git commit > (2.6.12-rc1) in the very old video-buf.c. So it is very, very old and the > reason is lost in the mists of time. > > I'm not sure if the 'force' argument of get_user_pages() at that time > even meant the same as FOLL_FORCE today. From what I can tell it has just > been faithfully used ever since, but I have my doubt that anyone understands > the reason behind it since it was never explained. > > Looking at this old LWN article https://lwn.net/Articles/28548/ suggests > that it might be related to calling get_user_pages for write buffers > (non-zero write argument) where you also want to be able to read from the > buffer. That is certainly something that some drivers need to do post-capture > fixups. > > But 'force' was also always set for read buffers, and I don't know if that > was something that was actually needed, or just laziness. > > I assume that removing FOLL_FORCE from 'FOLL_FORCE|FOLL_WRITE' will still > allow drivers to read from the buffer? Yes. The only problematic corner case I can imagine is if someone has a VMA without write permissions (no PROT_WRITE/VM_WRITE) and wants to pin user space pages as a read buffer. We'd specify now FOLL_WRITE without FOLL_FORCE and GUP would reject that: write access without write permissions is invalid. There would be no way around "fixing" this implementation to not specify FOLL_WRITE when only reading from user-space pages. Not sure what the implications are regarding that corruption that was mentioned in 707947247e95. Having said that, I assume such a scenario is unlikely -- but you might know better how user space usually uses this interface. There would be three options: 1) Leave the FOLL_FORCE hack in for now, which I *really* want to avoid. 2) Remove FOLL_FORCE and see if anybody even notices (this patch) and leave the implementation as is for now. 3) Remove FOLL_FORCE and fixup the implementation to only specify FOLL_WRITE if the pages will actually get written to. 3) would most probably ideal, however, I am no expert on that code and can't do it (707947247e95 confuses me). So naive me would go with 2) first. -- Thanks, David / dhildenb