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 4A2E8C433FE for ; Thu, 7 Oct 2021 16:06:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BFEE06103C for ; Thu, 7 Oct 2021 16:06:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BFEE06103C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2C9BF6B006C; Thu, 7 Oct 2021 12:06:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 278C7900002; Thu, 7 Oct 2021 12:06:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1405F6B0075; Thu, 7 Oct 2021 12:06:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 049386B006C for ; Thu, 7 Oct 2021 12:06:42 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A537C2DD7C for ; Thu, 7 Oct 2021 16:06:41 +0000 (UTC) X-FDA: 78670119402.11.CF82CF3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 5C21FF001D03 for ; Thu, 7 Oct 2021 16:06:41 +0000 (UTC) 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-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-600-TuH4f6ZOMfSOly75j7aimw-1; Thu, 07 Oct 2021 12:06:38 -0400 X-MC-Unique: TuH4f6ZOMfSOly75j7aimw-1 Received: by mail-qk1-f199.google.com with SMTP id w2-20020a3794020000b02903b54f40b442so5642523qkd.0 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=EXrJqb5ahhDHmnIoPCtSHI5cXzf3McCxfnqJprM+1KjCZxggQbyQPh8QdY0UxrmS0Q I09zDbzVmaRIUcPqsxhe11sESofclgZ2bS7KaV9jExL0Ll9MIVRncfBb0bCFCAOLtEXg f0/BaY4DbR7F1y0a6/OAYhPSb6SdtqvLpH4OpryIVyI1QAXdwIf2kpKmAGg9Vk/EByPW Wy+YdNnIP7zFDXiMdhwl2pBfMGgbzSvMPkMsN4MJzaWew7sfkW9HWyUAP8erwYC9l2Gl 5Hj1mssld4p3732aHrYVuaSJ/3yniGdA5GlPapT5pjO/dFBaCFPqSfeWbZaQynMzVAYy 4eBg== X-Gm-Message-State: AOAM533pYZsM9ucAHwTY+4UAW40O6EWkUQPtvCibCbRWdj9516Ng5cwj iwAPBLYYqys6UzJ0B9J0MkkybApfjH3oK5+zki214VLdXyXL4yl30znXkAlin7CUPj+jIRe46+4 UJW3mhX2nMZw= X-Received: by 2002:a05:622a:316:: with SMTP id q22mr5879951qtw.225.1633622797393; 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 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 5C21FF001D03 X-Stat-Signature: xxytecwetssaaydmskbb38jd4au5dfth Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dqnJL0pr; spf=none (imf11.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1633622801-186812 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 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