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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74E97C19F28 for ; Wed, 3 Aug 2022 13:19:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 049496B0071; Wed, 3 Aug 2022 09:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F20B26B0072; Wed, 3 Aug 2022 09:19:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB47E8E0001; Wed, 3 Aug 2022 09:19:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C698B6B0071 for ; Wed, 3 Aug 2022 09:19:15 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 90B4A806EA for ; Wed, 3 Aug 2022 13:19:15 +0000 (UTC) X-FDA: 79758337470.24.26D1623 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 3D45EA0018 for ; Wed, 3 Aug 2022 13:19:14 +0000 (UTC) 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=rsU14it5I11vaGIZQI8gRev6qBgMQTouPT4uZ3h44+k=; b=i+G39KKP6wLZgzR65HH4YM3NTv hr0sWl4+oo52KcqtPLBnt+c0wBiO+iYWvuB5qnpJogbclPNjrZumYJ3NMde6rz6zmOvEzm2Ld0E1E NO3e3GEvmEZrdmfyzn1FBWp/B57R+iQ0D6aEChXmKPhVmk0CayPZNRyhnEeH4zMsg427sIiPITUJG REkbuYXMS4yP6HPj7T0+dolqgN1XNCMf+enXCsHcKWN9uv459bEid0ql3N4URTyYzTQXw9txExafy den5v4nsZcLjfV5rA4NCRI/bchroFfK5vkNRzPWZsZq3Mjxl7tterq1LEZNdTL5IOOMgUsbbzu227 NSsWMq7A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJE0V-009Hph-Sq; Wed, 03 Aug 2022 13:01:51 +0000 Date: Wed, 3 Aug 2022 14:01:51 +0100 From: Matthew Wilcox To: Yin Fengwei Cc: linux-mm@kvack.org, naoya.horiguchi@nec.com, linmiaohe@huawei.com, aaron.lu@intel.com, tony.luck@intel.com, qiuxu.zhuo@intel.com Subject: Re: [RFC PATCH] mm/memory-failure: release private data before split THP Message-ID: References: <20220803025243.155798-1-fengwei.yin@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220803025243.155798-1-fengwei.yin@intel.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659532754; a=rsa-sha256; cv=none; b=sbLMcswMXaDuU0VS9QcMODovtB+p2d+OMDKKNf5qsxzWa4+K/IQzsFaIv31WcWJgcn+Zj4 yUvdNFBZ4ulkvMwzyg0gka9KTTi3XsRT/UN8P+5d9WppNwYjyR3Ye+ye80HSJE6woR/MwZ 8MguW7ycm3EGqaOYRuHlonrVRy7tT8o= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=i+G39KKP; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659532754; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=rsU14it5I11vaGIZQI8gRev6qBgMQTouPT4uZ3h44+k=; b=gOIh/xr6HwCI1Kmw8Q/wlpPzpSiknHyb588mIMRm0sOsy3uxdaGLMGxgdVDvBkNKgEMKrd KiMRzaIJ9wrzKKL0Cm26HJ8xEdxuzBWxU8ZbmH1JrraUaTVLQjNoxxCqwnBP+CD981Zeds 3fLyDL4FlzZCHWDj9l9WdMs/3gpcAmA= X-Stat-Signature: 85h7ikdoby1cgkq5tgjeuwn5mdew8dka X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 3D45EA0018 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=i+G39KKP; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspam-User: X-HE-Tag: 1659532754-71399 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: On Wed, Aug 03, 2022 at 10:52:43AM +0800, Yin Fengwei wrote: > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index da39ec8afca8..08e21973b120 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1484,7 +1484,16 @@ static int identify_page_state(unsigned long pfn, struct page *p, > > static int try_to_split_thp_page(struct page *page, const char *msg) > { > + struct page *head = compound_head(page); > + > lock_page(page); > + /* > + * If thp page has private data attached, thp split will fail. > + * Release private data before split thp. > + */ > + if (page_has_private(head)) > + try_to_release_page(head, GFP_KERNEL); > + > if (unlikely(split_huge_page(page))) { > unsigned long pfn = page_to_pfn(page); It seems a shame to use the old page approach instead of the shiny new folio approach. We're quite close to being able to remove try_to_release_page() in 6.1 or 6.2 so adding a new caller is a bad idea. How about this: diff --git a/mm/memory-failure.c b/mm/memory-failure.c index da39ec8afca8..765b383288b1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1484,16 +1484,21 @@ static int identify_page_state(unsigned long pfn, struct page *p, static int try_to_split_thp_page(struct page *page, const char *msg) { - lock_page(page); + struct folio *folio = page_folio(page); + + folio_lock(folio); + if (folio_test_private(folio)) + filemap_release_folio(folio, GFP_KERNEL); if (unlikely(split_huge_page(page))) { unsigned long pfn = page_to_pfn(page); - unlock_page(page); + folio_unlock(folio); pr_info("%s: %#lx: thp split failed\n", msg, pfn); - put_page(page); + folio_put(folio); return -EBUSY; } - unlock_page(page); + folio = page_folio(page); + folio_unlock(folio); return 0; }