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 8F728C19F28 for ; Wed, 3 Aug 2022 13:36:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 138DF6B0071; Wed, 3 Aug 2022 09:36:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E8D46B0072; Wed, 3 Aug 2022 09:36:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F196E8E0001; Wed, 3 Aug 2022 09:36:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E2B586B0071 for ; Wed, 3 Aug 2022 09:36:47 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B8D801A146E for ; Wed, 3 Aug 2022 13:36:47 +0000 (UTC) X-FDA: 79758381654.08.25A68F3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id DF0AEA0018 for ; Wed, 3 Aug 2022 13:36:46 +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=iiExYD1ZoRG/Z8BiD0NXZkt1IKw0iXTQamKQ0mSVNaQ=; b=o43PD5EJRo2f5qhWa5O8//ZRFy Pj24nUwlXveMPHgCIjbFgqybRVBRSDDXBMOOZhW/z4iIDQbtSmkkeWbYffpBCjv5Fd/lX52i0gkWt MSo4i8/QWTQpI31uCzo2+BOS3QkDUUx5XHhrDx9v6odGOF575s98HPY1LY4ebmdDCJJdKUKh2UR6k 8s5AOToWzQYBArU6IqB9YRUixUOJxRKnqA8dKBJo2juBmLCdB7v7JbFP+tdcKgP2Yb6K9peDdJ2r0 eoNQWJ2E0ZgnhgBXW6dv0tcxRyLXIb1gupbCWCyKqrjlEcQe3sK6mS30IHoIQ/xqwdi/7FdKSP7uP B3uE730Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oJEYF-009J7T-1Y; Wed, 03 Aug 2022 13:36:43 +0000 Date: Wed, 3 Aug 2022 14:36:43 +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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659533807; a=rsa-sha256; cv=none; b=unk2ZyqWcvm/LQ23l9O4hVO1UlMyMmqcKM83dlhJUKdBrQ2wtjSIQps0E2BUWjfIT0hqoC NZBOwyAN4tf5jia4m7UN9jVwr1ZDDgnm7Mn5OFcXOfyj11abrYFfOZB0nb7CNcjviJldzw KjMV1l9B0OisbsvHJcycAXvAR3CEAfQ= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=o43PD5EJ; 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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659533807; 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=iiExYD1ZoRG/Z8BiD0NXZkt1IKw0iXTQamKQ0mSVNaQ=; b=EV1Leyrt+Hpq8K13F9GCnTo2O7L8xtvXmEvdXmiv0DUp9Skw0bowMCsUZG9Yozm2cWh7fB eGVFRGWf6wkJdgJeC2iwRlMVE0EB3gQ9GSl7ZYSTkf2KK1L+SZ1A+5m9BT3GbsWWtvA1m2 Hpo4Osv74goKeYlNijOKYE/ICZQenvw= X-Rspam-User: X-Stat-Signature: y3bxfw53nrgdx8fzi9femodoq4dwmsd6 X-Rspamd-Queue-Id: DF0AEA0018 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=o43PD5EJ; 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; dmarc=none X-Rspamd-Server: rspam02 X-HE-Tag: 1659533806-886300 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 09:32:41PM +0800, Yin, Fengwei wrote: > On 8/3/2022 9:01 PM, Matthew Wilcox wrote: > > 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: > I am not aware try_to_release_page() was on remove plan. Yes. New API > is good. Generally, anything in folio-compat.c is on the remove schedule. Depending on the callers, that schedule might be a few years away (eg unlock_page() has around 700 callers). > > 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); > Already got page folio. I suppose don't need above line. Ah, no. If the thp split succeeded, we need to get the new folio for this page. > I will re-run the test with the new folio API based patch. Thanks!