From patchwork Fri Aug 5 06:28:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yin Fengwei X-Patchwork-Id: 12936864 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 44D59C00140 for ; Fri, 5 Aug 2022 06:29:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 719F48E0002; Fri, 5 Aug 2022 02:29:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67BB18E0001; Fri, 5 Aug 2022 02:29:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CE6C8E0002; Fri, 5 Aug 2022 02:29:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 36C248E0001 for ; Fri, 5 Aug 2022 02:29:50 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0CF27804C4 for ; Fri, 5 Aug 2022 06:29:50 +0000 (UTC) X-FDA: 79764563340.14.9BB87AC Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf26.hostedemail.com (Postfix) with ESMTP id CE458140131 for ; Fri, 5 Aug 2022 06:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659680988; x=1691216988; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+IcqgqVQyQRDO86fDltGadUuQSXspexlh/AURqC3o5A=; b=nwoQDYi3Zsh6qKk3ee7pL86SYfYYLGjkQsVhlnAPNeZeMYmPzh/1g5rT AmPG6K2UZQCdbDq5XHO6TChV4er1eOn1WFIU5XuOgKmdLhRPZTNEd02w8 27LkS8PsI7ajkrhKLW+0v3gdy/ni1eZLN07qqEJbvZXK5StG1CwztvlxB K2yjeawl+znLHJ57TRQj9qnO4AEgs7A38jR6bhEKsypBer3F4jEr+6wpA nuwKO1nADG7+GO4YcxI/Beymw8dDPefkN8KaoRAoEIoCJP3BhM4aZz0z7 5mjcVc2bMIXWsRT7xkOb3+vmg9HHwfKfBFXHKrPuGH/BQqLZaKGDbhoBg A==; X-IronPort-AV: E=McAfee;i="6400,9594,10429"; a="291355832" X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="291355832" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2022 23:29:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,216,1654585200"; d="scan'208";a="579388627" Received: from fyin-dev2.sh.intel.com ([10.239.146.202]) by orsmga006.jf.intel.com with ESMTP; 04 Aug 2022 23:29:44 -0700 From: Yin Fengwei To: linux-mm@kvack.org, naoya.horiguchi@nec.com, linmiaohe@huawei.com, willy@infradead.org, shy828301@gmail.com Cc: aaron.lu@intel.com, tony.luck@intel.com, qiuxu.zhuo@intel.com, fengwei.yin@intel.com Subject: [PATCH v2] mm: release private data before split THP Date: Fri, 5 Aug 2022 14:28:44 +0800 Message-Id: <20220805062844.439152-1-fengwei.yin@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659680989; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=au2YTpyVeK8sVvYMq5kDDO3azbnKyE3dtNp52nEnl2s=; b=hCLjMzIfMmHG+TVc39zT9RgVrrl9VwrAOPW449eGNr9i4z4KTv61wGcyTfnPz4oGlWNDSx R9N8RJwZ+WgL/Yvohu5O8HsPWNyoaL2+HWh9z1gqMtadk+jqjLfiAdcTSa0Gu4cHRZuVff F9xtPV31EtT32Sjfsu6k2pn7M5gqzbw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=nwoQDYi3; spf=pass (imf26.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659680989; a=rsa-sha256; cv=none; b=2Jb7WVgsTt6SLcnVnk72ZKfyaE1dwRnyH1itnyrIkFS+ZXucODQvjxD/V5ndmi0Y0QOk8v OL61rEVa2j+Ca82LETz0/DCEKZm6r22IHqLyzKKXBRRGXLnu59TVakiFmF1O15W9fSPw+C M1A9th6uCVpwjmY2StMbpLJ31+Ykm2Y= X-Stat-Signature: egfikc73nihqotuji8wkrft519pdexwh X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: CE458140131 Authentication-Results: imf26.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=nwoQDYi3; spf=pass (imf26.hostedemail.com: domain of fengwei.yin@intel.com designates 134.134.136.65 as permitted sender) smtp.mailfrom=fengwei.yin@intel.com; dmarc=pass (policy=none) header.from=intel.com X-HE-Tag: 1659680988-169327 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: If there is private data attached to THP, the refcount of THP will be increased and block the THP split. Release private data attached to THP before split it to increase the chance of splitting THP successfully. There was a memory failure issue hit during HW error injection testing with 5.18 kernel + xfs as rootfs. Test got killed and system reboot was required to re-run the test. The issue was tracked down to THP split failure caused the memory failure not being handled. The page dump showed: [ 1785.433075] page:0000000025f9530b refcount:18 mapcount:0 mapping:000000008162eea7 index:0xa10 pfn:0x2f0200 [ 1785.443954] head:0000000025f9530b order:4 compound_mapcount:0 compound_pincount:0 [ 1785.452408] memcg:ff4247f2d28e9000 [ 1785.456304] aops:xfs_address_space_operations ino:8555182 dentry name:"baseos-filenames.solvx" [ 1785.466612] flags: 0x1000000000012036(referenced|uptodate|lru|active|private|head|node=0|zone=2) [ 1785.476514] raw: 1000000000012036 ffb9460f8bc07c08 ffb9460f8bc08408 ff4247f22e6299f8 [ 1785.485268] raw: 0000000000000a10 ff4247f194ade900 00000012ffffffff ff4247f2d28e9000 It was like the error was injected to a large folio for xfs with private data attached. With private data released before split THP, the test case could be run successfully many times without reboot system. Co-developed-by: Qiuxu Zhuo Signed-off-by: Qiuxu Zhuo Signed-off-by: Yin Fengwei Suggested-by: Matthew Wilcox Reviewed-by: Aaron Lu --- Changelog from v1: - Move private release to split_huge_page_to_list to cover wider path per Yang's comment - Update to commit message Changelog from RFC: - Use new folio API per Mathhew Wilcox's suggestion - Add one line comment before re-get folio of page per Miaohe's comment - Remove RFC tag - Add Co-developed-by of Qiuxu who did a lot of debugging work to locate where the real issue is mm/huge_memory.c | 6 ++++++ 1 file changed, 6 insertions(+) base-commit: 31be1d0fbd950395701d9fd47d8fb1f99c996f61 diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 15965084816d..edcbc6c2bb3f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2590,6 +2590,12 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) goto out; } + if (folio_test_private(folio) && + !filemap_release_folio(folio, GFP_KERNEL)) { + ret = -EBUSY; + goto out; + } + xas_split_alloc(&xas, head, compound_order(head), mapping_gfp_mask(mapping) & GFP_RECLAIM_MASK); if (xas_error(&xas)) {