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 9DA95C4332F for ; Tue, 22 Nov 2022 17:33:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29D376B0071; Tue, 22 Nov 2022 12:33:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24D676B0073; Tue, 22 Nov 2022 12:33:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13D508E0001; Tue, 22 Nov 2022 12:33:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 00B386B0071 for ; Tue, 22 Nov 2022 12:33:39 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C93E5160D9B for ; Tue, 22 Nov 2022 17:33:39 +0000 (UTC) X-FDA: 80161775358.16.FC4F8DA Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 73EE2160013 for ; Tue, 22 Nov 2022 17:33:38 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id h24so9726675qta.9 for ; Tue, 22 Nov 2022 09:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=y0TG7RSDJLBsFmv13T+kVLFnKE/Gs/+y0yFrl/WZR6s=; b=L0dZyDnVDHFIaOItmPGH7qgeLVW0usPCwRH/4nTimj8Xh9l2UXEZKNFm/ei9gDcq24 Pk3u7Gq7lJi0kmr8z8NjnWgqP5s/GTGAjlS5nF3Rg8c28BPysVoaAoT/SPX3zkQcRIfE uip9ptnbHvWOX/Zei2bksChNqBhHUUkmXbxVE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y0TG7RSDJLBsFmv13T+kVLFnKE/Gs/+y0yFrl/WZR6s=; b=fh29WVXEloMGM9QS3a8thYUp9yrrmULj08deGkbseo4EgvBQKkRjhrT3ymxG0/xb9U RKzIsO0mx7RplyorPCmvcrMeuga13FasCe/r0ZPhlrTMYMmsEuJxHMwQ2RzYAVMmxeSt 9vBcZVbd8xc/BioP5tRVz1yDAJ+RiX34Ec/XbZ7pycyxAPHsPBXfM6ALaTBAyqz90zt3 uLolI8Lfua5SEfOX7Usd8mZGWwcZOgnepA9AsnYiGKEGjzxp88UDjDC1tGNdfdTdRY5O /2BxLROVxvFziyjNrpW2Gkc3qKf7k6hJpQNDiR7sNG5g7PXGGc3ANd1krdKnqE1D55/M q5Bg== X-Gm-Message-State: ANoB5pla5g9HBC7UAtZg+vLGxct+KYgz3xFSNpCuHuWkwfxpLEcD4JG8 J0+gfwIspzmFsRutSOOFVDvxeScddrFXFg== X-Google-Smtp-Source: AA0mqf7jASPH+DZNCaPckWd1NIkvDdWu9jle9NSf5u8JBVQ5gTx/astuktDwIiD/ZRqgt53y8fybXg== X-Received: by 2002:ac8:4d99:0:b0:3a5:5334:b3f7 with SMTP id a25-20020ac84d99000000b003a55334b3f7mr22830963qtw.584.1669138417167; Tue, 22 Nov 2022 09:33:37 -0800 (PST) Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com. [209.85.222.169]) by smtp.gmail.com with ESMTPSA id q46-20020a05620a2a6e00b006fbcab95d70sm10010610qkp.101.2022.11.22.09.33.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Nov 2022 09:33:33 -0800 (PST) Received: by mail-qk1-f169.google.com with SMTP id x18so10766060qki.4 for ; Tue, 22 Nov 2022 09:33:32 -0800 (PST) X-Received: by 2002:a05:620a:1fa:b0:6ee:24d5:b8fc with SMTP id x26-20020a05620a01fa00b006ee24d5b8fcmr21656006qkn.336.1669138412298; Tue, 22 Nov 2022 09:33:32 -0800 (PST) MIME-Version: 1.0 References: <20221107161740.144456-1-david@redhat.com> <20221107161740.144456-17-david@redhat.com> <6175d780-3307-854c-448a-8e6c7ad0772c@xs4all.nl> In-Reply-To: <6175d780-3307-854c-448a-8e6c7ad0772c@xs4all.nl> From: Linus Torvalds Date: Tue, 22 Nov 2022 09:33:16 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC 16/19] mm/frame-vector: remove FOLL_FORCE usage To: Hans Verkuil Cc: Tomasz Figa , David Hildenbrand , Marek Szyprowski , 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, 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 Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669138418; a=rsa-sha256; cv=none; b=5EuJRFSjZdxOH65qb3EY1wVaxmzElUuTbSKeiNtoo26gS4ziTVJjHpRPA1P/k0ge92eFqx oVPlr2uKEyLDLDq/CYmKaJ+EzZ/6I28K6x19G5O5Vj/A22/LeMF9uRz6q7N2c1JW0NpLRW vcy8eu+2Vy5t6Or+SiXJ2YsKmFpPzQ4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=L0dZyDnV; spf=pass (imf08.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.160.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669138418; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=y0TG7RSDJLBsFmv13T+kVLFnKE/Gs/+y0yFrl/WZR6s=; b=FY8Tx6MMav+cvQLHpz/8c3FHYUmvbRIpJXeQiE6D58WWbBvBwenAt2oA9zw1rewXxJ2qBN uPrKA7nH52sypUSekrn/+xjHNFwV81IU5/gyRBFwaLPIMbyVuNUpm2EdVI4Scs99IS19BS +vmgmPEDOCaAWi8t20CEKaP0eALfTPA= X-Rspam-User: X-Rspamd-Queue-Id: 73EE2160013 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=L0dZyDnV; spf=pass (imf08.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.160.178 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Stat-Signature: pd8a9axbhge43e3nbpaatmbpnhsdwrzn X-Rspamd-Server: rspam10 X-HE-Tag: 1669138418-612108 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 Tue, Nov 22, 2022 at 4:25 AM Hans Verkuil wrote: > > 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. Well, not entirely. For archaeology reasons, I went back to the old BK history, which exists as a git conversion in https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/ and there you can actually find it. Not with a lot of explanations, though - it's commit b7649ef789 ("[PATCH] videobuf update"): This updates the video-buf.c module (helper module for video buffer management). Some memory management fixes, also some adaptions to the final v4l2 api. but it went from err = get_user_pages(current,current->mm, - data, dma->nr_pages, - rw == READ, 0, /* don't force */ + data & PAGE_MASK, dma->nr_pages, + rw == READ, 1, /* force */ dma->pages, NULL); in that commit. So it goes back to October 2002. > 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 The timing roughly matches. > I assume that removing FOLL_FORCE from 'FOLL_FORCE|FOLL_WRITE' will still > allow drivers to read from the buffer? The issue with some of the driver hacks has been that - they only want to read, and the buffer may be read-only - they then used FOLL_WRITE despite that, because they want to break COW (due to the issue that David is now fixing with his series) - but that means that the VM layer says "nope, you can't write to this read-only user mapping" - ... and then they use FOLL_FORCE to say "yes, I can". iOW, the FOLL_FORCE may be entirely due to an (incorrect, but historically needed) FOLL_WRITE. Linus