From: Luis Chamberlain <mcgrof@kernel.org>
To: Petr Pavlu <petr.pavlu@suse.com>
Cc: christophe.leroy@csgroup.eu, tglx@linutronix.de,
peterz@infradead.org, song@kernel.org, rppt@kernel.org,
dave@stgolabs.net, willy@infradead.org, vbabka@suse.cz,
mhocko@suse.com, dave.hansen@linux.intel.com,
colin.i.king@gmail.com, jim.cromie@gmail.com,
catalin.marinas@arm.com, jbaron@akamai.com,
rick.p.edgecombe@intel.com, david@redhat.com,
patches@lists.linux.dev, linux-modules@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
pmladek@suse.com, prarit@redhat.com,
torvalds@linux-foundation.org, gregkh@linuxfoundation.org,
rafael@kernel.org
Subject: Re: [PATCH v3 3/4] module: add debug stats to help identify memory pressure
Date: Tue, 18 Apr 2023 11:30:36 -0700 [thread overview]
Message-ID: <ZD7hzIvJxFNDnzpU@bombadil.infradead.org> (raw)
In-Reply-To: <6110982a-bb68-c88b-6fd1-24d2c49d9fd7@suse.com>
On Mon, Apr 17, 2023 at 01:18:14PM +0200, Petr Pavlu wrote:
> On 4/14/23 07:08, Luis Chamberlain wrote:
<-- Petr's spell checking -->
> Note that there are plenty of other typos in the added comments and
> documentation. Please review them with a spell checker.
Yes I am terrible at that, I've now integrated a spell checker into
my workflow. Fixed all these, thanks.
> > @@ -2500,6 +2503,18 @@ static noinline int do_init_module(struct module *mod)
> > {
> > int ret = 0;
> > struct mod_initfree *freeinit;
> > +#if defined(CONFIG_MODULE_STATS)
> > + unsigned int text_size = 0, total_size = 0;
> > +
> > + for_each_mod_mem_type(type) {
> > + const struct module_memory *mod_mem = &mod->mem[type];
> > + if (mod_mem->size) {
> > + total_size += mod_mem->size;
> > + if (type == MOD_TEXT || type == MOD_INIT_TEXT)
> > + text_size += mod->mem[type].size;
>
> 'text_size += mod_mem->size;' would be simpler.
Sure.
> > +extern struct dentry *mod_debugfs_root;
>
> Files kernel/module/stats.c and kernel/module/tracking.c both add this extern
> declaration. Can it be moved to kernel/module/internal.h?
Sure.
> > +#if defined(CONFIG_MODULE_DECOMPRESS)
> > + if (flags & MODULE_INIT_COMPRESSED_FILE)
> > + atomic_long_add(info->compressed_len, &invalid_mod_byte);
>
> Variable invalid_mod_byte is not declared, should be invalid_mod_bytes.
Arnd already sent a fix for that, thanks.
> > +int try_add_failed_module(const char *name, size_t len, enum fail_dup_mod_reason reason)
>
> Function try_add_failed_module() is only called from
> module_patient_check_exists() which always passes in a NUL-terminated string.
> The len parameter could be then dropped and the comparison in
> try_add_failed_module() could simply use strcmp().
Sure, did that.
> Indentation in try_add_failed_module() uses spaces instead of tabs in a few
> places.
Fixed.
> > + size = MAX_PREAMBLE + min((unsigned int)(floads + fbecoming) * MAX_BYTES_PER_MOD,
> > + (unsigned int) MAX_FAILED_MOD_PRINT * MAX_BYTES_PER_MOD);
>
> Using
> 'size = MAX_PREAMBLE + min((unsigned int)(floads + fbecoming), (unsigned int)MAX_FAILED_MOD_PRINT) * MAX_BYTES_PER_MOD;'
> is a bit simpler and avoids any theoretical overflow of
> '(floads + fbecoming) * MAX_BYTES_PER_MOD'.
Sure.
> > + len += scnprintf(buf + len, size - len, "%25s\t%15s\t%25s\n",
> > + "module-name", "How-many-times", "Reason");
>
> "module-name" -> "Module-name"
OK sure.
> Function module_stats_init() requires mod_debugfs_root being initialized which
> is done in module_debugfs_init(). Both functions are recorded to be called via
> module_init(). Just to make sure, is their ordering guaranteed in some way?
Link order takes care of that and main.o goes first.
> mod_debugfs_root is initialized in module_debugfs_init() only if
> CONFIG_MODULE_DEBUG is set. However, my reading is that feature
> CONFIG_MODULE_UNLOAD_TAINT_TRACKING is orthogonal to it and doesn't require
> CONFIG_MODULE_DEBUG, so it looks this change breaks this tracking?
Ah yes We need a bool CONFIG_MODULE_DEBUGFS which is selected by those
that need it. Added.
Luis
next prev parent reply other threads:[~2023-04-18 18:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-14 5:08 [PATCH v3 0/4] module: avoid userspace pressure on unwanted allocations Luis Chamberlain
2023-04-14 5:08 ` [PATCH v3 1/4] module: fix kmemleak annotations for non init ELF sections Luis Chamberlain
2023-04-14 10:18 ` Catalin Marinas
2023-04-14 5:08 ` [PATCH v3 2/4] module: extract patient module check into helper Luis Chamberlain
2023-04-14 5:08 ` [PATCH v3 3/4] module: add debug stats to help identify memory pressure Luis Chamberlain
2023-04-17 11:18 ` Petr Pavlu
2023-04-18 18:30 ` Luis Chamberlain [this message]
2023-04-18 18:37 ` [PATCH v4] " Luis Chamberlain
2023-04-14 5:08 ` [PATCH v3 4/4] module: avoid allocation if module is already present and ready Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZD7hzIvJxFNDnzpU@bombadil.infradead.org \
--to=mcgrof@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=colin.i.king@gmail.com \
--cc=dave.hansen@linux.intel.com \
--cc=dave@stgolabs.net \
--cc=david@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=jbaron@akamai.com \
--cc=jim.cromie@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-modules@vger.kernel.org \
--cc=mhocko@suse.com \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=petr.pavlu@suse.com \
--cc=pmladek@suse.com \
--cc=prarit@redhat.com \
--cc=rafael@kernel.org \
--cc=rick.p.edgecombe@intel.com \
--cc=rppt@kernel.org \
--cc=song@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox