Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3346127pxb; Mon, 1 Nov 2021 12:08:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0yMTWoKYFbuNKB1qhrmKPmS8X3mVVQMmqs/KC8OAsdgh0oD5x+Q/rp0Fv92qZlb0ohlvF X-Received: by 2002:a17:906:478e:: with SMTP id cw14mr22681468ejc.46.1635793725448; Mon, 01 Nov 2021 12:08:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635793725; cv=none; d=google.com; s=arc-20160816; b=rQOdwLiFfBswE/oeyRfOELhJtY3hz/VMK4iAcjAxHGfptf+FF8P8Z2XIsAtoRrsCFv Tp+E8rkxGXOCF5YpJ//6GA12EYCRBLWrMuwO+6gD438pE6wm97/sNyTRd4M+y2Gxs/fL UK1Y12lrF+lX0WP0VcEYIJh3WWZiNJ2RVa+jlMgCghUnF30gd/FnU3KLzH9SGu+j1ZPx uN2zZK4moEMcep3rv4FghzQb8bc2ZyyOHvZb2FuTbltDSAQmF3j1k6Gwv6SGt0Z0Zfs7 DCYdDFfRLnhA+TP23kOhJsjZU4qGy0C468qjEaJwcVX2Zo9LjawTkkTKrGz3W3OWjW7Y Dmeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Q6V7Gw56j1fbOP3L/JmtSKoHD83KSTcHq7sV63glnuM=; b=yzX6/lIg324dogE7ovdLvkKucrAV2mdBf4TvNHvql3FL7k1n0lbg2N7aogNZL4wO07 HnXC0G9b1SD+NLfQX5+ygOLRF+YWpmjDiZovg+7qQotDVYC3XGC2v9yVGnPSMaxmV9VM S5qL+HFNPIuWoe6vmLAgWtvOnjg1qQmTUnruVkdOgezdn1BWzDrE0UDDxbN8h/UXEXti b8gqgE0MVbC/D1j/XXXOIiMSK8WqNxrv0+87J1UME0Xk/YoeMzgTe/VUPT6Zdma04sNr d09y+GN+6shcbGo8NSe7Lx2ewtfVFn7eIl5o7DwH9dGVl2njf+5fX8jTZu9CEWq1NNOX JryQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V9CryaeG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si20902369ejk.205.2021.11.01.12.08.14; Mon, 01 Nov 2021 12:08:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V9CryaeG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230317AbhKATIZ (ORCPT + 99 others); Mon, 1 Nov 2021 15:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232533AbhKATIW (ORCPT ); Mon, 1 Nov 2021 15:08:22 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E13BDC061764 for ; Mon, 1 Nov 2021 12:05:47 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 5so66643965edw.7 for ; Mon, 01 Nov 2021 12:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q6V7Gw56j1fbOP3L/JmtSKoHD83KSTcHq7sV63glnuM=; b=V9CryaeGoSXaoWNsE+V00jDIPAmNV1syxOy51AzEYZDOm2hSiu8r86+/rVypbmV17c DIA2RfuwhJjEzuEEH0EdhVwygq0RtJRbjnQ0papVbpbz3wtQ/iQu2f/ZPqrDzZ1KOJKa JRNRsMnlO2JHvR4YOgQQgGsP8sitiDOXQLRdwwn4INumJS44SX3W2Hbrajw6JadDFiuM fHVXYeobtqBPr988Xt53NYAeGAPjtJwOUPtHVuu0/GLCd2vK7JWW73mhzNliL3Tyo3gx izH3YL9RFKHzPb3JeWJcTSScj2W7a3QHPA1ZH9PJiwaKzXEIlrv63jqDfNLmyJrr9eU/ fGvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q6V7Gw56j1fbOP3L/JmtSKoHD83KSTcHq7sV63glnuM=; b=E+PQhXDLnkgytccIXtYvfZCt/ZW2lpU7sGwlqF87mAq9nomELV7KjiO5DMVQenoMtF NTJ0sVXrZzRo3czWWdycIc8JBTWWnLHqCjcGRWsUoBkP9VVboNwEi8ecovbzsTS+VhtA 3ShDJ1/WFhnZo+h+QUX4Xa5i9tTPuztnNh7gJys1D3+WPAnEVdrXmQQmhKHKyjnKZD3R /YfIfIgbx3I5zH74QkPlu80OQ+Pumv4O+uoS4wDwtu3cuVvXBSxcXnwCdqv3lOlnqPyv Z9Agwwm2tHuKfz44nBJ5XTG2uGE+dv8avVCPRzGpo1P0345tKoZsUh96zVtsvWtshB2F e/kw== X-Gm-Message-State: AOAM532ggGDQlVLOTCed7ZvY1n7Czywmo57Qng0vdmUr5sbPfHVYwFWU dkBShXWlyFDc+0/GGLMVOjGDrwQVUn+J7BUGyP84hA== X-Received: by 2002:a17:907:76b0:: with SMTP id jw16mr15259982ejc.169.1635793545753; Mon, 01 Nov 2021 12:05:45 -0700 (PDT) MIME-Version: 1.0 References: <20210930215311.240774-1-shy828301@gmail.com> <20210930215311.240774-3-shy828301@gmail.com> In-Reply-To: <20210930215311.240774-3-shy828301@gmail.com> From: Naresh Kamboju Date: Tue, 2 Nov 2021 00:35:34 +0530 Message-ID: Subject: Re: [v3 PATCH 2/5] mm: filemap: check if THP has hwpoisoned subpage for PMD page fault To: Yang Shi Cc: naoya.horiguchi@nec.com, hughd@google.com, kirill.shutemov@linux.intel.com, willy@infradead.org, peterx@redhat.com, osalvador@suse.de, akpm@linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Greg Kroah-Hartman , Sasha Levin , Anders Roxell , lkft-triage@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yang, On Fri, 1 Oct 2021 at 03:23, Yang Shi wrote: > > When handling shmem page fault the THP with corrupted subpage could be PMD > mapped if certain conditions are satisfied. But kernel is supposed to > send SIGBUS when trying to map hwpoisoned page. > > There are two paths which may do PMD map: fault around and regular fault. > > Before commit f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") > the thing was even worse in fault around path. The THP could be PMD mapped as > long as the VMA fits regardless what subpage is accessed and corrupted. After > this commit as long as head page is not corrupted the THP could be PMD mapped. > > In the regular fault path the THP could be PMD mapped as long as the corrupted > page is not accessed and the VMA fits. > > This loophole could be fixed by iterating every subpage to check if any > of them is hwpoisoned or not, but it is somewhat costly in page fault path. > > So introduce a new page flag called HasHWPoisoned on the first tail page. It > indicates the THP has hwpoisoned subpage(s). It is set if any subpage of THP > is found hwpoisoned by memory failure and cleared when the THP is freed or > split. > > Fixes: 800d8c63b2e9 ("shmem: add huge pages support") > Cc: > Suggested-by: Kirill A. Shutemov > Signed-off-by: Yang Shi > --- > include/linux/page-flags.h | 19 +++++++++++++++++++ > mm/filemap.c | 12 ++++++------ > mm/huge_memory.c | 2 ++ > mm/memory-failure.c | 6 +++++- > mm/memory.c | 9 +++++++++ > mm/page_alloc.c | 4 +++- > 6 files changed, 44 insertions(+), 8 deletions(-) When CONFIG_MEMORY_FAILURE not set we get these build failures. Regression found on x86_64 and i386 gcc-11 builds Following build warnings / errors reported on Linux mainline master. metadata: git_describe: v5.15-559-g19901165d90f git_repo: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git_short_log: 19901165d90f (\"Merge tag 'for-5.16/inode-sync-2021-10-29' of git://git.kernel.dk/linux-block\") target_arch: x86_64 toolchain: gcc-11 In file included from include/linux/mmzone.h:22, from include/linux/gfp.h:6, from include/linux/slab.h:15, from include/linux/crypto.h:20, from arch/x86/kernel/asm-offsets.c:9: include/linux/page-flags.h:806:29: error: macro "PAGEFLAG_FALSE" requires 2 arguments, but only 1 given 806 | PAGEFLAG_FALSE(HasHWPoisoned) | ^ include/linux/page-flags.h:411: note: macro "PAGEFLAG_FALSE" defined here 411 | #define PAGEFLAG_FALSE(uname, lname) TESTPAGEFLAG_FALSE(uname, lname) \ | include/linux/page-flags.h:807:39: error: macro "TESTSCFLAG_FALSE" requires 2 arguments, but only 1 given 807 | TESTSCFLAG_FALSE(HasHWPoisoned) | ^ include/linux/page-flags.h:414: note: macro "TESTSCFLAG_FALSE" defined here 414 | #define TESTSCFLAG_FALSE(uname, lname) \ | include/linux/page-flags.h:806:1: error: unknown type name 'PAGEFLAG_FALSE' 806 | PAGEFLAG_FALSE(HasHWPoisoned) | ^~~~~~~~~~~~~~ include/linux/page-flags.h:807:25: error: expected ';' before 'static' 807 | TESTSCFLAG_FALSE(HasHWPoisoned) | ^ | ; ...... 815 | static inline bool is_page_hwpoison(struct page *page) | ~~~~~~ make[2]: *** [scripts/Makefile.build:121: arch/x86/kernel/asm-offsets.s] Error 1 Reported-by: Linux Kernel Functional Testing build link: ----------- https://builds.tuxbuild.com/20KPBpXK6K0bKSIKAIKfwlBq7O4/build.log build config: ------------- https://builds.tuxbuild.com/20KPBpXK6K0bKSIKAIKfwlBq7O4/config # To install tuxmake on your system globally # sudo pip3 install -U tuxmake tuxmake --runtime podman --target-arch x86_64 --toolchain gcc-11 --kconfig defconfig --kconfig-add https://builds.tuxbuild.com/20KPBpXK6K0bKSIKAIKfwlBq7O4/config link: https://builds.tuxbuild.com/20KPBpXK6K0bKSIKAIKfwlBq7O4/tuxmake_reproducer.sh -- Linaro LKFT https://lkft.linaro.org