From patchwork Sat Nov 16 17:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13877669 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 543FCD68BF5 for ; Sat, 16 Nov 2024 17:59:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7299E9C001A; Sat, 16 Nov 2024 12:59:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D88F9C0018; Sat, 16 Nov 2024 12:59:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5520E9C001A; Sat, 16 Nov 2024 12:59:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 35FB99C0018 for ; Sat, 16 Nov 2024 12:59:29 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C7BC5C1742 for ; Sat, 16 Nov 2024 17:59:28 +0000 (UTC) X-FDA: 82792719996.29.86B20C9 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf25.hostedemail.com (Postfix) with ESMTP id 3488EA000D for ; Sat, 16 Nov 2024 17:58:53 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=NEUeMmcs; spf=pass (imf25.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731779820; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=9/2cx8m5V2KkB1LkibOPMizZ7amfyQzK5oG3Ev3ZaAc=; b=DsNFL2Dq+cRerQkXGkdm9T5BNxo/FpmTLHrk+ayGnp5TT8HNzW+jHRWJgj/cif/7MjR4Tp ZZcUJa3OwDmTvlJXG7vMnDeQMqAI5A0iIK+Xeq4seVbOEJTkadSPJaVwqtMcuxn0ImJVg/ j5Y+ADmkcqBRg9WtsiTcGJILRxWhUhE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731779820; a=rsa-sha256; cv=none; b=NyfqogD0yqYmr1u3Nfp5DhE1WRKUPeUvJkRD2JnWOObf8AakE8VXZGzswSKLIuJRwrND0j +uQdDCAHo8jd3QKSHVsQw5BB6yoG/gLzoFDLrdgBr7n+WVgAXUKN6eQGDB8ZbGJSyuU2DU 2vRrP1iagIBU3yXJRNlRcmN3V0gUzWg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=NEUeMmcs; spf=pass (imf25.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6d41864d745so1149726d6.2 for ; Sat, 16 Nov 2024 09:59:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1731779966; x=1732384766; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=9/2cx8m5V2KkB1LkibOPMizZ7amfyQzK5oG3Ev3ZaAc=; b=NEUeMmcsnD3+RB3FjZpjUi0RLQrCGXCVyAr1omEXRRJ5G26YyiJsTEM2933ZyaMvLZ zVI6k7/Ev+ChqnqPBQG2ahOeLMAA4KdHmv07uY4rUACdsydKFrsT01c+3sWozhx5jrcn fEh64p7og8RTwBOvVuuif+yJnE4NAaNOgjnFzAnEwsXUBf7VmzRf0bGr12jEUb8+jX9n EM4TI4P/7gBjdGDz5o3udiTxD9i4Rv2SI1xJCY+mFTxH1yXk382bhCmSG3etfdnl/sU8 BWr4Y0Lq1y9qFTvxfiyjGF+UxIiIvVTFtzYSKCDC3JAo6dLrF17EdIsRscxXm3Vf9m0g gyiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731779966; x=1732384766; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9/2cx8m5V2KkB1LkibOPMizZ7amfyQzK5oG3Ev3ZaAc=; b=pwB5dX2Ui+JgimTYLE4QaY4AB5+Mmdutblgh0RazttcR7ZruvuEE+l/UdOs972t3ox V1gcf2m6Ph5t9tRJt6ZZlwhv9jM33oW5jU5A+ILkChe5rgNRWqW5V7AmZASqMOsKI48Z KwcbBmokQt4HoteVdaYVy7EoUn43T2lVSIy//8jHisk6UwIZZ9Tb7/987QZUqzgqrGFS KN5XTPo0/UoSbRU3tDI54h4OuT1oumHABD5hBt2gOeZworgasVRUOE4ZSxbmVczlk8Et cboKc6zya/EZoD5tGQJIviE7dJeYVF8rxJYTzCkWQbNFa0TZ37oc9/aL+ijbOR7/jt6j 9PbQ== X-Forwarded-Encrypted: i=1; AJvYcCXyNYZZicxfNuk6Ob75OLOap3XPJ5c+4dYV+5IFd+tYZhjR7B5xXmkiKFqBA3HGOupFkaGTTVCFnw==@kvack.org X-Gm-Message-State: AOJu0YzdLrOxsMhDS5OSr2pv1+7o/9arUinMjFwzs1MkZNEo4Q/HzscK C75utzp2zXck6Sd6BQf4UxS4BpIUZ9JRsSXTar3cVbKBjJZkcw+7zYD8DF0i4lM= X-Google-Smtp-Source: AGHT+IG9khClVQZaK5gJiOlSuiW+HiW7mbHelDE5mIQzNETjqXaEChD5Y6UapjcY1u5FRRsYiVlDuQ== X-Received: by 2002:ad4:5c4d:0:b0:6d4:1a42:8efa with SMTP id 6a1803df08f44-6d41a4295admr9228036d6.0.1731779966175; Sat, 16 Nov 2024 09:59:26 -0800 (PST) Received: from soleen.c.googlers.com.com (51.57.86.34.bc.googleusercontent.com. [34.86.57.51]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b35ca309d6sm280530085a.94.2024.11.16.09.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 09:59:25 -0800 (PST) From: Pasha Tatashin To: pasha.tatashin@soleen.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, linux-kselftest@vger.kernel.org, akpm@linux-foundation.org, corbet@lwn.net, derek.kiernan@amd.com, dragan.cvetic@amd.com, arnd@arndb.de, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, tj@kernel.org, hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com, vbabka@suse.cz, jannh@google.com, shuah@kernel.org, vegard.nossum@oracle.com, vattunuru@marvell.com, schalla@marvell.com, david@redhat.com, willy@infradead.org, osalvador@suse.de, usama.anjum@collabora.com, andrii@kernel.org, ryan.roberts@arm.com, peterx@redhat.com, oleg@redhat.com, tandersen@netflix.com, rientjes@google.com, gthelen@google.com Subject: [RFCv1 0/6] Page Detective Date: Sat, 16 Nov 2024 17:59:16 +0000 Message-ID: <20241116175922.3265872-1-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 3488EA000D X-Stat-Signature: ghro9q43aioqj86ckgb3pqkw4ub6xkuq X-HE-Tag: 1731779933-213685 X-HE-Meta: U2FsdGVkX19C1BCpfn7rb0MoKsBJJZhK1BG4DffTf6LqBUElcmWHVnf7gO9rAvXf24tzgTPVHNwMuuNyELkvMtTLKoww6PXgncZQpRzGOqkrYbClQZUcj6QgISuaYWfAm9Pbz8lqL9OlD1l2QSHlK+kXfjs4AYEEGR72k6TzxwkhEEfyGufnwSl88gvq5rRVsK8F7pTUKz/ZaxUR+5ftVtaxNJaWxQtuMyUGWfpJOvYWS0upGetPMNAky3Uxz6/M+EW62Khicr6T4Nc8/rIG8+oJw1HuJPSyDzsRCEJTsR7Gq8TfpOpzUTwe+l2DyansQGp6gEqciElGnYZtgRCIXq6IZjdiDjWzhVOb2KIN+K2XIhdk46jwMQyT0lGI30clq5CU31BYeztb+HhiKMp1sGlpu5/n9ZMLrkkV/8I+pObV2iNNv2/UfZyE9ZzgEGUQafEgCaG/WF47SCRimS2P0bj+TOIHsmeSVK6QEa3CvqtGYiB8IQxhLP8xT20xeDuxFvr3+V4diuuYS+fEelSIKx+pSU/8UOWD39ppNCZzEn0OOFMWlgwPZvOyJefvNvBuzAA1F6sloYe+oJKMQYg1e4nSKDdUyJ/fbxB5j9wGrrLuOCJuUpxM23bJneI5LL+kB8wJ3o0MUtKLZGtGynuKaJRZ665bq3IqwSfSrB3qccRBPGci34FIKDCT5imJyib/aqccmQALHhJnbJlqoxD5UyQ/tnacIBAaQnhzaKPaCzDFsLXt0QNmMs81taYz5bxScNHwO9tY9l4p+l2IUWE/0QMf0ZqUrY7SorUnyyEI9Ybq4KHgJQO9rclpQOfUayEKg8wTq5dHej/Sc5CLLU8NIgr+ytC3oD3x8sqdEup/ltA9adPc4BfnfUWOKCR77rbC2VZVGYH1HcFCP+I7HL61UVA4oX/VLSYeQeBZP31L+YtZZhG6W2nmMSBmDq8XhQnzPTHMum+OZdW2iGyQkT1 i4MfhiXQ R8nYib9Ci6UO2A9RpeTeJ9gPoWxtulv7rkmERlh96h7/Ws+H8YGQoV3pdN5Kfko433z85B0ZuKpxsnSEzDPtR07iBGzAKTPtKGMYN8OZF52ZPqDqvhH2fUj5vCKuWdKT9VmEh8U8zTM72NSbJuDJYUEfCGIV1BUS0L778cXibBgiGSV+W4N+kynSAwmCfTV8MiOV+23rqlGTXSPW7UxYg4yJy8SODcAdWH01Hru2i6E7BJROu4pRSskrc3qT6OWrdkMVVPtZgR22sCBQ8NWphNzPhJ1pTZfQ+GwTdXL3nvxtsQXTH3BulWt4/VxjVS0k70RKUI6oj5hGbhZg= 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: List-Subscribe: List-Unsubscribe: Page Detective is a new kernel debugging tool that provides detailed information about the usage and mapping of physical memory pages. It is often known that a particular page is corrupted, but it is hard to extract more information about such a page from live system. Examples are: - Checksum failure during live migration - Filesystem journal failure - dump_page warnings on the console log - Unexcpected segfaults Page Detective helps to extract more information from the kernel, so it can be used by developers to root cause the associated problem. It operates through the Linux debugfs interface, with two files: "virt" and "phys". The "virt" file takes a virtual address and PID and outputs information about the corresponding page. The "phys" file takes a physical address and outputs information about that page. The output is presented via kernel log messages (can be accessed with dmesg), and includes information such as the page's reference count, mapping, flags, and memory cgroup. It also shows whether the page is mapped in the kernel page table, and if so, how many times. Pasha Tatashin (6): mm: Make get_vma_name() function public pagewalk: Add a page table walker for init_mm page table mm: Add a dump_page variant that accept log level argument misc/page_detective: Introduce Page Detective misc/page_detective: enable loadable module selftests/page_detective: Introduce self tests for Page Detective Documentation/misc-devices/index.rst | 1 + Documentation/misc-devices/page_detective.rst | 78 ++ MAINTAINERS | 8 + drivers/misc/Kconfig | 11 + drivers/misc/Makefile | 1 + drivers/misc/page_detective.c | 808 ++++++++++++++++++ fs/inode.c | 18 +- fs/kernfs/dir.c | 1 + fs/proc/task_mmu.c | 61 -- include/linux/fs.h | 5 +- include/linux/mmdebug.h | 1 + include/linux/pagewalk.h | 2 + kernel/pid.c | 1 + mm/debug.c | 53 +- mm/memcontrol.c | 1 + mm/oom_kill.c | 1 + mm/pagewalk.c | 32 + mm/vma.c | 60 ++ tools/testing/selftests/Makefile | 1 + .../selftests/page_detective/.gitignore | 1 + .../testing/selftests/page_detective/Makefile | 7 + tools/testing/selftests/page_detective/config | 4 + .../page_detective/page_detective_test.c | 727 ++++++++++++++++ 23 files changed, 1787 insertions(+), 96 deletions(-) create mode 100644 Documentation/misc-devices/page_detective.rst create mode 100644 drivers/misc/page_detective.c create mode 100644 tools/testing/selftests/page_detective/.gitignore create mode 100644 tools/testing/selftests/page_detective/Makefile create mode 100644 tools/testing/selftests/page_detective/config create mode 100644 tools/testing/selftests/page_detective/page_detective_test.c