From patchwork Mon Apr 11 11:34:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 12809038 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 017DFC433F5 for ; Mon, 11 Apr 2022 11:34:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6213F6B0072; Mon, 11 Apr 2022 07:34:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DBC36B0073; Mon, 11 Apr 2022 07:34:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BF876B0074; Mon, 11 Apr 2022 07:34:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 3AC2F6B0072 for ; Mon, 11 Apr 2022 07:34:49 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0067260A49 for ; Mon, 11 Apr 2022 11:34:48 +0000 (UTC) X-FDA: 79344391098.13.AC7C96B Received: from out199-8.us.a.mail.aliyun.com (out199-8.us.a.mail.aliyun.com [47.90.199.8]) by imf11.hostedemail.com (Postfix) with ESMTP id E5A7540002 for ; Mon, 11 Apr 2022 11:34:47 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0V9nhU4j_1649676883; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0V9nhU4j_1649676883) by smtp.aliyun-inc.com(127.0.0.1); Mon, 11 Apr 2022 19:34:44 +0800 From: Baolin Wang To: akpm@linux-foundation.org Cc: willy@infradead.org, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: migrate: Simplify the refcount validation when migrating hugetlb mapping Date: Mon, 11 Apr 2022 19:34:30 +0800 Message-Id: X-Mailer: git-send-email 1.8.3.1 X-Stat-Signature: 7hck3nij9yhsw8156arn9stoqyw3bfjn X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E5A7540002 Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 47.90.199.8 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=alibaba.com X-Rspam-User: X-HE-Tag: 1649676887-764392 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: There is no need to validate the hugetlb page's refcount before trying to freeze the hugetlb page's expected refcount, instead we can just rely on the page_ref_freeze() to simplify the validation. Moreover we are always under the page lock when migrating the hugetlb page mapping, which means nowhere else can remove it from the page cache, so we can remove the xas_load() validation under the i_pages lock. Signed-off-by: Baolin Wang Cc: Matthew Wilcox Acked-by: Mike Kravetz --- mm/migrate.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index a3d8c2b..b267827 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -477,11 +477,6 @@ int migrate_huge_page_move_mapping(struct address_space *mapping, xas_lock_irq(&xas); expected_count = 2 + page_has_private(page); - if (page_count(page) != expected_count || xas_load(&xas) != page) { - xas_unlock_irq(&xas); - return -EAGAIN; - } - if (!page_ref_freeze(page, expected_count)) { xas_unlock_irq(&xas); return -EAGAIN;