Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1016412pxb; Fri, 1 Oct 2021 01:13:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhME03axLzzhiZUKyGYztf/pMqy3FEg6BtADupZkezCUbCQxVKFHvoz2HNjeFfCblBi4VG X-Received: by 2002:a63:b04c:: with SMTP id z12mr8585561pgo.371.1633076031638; Fri, 01 Oct 2021 01:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633076031; cv=none; d=google.com; s=arc-20160816; b=oZfVkxTNn8gYSljXtHUpUfKGH1GMZhg0w33BVHRtitGxgFC1A95NtXSwcykWd3eXM1 4DUsWHXAm3sWPmTIzU0xIzvNBIPC7ahgywGqDehIzKSJnKLrY9WXCCI+6P03bT1yL4RM qwv0SI08aFdjQbSgkiikhjs2RGlK1vOSrl6kDYa7SvNgIq8CbwnltgFOYDF4RLaAnKbe uIuXNYz339pGABa4i8ee3oeaessfMj6S9QrfHL7E9flqbB1PSY8afNbUDeyklETtxY9B kHfNINy9ke+ZbRnpQ8vXbwqmb+tuzohYR4MVjmWIEvj+32DnVRmM29GH3xDdMZPflFXD 9zdg== 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:dkim-signature:date; bh=ymfgiYvTlJ3AQGX94b1sSvkk9jsxxsuG2lLJcwnPHCo=; b=A97KThwfZIRRDRAaAWNNKMje2419UqGEDzEIRWQiWPt6QWLVHy1ROEFYdtDlNZpU5X DMvm/GJiofNrwN2QbjNOpSHDZWFA7W2yaJStgSHk8tDddQCpkIkZl7GO5HNJViyIJ16d eGXGpH1vrFPvmvqndwuMhzlIQzU7QLiXkhWmVw1aj2mjat4l/1hhK0SAj2uvJnkzSPGr MUL4QA050DdxCXkSFgDPWYrvnaBzHzwJZxSirypRoSSYZZ9BuKTqavRQ4Y8HjOkO8F24 1rs15PGok6aYNgSX2m18h6vpmX+dzS5OjX8Q7URmHHkejGJo1cKLRyG+ZTBKKj5QhSvG nywg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=rqf1nYtN; 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=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si6418776plm.160.2021.10.01.01.13.36; Fri, 01 Oct 2021 01:13:51 -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=@linux.dev header.s=key1 header.b=rqf1nYtN; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352481AbhJAHYy (ORCPT + 99 others); Fri, 1 Oct 2021 03:24:54 -0400 Received: from out2.migadu.com ([188.165.223.204]:29995 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352464AbhJAHYw (ORCPT ); Fri, 1 Oct 2021 03:24:52 -0400 Date: Fri, 1 Oct 2021 16:23:00 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1633072987; 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=ymfgiYvTlJ3AQGX94b1sSvkk9jsxxsuG2lLJcwnPHCo=; b=rqf1nYtN4SSLByWt0acEMV39Uq8aX7PCQTdJEG0XpnxSKHWodaJOaMJTMmm2ooZnAdd0O7 NtF8R/UrBhknWFSHuDXNfOxzmwsN4GZESadxdACEuAjYeedQmotJ8FpD1XDj8BxKFatkHr EKSkJuMS7qGRFa/w9j/L1qpi7deXeFY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Yang Shi Cc: naoya.horiguchi@nec.com, hughd@google.com, kirill.shutemov@linux.intel.com, willy@infradead.org, peterx@redhat.com, osalvador@suse.de, akpm@linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [v3 PATCH 2/5] mm: filemap: check if THP has hwpoisoned subpage for PMD page fault Message-ID: <20211001072300.GC1364952@u2004> 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: <20210930215311.240774-3-shy828301@gmail.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: naoya.horiguchi@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 30, 2021 at 02:53:08PM -0700, Yang Shi wrote: > When handling shmem page fault the THP with corrupted subpage could be PMD > mapped if certain conditions are satisfied. But kernel is supposed to > send SIGBUS when trying to map hwpoisoned page. > > There are two paths which may do PMD map: fault around and regular fault. > > Before commit f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") > the thing was even worse in fault around path. The THP could be PMD mapped as > long as the VMA fits regardless what subpage is accessed and corrupted. After > this commit as long as head page is not corrupted the THP could be PMD mapped. > > In the regular fault path the THP could be PMD mapped as long as the corrupted > page is not accessed and the VMA fits. > > This loophole could be fixed by iterating every subpage to check if any > of them is hwpoisoned or not, but it is somewhat costly in page fault path. > > So introduce a new page flag called HasHWPoisoned on the first tail page. It > indicates the THP has hwpoisoned subpage(s). It is set if any subpage of THP > is found hwpoisoned by memory failure and cleared when the THP is freed or > split. > > Fixes: 800d8c63b2e9 ("shmem: add huge pages support") > Cc: > Suggested-by: Kirill A. Shutemov > Signed-off-by: Yang Shi ... > @@ -668,6 +673,20 @@ PAGEFLAG_FALSE(DoubleMap) > TESTSCFLAG_FALSE(DoubleMap) > #endif > > +#if defined(CONFIG_MEMORY_FAILURE) && defined(CONFIG_TRANSPARENT_HUGEPAGE) > +/* > + * PageHasPoisoned indicates that at least on subpage is hwpoisoned in the Maybe you meant as follow? + * PageHasHWPoisoned indicates that at least one subpage is hwpoisoned in the Thanks, Naoya Horiguchi