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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B102CC433F5 for ; Mon, 1 Nov 2021 19:05:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3FA5F60F58 for ; Mon, 1 Nov 2021 19:05:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3FA5F60F58 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 50BEF6B00BB; Mon, 1 Nov 2021 15:05:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BB6F6B00BC; Mon, 1 Nov 2021 15:05:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 382F16B00BD; Mon, 1 Nov 2021 15:05:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 223DC6B00BB for ; Mon, 1 Nov 2021 15:05:48 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C7D8F3C67B for ; Mon, 1 Nov 2021 19:05:47 +0000 (UTC) X-FDA: 78761290734.30.52F3399 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by imf01.hostedemail.com (Postfix) with ESMTP id 85EE1508C366 for ; Mon, 1 Nov 2021 19:05:37 +0000 (UTC) Received: by mail-ed1-f52.google.com with SMTP id h7so68269363ede.8 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=6MBt2mRHqksF7f/BKbgP98+S4hMzUlPaEd6z1HYPQ+oDkcXQ79Izd9eh84BDT9c4ek IrPhxGeqysCpv2ro5RGpsdpaKvXEn9yHOkD8LELd77i1tNrW5yDRAYwBr6+8TOFnNitA 6+dzgc2cPeYn98TcFIFzoNQLrOoxTfP95YKjizFBgcXZR0TOoyJGQh9hVr8GEF1baSTz +oYIImQu2QuDkcwXu7cCXL4UWIDejMYE2QXlr7MuU0AK+TD/l0TAns/aPbXeTjs6rFKS xJ2TMl9KpcJGZ3NteidxiRGQDVugJtYUsz9JFt39OssNbpd2yRRfjB3AaPd6RBCoYP24 /fEQ== X-Gm-Message-State: AOAM533OZOvANo9enX45yKj5CrhFbwkZ4ZCyptZ/4cV7IPMfEeHDYgy+ XVV8IJuph3uHYM4jmIgkxvER7i3hMz4r+IwskyKZlA== X-Google-Smtp-Source: ABdhPJwm9tqfzMwKrynpgXZqW17xbGvx5x4ZefxF1ARwrFkZgkhlyGDPME39ifBybz9u/RIFdwDlKH/D7dG3hxwvT38= 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" X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 85EE1508C366 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=V9CryaeG; spf=pass (imf01.hostedemail.com: domain of naresh.kamboju@linaro.org designates 209.85.208.52 as permitted sender) smtp.mailfrom=naresh.kamboju@linaro.org; dmarc=pass (policy=none) header.from=linaro.org X-Stat-Signature: uemizcfku5j34rjetyrpf5c44d83qj1j X-HE-Tag: 1635793537-268449 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: 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