Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3314355rwb; Fri, 20 Jan 2023 14:22:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXvSKvEe4rA1iITpZvYnlH90d4YrBLPUttmXbit9NTWKlZbq4uV1y1CK3fw4TONjJpg8kK0O X-Received: by 2002:a17:902:9693:b0:191:11ec:2028 with SMTP id n19-20020a170902969300b0019111ec2028mr17515232plp.46.1674253350175; Fri, 20 Jan 2023 14:22:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674253350; cv=none; d=google.com; s=arc-20160816; b=Onv+uxnC8RxrgR3YGjEQccfmr4odyblO4IEXt62tp7MMdZl82MMkJMdnjpnO172RdO mOwJewR4IsN38oQVEjfthlXtGGxoWAX8VrTbYEPKwSg62Q0wu6mmF6SzkQATfh/BA/2C LUmb5yty3MMShnIKERopsraTUro/ANGoZo+AjQ34xeMiecM92DCZqEwRb2uOKyk/CGdG nsv0kIPxhoaX5Cn8WB3dwyJ8FW36GU/WyO56SoAHvVsx6mpMACzjBtsxqS0ZaKt+nBHJ jP4hkKe2HZeH55iGjUJAlS9yYsFlwnl+2yTAuYV0ue2ZSzkLkuEyLs2wrYXC/CPamw+c P/6Q== 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=z3qwBR1dme9ZLOZh/BdaJZP6SjgmfrYQcarF0e5ic9A=; b=g64zhcuZI5dXOmLoyvt+xDhoYhxsjyeyB9V70Efcc2ax+tIyJp5PLx80irEw8lhw+W ZAn0bnt38bb/Um64QGse+tGM+FO06LxuUDV0reyi0cIN++dEW+3U5I36g8M/VO/BgcVs WEZhz/kOXI2tSe9xyjmc5Hu5jouUU2eM/0/3ltRS2g7l2f2Ivnl2g8TYGuF55e8+ZZEJ oafLsEyCR8Yjnkjs6FABZv/DKZs/ZXBROAWB6AfpsMN8K0BH4lOyqr23Sq/Uzsc9Wcx4 9IJd0UDRTa+2fTNw9gHWHQLzLp9aw4ZokokZmGZ9Q9hnx0cXJazwDVtAWmxX7+a9GN/2 Doqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZxXUlCsd; 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 ja12-20020a170902efcc00b001782a6fbc7csi23046046plb.463.2023.01.20.14.22.23; Fri, 20 Jan 2023 14:22:30 -0800 (PST) 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=ZxXUlCsd; 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 S229590AbjATVRX (ORCPT + 50 others); Fri, 20 Jan 2023 16:17:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjATVRW (ORCPT ); Fri, 20 Jan 2023 16:17:22 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC2B86BC for ; Fri, 20 Jan 2023 13:17:21 -0800 (PST) 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=z3qwBR1dme9ZLOZh/BdaJZP6SjgmfrYQcarF0e5ic9A=; b=ZxXUlCsdh/y0w6ElZl8eI3uddq zzz7OABkK4eO5/v1XGNVIGaS0fYe6nH6xrzZA2PMBERmN1uUoYLXBmBPlJ/uzSnPq0lwzuSrqlelD o5wGqUVzS1ssbhyafBNuDT8i4MOpb2XpC1b6JrlcYdo5k+FkrGEKD1xch69OiMBDzRUB3ibxb+AIK ZEDUy9Ov8qmD/3N/JUt1/trsLlYXF6PWhinKI4Ull8Ed/OC9HY4htzEgHZpvNREw0SXA+iWtO6Eoz ruDN0BJ54ilE1kG0lxgwDHA7ssa7HyEhux2H22BAy0PEel6xiWTyR7VXBVM9dWWWXvT8roNVVpqNI HlWDGUmw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIyl8-002RNk-SW; Fri, 20 Jan 2023 21:17:14 +0000 Date: Fri, 20 Jan 2023 21:17:14 +0000 From: Matthew Wilcox To: Sidhartha Kumar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, songmuchun@bytedance.com, mike.kravetz@oracle.com, jhubbard@nvidia.com Subject: Re: [PATCH 4/9] mm/rmap: change hugepage_add_new_anon_rmap to take in a folio Message-ID: References: <20230119211446.54165-1-sidhartha.kumar@oracle.com> <20230119211446.54165-5-sidhartha.kumar@oracle.com> <9c276d01-379f-9bd7-0a7a-6a831b7b4571@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9c276d01-379f-9bd7-0a7a-6a831b7b4571@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 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 Fri, Jan 20, 2023 at 12:45:38PM -0800, Sidhartha Kumar wrote: > > > @@ -6176,6 +6186,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, > > > spinlock_t *ptl; > > > int ret = -ENOMEM; > > > struct page *page; > > > + struct folio *folio = NULL; > > > int writable; > > > bool page_in_pagecache = false; > > > @@ -6251,12 +6262,15 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, > > > *pagep = NULL; > > > } > > > + if (page) > > > + folio = page_folio(page); > > > + > > > /* > > > - * The memory barrier inside __SetPageUptodate makes sure that > > > + * The memory barrier inside __folio_mark_uptodate makes sure that > > > * preceding stores to the page contents become visible before > > > * the set_pte_at() write. > > > */ > > > - __SetPageUptodate(page); > > > + __folio_mark_uptodate(folio); > > > > Hi Matthew, > > In the snippet: > > page = alloc_huge_page(dst_vma, dst_addr, 0); > if (IS_ERR(page)) { > put_page(*pagep); > ret = -ENOMEM; > *pagep = NULL; > goto out; > } > copy_user_huge_page(page, *pagep, dst_addr, dst_vma, > pages_per_huge_page(h)); > > I thought the IS_ERR() call does not handle the NULL case and is a check for > high memory addresses, and copy_user_huge_page() path does not seem to > handle the NULL case as well but alloc_huge_page() can possibly return NULL > so I was unsure about how to handle the folio conversion. I'm not sure how alloc_huge_page() can return NULL. It seems like it returns ERR_PTR(-ENOSPC) or ERR_PTR(-ENOMEM) if it cannot allocate memory?