From patchwork Sat Nov 16 17:59:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13877672 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 B1D13D68BE7 for ; Sat, 16 Nov 2024 17:59:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 469B59C001D; Sat, 16 Nov 2024 12:59:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4023E9C0018; Sat, 16 Nov 2024 12:59:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2474A9C001D; Sat, 16 Nov 2024 12:59:33 -0500 (EST) 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 F32699C0018 for ; Sat, 16 Nov 2024 12:59:32 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9FE1081C82 for ; Sat, 16 Nov 2024 17:59:32 +0000 (UTC) X-FDA: 82792718190.01.388ECEA Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by imf01.hostedemail.com (Postfix) with ESMTP id 77BBE40005 for ; Sat, 16 Nov 2024 17:58:54 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=icf1sKLK; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.182 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=1731779772; 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:in-reply-to:references:references:dkim-signature; bh=O+zqV+yymXPy0a+WK0KlfZbpXJ50Be1gsnAxvt14Xcw=; b=3uUnZe/tEEj5RujUTscbsBao6pwdwsPi1a3TgT3ro50QMHv8AHZY/G96McZKfTUfmpn8Jb +F+muFaK7CpmJWwRcdmodtzKuhDCkQF6xpvZgvGiDSoZzsuRm2NEciPLbbEyUZjTq9397k xUy5zMGGUAyrsgX75xVBtCkQ/sjjJ8Q= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=icf1sKLK; spf=pass (imf01.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.182 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731779772; a=rsa-sha256; cv=none; b=kVjMDQCi354Xf+k8E3HwiAwmfwHNe0Yglzgkd3uxF0bLweqNe2BnEvyU261rY5QhhgXR9p gBQk8EWRWIBtqjwmKGvyrmFU98DVKuln9Db06JpQBGWPPJ+G+h8JVd4DDGH9xz7siIZlTb D5li0CWc6wCSg0tBZFKCWioi2nYT7Ms= Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7b1511697a5so173883785a.2 for ; Sat, 16 Nov 2024 09:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1731779970; x=1732384770; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=O+zqV+yymXPy0a+WK0KlfZbpXJ50Be1gsnAxvt14Xcw=; b=icf1sKLKaa/waM3rFI+Vn6swiT4B2N1HvuhiobqmqiIzSncrxORPR2hEf8OEBoNCE+ RR1jhSsVeJt01fKxOU91c7dpaznHu4G8K/1AninbOPQrIW/n0G6tkLzo5LA7XITgmbSj hLyHPeeJ9cosmVjud20EU8kzgZHLdAO2OKQMHJ+BPLMBGtTRhgSXwtvod4SJKU29qXDj Yra7YMttqqSbWPIlVqn4tserWLWg8yBWSYZMhVB8azEf3e79IaXUzFb6iiS6j9HA3hm8 goqj3XKDg2lOEohTCfdzOsVmqeaWN3mbm7xfWfFYsLsg0CRSSqV2Dewtub5drnoelQgc 9/xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731779970; x=1732384770; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O+zqV+yymXPy0a+WK0KlfZbpXJ50Be1gsnAxvt14Xcw=; b=QA22XVE1yUwfRPCRng9LFhf2rzp5STVvA9kkFSzZaz9AtHh9r2kcg2tEivkHMP8obA hqXpf30+am52gyve51nwQZnVSiihbtC1qyvlFvVb3+iwNxYRNojkYLq8o4g/42PSPwCF noHnP8veZvVWw5zyAAFjK7pYPzSxHPTFk02DOAukuZLmdJJ0WvlZ3asFkepcXxPln8m8 u9Hp7hUREHItdQ9c9Y3VkjtzP5R5Dr7YCgOoA4BbzjoQT0OjuT49Mr4MWBJWS9ZP16cT XpIYGjEhHtYKq0DguYnDQ9xFHgw0Ax1PMbtmw3uyFJ/j7excaIt+Ih6+raoFyGxIT9AE GB0g== X-Forwarded-Encrypted: i=1; AJvYcCW5tSXklYeTlxZbVftjZs/iejfkO8SO39lf2jlXrw94ITRyuthTtZP1Yl1MwJWmc0KcpXrKgNUNdg==@kvack.org X-Gm-Message-State: AOJu0Yy9qkYrUJtuGb+gsoU5QO+kWnl9TEqidBXAIMJvQv9AhYNDMgLS FzMmnc2N0a51MbLz0zfgHjZ94/0UCKRWdcNRFv/ByCRDkbWzhCjjUK1KjcXx2VA= X-Google-Smtp-Source: AGHT+IFM6KBibOKfJYXQZBFVrr3w+/SZOQZsHgHNA1kQveXXhFr8pkzrxC/81+yPU1STXi1ZMpKadw== X-Received: by 2002:a05:620a:4507:b0:7b1:4762:65 with SMTP id af79cd13be357-7b3622b4a6bmr766363285a.20.1731779970003; Sat, 16 Nov 2024 09:59:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Nov 2024 09:59:29 -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 3/6] mm: Add a dump_page variant that accept log level argument Date: Sat, 16 Nov 2024 17:59:19 +0000 Message-ID: <20241116175922.3265872-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241116175922.3265872-1-pasha.tatashin@soleen.com> References: <20241116175922.3265872-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 77BBE40005 X-Stat-Signature: b3jhb1ptacwf463pjn7dcortfuiu8ypa X-Rspam-User: X-HE-Tag: 1731779934-317128 X-HE-Meta: U2FsdGVkX18zl294Mv2R49XEECNFefl5o002zknpaLLMu9HVa6R3z5zysYUeueVcg2J01KBOf+fMpyeYmMF4MpW1fohJQWIgcC/lAI4GY+DxIBDAhhP3UdMbXG7UKr+drVGqsOpXYLW41EuQ6rDrjU/YOvSeMLQA/UbgWz3LbZDnwf57YxW+xzvT6XvLYvUkGdEkeRsaDok6wKBH11tMtTE0jpmkdDxlnkwsIoEo0n1a8uFLi6za/IwBc+08Wkxr8fOnqj1eYvp/xJiceTjOHtewptnnjd0rJRKL8flOS+QaMj1JHQH1bPSMc/9TwQmr/19xgN3CJPmRXHNp2WtfUCUKprYYx1L58q4CvVpFiQRfK4Hyio6HIUEBVF62uXjoY//2rtDM073cHxp40JX3v0Eoebf/8gu26KYql2SigXtYyCGy/mTuOWOzC6yuO0j4AvmxctaKegz6D8Sa++QIIsCvKKuMP66djMCe/3Epr0n3aq0K5ew0rhhEZKtZS/Ph37+E+LyfF98Hnt7zsMyFEMkC1Th24lWo//FRIuTychJaohXwuN8gqIHbqFQ2R7exPCvaG0jqdR5Ceb5ichIvEntbi+ivWLG+U/eaR3zbq6bTkryw0lCTlnjv7TesJrwuwF51/iI3J+UK/3w0wuMMkhCRcWopUIxAhy4E4bI6jXgCrl+axHI9/wfSf0gFiUCBFc8WR78ePIgtTeCqAXVKU+KN94QNUPzigC8d4QW+peTiCzLGEPQ6kOLU6CRz5gcFovDLsfmS9xkhrvpat6yVkVGd9jSe6dwq44KP0uOpVHzNpy0JOjS6iy/wiYGRN4u5gX3rOy1Gc0rW4qTpYk+fugaPD0JsT88WAUn28vmki3ouRjaOIQn0eFA5wboJO1Y2A0VM6nwwSf7PG2EAfvc3FipaaoleCHXhW/YtfiZBNTi7WH2s2G7VAuzDbDmjZ0o3qzEgcblNiaHxj6nb4Zz 3ht0VOdX iEZxVBRDi25qQ+iYS37RI5EH7ylgS3jp6QPnrbeEK3l8FewewtQbwbnPlD8vm0eEFNyawpu2gjoDRur06GIrL761ojgOulsHInUpS+CjYNIGu+BeasxhtkPrv01JfEKPnF3VxKMVGb9/Q0MXO0PUjE+n/ijd/+A21tP1pPIwmMiDFroslo38OYYi72Ge0ECEEmal6/pkPNXwPYWvG6kIwDk3KQ00jWwZqHr/Jb3EIc7u8Tg6xvfPQg1IKL/AB16o96m9+cfX0FONMgSNJCIVe3+uHT4J3+3IgoDyXLuoyBCJhdfUtobC9IHzf8hHuYVzvJzBxf70IF+5bTisJlcI8DVWGXFrJUUs59RLSyvzU6eHTrk558MLt8zh0SP9saYQgbuc0N+IbuzDgbaNeCEBqa7x+44eZAw1tbdGNXTjDI8if2msg80qAJPvdnJkzfS9xcvt9 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 uses info level, while dump_page() uses warn level. Add a new function dump_page_lvl() that accepts log level argument to be able to dump pages at specific level. Also, this enables adding a modules specific prefix to output of this function. Signed-off-by: Pasha Tatashin --- fs/inode.c | 18 +++++++------- include/linux/fs.h | 2 +- include/linux/mmdebug.h | 1 + mm/debug.c | 53 ++++++++++++++++++++++------------------- 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 8dabb224f941..1114319d82b2 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -603,7 +603,7 @@ void __remove_inode_hash(struct inode *inode) } EXPORT_SYMBOL(__remove_inode_hash); -void dump_mapping(const struct address_space *mapping) +void dump_mapping(const char *loglvl, const struct address_space *mapping) { struct inode *host; const struct address_space_operations *a_ops; @@ -619,31 +619,31 @@ void dump_mapping(const struct address_space *mapping) */ if (get_kernel_nofault(host, &mapping->host) || get_kernel_nofault(a_ops, &mapping->a_ops)) { - pr_warn("invalid mapping:%px\n", mapping); + printk("%sinvalid mapping:%px\n", loglvl, mapping); return; } if (!host) { - pr_warn("aops:%ps\n", a_ops); + printk("%saops:%ps\n", loglvl, a_ops); return; } if (get_kernel_nofault(dentry_first, &host->i_dentry.first) || get_kernel_nofault(ino, &host->i_ino)) { - pr_warn("aops:%ps invalid inode:%px\n", a_ops, host); + printk("%saops:%ps invalid inode:%px\n", loglvl, a_ops, host); return; } if (!dentry_first) { - pr_warn("aops:%ps ino:%lx\n", a_ops, ino); + printk("%saops:%ps ino:%lx\n", loglvl, a_ops, ino); return; } dentry_ptr = container_of(dentry_first, struct dentry, d_u.d_alias); if (get_kernel_nofault(dentry, dentry_ptr) || !dentry.d_parent || !dentry.d_name.name) { - pr_warn("aops:%ps ino:%lx invalid dentry:%px\n", - a_ops, ino, dentry_ptr); + printk("%saops:%ps ino:%lx invalid dentry:%px\n", + loglvl, a_ops, ino, dentry_ptr); return; } @@ -653,8 +653,8 @@ void dump_mapping(const struct address_space *mapping) * Even if strncpy_from_kernel_nofault() succeeded, * the fname could be unreliable */ - pr_warn("aops:%ps ino:%lx dentry name(?):\"%s\"\n", - a_ops, ino, fname); + printk("%saops:%ps ino:%lx dentry name(?):\"%s\"\n", + loglvl, a_ops, ino, fname); } void clear_inode(struct inode *inode) diff --git a/include/linux/fs.h b/include/linux/fs.h index a25b72397af5..fa2b04bed9d6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3137,7 +3137,7 @@ extern void unlock_new_inode(struct inode *); extern void discard_new_inode(struct inode *); extern unsigned int get_next_ino(void); extern void evict_inodes(struct super_block *sb); -void dump_mapping(const struct address_space *); +void dump_mapping(const char *loglvl, const struct address_space *); /* * Userspace may rely on the inode number being non-zero. For example, glibc diff --git a/include/linux/mmdebug.h b/include/linux/mmdebug.h index 39a7714605a7..69849d457f4c 100644 --- a/include/linux/mmdebug.h +++ b/include/linux/mmdebug.h @@ -11,6 +11,7 @@ struct mm_struct; struct vma_iterator; void dump_page(const struct page *page, const char *reason); +void dump_page_lvl(const char *loglvl, const struct page *page); void dump_vma(const struct vm_area_struct *vma); void dump_mm(const struct mm_struct *mm); void vma_iter_dump_tree(const struct vma_iterator *vmi); diff --git a/mm/debug.c b/mm/debug.c index aa57d3ffd4ed..0df242c77c7c 100644 --- a/mm/debug.c +++ b/mm/debug.c @@ -67,36 +67,38 @@ static const char *page_type_name(unsigned int page_type) return page_type_names[i]; } -static void __dump_folio(struct folio *folio, struct page *page, - unsigned long pfn, unsigned long idx) +static void __dump_folio(const char *loglvl, struct folio *folio, + struct page *page, unsigned long pfn, + unsigned long idx) { struct address_space *mapping = folio_mapping(folio); int mapcount = atomic_read(&page->_mapcount); char *type = ""; mapcount = page_mapcount_is_type(mapcount) ? 0 : mapcount + 1; - pr_warn("page: refcount:%d mapcount:%d mapping:%p index:%#lx pfn:%#lx\n", - folio_ref_count(folio), mapcount, mapping, - folio->index + idx, pfn); + printk("%spage: refcount:%d mapcount:%d mapping:%p index:%#lx pfn:%#lx\n", + loglvl, folio_ref_count(folio), mapcount, mapping, + folio->index + idx, pfn); if (folio_test_large(folio)) { - pr_warn("head: order:%u mapcount:%d entire_mapcount:%d nr_pages_mapped:%d pincount:%d\n", - folio_order(folio), - folio_mapcount(folio), - folio_entire_mapcount(folio), - folio_nr_pages_mapped(folio), - atomic_read(&folio->_pincount)); + printk("%shead: order:%u mapcount:%d entire_mapcount:%d nr_pages_mapped:%d pincount:%d\n", + loglvl, + folio_order(folio), + folio_mapcount(folio), + folio_entire_mapcount(folio), + folio_nr_pages_mapped(folio), + atomic_read(&folio->_pincount)); } #ifdef CONFIG_MEMCG if (folio->memcg_data) - pr_warn("memcg:%lx\n", folio->memcg_data); + printk("%smemcg:%lx\n", loglvl, folio->memcg_data); #endif if (folio_test_ksm(folio)) type = "ksm "; else if (folio_test_anon(folio)) type = "anon "; else if (mapping) - dump_mapping(mapping); + dump_mapping(loglvl, mapping); BUILD_BUG_ON(ARRAY_SIZE(pageflag_names) != __NR_PAGEFLAGS + 1); /* @@ -105,22 +107,22 @@ static void __dump_folio(struct folio *folio, struct page *page, * state for debugging, it should be fine to accept a bit of * inaccuracy here due to racing. */ - pr_warn("%sflags: %pGp%s\n", type, &folio->flags, - is_migrate_cma_folio(folio, pfn) ? " CMA" : ""); + printk("%s%sflags: %pGp%s\n", loglvl, type, &folio->flags, + is_migrate_cma_folio(folio, pfn) ? " CMA" : ""); if (page_has_type(&folio->page)) pr_warn("page_type: %x(%s)\n", folio->page.page_type >> 24, page_type_name(folio->page.page_type)); - print_hex_dump(KERN_WARNING, "raw: ", DUMP_PREFIX_NONE, 32, - sizeof(unsigned long), page, - sizeof(struct page), false); + print_hex_dump(loglvl, "raw: ", DUMP_PREFIX_NONE, 32, + sizeof(unsigned long), page, + sizeof(struct page), false); if (folio_test_large(folio)) - print_hex_dump(KERN_WARNING, "head: ", DUMP_PREFIX_NONE, 32, - sizeof(unsigned long), folio, - 2 * sizeof(struct page), false); + print_hex_dump(loglvl, "head: ", DUMP_PREFIX_NONE, 32, + sizeof(unsigned long), folio, + 2 * sizeof(struct page), false); } -static void __dump_page(const struct page *page) +void dump_page_lvl(const char *loglvl, const struct page *page) { struct folio *foliop, folio; struct page precise; @@ -149,22 +151,23 @@ static void __dump_page(const struct page *page) if (idx > nr_pages) { if (loops-- > 0) goto again; - pr_warn("page does not match folio\n"); + printk("%spage does not match folio\n", loglvl); precise.compound_head &= ~1UL; foliop = (struct folio *)&precise; idx = 0; } dump: - __dump_folio(foliop, &precise, pfn, idx); + __dump_folio(loglvl, foliop, &precise, pfn, idx); } +EXPORT_SYMBOL_GPL(dump_page_lvl); void dump_page(const struct page *page, const char *reason) { if (PagePoisoned(page)) pr_warn("page:%p is uninitialized and poisoned", page); else - __dump_page(page); + dump_page_lvl(KERN_WARNING, page); if (reason) pr_warn("page dumped because: %s\n", reason); dump_page_owner(page);