Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1981754pxb; Mon, 11 Oct 2021 18:01:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAbP2Ldf9waAkaUzPevJy7o/2Q56rkQTda71wInB/APFEybtpf2yT/NHFxioBzfESGYc1M X-Received: by 2002:a50:e1cf:: with SMTP id m15mr46719012edl.309.1634000488692; Mon, 11 Oct 2021 18:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634000488; cv=none; d=google.com; s=arc-20160816; b=Puqt980wXbHJp3+y+cYgt36E1zoTi3LP/Ha3wsi+77BACOhdSHMI7uc7ZwvScJwcD5 q9DMmv86Q0Syfi2Slt36xnT9VLl0My4quSN6QrfKUFiC3RLmLy+HKeLA3ttATd4qZt7U WwGM/iqUq1z1SUu+CwkX2H68mdPZs7wQNkVSNTHglfBBUl55oUncS70O72ustJuLQcOL ZncZ96CPIgQNnmM5YVIt2jcToAQ9azAZ4kz0xOIhy3DEt8aEYbx1gV1IUaB56Pe7Aq5w 1+9E/gyNIaH1gMaf1yUjk0Mru+vU/wUA+cQAIDmr8XJx9f1VRsZWEjAVu5G16hPiNiMi 5wWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5XDAu3SGcluw99zx826t100OV6JMSzpG+T+53hkiL5g=; b=gdZycI1+gfCtOnsAE540flhOLsu3hMA6xUn99mCsVuWmFXvfz84PKJdCh6TR5szFaR ZRlvCpEMUDNub4zfC4wzoW2GWjB2bqpGvGbK9jttJAEg17CbTxVHXtejVngkNzC6+82m IkX7lE+lw08uzp7k8VhRIvTJK5H+SQ0hbdK96/9cXA2TByae0xTZisWmaFPmeXJHgcEu /gFhMD9D+GCdfGkv26jnp0m1EfqBnmFpWxTbIiBPOjY8kETZ94QJYtzMzcAcZAMJvmA5 8za5neGCSqgrAv7wRVA1vFcwN/gbX1d6xpgFTi0xKyWP7EfCdWJA/3Qvr9rYSojjO1iG C+Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K09u9CQ4; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si17589362ede.264.2021.10.11.18.00.55; Mon, 11 Oct 2021 18:01: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=@redhat.com header.s=mimecast20190719 header.b=K09u9CQ4; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbhJLA5j (ORCPT + 99 others); Mon, 11 Oct 2021 20:57:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53328 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbhJLA5i (ORCPT ); Mon, 11 Oct 2021 20:57:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634000137; 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=5XDAu3SGcluw99zx826t100OV6JMSzpG+T+53hkiL5g=; b=K09u9CQ4/2KFzfVf43Z08XpiGplBvJdyZZNnZwk6r3z23ioZxkIgxG+kt/spMGIb6us9nm AO+X4/dWyGvUOn+nygdHDuo11AsLb/zvM0hLU+H4FZQZE/tBfiXewQQbC3qxBfmikSWTgL tOT4RtVBm614aE3/jaTBWoWaFx6+t8g= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-ZsFZ4jbzPVeZJRJhiKLmWA-1; Mon, 11 Oct 2021 20:55:36 -0400 X-MC-Unique: ZsFZ4jbzPVeZJRJhiKLmWA-1 Received: by mail-pj1-f71.google.com with SMTP id b11-20020a17090aa58b00b0019c8bfd57b8so9904315pjq.1 for ; Mon, 11 Oct 2021 17:55:36 -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=5XDAu3SGcluw99zx826t100OV6JMSzpG+T+53hkiL5g=; b=mhHZJFnSb9nQCwnsNdy454YZMK8fYTOJCQEommOPvFLB6WoSgEhv+MsucjxKEtsrdB MojdI9b7WTEV04bpOU1T2FwUVb2ru+WY4lWfD8rRBXgrLtHPNi4be/cMsHWwdBFPDbdt OLdh4UZ/RXgSE5KHXmlE2R2xU7HwjbxqrxaENHaiZ0DdO4G/6BxA09RnpluW/m0vMYm2 Ha0ATTd+vDfQv9GCmHO8c80l9mBwWyDyvGgZ+Xr940rwAN3clE5ATbsxpQ0+NL06GJ54 78T8xCLGMd/YTVSj47b88+VWoHXgNmsLdNyJVBvQB6+/rytnMD45rMir0xbYAitvUlHY DERA== X-Gm-Message-State: AOAM533UNQoZPXhRPh2Ntb8f7b21SoOXPmp3j+lfljwntIiCc8pUVeqV aEQX+Je4GC7IS3YBMuwlgpj9YO0ZpN/3xQqYnaOVrxMuQUJa2njw9KTe+VJVmtDpUvCAPYRb8nU gghMeR9ZcW1lWKk8DOLNHwNmO X-Received: by 2002:a17:90a:5583:: with SMTP id c3mr2475848pji.133.1634000135079; Mon, 11 Oct 2021 17:55:35 -0700 (PDT) X-Received: by 2002:a17:90a:5583:: with SMTP id c3mr2475808pji.133.1634000134583; Mon, 11 Oct 2021 17:55:34 -0700 (PDT) Received: from t490s ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id z9sm578759pji.42.2021.10.11.17.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Oct 2021 17:55:33 -0700 (PDT) Date: Mon, 11 Oct 2021 20:55:26 -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 Thu, Oct 07, 2021 at 02:28:35PM -0700, Yang Shi wrote: > On Wed, Oct 6, 2021 at 4:57 PM Yang Shi wrote: > > > > On Wed, Oct 6, 2021 at 1:15 PM Peter Xu wrote: > > > > > > On Thu, Sep 30, 2021 at 02:53:08PM -0700, Yang Shi wrote: > > > > @@ -1148,8 +1148,12 @@ static int __get_hwpoison_page(struct page *page) > > > > return -EBUSY; > > > > > > > > if (get_page_unless_zero(head)) { > > > > - if (head == compound_head(page)) > > > > + if (head == compound_head(page)) { > > > > + if (PageTransHuge(head)) > > > > + SetPageHasHWPoisoned(head); > > > > + > > > > return 1; > > > > + } > > > > > > > > pr_info("Memory failure: %#lx cannot catch tail\n", > > > > page_to_pfn(page)); > > > > > > Sorry for the late comments. > > > > > > I'm wondering whether it's ideal to set this bit here, as get_hwpoison_page() > > > sounds like a pure helper to get a refcount out of a sane hwpoisoned page. I'm > > > afraid there can be side effect that we set this without being noticed, so I'm > > > also wondering we should keep it in memory_failure(). > > > > > > Quotting comments for get_hwpoison_page(): > > > > > > * get_hwpoison_page() takes a page refcount of an error page to handle memory > > > * error on it, after checking that the error page is in a well-defined state > > > * (defined as a page-type we can successfully handle the memor error on it, > > > * such as LRU page and hugetlb page). > > > > > > 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. > > */ > > > > > > And I think we should set the flag for soft offline too, right? The > > soft offline does set the hwpoison flag for the corrupted sub page and > > doesn't split file THP, so it should be captured by page fault as > > well. And yes for poison injection. > > Err... I must be blind. The soft offline does *NOT* set hwpoison flag > for any page. So your comment does stand. The flag should be set > outside get_hwpoison_page(). I saw that page_handle_poison() sets it, so perhaps we do need to take care of soft offline? Though I still think the extra bit should be set outside of the get_hwpoison_page() function. Another thing is I noticed soft_offline_in_use_page() will still ignore file backed split. I'm not sure whether it means we'd better also handle that case as well, so shmem thp can be split there too? -- Peter Xu