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 E5E69C4332F for ; Tue, 22 Nov 2022 12:25:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FF216B0071; Tue, 22 Nov 2022 07:25:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 487066B0073; Tue, 22 Nov 2022 07:25:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 327756B0074; Tue, 22 Nov 2022 07:25:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 22AB16B0071 for ; Tue, 22 Nov 2022 07:25:57 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EC247160FDA for ; Tue, 22 Nov 2022 12:25:56 +0000 (UTC) X-FDA: 80160999912.26.7E627ED Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 5649A18000B for ; Tue, 22 Nov 2022 12:25:55 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4970B61557; Tue, 22 Nov 2022 12:25:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8585C433C1; Tue, 22 Nov 2022 12:25:47 +0000 (UTC) Message-ID: <6175d780-3307-854c-448a-8e6c7ad0772c@xs4all.nl> Date: Tue, 22 Nov 2022 13:25:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH RFC 16/19] mm/frame-vector: remove FOLL_FORCE usage Content-Language: en-US To: Tomasz Figa , David Hildenbrand , 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> From: Hans Verkuil In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669119955; a=rsa-sha256; cv=none; b=qyOD0Yu7MEhLUaUIemzwcVaRbA7fqRPgt/hUswtckgmZRrGbt1QKeHEDRyFQr237rFALO3 vKA1SZwqXF7iKxosyaEVe/YlnZ0dqBrHdY0KEgAXDuLn4X1JQSrdhC8011e5qgCtUQDKR6 P7T3nCag9ZHW9M9w1eMmbBickFqTmKM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=xs4all.nl (policy=none); spf=pass (imf06.hostedemail.com: domain of "SRS0=l8Ei=3W=xs4all.nl=hverkuil@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=l8Ei=3W=xs4all.nl=hverkuil@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669119955; h=from:from:sender: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=jFygXfP0bf5zqhfkEj3gmQcMXgdgPjbznwjYFLjyS04=; b=VBBCB/dRaY5MhzGX95YLdKtQLBFqEJc7QDNRTMpmMJnk39zDr3Fmi6GbRA17ciovjZaeFm +LKzD5oEP0jW1s7CQREDd48f+f7jQsM2Qh9PTb2JRyyBGUdweNzb2bCFplZkNXgmzuEzGm +sKwNbRSwEaf6eeJZsOVe1ABLy+NdGc= X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5649A18000B X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=xs4all.nl (policy=none); spf=pass (imf06.hostedemail.com: domain of "SRS0=l8Ei=3W=xs4all.nl=hverkuil@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=l8Ei=3W=xs4all.nl=hverkuil@kernel.org" X-Stat-Signature: aj6hzoxxb3pxe9zf91j5suhg579w3ru1 X-HE-Tag: 1669119955-298926 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: 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? Regards, Hans > > Best regards, > Tomasz > >> >> FOLL_FORCE in this case seems to be a legacy leftover. Let's just remove >> it. >> >> Cc: Tomasz Figa >> Cc: Marek Szyprowski >> Cc: Mauro Carvalho Chehab >> Signed-off-by: David Hildenbrand >> --- >> drivers/media/common/videobuf2/frame_vector.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/media/common/videobuf2/frame_vector.c b/drivers/media/common/videobuf2/frame_vector.c >> index 542dde9d2609..062e98148c53 100644 >> --- a/drivers/media/common/videobuf2/frame_vector.c >> +++ b/drivers/media/common/videobuf2/frame_vector.c >> @@ -50,7 +50,7 @@ int get_vaddr_frames(unsigned long start, unsigned int nr_frames, >> start = untagged_addr(start); >> >> ret = pin_user_pages_fast(start, nr_frames, >> - FOLL_FORCE | FOLL_WRITE | FOLL_LONGTERM, >> + FOLL_WRITE | FOLL_LONGTERM, >> (struct page **)(vec->ptrs)); >> if (ret > 0) { >> vec->got_ref = true; >> -- >> 2.38.1 >>