From patchwork Wed May 17 16:09:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaqi Yan X-Patchwork-Id: 13245278 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD40FC77B7F for ; Wed, 17 May 2023 16:10:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C51F900005; Wed, 17 May 2023 12:10:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 473A3900003; Wed, 17 May 2023 12:10:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33B61900005; Wed, 17 May 2023 12:10:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 25A12900003 for ; Wed, 17 May 2023 12:10:19 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ECA20120660 for ; Wed, 17 May 2023 16:10:18 +0000 (UTC) X-FDA: 80800234116.22.F624D34 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf24.hostedemail.com (Postfix) with ESMTP id E05A1180047 for ; Wed, 17 May 2023 16:10:00 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xZ7BRyrR; spf=pass (imf24.hostedemail.com: domain of 3V_xkZAgKCA4xwo4wCo1u22uzs.q20zw18B-00y9oqy.25u@flex--jiaqiyan.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3V_xkZAgKCA4xwo4wCo1u22uzs.q20zw18B-00y9oqy.25u@flex--jiaqiyan.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684339800; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=rgBNWBxudxifYf13fc5/OPTdkwgzhiJTdekK9406sZk=; b=Obyx74WhMnYOpO6CnbPmV1Ubyk5+u+x+ZdRVAMGVEmiaZhRSUlS9+gs0Ohf5Plvd25FuN9 F4lVbNsNYThPZUpua45LR/XEEzY2WyR4m12uWmLnhNL5qE5kiQ+Ornkix+w8xQtXN/aYP3 gBcCprjtLWQujBMlfQECxOes3mu1+6g= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=xZ7BRyrR; spf=pass (imf24.hostedemail.com: domain of 3V_xkZAgKCA4xwo4wCo1u22uzs.q20zw18B-00y9oqy.25u@flex--jiaqiyan.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3V_xkZAgKCA4xwo4wCo1u22uzs.q20zw18B-00y9oqy.25u@flex--jiaqiyan.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684339800; a=rsa-sha256; cv=none; b=t+9nN4c7jcguQeXHIgmXi07hhbJiFep2W1pquRMnMGwyphSHG1JXs8EVs9wsL7/p194ot2 HG7lO+1TELBHHQNtb7REkssDOvNKh+NgGI0rziy8GDsbtd7ysPf2zwHM9+RE2rgcy9QLvB lkIgRCI1Ee5W3U1BRFoorfhHt+r+M2Q= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-ba8337a578dso1138757276.1 for ; Wed, 17 May 2023 09:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684339800; x=1686931800; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=rgBNWBxudxifYf13fc5/OPTdkwgzhiJTdekK9406sZk=; b=xZ7BRyrRuqfjm0Tqe9XVSbolDZPqt9jPwAQAa6wtxikuVD0C8co7/c5Y9GurownWnE Vwb4VYj9ILg7MQSLYToewHVogtaYlXawfGom6s6TFghwK2Ye8vxhnGTSlxBKK024PdCw pW53F9+8Kt5WjPNu6wSsWwfHYaB3WT4L8FO8HoI/+DAJRD4/h+kGo7aJ2B8cPrgAVTso VY6HB3lvP0aYcDOt4Ipv5b1aIuQNkVwZrP/ekM4nH8cRI6aHFqD4VhzC4kQPdgBkwQia nxZcw+Zr4vXrF1Sv1dvHUCuW6bvBBplwGKHfNZxImBEq5kNy1lfgsZLDDROAw0zUDdja XQ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684339800; x=1686931800; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rgBNWBxudxifYf13fc5/OPTdkwgzhiJTdekK9406sZk=; b=aTNjvu9y50nmHCAvPJWi9MsciLqxGRrDxkPvItlEtGAJZzs01GQCuvrdY+IMrVnlO2 6y6EprDgK2KOAquXmIRDfQZDyzRl4cVn6kpg2Z/iYOOD2HFcY7Bl6RTPzfM2SjPVDGrs J7vEqDGGRkf7yYe/eJbHewiilCsl49NHybR8VATZF3klJYbVrmXv+/pDdp2839kKqaM3 EWnASqmwQq7iR4SUZM9MPpqe4wMxzZX7ipwq3fQ8YeLg1vTFCG/SQT9Agzr6IPw14qKK JZl3YJDz2F8NmWkxoI0/0IdhiodaORDxhP7AznmcXHBFM61KnxE0nLoS+zyQ4920KYZX vtNg== X-Gm-Message-State: AC+VfDxFJGQxroBZS5BcZlup2sKoZ09LlohZlETkZiz830DOvDckmh3X //9xWzB5nF7AqcQOhpB0YMrv2HOyqcVNwA== X-Google-Smtp-Source: ACHHUZ6l+7V7zh/9o9ANvR18oYNtr6L0CFFmD7ZWpbPjx5EADmQYczbHcI+60Zrnel4Bh7QQTNeC5syqi7/Hcw== X-Received: from yjq3.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:272f]) (user=jiaqiyan job=sendgmr) by 2002:a5b:e86:0:b0:ba8:4489:74c0 with SMTP id z6-20020a5b0e86000000b00ba8448974c0mr2602322ybr.6.1684339799873; Wed, 17 May 2023 09:09:59 -0700 (PDT) Date: Wed, 17 May 2023 16:09:45 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Message-ID: <20230517160948.811355-1-jiaqiyan@google.com> Subject: [PATCH v1 0/3] Improve hugetlbfs read on HWPOISON hugepages From: Jiaqi Yan To: mike.kravetz@oracle.com, songmuchun@bytedance.com, naoya.horiguchi@nec.com, shy828301@gmail.com, linmiaohe@huawei.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duenwen@google.com, axelrasmussen@google.com, jthoughton@google.com, Jiaqi Yan X-Stat-Signature: 3984uwd1xt6nbs8eznsxu7k5ow6sqbi4 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: E05A1180047 X-Rspam-User: X-HE-Tag: 1684339800-805099 X-HE-Meta: U2FsdGVkX18881Cb5Fs5EhIBPZDcHA/Bl7Kr4/5HGrbpMl1SgZIs0Q1sch1CfyriOkZITpBUywk2GorEh10D4rzf4BWhWwRMwPjDECabEBVDOIPZBix08UioxlHHoEbcluMb02IDCgLclBo77apbk5A6Zqs7FrUhiyaHt1bDdWHajxWy43DRFeY9qU9YlIBebAysh2F3vAZae1XgY5ty8nfAYJKzKRwmyzGzmAOs0+yNVkBw4PnLkEPBuePz0yHnpwJb0oU7V2brfOOfEGZ2TAJfvMlsjTBBptcyqxrcLReEObH4zE6/GKDIj7sAJcLrd6KIjQQTbSKx7iQMupdsEl3MM35FKMKIS+GP49uG0SljDL5siwtVnMklWB3zxd1tIPuG86KBJ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LuCKz+iAL6GY3eUHJDtA5ydykQmbLFBBgOr6YPbkVkAOeD0zu55EwNzsoxBZU0GRZHOJMX9WZYq8op7z4diGhUOW17cVY/j0dkxqhXUFvt2evSQeQsNdBeHgDSYoiVgER/gQfc 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: Today when hardware memory is corrupted in a hugetlb hugepage, kernel leaves the hugepage in pagecache [1]; otherwise future mmap or read will suject to silent data corruption. This is implemented by returning -EIO from hugetlb_read_iter immediately if the hugepage has HWPOISON flag set. Since memory_failure already tracks the raw HWPOISON subpages in a hugepage, a natural improvement is possible: if userspace only asks for healthy subpages in the pagecache, kernel can return these data. This patchset implements this improvement. It consist of three parts. The 1st commit exports the functionality to tell if a subpage inside a hugetlb hugepage is a raw HWPOISON page. The 2nd commit teaches hugetlbfs_read_iter to return as many healthy bytes as possible. The 3rd commit properly tests this new feature. [1] commit 8625147cafaa ("hugetlbfs: don't delete error page from pagecache") Jiaqi Yan (3): mm/hwpoison: find subpage in hugetlb HWPOISON list hugetlbfs: improve read HWPOISON hugepage selftests/mm: add tests for HWPOISON hugetlbfs read fs/hugetlbfs/inode.c | 62 +++- include/linux/mm.h | 23 ++ mm/memory-failure.c | 26 +- tools/testing/selftests/mm/.gitignore | 1 + tools/testing/selftests/mm/Makefile | 1 + .../selftests/mm/hugetlb-read-hwpoison.c | 322 ++++++++++++++++++ 6 files changed, 419 insertions(+), 16 deletions(-) create mode 100644 tools/testing/selftests/mm/hugetlb-read-hwpoison.c