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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F195EB64DA for ; Wed, 5 Jul 2023 20:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233527AbjGEUNN (ORCPT ); Wed, 5 Jul 2023 16:13:13 -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> 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)