From patchwork Sat Jun 5 01:06:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 12301105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-25.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MISSING_HEADERS, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 774CCC4743C for ; Sat, 5 Jun 2021 03:08:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1B182613FF for ; Sat, 5 Jun 2021 03:08:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B182613FF Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B11A56B006C; Fri, 4 Jun 2021 23:08:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AE7376B006E; Fri, 4 Jun 2021 23:08:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AFE06B0070; Fri, 4 Jun 2021 23:08:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id 6A9DC6B006C for ; Fri, 4 Jun 2021 23:08:27 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0809EEFAA for ; Sat, 5 Jun 2021 03:08:27 +0000 (UTC) X-FDA: 78218187054.18.47C0414 Received: from mail-vs1-f74.google.com (mail-vs1-f74.google.com [209.85.217.74]) by imf30.hostedemail.com (Postfix) with ESMTP id 280E6E0004F7 for ; Sat, 5 Jun 2021 03:08:15 +0000 (UTC) Received: by mail-vs1-f74.google.com with SMTP id s128-20020a672c860000b02902572698f365so3840784vss.0 for ; Fri, 04 Jun 2021 20:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:cc; bh=Fa0p5kaxCg9ESS+YbH/RbZiup0gha0dysH3j0Zhy1+U=; b=TzMnsIeD/funOD+ByHCZiSMl5ZeNWCfLkbqjRlNbd6w6sxMN5KX2AkgK5t/RS+ESEt EhyPXJkAQ0Xz06gvwKq1lRb7do3OCOplUgAeb08l/ec74HprXY3/hCGCvtStY73+7drA 7JjcWI2c+nENkux7kJr+WAl0xjomMwcB813RWOYqzhLpwdGsim0b9zgwvZYHUFDfL4hq chwwjSX0ZWJ6dMwBX5fHaiFOW6gTPR81MqY86ir4174QMb6aYLxYpoNTJHVrLGBMVxrz Exl9Np4r6qYyEWyBmUO93d5dInjsdm7rUsXE5+dmgRrsXZWDKAVprnj0K0JkV6scOvRW ahnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:cc; bh=Fa0p5kaxCg9ESS+YbH/RbZiup0gha0dysH3j0Zhy1+U=; b=HkNV7IZVmnuFXKuCRFvFqkweZ0iiwJy4hOdAF//124fQWRoe/lkoe6+RJ9os0YUwPn w3KbRwyVkCs8ONAFnZm0kehsUkle3mm1N4Zfu3SPnWX3g/NuaQmx1l2QvjNwERPCG/+h Mm8Np3+2GoGdgRE6lFByb2MQ2sK7rpMdjgHKbxd7xoepwP4k3tNSHbDsbLYDMpaSsxH3 VS6npL/ca9g/0Ykjz8kHJl4h9srC8/q4bw4xJicbw5fDt4PxHgOSBWb7EwXsKeYNJsBH C88WpAH2Sw9knAGMAImtZsfOFCr1hQOb1d/LpCxR6D+bxkBd8keyDBOMHIt0ilJ+cel2 +Mpg== X-Gm-Message-State: AOAM5323IkoSS6PvasNh5tssOclAamu6xBzYG0RdK18e8IXXNusthCIS q6cOn8Ta1Mfj+QUYbzJnrpptpCgW9f1sI2TPAg== X-Google-Smtp-Source: ABdhPJz228fTUBbe5ZDRR6Veq2+4ZrCZpbbLd3fuEIYo9zK1E4n/k0W+KuCqxm/+k81Owl0e1bweqFiw+6M9D8SMMA== X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2cd:202:f57f:1ac2:dde3:a713]) (user=almasrymina job=sendgmr) by 2002:ad4:566f:: with SMTP id bm15mr7233221qvb.54.1622855190002; Fri, 04 Jun 2021 18:06:30 -0700 (PDT) Date: Fri, 4 Jun 2021 18:06:26 -0700 In-Reply-To: <1fd32aad-c99d-e89a-cdb1-05843f568f0c@oracle.com> Message-Id: <20210605010626.1459873-1-almasrymina@google.com> Mime-Version: 1.0 References: <1fd32aad-c99d-e89a-cdb1-05843f568f0c@oracle.com> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog Subject: [PATCH] mm, hugetlb: fix allocation error check and copy func name From: Mina Almasry Cc: Mina Almasry , linux-mm@kvack.org, Mike Kravetz , Andrew Morton , linux-kernel@vger.kernel.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 280E6E0004F7 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=TzMnsIeD; spf=pass (imf30.hostedemail.com: domain of 3Fs66YAsKCKkJUVJbahVRWJPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--almasrymina.bounces.google.com designates 209.85.217.74 as permitted sender) smtp.mailfrom=3Fs66YAsKCKkJUVJbahVRWJPXXPUN.LXVURWdg-VVTeJLT.XaP@flex--almasrymina.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: crq5rqk4j1e36w4amieujebfh1je7jw4 X-HE-Tag: 1622862495-992218 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: The alloc_huge_page_vma() doesn't return error pointers, it returns NULL. There is an existing migrate_page_copy() which not only copies the page contents, but also page state/metadata. People could get confused that 'migrate_page_copy' and 'migrate_copy_huge_page' do not have the same functionality. Rename to 'copy_huge_page()' to make it less likely folks get confused. Fixes: 6a0badc266df ("mm, hugetlb: fix racy resv_huge_pages underflow on UFFDIO_COPY") Signed-off-by: Mina Almasry Cc: linux-mm@kvack.org Cc: Mike Kravetz Cc: Andrew Morton Cc: linux-kernel@vger.kernel.org Reviewed-by: Muchun Song Reviewed-by: Mike Kravetz --- include/linux/migrate.h | 4 ++-- mm/hugetlb.c | 4 ++-- mm/migrate.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) -- 2.32.0.rc1.229.g3e70b5a671-goog diff --git a/include/linux/migrate.h b/include/linux/migrate.h index e0b98876a52e..9b7b7cd3bae9 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -51,7 +51,7 @@ extern int migrate_huge_page_move_mapping(struct address_space *mapping, struct page *newpage, struct page *page); extern int migrate_page_move_mapping(struct address_space *mapping, struct page *newpage, struct page *page, int extra_count); -extern void migrate_copy_huge_page(struct page *dst, struct page *src); +extern void copy_huge_page(struct page *dst, struct page *src); #else static inline void putback_movable_pages(struct list_head *l) {} @@ -78,7 +78,7 @@ static inline int migrate_huge_page_move_mapping(struct address_space *mapping, return -ENOSYS; } -static inline void migrate_copy_huge_page(struct page *dst, struct page *src) +static inline void copy_huge_page(struct page *dst, struct page *src) { } #endif /* CONFIG_MIGRATION */ diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 64a460ff2d5b..637395907908 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5130,7 +5130,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, * contents. */ page = alloc_huge_page_vma(h, dst_vma, dst_addr); - if (IS_ERR(page)) { + if (!page) { ret = -ENOMEM; goto out; } @@ -5156,7 +5156,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, *pagep = NULL; goto out; } - migrate_copy_huge_page(page, *pagep); + copy_huge_page(page, *pagep); put_page(*pagep); *pagep = NULL; } diff --git a/mm/migrate.c b/mm/migrate.c index 2515210a9747..51f355757490 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -557,7 +557,7 @@ static void __copy_gigantic_page(struct page *dst, struct page *src, } } -void migrate_copy_huge_page(struct page *dst, struct page *src) +void copy_huge_page(struct page *dst, struct page *src) { int i; int nr_pages; @@ -662,7 +662,7 @@ EXPORT_SYMBOL(migrate_page_states); void migrate_page_copy(struct page *newpage, struct page *page) { if (PageHuge(page) || PageTransHuge(page)) - migrate_copy_huge_page(newpage, page); + copy_huge_page(newpage, page); else copy_highpage(newpage, page);