Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29590149rwd; Wed, 5 Jul 2023 14:21:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrJp8Pa4QD6aaqsGiHYclbxUnRBxs8LdYQErjaLydQfLCHoY6amOqKOtIE/wB6foL7G1cG X-Received: by 2002:a05:6358:e48b:b0:135:24ed:5108 with SMTP id by11-20020a056358e48b00b0013524ed5108mr72487rwb.10.1688592113367; Wed, 05 Jul 2023 14:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688592113; cv=none; d=google.com; s=arc-20160816; b=hy7QcuFC1ZPycSyf7dTaCttf/SajNAAQUBbnnFYAC3cBwGIAxcYBzH5rR6Oc8Eeqvv l+HJDTPgLmC6hM4gsvAKt4JAjp7BhNt177Lic1ltStG/gJ1GaYmho2iejt/V4gQIAGQj ODP1BG6P4yBPmGasiv1fSsiadadUBkIZJW5T4DvDSiDu0wgejkO18cJLO3nBRGx97eRp iAt7py+o/7s8jhqeX/VmNx5dxtNVtqzbBT30mi8iBMpuqQUHuQC+jAqSGnu/Tz1qlt/P JolJ8FuonyaUu7IEAIjZ66B1SG+KJeHZo/o2rtCloQREUuMVkiGRPULddxWE1oZKSwLo qk3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TAqSZvBrVA5ulnUR04yLKG/QIDGzGFDcBotXrFut/iI=; fh=rFBXwciewBJ5o1wYI8iFu+fFsqSMrTS1etjlp0ekYio=; b=oOoLRxw4dn0D2524OsqiVIEvHpXMutQVUuNzhi6dfDUAKm1JO0PntrJas/ICz8LJ7L qjlH3hYxizmD9va3gi8dqhn4bTfbUm3dzpGtr4osoAIqegeL5lRjcAF66oRWLS0f3i6A nqMUOQJsxmrmrV0db0N3UUSvBUSKqs73RUuB/0y3NHSoCCjqL1oO3+T+AfJI2hB+dPll HcVqz7UfbFe0urOFf/fFLsF/iyh7XsEMnWXe5z4czmu63AJbTd3jQETN9wHewoUavHo4 idDvgV3c5KDKoArDz8faNUBOhWGMn5RnIvF98szzX0XdxEJ/yF5GbX1KgCepkuGJ2w14 yx7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VY2XPKhw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv67-20020a632e46000000b0055bc5ac22acsi25002pgb.229.2023.07.05.14.21.39; Wed, 05 Jul 2023 14:21:53 -0700 (PDT) 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=@infradead.org header.s=casper.20170209 header.b=VY2XPKhw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233508AbjGEUNM (ORCPT + 99 others); Wed, 5 Jul 2023 16:13:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbjGEUNL (ORCPT ); Wed, 5 Jul 2023 16:13:11 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CD4E173B for ; Wed, 5 Jul 2023 13:13:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=TAqSZvBrVA5ulnUR04yLKG/QIDGzGFDcBotXrFut/iI=; b=VY2XPKhwqq4d9GAo+TWyqUYjxt imEkEQPBHIcaXVfMFRRqHGrnZaR4U0ogZOS5ExntaaMm1bgZ5IDUF9xTuWbEzQD109kVG9sJui4ar fRMqCmG4yFTA+mifhSr/Ur4agB/xSPx2QkcbD6ogkciR3uJTF+fvbmKYQybyiABsRdMDqILpdHiO6 bcZggAZXJKk9t0f3dy3lR2oKJuQKNvwsL9GegqqrQG1Oe34yCkHj3Lb2XE6pk+hVHbv6NYMGOyaq6 6wM/veh8j2HhRZeTn5NbrYtyyuIBSRPopaD8Bdsf8WwQeTc45d/En8wb7RAag8vXJBlJCcjE5ELaS b5pA6NNA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qH8s7-00AOCy-Ko; Wed, 05 Jul 2023 20:13:07 +0000 Date: Wed, 5 Jul 2023 21:13:07 +0100 From: Matthew Wilcox To: Sidhartha Kumar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org Subject: Re: [PATCH v2 3/4] mm/memory: convert do_shared_fault() to folios Message-ID: References: <20230705194335.273790-1-sidhartha.kumar@oracle.com> <20230705194335.273790-3-sidhartha.kumar@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230705194335.273790-3-sidhartha.kumar@oracle.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Wed, Jul 05, 2023 at 12:43:34PM -0700, Sidhartha Kumar wrote: > /* > * Check if the backing address space wants to know that the page is > * about to become writable > */ > if (vma->vm_ops->page_mkwrite) { > - unlock_page(vmf->page); > + folio_unlock(folio); > tmp = do_page_mkwrite(vmf); > if (unlikely(!tmp || > (tmp & (VM_FAULT_ERROR | VM_FAULT_NOPAGE)))) { > - put_page(vmf->page); > + folio_put(folio); This is _probably_ OK. However, do_page_mkwrite() calls vm_ops->page_mkwrite(), and I think it's theoretically possible for the driver to replace vmf->page with a different one. The chance of them actually doing that is pretty low (particularly if they return error or nopage!), but I'm going to flag it just in case it comes up. Also, should we pass a folio to do_page_mkwrite() instead of having it extract the folio from vmf->page? Signed-off-by: Matthew Wilcox (Oracle)