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 3207DC433EF for ; Fri, 1 Oct 2021 21:08:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A1ACD619E7 for ; Fri, 1 Oct 2021 21:08:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A1ACD619E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3401894014A; Fri, 1 Oct 2021 17:08:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2EFC9940121; Fri, 1 Oct 2021 17:08:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B7DA94014A; Fri, 1 Oct 2021 17:08:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 056F4940121 for ; Fri, 1 Oct 2021 17:08:12 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id AF37A3C66A for ; Fri, 1 Oct 2021 21:08:11 +0000 (UTC) X-FDA: 78649106382.19.848F95A Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by imf25.hostedemail.com (Postfix) with ESMTP id 63D33B000E26 for ; Fri, 1 Oct 2021 21:08:11 +0000 (UTC) Received: by mail-ed1-f41.google.com with SMTP id v18so38315367edc.11 for ; Fri, 01 Oct 2021 14:08:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xsjTuS01OWyAiv5jzPDJK7nI7OXAtfzB78KCIx/PZ2s=; b=nmjVVVJUzIaGOMd2Ez9MncVBsQftTFkxVlmU81mHfpKglskE8/1IJ8cU4Rx9bvp1KH APKmkczWks8+GdpU1gnbKg3qoY80lATu4fOvBksxGg/ZTlzo4I4svGKdC9aBfYYGXwER ukWCBRkNXxe5f24KiUPXc15tBuEmh38tUJYn/0mnKKLk0wZ72ZrS1u1d8cObVGBsJH82 ZcYiXNfZAUnk1JZDObr+iH4YIlRsxJnzroIpelTIWtU7RWn+QNRHe2wgJ7Bd7chnsUv5 d+58J/52gRlQiAGPBvB5PTVY/7F4g+4ATUNYYOk+FrULDR9tO3tHQ6oHfM9JuuShGXNr BScg== 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=xsjTuS01OWyAiv5jzPDJK7nI7OXAtfzB78KCIx/PZ2s=; b=5AqQcfpr8+2RWPZXtMqGLoCdFzFV6WfKlOxgHS/sgKbTxxprby9MSOS6HIIIy6nRsH 2Uwa8lLnGFQpSxFe0ejdVZSDXlkkncVbtFK42hJ1vWMokHMVK5Au67hDw2Q8/gXyUhJm 7UxykSCpZx5vAcxdhN2Lqp0urLTTgADg9LIozR1+IlKDuRhKBShXWVjH18yuUSUZ1rhX SCGPwMcq44sPGFjQrE7ZMREFG7c4piGqCQ+MvzQXrP11wTJOeVm6HAjC/1FO118vvybu uLz0Z57ikBkWH+fOjGoH5BrVTWXo4L3Lj4DRGO9167SnPF05Odq0+VFhsr+9x+Ij4TFa Ta2g== X-Gm-Message-State: AOAM531xwzJg5JcVRo2Qqx9gCh8McwA5uUz5O41zjo9P3qhfsk5HsI9P ViHF6ixfBSS+9Qoq86s+IxE1tmFef01V6h6GGaM= X-Google-Smtp-Source: ABdhPJzaxRyXbpY5V9tLY9TTm6Jg0RXZDwe28BXKRxqBijswVUPXv+dFb8IhcLIVyB9Bg/oQv+znrRMt50zGtM2djtw= X-Received: by 2002:a17:906:3854:: with SMTP id w20mr63006ejc.537.1633122489844; Fri, 01 Oct 2021 14:08:09 -0700 (PDT) MIME-Version: 1.0 References: <20210930215311.240774-1-shy828301@gmail.com> <20210930215311.240774-3-shy828301@gmail.com> <20211001072300.GC1364952@u2004> In-Reply-To: <20211001072300.GC1364952@u2004> From: Yang Shi Date: Fri, 1 Oct 2021 14:07:56 -0700 Message-ID: Subject: Re: [v3 PATCH 2/5] mm: filemap: check if THP has hwpoisoned subpage for PMD page fault To: Naoya Horiguchi Cc: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Peter Xu , Oscar Salvador , Andrew Morton , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 63D33B000E26 X-Stat-Signature: ejee3otj4mhr9nhqyw4w5fdnqdmdiofi Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=nmjVVVJU; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf25.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.41 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-HE-Tag: 1633122491-894390 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 Fri, Oct 1, 2021 at 12:23 AM Naoya Horiguchi wrote: > > On Thu, Sep 30, 2021 at 02:53:08PM -0700, 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 > ... > > @@ -668,6 +673,20 @@ PAGEFLAG_FALSE(DoubleMap) > > TESTSCFLAG_FALSE(DoubleMap) > > #endif > > > > +#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE) > > +/* > > + * PageHasPoisoned indicates that at least on subpage is hwpoisoned in the > > Maybe you meant as follow? > > + * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the Yeah, thanks for catching it. It is a typo because the flag was called PageHasPoisoned. But "poisoned" seems ambiguous for some cases since, for example, some memory sanitizers use "poisoned", so I renamed it to PageHasHWPoisoned to make it less ambiguous. > > Thanks, > Naoya Horiguchi