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 5F918C433F5 for ; Thu, 7 Oct 2021 18:19:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F1B2061040 for ; Thu, 7 Oct 2021 18:19:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F1B2061040 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 36FDF6B006C; Thu, 7 Oct 2021 14:19:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3200A6B0071; Thu, 7 Oct 2021 14:19:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BFBD6B0072; Thu, 7 Oct 2021 14:19:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id 089136B006C for ; Thu, 7 Oct 2021 14:19:30 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AA7ED181958A3 for ; Thu, 7 Oct 2021 18:19:29 +0000 (UTC) X-FDA: 78670454058.01.86062AD Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by imf21.hostedemail.com (Postfix) with ESMTP id 66C4BD03BFD1 for ; Thu, 7 Oct 2021 18:19:29 +0000 (UTC) Received: by mail-ed1-f46.google.com with SMTP id y12so13189049eda.4 for ; Thu, 07 Oct 2021 11:19:29 -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=iLeSFUziBQBa2nfyLYU7/W4j+xBwKu7dSm2xdvN4YL4=; b=m8okmC3zr7UD9/li1nvBU2McS2L9K4AnobrF92DJzJ9Z9tffjsHoSEuW+70rUZvQMN AdcMSJJeZ4ZNvPIRAlqPGej2NlOHfSmJICDdNQgH/RpdSkyZfXsG8EKam4pcUn9IyT9s 5kJRYQGC9ejisi2qDiyq3DFRwiYYrkG/iNw4UAlFIZVkn/y6FfgKGZYBJGEBBvl6OzQh lhQMKI95h37zzezwhmFmIazKpRkpY7SDm612HQKvua2Vrzjl3pgSG9KcAJx5FOLl0boW H3jkue6ubrw2SwsdhyhLbt38/7/6b89HifwYOw7fuaEZQGx5GB88NOdRLIkde16ipsdc XdLg== 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=iLeSFUziBQBa2nfyLYU7/W4j+xBwKu7dSm2xdvN4YL4=; b=i2EuB3P9zaighKiUTt8vwDtpTEafdq1BgA6FhaA0HMU+d8op2MNWsQshVOgS3ySCvG nYKASMKuLVhdC9dfBovFxmGL2iQ9vRq9Wa5Z2UMkzEGNfhWuCYxJzAG/6ZVHDKnYOlp7 xULVEdLDBxIR3oFrrfLDw6uGQIeahbwowjW0I0Pf8Ai+nk5GPt1CblLtYK7aAeq8QYKQ +B9DxTdriYPaccpKeUBxPDV6tb7ZGRUt0pyScqW3Jgv3LiRg1p40vO6yQdUZopYX32zG Br6CZnCIzhADsUWY7+Bf+/1/xht3dMpl3s4YnH25BOAfsmj4QXQinQOWM7trZZRutWGu G8Fw== X-Gm-Message-State: AOAM533jloHHjXTP4/+g2UdDsqOoKSgAPiRZ5P2DO4pgkJaqSoNVqDqy M0kO59e8LNlpGK4c4n799+b6d0xxKCG7JGraeTI= X-Google-Smtp-Source: ABdhPJxoNh6UJJ8wPJQfMSzbLWFicPr+jLK/UU9HxPMV70hLqQy0n9zs3d+z/584Rcc28s0HGFyu+/EKZhfBZCyFhN8= X-Received: by 2002:a50:e044:: with SMTP id g4mr8162515edl.46.1633630767900; Thu, 07 Oct 2021 11:19:27 -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 11:19:15 -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: rspam02 X-Rspamd-Queue-Id: 66C4BD03BFD1 X-Stat-Signature: 6krrw41uu4ffpwc98e31n1upfnxojkp3 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=m8okmC3z; spf=pass (imf21.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.46 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1633630769-803775 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 Thu, Oct 7, 2021 at 9:06 AM Peter Xu wrote: > > On Wed, Oct 06, 2021 at 04:57:38PM -0700, Yang Shi wrote: > > > 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. > > */ > > But I still think setting the subpage-hwpoison bit hides too deep there, it'll > be great we can keep get_hwpoison_page() as simple as a safe version of getting > the refcount of the page we want. Or we'd still better touch up the comment > above get_hwpoison_page() to show that side effect. > > > > > > > And I think we should set the flag for soft offline too, right? The > > I'm not familiar with either memory failure or soft offline, so far it looks > right to me. However.. > > > soft offline does set the hwpoison flag for the corrupted sub page and > > doesn't split file THP, > > .. I believe this will become not true after your patch 5, right? But THP split may fail, right? > > > so it should be captured by page fault as well. And yes for poison injection. > > One more thing: besides thp split and page free, do we need to conditionally > drop the HasHwpoisoned bit when received an unpoison event? It seems not to me, as the above comment from unpoison_memory() says unpoison can encounter thp only when the thp is being worked by memory_failure() and the page lock is not held yet. So it just bails out. In addition, unpoison just works for software injected errors, not real hardware failure. > > If my understanding is correct, we may need to scan all the subpages there, to > make sure HasHwpoisoned bit reflects the latest status for the thp in question. > > > > > 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. > > Right, maybe that's also a clue that we shouldn't set the new page flag within > get_hwpoison_page(), since get_hwpoison_page() is actually well coupled with > MF_COUNT_INCREASED and all of them are only about refcounting of the pages. Yeah, maybe, as long as there is not early bail out in some error handling paths. > > -- > Peter Xu >