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 3EF46C433EF for ; Thu, 7 Oct 2021 16:06:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25EBF61038 for ; Thu, 7 Oct 2021 16:06:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242543AbhJGQIg (ORCPT ); Thu, 7 Oct 2021 12:08:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49969 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241776AbhJGQIe (ORCPT ); Thu, 7 Oct 2021 12:08:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633622800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2f7G2WKXlw2VVvH2sPBaPxflHdQi/DqI+SXI7iCozBY=; b=dqnJL0prfXgWYQIQoK/pU5YgSeb/v2fbfGLnAyF30AUtE6Vh8nW9umXp16LNULAHUBhXTe szrw+fDeRgcvblFVKz2Okun4JL4ZxYERgxNSNL8n+Egx8+zNIKhRLblZCTjbfy6g8Haqr6 lEqj66akDoAvrADCJRNAfsj3ha+Y8X4= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-600-9WYIRdrlPzCB0_bTyCZHJQ-1; Thu, 07 Oct 2021 12:06:38 -0400 X-MC-Unique: 9WYIRdrlPzCB0_bTyCZHJQ-1 Received: by mail-qk1-f200.google.com with SMTP id k3-20020a05620a414300b0045e623cd1afso5542647qko.20 for ; Thu, 07 Oct 2021 09:06:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2f7G2WKXlw2VVvH2sPBaPxflHdQi/DqI+SXI7iCozBY=; b=RJDlXKkKV/CQ/Nk61GGCM/nUj+o+t9TJwhMJ6XSPe/o4iMwypa/AMXZF9S4y9ONeoC 7+qD7MYfpLUCmC92xIFkGoCALT/VOzsOM3cNbewGoqUwFes1ctWLfUMLBYOOGxHhpUgt DoALtLJ1G9Xpa8UEDs8Ckb1Zt2GVr3yXpwmeJWadmk5bzIj+LaaQCOMrZgoczXap0RSW 4Njx5KoX/xkf449H929tIR11DGixGYigDE9c7LjPZ1V0Ru4bcf8jmA2Bv4faMzdEZGX/ K5eGiyyxsV9ATxYz1iWawibaS7VspY9FwKlyu7NAYFhGatumFQtUVehEfbDv/9Mm6t3M ItNg== X-Gm-Message-State: AOAM531yT/lnHfl5n8eAT6JVkUAjWtYlEug5lCRSgnvI+9puSsA2Y1A6 bj7UwU/25/lzX6SDFGBkVTpODXEfWx7FVDrt5INKFWU+4WEjeHGinS8OZx86s3gfVW7oLHVvxzz kIzPuMQeMDolxvav4CURU4Ctn X-Received: by 2002:a05:622a:316:: with SMTP id q22mr5879946qtw.225.1633622797389; Thu, 07 Oct 2021 09:06:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQLtzYt82r2CQEo/KkLz+OGcn7fBHhOWmfQckkRZ52geA1vPZXzGXWU4k0xWh+LgMLH0BJxA== X-Received: by 2002:a05:622a:316:: with SMTP id q22mr5879906qtw.225.1633622797114; Thu, 07 Oct 2021 09:06:37 -0700 (PDT) Received: from t490s ([2607:fea8:56a2:9100::bed8]) by smtp.gmail.com with ESMTPSA id a16sm13820149qkn.16.2021.10.07.09.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 09:06:36 -0700 (PDT) Date: Thu, 7 Oct 2021 12:06:34 -0400 From: Peter Xu To: Yang Shi Cc: HORIGUCHI =?utf-8?B?TkFPWUEo5aCA5Y+jIOebtOS5nyk=?= , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oscar Salvador , Andrew Morton , Linux MM , Linux FS-devel Mailing List , Linux Kernel Mailing List Subject: Re: [v3 PATCH 2/5] mm: filemap: check if THP has hwpoisoned subpage for PMD page fault Message-ID: References: <20210930215311.240774-1-shy828301@gmail.com> <20210930215311.240774-3-shy828301@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > 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? 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. -- Peter Xu