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 12851C433F5 for ; Thu, 7 Oct 2021 20:27:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 894FD61074 for ; Thu, 7 Oct 2021 20:27:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 894FD61074 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 BB5D26B006C; Thu, 7 Oct 2021 16:27:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B64C86B0071; Thu, 7 Oct 2021 16:27:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5316900002; Thu, 7 Oct 2021 16:27:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0193.hostedemail.com [216.40.44.193]) by kanga.kvack.org (Postfix) with ESMTP id 927726B006C for ; Thu, 7 Oct 2021 16:27:25 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 43DAE2BFA6 for ; Thu, 7 Oct 2021 20:27:25 +0000 (UTC) X-FDA: 78670776450.05.DE43AA2 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf28.hostedemail.com (Postfix) with ESMTP id 0B2BF9000841 for ; Thu, 7 Oct 2021 20:27:24 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id g8so27727342edt.7 for ; Thu, 07 Oct 2021 13:27:24 -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=meVJZ/Jk9W+dixJB/LuoRy3/ra68qi2MQkPwKdp2JR0=; b=dC3cFYY77OUrg+THR4IJ3I2oKuVLU5NSml5IEdGdu6ALMQsgw7cGj1UOTk+KnVafC8 WmMnI2+MGrYTNPMEsAYvM4Zu3CRhN0teC0n5DOZhRZciYUG0Fetg16qbxTcZSNhMU3Tp JujjjOUoFS9YamfOmoBzKq+V5TbhO0vk9t7lUAk4L0/vHkvXFyak1xXYvDGIebJ23aq2 hi3trJbkmsgYlk7Khk9I6T4vZwH4CJZBuaCXtD+hptTOB3SCIMtJkwQ0mkb5DMCW6IZd nJkx8OiRHss3dQDysCNPuNadNVY6furpZhVuSqTjCWtr3RfsdfqzJJkpTiDpXQsGaCUT 1+pg== 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=meVJZ/Jk9W+dixJB/LuoRy3/ra68qi2MQkPwKdp2JR0=; b=XYO5mbLAZJ/L09DhxNdYIsspdwjnAfspYEzq95MYWdLfkj8L44RuBlssD/QBmMnhYQ dJH34s+/FscWwehhfNJhLGowqfbTrsZz0ODfk/pw1r7hGR1cqakI9oDMDtVPHUsBRSuc Rd1ByDI1d9oOA/7QpphnkZLhvWwugOWbfHy2nnq9ZxYd81DPNejR/Kb2m6upVGHFW6kP 9rF9OYAt+I42Pv2U+F5LMP1eFPreDG2UZvbmFhxSTP12RAigiCzo6uPGnkhMDoHVQxDY 5goCJIj1d176bnvIqUscW0q4v8my2voOMVTkthTaMyOTYDr/7/aUWmQ5kGDeMu9zghOv 4wRg== X-Gm-Message-State: AOAM532CNjpdgAvUBpXdWAZkSh+yWdWLMlYf8taVMAVzpwWZmULHDkWG ww9AQD9z5UlyA8co3pbDNf0aM+aRpZidU9eQHkY= X-Google-Smtp-Source: ABdhPJyVJJHP5DLZjFy9sZ2fQ4TiUIi7xOmAIdHWsergF9thozLAZHG3qA9EUTfaiTDl1+7P+HlIL3WfongsKIaiFx8= X-Received: by 2002:a17:906:c2ca:: with SMTP id ch10mr5567576ejb.311.1633638443670; Thu, 07 Oct 2021 13:27:23 -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 13:27:11 -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" Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=dC3cFYY7; spf=pass (imf28.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0B2BF9000841 X-Stat-Signature: p8efskhznin9ya13eqtxzu49giwmpc9h X-HE-Tag: 1633638444-296367 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 11:19 AM Yang Shi wrote: > > 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. It seems fine to move setting the flag out of get_hwpoison_page() to right before splitting THP so that both MF_COUNT_INCREASED and !MF_COUNT_INCREASED could be covered. > > > > > -- > > Peter Xu > >