Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1773278pxb; Thu, 7 Oct 2021 15:02:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAlFgrqAOrOLsV8XiKo2175MLAfHyFcLnk0ZmJ9XJu4wKnpx6GAhRpKhXzOf6110BKLIs9 X-Received: by 2002:a17:906:11db:: with SMTP id o27mr8344952eja.540.1633644148167; Thu, 07 Oct 2021 15:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633644148; cv=none; d=google.com; s=arc-20160816; b=M0tUydGgckUXJdQxd4VspJhXwzohFxEEzNqK5ZoxwoSDy4rkLmdFocABG81u9XR36Z 6CwNLL9yMmc7GXzmaXkgS1Fai5PfmyHWLvcGiKIQSxfQDr/VCf9J3mCOuN9EDHIgUUXE usDcGr949iHn5ATEiZ0PwRjU2RxcfoirroQvE0DDa10rTld0rMdQtIF1fQTb6cM58CRc IfW5ogY8T5DTHa4erYHDK7czo5wpx6EnCOEymEXGUn2B4G9Cr+CMHEbXWX+qqlL66lwq YVsMM1pPOB/FdpfU+yFp0ALZ5BEnbDTaMb2xVUbBdoxH6gvbZW0A9uJkpaVBa4UHKlfn ng/A== 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=iLeSFUziBQBa2nfyLYU7/W4j+xBwKu7dSm2xdvN4YL4=; b=hnvKUAPOkHn3Q64KTL7Wf6r8eMD5cNrGcFWB6gjzmdDJb2rgcw8DlOnkwasEeHswze 9FhQTfitCLHSn1wNtwq/K+a8h7id3Uyxlu5qrECP2tDDkD0/te/hACA7VaW4lkxaObYp 8HlLAc+JxIfgjHSH8cszEfOZmFMjj6E/IbhkbVwXOeFo5MGsMTli+zSOvqGLSXudHpvJ nFWmCyXIZ0pQ+PKCuCDPrE7e4qlRcEOr9EXAL6NSjDwYFShVgm3KksKDYHtBlr6sqn2L eD23ABdhthS4BE1DWNiMjqGd6dQb+0nYdrU2Z+idm3U5kw4eHunB0KTB0kLJvtp4aqyo T7gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=m8okmC3z; 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 n10si1151995edx.60.2021.10.07.15.02.04; Thu, 07 Oct 2021 15:02:28 -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=m8okmC3z; 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 S243571AbhJGSVY (ORCPT + 99 others); Thu, 7 Oct 2021 14:21:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233844AbhJGSVX (ORCPT ); Thu, 7 Oct 2021 14:21:23 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4769BC061570; Thu, 7 Oct 2021 11:19:29 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id l7so26600506edq.3; 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=v8kxt76PzGIJ5Yvb4z9vZ+Qv218tnCXzGWBKCedSAITnB+H7P9WpMEGYC4gCGqeBLO qZN5baoT0p5Xd5LTpA6NGr6uz4dXkpEBHS1DDJAb/vD9huU1QdXbxZYgHEQJUWXpdNjD QlasByzab0tCzT1TDoonoEXbbA5yJ5B95Hx+BFMrGxZ05Cls+admytaekWwU+tdb7dcR g4bvpJJQSd8N1BziH+/tgOkNBmCc4b9wPf3FfsOtggcjL4WxXRHGwmDjVCEiXFuJWK4c oLt5EJWOdtGYVC+rOaF5xUAr7uKKu8LoCNtQWBIBDWq7FxvMFLXmb9ArZ9H72CM6Zcs6 EFTA== X-Gm-Message-State: AOAM531lv3lzGnsBqn4/ZHMRV8w/afHnRuLv1DRV3Jnm8SiJI8hDUGAi 1A60xa+/tXIhuA/Zsr+joObQEmibOEt4YdL5cYo= 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >