linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jessica Yu <jeyu@kernel.org>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: linux-kernel@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] module: check for exit sections in layout_sections() instead of module_init_section()
Date: Fri, 14 May 2021 09:12:29 +0200	[thread overview]
Message-ID: <YJ4i3XNa3V7ifCih@p200300cbcf361a0029e37a38368d6727.dip0.t-ipconnect.de> (raw)
In-Reply-To: <20210512160651.GP1336@shell.armlinux.org.uk>

+++ Russell King - ARM Linux admin [12/05/21 17:06 +0100]:
>Hi,
>
>On Wed, May 12, 2021 at 04:46:53PM +0200, Jessica Yu wrote:
>> diff --git a/kernel/module.c b/kernel/module.c
>> index 173a09175511..a5c9842371b1 100644
>> --- a/kernel/module.c
>> +++ b/kernel/module.c
>> @@ -2430,6 +2430,9 @@ static void layout_sections(struct module *mod, struct load_info *info)
>>  			if ((s->sh_flags & masks[m][0]) != masks[m][0]
>>  			    || (s->sh_flags & masks[m][1])
>>  			    || s->sh_entsize != ~0UL
>> +#ifndef CONFIG_MODULE_UNLOAD
>> +			    || module_exit_section(sname)
>> +#endif
>>  			    || module_init_section(sname))
>
>How about a helper to make this a bit easier in both these places to
>make the code more undertsandable? I think the great value comes from
>the resulting change in the second hunk.
>
>static bool module_evictable_section(const char *sname)
>{
>#ifndef CONFIG_MODULE_UNLOAD
>	if (module_exit_section(sname))
>		return true;
>#endif
>	return module_init_section(sname);
>}
>
>and then just use that above?
>
>>  				continue;
>>  			s->sh_entsize = get_offset(mod, &mod->core_layout.size, s, i);
>> @@ -2463,7 +2466,11 @@ static void layout_sections(struct module *mod, struct load_info *info)
>>  			if ((s->sh_flags & masks[m][0]) != masks[m][0]
>>  			    || (s->sh_flags & masks[m][1])
>>  			    || s->sh_entsize != ~0UL
>> +#ifndef CONFIG_MODULE_UNLOAD
>> +			    || (!module_init_section(sname) && !module_exit_section(sname)))
>> +#else
>>  			    || !module_init_section(sname))
>> +#endif
>
>I find this a tad confusing, and this is the reason for my suggestion
>above. With that, this becomes:
>
>			    || !module_evictable_section(sname))
>
>which can be clearly seen is the opposite condition from the above
>without doing mental logic gymnastics.

Thanks Russell for the feedback! Yeah, agreed that it could be made
easier to read - will respin with a helper function.

Jessica

      reply	other threads:[~2021-05-14  7:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 14:46 [PATCH] module: check for exit sections in layout_sections() instead of module_init_section() Jessica Yu
2021-05-12 16:06 ` Russell King - ARM Linux admin
2021-05-14  7:12   ` Jessica Yu [this message]

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=YJ4i3XNa3V7ifCih@p200300cbcf361a0029e37a38368d6727.dip0.t-ipconnect.de \
    --to=jeyu@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=peterz@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;
as well as URLs for NNTP newsgroup(s).