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 2FAACC19F2A for ; Thu, 4 Aug 2022 17:39:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E27F6B0071; Thu, 4 Aug 2022 13:39:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 691096B0072; Thu, 4 Aug 2022 13:39:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 581208E0001; Thu, 4 Aug 2022 13:39:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 49BB26B0071 for ; Thu, 4 Aug 2022 13:39:56 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2422C404E8 for ; Thu, 4 Aug 2022 17:39:56 +0000 (UTC) X-FDA: 79762623192.30.6D03ECB Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf04.hostedemail.com (Postfix) with ESMTP id C6F4840009 for ; Thu, 4 Aug 2022 17:39:55 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id h21-20020a17090aa89500b001f31a61b91dso5940220pjq.4 for ; Thu, 04 Aug 2022 10:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=KocIm5VC42oplais5i/SWrfsniRfwjAg+AY21sI7Jk8=; b=imlRuUV3Uivbl/647y6BE+ppRDbMrBHzREzlSP+7u+qRaBPfc2p+4L3TkE5lE+G1tG 1R+XrFMnk9bmtD2hp4+gA2gVg5CJSJ2YJM+BaN/FfAobwyGDnqdYfieEOqN+YZVMXUGi WiUBn0+9va4g9jJ/RtDDd6bkO8mRitPDy5n58pgfkD0xLGXkGqmnV1hBTeMJCiYWsY+v GbEPDtgLnG4HI8jIQ2Lr19BwNk7826L5Agf2Bw0B2UrrDuOz8G2209tKHjNCuXC4bfJQ a4vAIlp9ISAYOJe1IJ+hqMsNeMRmg2csIKcDgkXpQ0iIE0LHpKZsCQvk7yCI1Zom0gjp 9Prg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=KocIm5VC42oplais5i/SWrfsniRfwjAg+AY21sI7Jk8=; b=RJfWNLjk2m4gzJ152VQDcBAYwecRktLG9Nhkzz7RKO+dRbcN4hZ3XJrWbTJJEd1pDu FcRI6odjFr7RA4cAa0RhN2ZY2b2vYvXzFw+OBlS2v8hdh7dRlh/+8sdQPbM5xT0F+a+K 7lETDeEpv03UlfI//NDOSfbgq2jH0ndbaZ+LZiVKHBaeNHT3ntV4duwmUbDsw9/OTrZ2 36xZOma49a9RClDdqshyyMTygY0ItJ+MWy9GpqQZ4VvQHpHdBbLePMwTnOe457RxflT+ AGbp0Ck36QTv3DccucHAYrwJzxx0V+uSjRDV3iEp0R8A458wFcMgrE8/FC3gP8OjGa/I EuIQ== X-Gm-Message-State: ACgBeo11HG3dwRyk7VdDoCiDtPrM0pdeYpGXUaX29GV8sWmbAFILtm/2 Yo9yq2G+sq4AoBgD/Wi3NZk0AGHXtnRQFM4PXcQ= X-Google-Smtp-Source: AA6agR5WTOPbidACA5JC1w20xtPhHiqLYtAjpPNRoVp6IMHsvLe8R2q8cz06BuTkkyuqNog/++Lfcb2YsjmWGNNBTSs= X-Received: by 2002:a17:902:9005:b0:16c:f62c:4376 with SMTP id a5-20020a170902900500b0016cf62c4376mr2913250plp.87.1659634794631; Thu, 04 Aug 2022 10:39:54 -0700 (PDT) MIME-Version: 1.0 References: <20220804025121.4001361-1-fengwei.yin@intel.com> In-Reply-To: <20220804025121.4001361-1-fengwei.yin@intel.com> From: Yang Shi Date: Thu, 4 Aug 2022 10:39:42 -0700 Message-ID: Subject: Re: [PATCH] mm/memory-failure: release private data before split THP To: Yin Fengwei Cc: linux-mm@kvack.org, naoya.horiguchi@nec.com, linmiaohe@huawei.com, willy@infradead.org, aaron.lu@intel.com, tony.luck@intel.com, qiuxu.zhuo@intel.com Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=imlRuUV3; spf=pass (imf04.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659634795; a=rsa-sha256; cv=none; b=f+/2W0yG7eOnJ5qvdAqpsmY0AKcmxyKavpQAOucUDowGRqNPvUhBE5C7euXp0148JJMkzn 4+14Pi72oO8pVzRsaYNypzEA+od0tJW5Rncjtchp2EVwG7w0PcIt3ienXIOaHV5zwktx6w pSneGpgO1gsyyTvYIRGdrgWiNbSD5I4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659634795; 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=KocIm5VC42oplais5i/SWrfsniRfwjAg+AY21sI7Jk8=; b=old56yduKTZQGSrjdxfyVncISffMfOixVkVRx8Yv3m4o7GqDAyDdqGMN/MnrABd36f4an4 jO6L01W/pRgIIEB8nfngq6COZUW1sD/w3FpZmqDzV1V8O51jPqMIN1MZG5F05r0jKqzpU8 EV2sXUXatzYTONpuzy8i5D18Tkdm6dA= X-Stat-Signature: xczqfic5gsu68nyi4d4tugmfb78nensx X-Rspamd-Queue-Id: C6F4840009 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=imlRuUV3; spf=pass (imf04.hostedemail.com: domain of shy828301@gmail.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1659634795-678236 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 3, 2022 at 7:52 PM Yin Fengwei wrote: > > If there is private data attached to THP, the refcount of > THP will be increased and block the THP split. Which could > further cause the meomry failure not recovered. > > Release private data attached to THP before split it to > increase the chance of splitting THP successfully. > > The issue was 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. Yes, now we have more file large pages/THP than before. The patch itself looks good to me. But I'm wondering whether it is better to release buffer in split_huge_page() itself since other callsites may experience the same issue. Before only anonymous and shmem THP were supported so we don't have to worry about the extra pin from buffers, but it may be time to consider it now. > > 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 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/memory-failure.c | 16 ++++++++++++---- > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index b864c2eff641..ef87741b0fea 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1484,16 +1484,24 @@ 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); > + > + /* If split_huge_page success, folio could be different */ > + folio = page_folio(page); > + folio_unlock(folio); > > return 0; > } > > base-commit: f86d1fbbe7858884d6754534a0afbb74fc30bc26 > -- > 2.25.1 > >