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 AA24EC433F5 for ; Thu, 7 Oct 2021 21:28:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 45B3861073 for ; Thu, 7 Oct 2021 21:28:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 45B3861073 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 74DEA900002; Thu, 7 Oct 2021 17:28:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FCF86B0071; Thu, 7 Oct 2021 17:28:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EBA5900002; Thu, 7 Oct 2021 17:28:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0172.hostedemail.com [216.40.44.172]) by kanga.kvack.org (Postfix) with ESMTP id 4F87B6B006C for ; Thu, 7 Oct 2021 17:28:50 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EA27E18036181 for ; Thu, 7 Oct 2021 21:28:49 +0000 (UTC) X-FDA: 78670931178.01.1703FB0 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf16.hostedemail.com (Postfix) with ESMTP id B3FAFF001391 for ; Thu, 7 Oct 2021 21:28:49 +0000 (UTC) Received: by mail-ed1-f44.google.com with SMTP id a25so12521593edx.8 for ; Thu, 07 Oct 2021 14:28:49 -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=Tdt4Z6gD2SotM9uwBoNTC6A69WAvkEP9uA/es2f4JS4=; b=Cfe0j/2pn6srl6JwVwT8bmkvO+wYhRtDDv1zN9zG5YrUJHeQF9vH973c2rokmdxlX9 Xqs6VgzC+hqkI8npkwsUvtK8GG92bRK0CTb3SkDbiOC49eMqHiht71PzsxeXRm3ybBBU RZAZ15EDnfzffHDxqYnwTP6MIfFWue6KSqngkA6yFbvxAGC2Nk3nKYmsF6s6NgxMmWUp /Sbgb5ubtGhc7iPzOeHvEVZ1xsoAL4l6peXtkuYBped76CIsmFXnVq2nD4t8KUb3mv83 wBB0QwhRmvm7nvgSoD7Rnpv1oOvBvvV9+Zv1V/gthePStZhT79eH8oe0psbopfU0niam aB6w== 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=Tdt4Z6gD2SotM9uwBoNTC6A69WAvkEP9uA/es2f4JS4=; b=09ybE+9r31bZbtwt/oCESj3OxZcPESxmhQzCdqJQ4j+D+5iG51C2Xmk/JBsgTp+vo1 +WEtedQxFjBJk9smzTX9WpA1LjSG0FKgEnR0sT4bKp5lUl4z1HeftV7akAefJ0Dr4I8g Xjitv04BJsjAYXUNYBS4/yG8sCiFZKPq8OfcXYFBwTjpZXGW9qw+6NObvCWIaG3Jk+IJ KfRR2W19d1ZlyUESnpzbYrsfmTzsVNtu2qDCT/YxUUpPbZ/zgeU/5RIEFbyO/RhG7DRP NrRwWxICAmAZBbMnO6hmWF+uRFQZ3FkrdrtErThZaCDE4OIqswJzjFNu9j8LGteWJF4E 8jSA== X-Gm-Message-State: AOAM5323L3hBnKmgjp/gEMPIR4U76PxKobe9U3Cv3vhsdGf4sMcSQgG6 V9wjsgeKK5ybzwJwpz+hr2iTIlAkhW7b2XEusxg= X-Google-Smtp-Source: ABdhPJwHkpqhpEJHk4pkSK+KRd3OlC6ir1ygi5FBtU+rV+Hkg2+HxQdGjDo1rMbJYY+cRLTQIipIoIhIIBl/0K9D7r4= X-Received: by 2002:a50:ff14:: with SMTP id a20mr9740127edu.81.1633642128408; Thu, 07 Oct 2021 14:28:48 -0700 (PDT) MIME-Version: 1.0 References: <20210930215311.240774-1-shy828301@gmail.com> <20210930215311.240774-3-shy828301@gmail.com> In-Reply-To: From: Yang Shi Date: Thu, 7 Oct 2021 14:28:35 -0700 Message-ID: Subject: Re: [v3 PATCH 2/5] mm: filemap: check if THP has hwpoisoned subpage for PMD page fault To: Peter Xu Cc: =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , 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: rspam05 X-Rspamd-Queue-Id: B3FAFF001391 X-Stat-Signature: no5i67w5dw8ifdgsxefey83ctx1in44r Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="Cfe0j/2p"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf16.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=shy828301@gmail.com X-HE-Tag: 1633642129-535380 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, Oct 6, 2021 at 4:57 PM Yang Shi wrote: > > On Wed, Oct 6, 2021 at 1:15 PM Peter Xu wrote: > > > > On Thu, Sep 30, 2021 at 02:53:08PM -0700, Yang Shi wrote: > > > @@ -1148,8 +1148,12 @@ static int __get_hwpoison_page(struct page *page) > > > return -EBUSY; > > > > > > if (get_page_unless_zero(head)) { > > > - if (head == compound_head(page)) > > > + if (head == compound_head(page)) { > > > + if (PageTransHuge(head)) > > > + SetPageHasHWPoisoned(head); > > > + > > > return 1; > > > + } > > > > > > pr_info("Memory failure: %#lx cannot catch tail\n", > > > page_to_pfn(page)); > > > > Sorry for the late comments. > > > > I'm wondering whether it's ideal to set this bit here, as get_hwpoison_page() > > sounds like a pure helper to get a refcount out of a sane hwpoisoned page. I'm > > afraid there can be side effect that we set this without being noticed, so I'm > > also wondering we should keep it in memory_failure(). > > > > Quotting comments for get_hwpoison_page(): > > > > * get_hwpoison_page() takes a page refcount of an error page to handle memory > > * error on it, after checking that the error page is in a well-defined state > > * (defined as a page-type we can successfully handle the memor error on it, > > * such as LRU page and hugetlb page). > > > > For example, I see that both unpoison_memory() and soft_offline_page() will > > call it too, does it mean that we'll also set the bits e.g. even when we want > > to inject an unpoison event too? > > unpoison_memory() should be not a problem since it will just bail out > once THP is met as the comment says: > > /* > * unpoison_memory() can encounter thp only when the thp is being > * worked by memory_failure() and the page lock is not held yet. > * In such case, we yield to memory_failure() and make unpoison fail. > */ > > > And I think we should set the flag for soft offline too, right? The > soft offline does set the hwpoison flag for the corrupted sub page and > doesn't split file THP, so it should be captured by page fault as > well. And yes for poison injection. Err... I must be blind. The soft offline does *NOT* set hwpoison flag for any page. So your comment does stand. The flag should be set outside get_hwpoison_page(). > > But your comment reminds me that get_hwpoison_page() is just called > when !MF_COUNT_INCREASED, so it means MADV_HWPOISON still could > escape. This needs to be covered too. > > BTW, I did the test with MADV_HWPOISON, but I didn't test this change > (moving flag set after get_page_unless_zero()) since I thought it was > just a trivial change and did overlook this case. > > > > > Thanks, > > > > -- > > Peter Xu > >