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 CB7A4C38142 for ; Mon, 23 Jan 2023 13:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231681AbjAWNMw (ORCPT ); Mon, 23 Jan 2023 08:12:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbjAWNMv (ORCPT ); Mon, 23 Jan 2023 08:12:51 -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 F092E23847 for ; Mon, 23 Jan 2023 05:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674479518; 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=FQv8e3zi0tb0sZVAWv+R67RLgpAS0mltaNdAlpxPgD4=; b=TSf4U912KSZ8/+DprXqrnobMe6DtKoI5uUNJsmRKE4DPy3lREtGKRy8R4o8xENcTXrQcup 9hEPeG+Pmbe9C/tXq2HHh7tMkeD6VEsGi9BJNuOKPoHJOupOiXD+39iQd/n4zWAv8fPpTq CBgnQyXUA+d4zpsdk83uKgghiEw+OFE= 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-492-390wd_91Msid-z9R7ngb6Q-1; Mon, 23 Jan 2023 08:11:56 -0500 X-MC-Unique: 390wd_91Msid-z9R7ngb6Q-1 Received: by mail-wm1-f70.google.com with SMTP id k34-20020a05600c1ca200b003db30c3ed63so5605495wms.2 for ; Mon, 23 Jan 2023 05:11:56 -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=FQv8e3zi0tb0sZVAWv+R67RLgpAS0mltaNdAlpxPgD4=; b=xDERjSgWBi8EtiXJBLdws8UNfRfB05eMR+MKzSMpvSDt7oevmH73zC+wGlYQmLcb4v kHES7TqbI2L7yZn9rWuLOmODWGsYgAbzhSulAugloPLaeHVN41NDc2xZeW9tkUvgzcez s+67mvZQll3w9mF2oMgUJsW/99HyW6JynQHaucHfWXDyeLTMUwmzAxMxeC6sf0H8bn2/ MOelv8QWnWosq7wee8kX6+Dhh0bPTAj15KoK+A3028fw3J3FZXsPYVXJi3Cm7q+Na8qU 57Ry4gdTloIC7qir3ORbmz+mM74YU6sw31Z77U2gOtxHIzOBpEhKbykh4PCjEunlazU6 IaUw== X-Gm-Message-State: AFqh2kqE4JhoY+6FMLlw0CGx/PSRes9CAd0Q8Q7/lzIZzOW2T4G2sT/J TixJc2GN+tP+twXk8OcMCHez17q28Gj3CcXBudtWGr657riouwEDcnXio0itHTN4nQx4m+HXcP2 BDU99YjEBbM5hdT1cZAGH23fy X-Received: by 2002:a05:600c:4d08:b0:3da:fef0:226b with SMTP id u8-20020a05600c4d0800b003dafef0226bmr23798172wmp.32.1674479515646; Mon, 23 Jan 2023 05:11:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXsRmwBRBfSgTGOZ07Dfbcl+YnLqnHekKSXbUAgHGKp4HT9xIK23+Golki9zb+CdiaKU8XQ7wg== X-Received: by 2002:a05:600c:4d08:b0:3da:fef0:226b with SMTP id u8-20020a05600c4d0800b003dafef0226bmr23798149wmp.32.1674479515328; Mon, 23 Jan 2023 05:11:55 -0800 (PST) Received: from ?IPV6:2003:cb:c704:1100:65a0:c03a:142a:f914? (p200300cbc704110065a0c03a142af914.dip0.t-ipconnect.de. [2003:cb:c704:1100:65a0:c03a:142a:f914]) by smtp.gmail.com with ESMTPSA id c40-20020a05600c4a2800b003db16770bc5sm10278946wmp.6.2023.01.23.05.11.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Jan 2023 05:11:54 -0800 (PST) Message-ID: <7bbcccc9-6ebf-ffab-7425-2a12f217ba15@redhat.com> Date: Mon, 23 Jan 2023 14:11:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Content-Language: en-US To: David Howells Cc: Al Viro , Christoph Hellwig , Matthew Wilcox , Jens Axboe , Jan Kara , Jeff Layton , Logan Gunthorpe , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig , John Hubbard , linux-mm@kvack.org References: <246ba813-698b-8696-7f4d-400034a3380b@redhat.com> <20230120175556.3556978-1-dhowells@redhat.com> <20230120175556.3556978-3-dhowells@redhat.com> <3814749.1674474663@warthog.procyon.org.uk> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v7 2/8] iov_iter: Add a function to extract a page list from an iterator In-Reply-To: <3814749.1674474663@warthog.procyon.org.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23.01.23 12:51, David Howells wrote: > David Hildenbrand wrote: > >> How does this work align with the goal of no longer using FOLL_GET for >> O_DIRECT? We should get rid of any FOLL_GET usage for accessing page content. > > Would that run the risk of changes being made by the child being visible to > the a DIO write if the parent changes the buffer first? > > > PARENT CHILD > ====== ===== > start-DIO-write > fork() = pid fork() = 0 > alter-buffer > CoW happens > page copied original page retained > alter-buffer > FOLL_PIN users are fine in that regard, because we properly detect "maybe pinned" during fork() and copy the page. See tools/testing/selftests/mm/cow.c (still called tools/testing/selftests/vm/cow.c upstream IIRC) for some test cases for that handling. FOLL_GET does not work as expected in that regard: pages can't be detected as pinned and we won't be copying them during fork(). We'll end up COW-sharing them, which can result in trouble later. Switching from FOLL_GET to FOLL_PIN was in the works by John H. Not sure what the status is. Interestingly, Documentation/core-api/pin_user_pages.rst already documents that "CASE 1: Direct IO (DIO)" uses FOLL_PIN ... which does, unfortunately, no reflect reality yet. -- Thanks, David / dhildenb