Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4427509ybv; Mon, 10 Feb 2020 19:22:37 -0800 (PST) X-Google-Smtp-Source: APXvYqz/tO1mwdIXwUE2jqYSf2KnT4aUIj18t4G5GwGZMhgFtTEH+ThnuDYIuhBYaIyBTyQwPwRt X-Received: by 2002:a9d:7305:: with SMTP id e5mr3481725otk.64.1581391357211; Mon, 10 Feb 2020 19:22:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581391357; cv=none; d=google.com; s=arc-20160816; b=B1QelIxmM1NFNhgTH/d/NXxZ3Fl1p1B8XtxSVsSMSgWYftNzLjSThLMWJxwKHPmLmS KMFcHXgdkmsGxcY8aeR2xIF5cQiUB/Svts+R2NEhEoGUPs5+V31PQOkRSf4WNdFisj7b WxjiEyz3PUnJH5iWSNs97VI89glJ3RUH66S978iRiD3w6t8stCDfpMNWME5iPWPWRwE1 nFaWDvPtbzjmmLQzE6i/tQaiDA14m0EzK3tfPm/mYNrIFSP4lXQ6nvYZYjxpLYB4QkLV 7/kwICyvLHgKQ7dsCnLAycfqOTlbdw/CjcauoFio1i92cM0MNkbhvALanuAUexJLIxGh O+RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=eF3EKJVdP05eLD326V9nYYkPMxkGb3c0ZwIS91HSDBE=; b=ttT08gq9S2lyfFoPWQ05gAJPy5AxK7xNLFNB/kTctZhjfAnCYkr0qP8t6CKzSyu8c6 u0uZzvK/OFNrI1yfbgDzMbAYtBDuHM7ZAhmsI4GJI9/XWGQyxQ167OXIwDGotc5jYF7p TTOU8DjW8j1+eeIr0nZg2CSSNMm5hg0K49lpk47oKAs4fKYgL7kqmSDaHOBJ0aR7Wr/s YWb/hl11zAInaGtBO3bQsB+xiC4Ms3slAzD/0YIdtKV9/A8FsNfDvaBPFl/0VEkex+Na IbYDXRNZ0gqwaVD71xMHfhih5dfzQz3yWWFxie0Isku5JR4x9Sz7iQKC9QpPcMyV67Qv 0wZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g0yjulO0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si1248940otk.193.2020.02.10.19.22.25; Mon, 10 Feb 2020 19:22:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=g0yjulO0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727762AbgBKDTg (ORCPT + 99 others); Mon, 10 Feb 2020 22:19:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:38622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727509AbgBKDTf (ORCPT ); Mon, 10 Feb 2020 22:19:35 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF5D020714; Tue, 11 Feb 2020 03:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581391173; bh=0ZZlJcK8McjXh01uz81yZISTYzV8JaT6PQSW2nSfIRg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g0yjulO0gpAn3JrqNTcILV2aa0BdwPiiPtg13Gwk+GZjqSbP7Lg4hZfcfz4H1pfZF lo1tBdrp5GQ3T0pnkstQjBlHj0M4IVd4x7Eg3F5R3NExW89k3ywsnOwTpM48x81tdX PmQeMDqOY+TfvSN9IrWwiSC9g3F7jo44up3zmNBY= Date: Mon, 10 Feb 2020 19:19:33 -0800 From: Greg KH To: Jing Xia Cc: akpm@linux-foundation.org, npiggin@gmail.com, rppt@linux.ibm.com, allison@lohutok.net, tglx@linutronix.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org, yuming.han@unisoc.com, chunyang.zhang@unisoc.com, Jing Xia Subject: Re: [RFC] lib/show_mem.c: extend show_mem() to support showing drivers' memory consumption Message-ID: <20200211031933.GA1835339@kroah.com> References: <1579249445-27429-1-git-send-email-jing.xia.mail@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1579249445-27429-1-git-send-email-jing.xia.mail@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 17, 2020 at 04:24:05PM +0800, Jing Xia wrote: > From: Jing Xia > > In low memory situations, sometimes we need to check how much memory > a driver using.This patch add a notifer chain to show_mem.So a driver > can show their memory usage when show_mem_extend() is called. > > Co-developed-by: Yuming Han > Signed-off-by: Yuming Han > Signed-off-by: Jing Xia > --- > include/linux/mm.h | 9 +++++++++ > lib/show_mem.c | 36 ++++++++++++++++++++++++++++++++++++ > 2 files changed, 45 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index cfaa8fe..a37274a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -2201,6 +2201,15 @@ extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long, > #ifdef __HAVE_ARCH_RESERVED_KERNEL_PAGES > extern unsigned long arch_reserved_kernel_pages(void); > #endif > +enum show_mem_extend_type { > + SHOW_MEM_EXTEND_BASIC, > + SHOW_MEM_EXTEND_CLASSIC, > + SHOW_MEM_EXTEND_ALL > +}; > +extern int register_show_mem_notifier(struct notifier_block *nb); > +extern int unregister_show_mem_notifier(struct notifier_block *nb); > +extern void show_mem_extend(unsigned int flags, nodemask_t *nodemask, > + enum show_mem_extend_type type); > > extern __printf(3, 4) > void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...); > diff --git a/lib/show_mem.c b/lib/show_mem.c > index 1c26c14..6b013cb 100644 > --- a/lib/show_mem.c > +++ b/lib/show_mem.c > @@ -7,6 +7,8 @@ > > #include > #include > +#include > +#include > > void show_mem(unsigned int filter, nodemask_t *nodemask) > { > @@ -42,3 +44,37 @@ void show_mem(unsigned int filter, nodemask_t *nodemask) > printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages)); > #endif > } > + > +static BLOCKING_NOTIFIER_HEAD(show_mem_notify_list); > + > +int register_show_mem_notifier(struct notifier_block *nb) > +{ > + return blocking_notifier_chain_register(&show_mem_notify_list, nb); > +} > +EXPORT_SYMBOL_GPL(register_show_mem_notifier); > + > +int unregister_show_mem_notifier(struct notifier_block *nb) > +{ > + return blocking_notifier_chain_unregister(&show_mem_notify_list, nb); > +} > +EXPORT_SYMBOL_GPL(unregister_show_mem_notifier); You are exporting functions that are never used at all. We can't do that. > + > +void show_mem_extend(unsigned int filter, nodemask_t *nodemask, > + enum show_mem_extend_type type) > +{ > + unsigned long used = 0; > + struct sysinfo si; > + > + pr_info("Mem-Info-Extend:\n"); > + show_mem(filter, NULL); > + si_meminfo(&si); > + pr_info("MemTotal: %8lu KB\n" > + "Buffers: %8lu KB\n" > + "SwapCached: %8lu KB\n", > + (si.totalram) << (PAGE_SHIFT - 10), > + (si.bufferram) << (PAGE_SHIFT - 10), > + total_swapcache_pages() << (PAGE_SHIFT - 10)); > + > + blocking_notifier_call_chain(&show_mem_notify_list, > + (unsigned long)type, &used); > +} Who calls this function? As a stand-alone patch, this makes no sense as it doesn't seem to do anything, so there's no way it can be accepted. Please submit this as a patch series, with actual users of these functions, if you wish to have it properly considered. thanks, greg k-h