Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1711906pxb; Thu, 7 Oct 2021 13:29:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/FFtHnDAOEQorceFG4mtajVI6qs2VmAyHUy8HkCZLe7bbPcIEmnrT8IPBugsDd5E0G9Ny X-Received: by 2002:a17:906:5d6:: with SMTP id t22mr8325618ejt.98.1633638598844; Thu, 07 Oct 2021 13:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633638598; cv=none; d=google.com; s=arc-20160816; b=Qa/aHxOCBR1XlasQCTeX5uMdDfQeHJsTB3467JN147/O0LGyccUJIVEeT+D3M4su3y so8vFxKNPUHkTa8to+yyLzfwuDCT/zMkx7pA1oRN8DudeyVLtfsYPtQdPY/x1xOIaLo+ k6tfpKOtZllk+xnEHFRxwwv+5JOdCxzCHSAFglyzObLB7D7+DyCxpzKkuYYCT7QBwbaA ndREwiyTJjNawraDlT+fqCrT6rUC6KmAvINbgAtbpKyc8D+8KFCx8vIFmc49RWIwLX/c vpAuSXI0shZzgvXPHkD8CMmjFtt7fMCFzcyM+z1H7bOEABJ/lqKRqx3EMd6qVX1aBE6x DOCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=meVJZ/Jk9W+dixJB/LuoRy3/ra68qi2MQkPwKdp2JR0=; b=EBLRFCu365GI4oAFmF2EeXx3yx2tWTVUvkLVOWV6fs5iDfEb33BXQfaK75A+uk/XQN tqge2YfgnyQdh8zfdZkRvugqNFLXY29GjRRN9Za1UNfZ/5w+4sf2hf1D3E8XOaY7Qww9 gswaziubhFnTrAAN41pNsHbbahps9EBeZiMQmIVtspMAgYXurt0vN6wUCwSiJh2Fl8AB ja4RS+FxaYoxMJv6LC1+G4loK5xHhzV7d6dOrlniYI9NVa6nYtdrnPXd41fvGBL68wzI dh4bvJmbYPKVCiXHQNqGttDGxv1F/sejLuEx6QRKK9IlpfZsXEZrQX3A6MOd9bQLyKsz m2Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dC3cFYY7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 2si417290ejl.511.2021.10.07.13.29.33; Thu, 07 Oct 2021 13:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dC3cFYY7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233719AbhJGU3U (ORCPT + 99 others); Thu, 7 Oct 2021 16:29:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbhJGU3T (ORCPT ); Thu, 7 Oct 2021 16:29:19 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CBC1C061570; Thu, 7 Oct 2021 13:27:25 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id v18so28036926edc.11; Thu, 07 Oct 2021 13:27:25 -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=BM/9pA0Agfuq5w7F1CJeSiWoJjirD4EQtH4zT0U2gDI1pI7VVsmTPzBQwHn4S6ZOv1 8azR8CS+FGhqgAnng5GyxWVAhaiI9C9wAsk5bl07fqV+gljE9Vs8f6mkqS875DceAU82 LVIt8ZK9dbR0d9N7uZVPr0l9gJdYlDI33hkpF27Rx4d/s3GX33ckOZvHHDrxTKW+PuPN TdyFsoldK2Do0OWRhPP+XLCtM4RKgGmSLFOWlL86ujY6jZ3uSTgLrD86yyKDVaxyjnII Lb76GmFAFfIfBqxFuNaelc0jSohaCMk5G5+CzRS1ghCJCimfUkeTaPOUlT0CoGlt1nHb Qq0A== X-Gm-Message-State: AOAM530H2ZyCHYriK/I3q00Xc5n6kTvxNBiChxwaMsfCq00ezD8o1Bc3 E4OBS8X5WYHwSZJRIVhDoGv8WBzhG4DizJnUwBE= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >