[v4,2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counte
Message ID | 20230421101415.5734-3-osalvador@suse.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp959816vqo; Fri, 21 Apr 2023 03:19:33 -0700 (PDT) X-Google-Smtp-Source: AKy350a3pdDpPsq92Uc3qkiOFiGhWTc0CE+03WfFQnqN73354BQ3toOlaC2lFy1GiOjPnrdKbr9a X-Received: by 2002:a17:902:9688:b0:1a6:b98b:eea9 with SMTP id n8-20020a170902968800b001a6b98beea9mr4093400plp.20.1682072372931; Fri, 21 Apr 2023 03:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682072372; cv=none; d=google.com; s=arc-20160816; b=gQtaR+lfoYX9PDDRNldOH25qF4aJdr7+sUg3vzvhnLPwv2ovDiXfPhy9yJCj3xrqlG k4StGVT2EVmQTEnyXf8/Ukjac/37Pf0FlWdquNhGoOl2yFLxO4AJfuNmsJhscliaNvoP Z5/G2BNiRJzU8hoaQ7KdjUPdJDgFPfx/H1l0QRGp/GJoXYBCSU1ueQCiByLlLzBrfYIy aqnmYB2ri8oHEY51iVzIZkKGIHX4iJbEyzfNLGIJhqyZpbWvU60eh3hUcdm8Hxloq1Gt x3KHkfzYv02vlndmHDiN1CE5Oko8kOAcsOmHkOw8d6VxNawUWayUyqAPNLtMMf51U4RS w8ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=zE4KUQItN/3/UV4PaOZpW67hAUQM7k7JGXQXpSUX7jM=; b=bAbobomEqZZiI+UcQeKmReGjbbcwgZGALE5+sBSb6MIocA1hECj+bYapU1ZSF/XOhN 6Jb5OFVXDXVki7v2BDukX1GWyeQNXJoLNokiDVoZB+8SVsqaQ/5neBMi4wFDTyYpAyIB GAoWF0J5niOjGZK7LygtO2Q3CSGitgc7tOyHCFhFozFFxDPkkRPId6iGCYZI4TpL31Jw Slmd9EFaSKI+CD/exM5DfQ7mL9UUsmxqV/Z0a3G0lbug7k29uxjWd7XsrLu1jyWVOT9m kqHgUc1didVqQWKKcHFqpjuXHGlngW8TLYT2jOD0SNVNfOEC4fdyu4W78OuRqnPhNlmd d5qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LxPC06Rf; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=TfOtgFn8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u13-20020a170902e80d00b0019ca7d69673si4975028plg.196.2023.04.21.03.19.20; Fri, 21 Apr 2023 03:19:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LxPC06Rf; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=TfOtgFn8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231348AbjDUKPC (ORCPT <rfc822;cjcooper78@gmail.com> + 99 others); Fri, 21 Apr 2023 06:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231342AbjDUKOk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Apr 2023 06:14:40 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 706FCC16B for <linux-kernel@vger.kernel.org>; Fri, 21 Apr 2023 03:14:39 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 236311FDDE; Fri, 21 Apr 2023 10:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682072078; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zE4KUQItN/3/UV4PaOZpW67hAUQM7k7JGXQXpSUX7jM=; b=LxPC06RfpZaf/PV59ic/kcvwI8MQ/gLjs6JkYCNJ/RNb4xRaG70GAN+PGm+8H+ryznSgpc YrF8dckTbYzILZ5H8nPsp0rNBoS1mIsN58UGleQbLSkmKQt45pkJxWA4xeNLFKhm3E6CSB bgDU8rZ29b2J1dRT10rROtiAB8ISjTE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682072078; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zE4KUQItN/3/UV4PaOZpW67hAUQM7k7JGXQXpSUX7jM=; b=TfOtgFn8V7n2eVcwCSKoDkdsIoC3KMz6ZTBfi4H+A0+FegXVYPQtLSIWwe1Nz6zW8lDvXx 1QolS+TvzBBDJnBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 542F01390E; Fri, 21 Apr 2023 10:14:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GNpvEQ1iQmRNaAAAMHmgww (envelope-from <osalvador@suse.de>); Fri, 21 Apr 2023 10:14:37 +0000 From: Oscar Salvador <osalvador@suse.de> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>, Eric Dumazet <edumazet@google.com>, Waiman Long <longman@redhat.com>, Suren Baghdasaryan <surenb@google.com>, Marco Elver <elver@google.com>, Andrey Konovalov <andreyknvl@gmail.com>, Alexander Potapenko <glider@google.com>, Oscar Salvador <osalvador@suse.de> Subject: [PATCH v4 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counte Date: Fri, 21 Apr 2023 12:14:14 +0200 Message-Id: <20230421101415.5734-3-osalvador@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230421101415.5734-1-osalvador@suse.de> References: <20230421101415.5734-1-osalvador@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763780720327486728?= X-GMAIL-MSGID: =?utf-8?q?1763780720327486728?= |
Series |
page_owner: print stacks and their counter
|
|
Commit Message
Oscar Salvador
April 21, 2023, 10:14 a.m. UTC
We might be only interested in knowing about stacks <-> count
relationship, so instead of having to fiddle with page_owner
output and screen through pfns, let us add a new file called
'page_owner_stacks' that does just that.
By cating such file, we will get all the stacktraces followed by
its counter, so we can have a more global view.
Signed-off-by: Oscar Salvador <osalvador@suse.de
---
include/linux/stackdepot.h | 6 ++++
lib/stackdepot.c | 73 ++++++++++++++++++++++++++++++++++++++
mm/page_owner.c | 28 +++++++++++++++
3 files changed, 107 insertions(+)
Comments
Hi Oscar, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.3-rc7] [cannot apply to akpm-mm/mm-everything next-20230420] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709 patch link: https://lore.kernel.org/r/20230421101415.5734-3-osalvador%40suse.de patch subject: [PATCH v4 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counte config: ia64-allyesconfig (https://download.01.org/0day-ci/archive/20230421/202304212153.jLLmROz6-lkp@intel.com/config) compiler: ia64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/6c6dfc43015e1939f433f4371d33418ab4d03411 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709 git checkout 6c6dfc43015e1939f433f4371d33418ab4d03411 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash M=lib/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304212153.jLLmROz6-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from include/linux/page_ext.h:7, from include/linux/mm.h:22, from include/linux/mman.h:5, from lib/test_user_copy.c:13: >> include/linux/stackdepot.h:120:26: warning: 'struct seq_file' declared inside parameter list will not be visible outside of this definition or declaration 120 | void *stack_start(struct seq_file *m, loff_t *ppos); | ^~~~~~~~ include/linux/stackdepot.h:121:25: warning: 'struct seq_file' declared inside parameter list will not be visible outside of this definition or declaration 121 | void *stack_next(struct seq_file *m, void *v, loff_t *ppos); | ^~~~~~~~ include/linux/stackdepot.h:122:24: warning: 'struct seq_file' declared inside parameter list will not be visible outside of this definition or declaration 122 | int stack_print(struct seq_file *m, void *v); | ^~~~~~~~ vim +120 include/linux/stackdepot.h 99 100 /** 101 * stack_depot_save - Save a stack trace to stack depot 102 * 103 * @entries: Pointer to the stack trace 104 * @nr_entries: Number of frames in the stack 105 * @alloc_flags: Allocation GFP flags 106 * 107 * Context: Contexts where allocations via alloc_pages() are allowed. 108 * See __stack_depot_save() for more details. 109 * 110 * Return: Handle of the stack trace stored in depot, 0 on failure 111 */ 112 depot_stack_handle_t stack_depot_save(unsigned long *entries, 113 unsigned int nr_entries, gfp_t gfp_flags); 114 depot_stack_handle_t stack_depot_save_action(unsigned long *entries, 115 unsigned int nr_entries, 116 gfp_t gfp_flags, 117 bool counter); 118 119 #ifdef CONFIG_PAGE_OWNER > 120 void *stack_start(struct seq_file *m, loff_t *ppos); 121 void *stack_next(struct seq_file *m, void *v, loff_t *ppos); 122 int stack_print(struct seq_file *m, void *v); 123 #endif 124
Hi Oscar, kernel test robot noticed the following build errors: [auto build test ERROR on linus/master] [also build test ERROR on v6.3-rc7] [cannot apply to akpm-mm/mm-everything next-20230421] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709 base: linus/master patch link: https://lore.kernel.org/r/20230421101415.5734-3-osalvador%40suse.de patch subject: [PATCH v4 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counte config: powerpc-randconfig-r026-20230421 (https://download.01.org/0day-ci/archive/20230422/202304220715.syaqgRUa-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 437b7602e4a998220871de78afcb020b9c14a661) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install powerpc cross compiling tool for clang build # apt-get install binutils-powerpc-linux-gnu # https://github.com/intel-lab-lkp/linux/commit/6c6dfc43015e1939f433f4371d33418ab4d03411 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709 git checkout 6c6dfc43015e1939f433f4371d33418ab4d03411 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash arch/powerpc/kernel/ kernel/dma/ lib/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202304220715.syaqgRUa-lkp@intel.com/ All error/warnings (new ones prefixed by >>): In file included from lib/show_mem.c:8: In file included from include/linux/mm.h:22: In file included from include/linux/page_ext.h:7: >> include/linux/stackdepot.h:120:26: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] void *stack_start(struct seq_file *m, loff_t *ppos); ^ include/linux/stackdepot.h:121:25: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] void *stack_next(struct seq_file *m, void *v, loff_t *ppos); ^ include/linux/stackdepot.h:122:24: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] int stack_print(struct seq_file *m, void *v); ^ 3 warnings generated. -- In file included from lib/scatterlist.c:9: In file included from include/linux/scatterlist.h:8: In file included from include/linux/mm.h:22: In file included from include/linux/page_ext.h:7: >> include/linux/stackdepot.h:120:26: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] void *stack_start(struct seq_file *m, loff_t *ppos); ^ include/linux/stackdepot.h:121:25: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] void *stack_next(struct seq_file *m, void *v, loff_t *ppos); ^ include/linux/stackdepot.h:122:24: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] int stack_print(struct seq_file *m, void *v); ^ In file included from lib/scatterlist.c:9: In file included from include/linux/scatterlist.h:9: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:214:1: note: expanded from here __do_insb ^ arch/powerpc/include/asm/io.h:577:56: note: expanded from macro '__do_insb' #define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/scatterlist.c:9: In file included from include/linux/scatterlist.h:9: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:216:1: note: expanded from here __do_insw ^ arch/powerpc/include/asm/io.h:578:56: note: expanded from macro '__do_insw' #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/scatterlist.c:9: In file included from include/linux/scatterlist.h:9: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:218:1: note: expanded from here __do_insl ^ arch/powerpc/include/asm/io.h:579:56: note: expanded from macro '__do_insl' #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/scatterlist.c:9: In file included from include/linux/scatterlist.h:9: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:220:1: note: expanded from here __do_outsb ^ arch/powerpc/include/asm/io.h:580:58: note: expanded from macro '__do_outsb' #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/scatterlist.c:9: In file included from include/linux/scatterlist.h:9: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:222:1: note: expanded from here __do_outsw ^ arch/powerpc/include/asm/io.h:581:58: note: expanded from macro '__do_outsw' #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/scatterlist.c:9: In file included from include/linux/scatterlist.h:9: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:224:1: note: expanded from here __do_outsl ^ arch/powerpc/include/asm/io.h:582:58: note: expanded from macro '__do_outsl' #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ 9 warnings generated. -- In file included from lib/stackdepot.c:20: In file included from include/linux/mm.h:22: In file included from include/linux/page_ext.h:7: >> include/linux/stackdepot.h:120:26: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] void *stack_start(struct seq_file *m, loff_t *ppos); ^ include/linux/stackdepot.h:121:25: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] void *stack_next(struct seq_file *m, void *v, loff_t *ppos); ^ include/linux/stackdepot.h:122:24: warning: declaration of 'struct seq_file' will not be visible outside of this function [-Wvisibility] int stack_print(struct seq_file *m, void *v); ^ In file included from lib/stackdepot.c:29: In file included from include/linux/memblock.h:13: In file included from arch/powerpc/include/asm/dma.h:22: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:217:1: note: expanded from here __do_insb ^ arch/powerpc/include/asm/io.h:577:56: note: expanded from macro '__do_insb' #define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/stackdepot.c:29: In file included from include/linux/memblock.h:13: In file included from arch/powerpc/include/asm/dma.h:22: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:219:1: note: expanded from here __do_insw ^ arch/powerpc/include/asm/io.h:578:56: note: expanded from macro '__do_insw' #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/stackdepot.c:29: In file included from include/linux/memblock.h:13: In file included from arch/powerpc/include/asm/dma.h:22: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:221:1: note: expanded from here __do_insl ^ arch/powerpc/include/asm/io.h:579:56: note: expanded from macro '__do_insl' #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/stackdepot.c:29: In file included from include/linux/memblock.h:13: In file included from arch/powerpc/include/asm/dma.h:22: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:223:1: note: expanded from here __do_outsb ^ arch/powerpc/include/asm/io.h:580:58: note: expanded from macro '__do_outsb' #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/stackdepot.c:29: In file included from include/linux/memblock.h:13: In file included from arch/powerpc/include/asm/dma.h:22: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:225:1: note: expanded from here __do_outsw ^ arch/powerpc/include/asm/io.h:581:58: note: expanded from macro '__do_outsw' #define __do_outsw(p, b, n) writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from lib/stackdepot.c:29: In file included from include/linux/memblock.h:13: In file included from arch/powerpc/include/asm/dma.h:22: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:227:1: note: expanded from here __do_outsl ^ arch/powerpc/include/asm/io.h:582:58: note: expanded from macro '__do_outsl' #define __do_outsl(p, b, n) writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ >> lib/stackdepot.c:505:7: error: conflicting types for 'stack_start' void *stack_start(struct seq_file *m, loff_t *ppos) ^ include/linux/stackdepot.h:120:7: note: previous declaration is here void *stack_start(struct seq_file *m, loff_t *ppos); ^ >> lib/stackdepot.c:523:7: error: conflicting types for 'stack_next' void *stack_next(struct seq_file *m, void *v, loff_t *ppos) ^ include/linux/stackdepot.h:121:7: note: previous declaration is here void *stack_next(struct seq_file *m, void *v, loff_t *ppos); ^ >> lib/stackdepot.c:552:5: error: conflicting types for 'stack_print' int stack_print(struct seq_file *m, void *v) ^ include/linux/stackdepot.h:122:5: note: previous declaration is here int stack_print(struct seq_file *m, void *v); ^ 9 warnings and 3 errors generated. -- In file included from arch/powerpc/kernel/align.c:17: In file included from include/linux/mm.h:22: In file included from include/linux/page_ext.h:7: >> include/linux/stackdepot.h:120:26: error: declaration of 'struct seq_file' will not be visible outside of this function [-Werror,-Wvisibility] void *stack_start(struct seq_file *m, loff_t *ppos); ^ include/linux/stackdepot.h:121:25: error: declaration of 'struct seq_file' will not be visible outside of this function [-Werror,-Wvisibility] void *stack_next(struct seq_file *m, void *v, loff_t *ppos); ^ include/linux/stackdepot.h:122:24: error: declaration of 'struct seq_file' will not be visible outside of this function [-Werror,-Wvisibility] int stack_print(struct seq_file *m, void *v); ^ In file included from arch/powerpc/kernel/align.c:22: In file included from arch/powerpc/include/asm/emulated_ops.h:10: In file included from include/linux/perf_event.h:52: In file included from include/linux/ftrace.h:10: In file included from include/linux/trace_recursion.h:5: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:43:1: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insb, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:220:1: note: expanded from here __do_insb ^ arch/powerpc/include/asm/io.h:577:56: note: expanded from macro '__do_insb' #define __do_insb(p, b, n) readsb((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from arch/powerpc/kernel/align.c:22: In file included from arch/powerpc/include/asm/emulated_ops.h:10: In file included from include/linux/perf_event.h:52: In file included from include/linux/ftrace.h:10: In file included from include/linux/trace_recursion.h:5: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:45:1: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:222:1: note: expanded from here __do_insw ^ arch/powerpc/include/asm/io.h:578:56: note: expanded from macro '__do_insw' #define __do_insw(p, b, n) readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from arch/powerpc/kernel/align.c:22: In file included from arch/powerpc/include/asm/emulated_ops.h:10: In file included from include/linux/perf_event.h:52: In file included from include/linux/ftrace.h:10: In file included from include/linux/trace_recursion.h:5: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:47:1: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:224:1: note: expanded from here __do_insl ^ arch/powerpc/include/asm/io.h:579:56: note: expanded from macro '__do_insl' #define __do_insl(p, b, n) readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n)) ~~~~~~~~~~~~~~~~~~~~~^ In file included from arch/powerpc/kernel/align.c:22: In file included from arch/powerpc/include/asm/emulated_ops.h:10: In file included from include/linux/perf_event.h:52: In file included from include/linux/ftrace.h:10: In file included from include/linux/trace_recursion.h:5: In file included from include/linux/interrupt.h:11: In file included from include/linux/hardirq.h:11: In file included from arch/powerpc/include/asm/hardirq.h:6: In file included from include/linux/irq.h:20: In file included from include/linux/io.h:13: In file included from arch/powerpc/include/asm/io.h:640: arch/powerpc/include/asm/io-defs.h:49:1: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic] DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/powerpc/include/asm/io.h:637:3: note: expanded from macro 'DEF_PCI_AC_NORET' __do_##name al; \ ^~~~~~~~~~~~~~ <scratch space>:226:1: note: expanded from here __do_outsb ^ arch/powerpc/include/asm/io.h:580:58: note: expanded from macro '__do_outsb' #define __do_outsb(p, b, n) writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n)) ~~~~~~~~~~~~~~~~~~~~~^ vim +/stack_start +505 lib/stackdepot.c 503 504 #ifdef CONFIG_PAGE_OWNER > 505 void *stack_start(struct seq_file *m, loff_t *ppos) 506 { 507 unsigned long *table = m->private; 508 struct stack_record **stacks, *stack; 509 510 /* First time */ 511 if (*ppos == 0) 512 *table = 0; 513 514 if (*ppos == -1UL) 515 return NULL; 516 517 stacks = &stack_table[*table]; 518 stack = (struct stack_record *)stacks; 519 520 return stack; 521 } 522 > 523 void *stack_next(struct seq_file *m, void *v, loff_t *ppos) 524 { 525 unsigned long *table = m->private; 526 unsigned long nr_table = *table; 527 struct stack_record *next = NULL, *stack = v, **stacks; 528 unsigned long stack_table_entries = stack_hash_mask + 1; 529 530 if (!stack) { 531 new_table: 532 /* New table */ 533 nr_table++; 534 if (nr_table >= stack_table_entries) 535 goto out; 536 stacks = &stack_table[nr_table]; 537 stack = (struct stack_record *)stacks; 538 next = stack; 539 } else { 540 next = stack->next; 541 } 542 543 if (!next) 544 goto new_table; 545 546 out: 547 *table = nr_table; 548 *ppos = (nr_table >= stack_table_entries) ? -1UL : *ppos + 1; 549 return next; 550 } 551 > 552 int stack_print(struct seq_file *m, void *v) 553 { 554 char *buf; 555 int ret = 0; 556 struct stack_record *stack =v; 557 558 if (!stack->size || stack->size < 0 || 559 stack->size > PAGE_SIZE || stack->handle.valid != 1 || 560 refcount_read(&stack->count) < 1) 561 return 0; 562 563 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); 564 ret += stack_trace_snprint(buf, PAGE_SIZE, stack->entries, stack->size, 0); 565 scnprintf(buf + ret, PAGE_SIZE - ret, "stack count: %d\n\n", 566 refcount_read(&stack->count)); 567 seq_printf(m, buf); 568 seq_puts(m, "\n\n"); 569 kfree(buf); 570 571 return 0; 572 } 573 #endif 574
Hi Oscar,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.3-rc7]
[cannot apply to akpm-mm/mm-everything next-20230421]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709
base: linus/master
patch link: https://lore.kernel.org/r/20230421101415.5734-3-osalvador%40suse.de
patch subject: [PATCH v4 2/3] mm, page_owner: Add page_owner_stacks file to print out only stacks and their counte
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20230422/202304221906.CKlcyd2r-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304221906.CKlcyd2r-lkp@intel.com/
smatch warnings:
lib/stackdepot.c:558 stack_print() warn: unsigned 'stack->size' is never less than zero.
vim +558 lib/stackdepot.c
551
552 int stack_print(struct seq_file *m, void *v)
553 {
554 char *buf;
555 int ret = 0;
556 struct stack_record *stack =v;
557
> 558 if (!stack->size || stack->size < 0 ||
559 stack->size > PAGE_SIZE || stack->handle.valid != 1 ||
560 refcount_read(&stack->count) < 1)
561 return 0;
562
563 buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
564 ret += stack_trace_snprint(buf, PAGE_SIZE, stack->entries, stack->size, 0);
565 scnprintf(buf + ret, PAGE_SIZE - ret, "stack count: %d\n\n",
566 refcount_read(&stack->count));
567 seq_printf(m, buf);
568 seq_puts(m, "\n\n");
569 kfree(buf);
570
571 return 0;
572 }
573 #endif
574
diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index b94d33312839..e1d05d9adcd1 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -116,6 +116,12 @@ depot_stack_handle_t stack_depot_save_action(unsigned long *entries, gfp_t gfp_flags, bool counter); +#ifdef CONFIG_PAGE_OWNER +void *stack_start(struct seq_file *m, loff_t *ppos); +void *stack_next(struct seq_file *m, void *v, loff_t *ppos); +int stack_print(struct seq_file *m, void *v); +#endif + /** * stack_depot_fetch - Fetch a stack trace from stack depot * diff --git a/lib/stackdepot.c b/lib/stackdepot.c index e99f4ef218ef..d0a4e6ac0bc9 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -28,6 +28,8 @@ #include <linux/types.h> #include <linux/memblock.h> #include <linux/kasan-enabled.h> +#include <linux/seq_file.h> +#include <linux/debugfs.h> #define DEPOT_HANDLE_BITS (sizeof(depot_stack_handle_t) * 8) @@ -499,6 +501,77 @@ static struct stack_record *stack_depot_getstack(depot_stack_handle_t handle) return stack; } +#ifdef CONFIG_PAGE_OWNER +void *stack_start(struct seq_file *m, loff_t *ppos) +{ + unsigned long *table = m->private; + struct stack_record **stacks, *stack; + + /* First time */ + if (*ppos == 0) + *table = 0; + + if (*ppos == -1UL) + return NULL; + + stacks = &stack_table[*table]; + stack = (struct stack_record *)stacks; + + return stack; +} + +void *stack_next(struct seq_file *m, void *v, loff_t *ppos) +{ + unsigned long *table = m->private; + unsigned long nr_table = *table; + struct stack_record *next = NULL, *stack = v, **stacks; + unsigned long stack_table_entries = stack_hash_mask + 1; + + if (!stack) { +new_table: + /* New table */ + nr_table++; + if (nr_table >= stack_table_entries) + goto out; + stacks = &stack_table[nr_table]; + stack = (struct stack_record *)stacks; + next = stack; + } else { + next = stack->next; + } + + if (!next) + goto new_table; + +out: + *table = nr_table; + *ppos = (nr_table >= stack_table_entries) ? -1UL : *ppos + 1; + return next; +} + +int stack_print(struct seq_file *m, void *v) +{ + char *buf; + int ret = 0; + struct stack_record *stack =v; + + if (!stack->size || stack->size < 0 || + stack->size > PAGE_SIZE || stack->handle.valid != 1 || + refcount_read(&stack->count) < 1) + return 0; + + buf = kzalloc(PAGE_SIZE, GFP_KERNEL); + ret += stack_trace_snprint(buf, PAGE_SIZE, stack->entries, stack->size, 0); + scnprintf(buf + ret, PAGE_SIZE - ret, "stack count: %d\n\n", + refcount_read(&stack->count)); + seq_printf(m, buf); + seq_puts(m, "\n\n"); + kfree(buf); + + return 0; +} +#endif + unsigned int stack_depot_fetch(depot_stack_handle_t handle, unsigned long **entries) { diff --git a/mm/page_owner.c b/mm/page_owner.c index b6637524e442..b191ad1d41f9 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -718,6 +718,31 @@ static const struct file_operations proc_page_owner_operations = { .llseek = lseek_page_owner, }; +static void stack_stop(struct seq_file *m, void *v) +{ + return; +} + +static const struct seq_operations page_owner_stack_op = { + .start = stack_start, + .next = stack_next, + .stop = stack_stop, + .show = stack_print +}; + +static int page_owner_stack_open(struct inode *inode, struct file *file) +{ + return seq_open_private(file, &page_owner_stack_op, + sizeof(unsigned long)); +} + +const struct file_operations page_owner_stack_operations = { + .open = page_owner_stack_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, +}; + static int __init pageowner_init(void) { if (!static_branch_unlikely(&page_owner_inited)) { @@ -728,6 +753,9 @@ static int __init pageowner_init(void) debugfs_create_file("page_owner", 0400, NULL, NULL, &proc_page_owner_operations); + debugfs_create_file("page_owner_stacks", S_IRUSR, NULL, NULL, + &page_owner_stack_operations); + return 0; } late_initcall(pageowner_init)