lkml.org 
[lkml]   [2023]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH/RFC] module: replace module_layout with module_memory
On Tue, Jan 17, 2023 at 11:40 PM Christoph Hellwig <hch@lst.de> wrote:
>
> On Tue, Jan 17, 2023 at 10:50:55AM -0800, Song Liu wrote:
> > Hi Thomas and Luis,
> >
> > Could you please share your comments on this? Specifically, is this on
> > the right direction? And, what's your preference with Christophe's
> > suggestions?
> >
> > "I dislike how it looks with enums, things like
> > mod->mod_mem[MOD_MEM_TYPE_INIT
> > _TEXT] are odd and don't read nicely.
> > Could we have something nicer like mod->mod_mem_init_text ?
> > I know it will complicate your for_each_mod_mem_type() but it would look
> > nicer."
>
> FYI, I don't particularly like the array either. But if it makes
> the code much simpler I can live with it.

How about we do something like this

struct module {
...
/* rbtree is accessed frequently, so keep together. */
union {
struct module_memory mod_mem[MOD_MEM_NUM_TYPES]
__module_memory_align;
struct {
/* keep the same order as enum mod_mem_type */
struct module_memory core_text;
struct module_memory core_data;
struct module_memory core_rodata;
struct module_memory core_ro_after_init;
struct module_memory init_text;
struct module_memory init_data;
struct module_memory init_rodata;
};
};
...
};

In this way we can use the array in the for loops, and use mod->core_text,
etc. when we only need to access one of them.

Thanks,
Song

PS: Do we need __no_randomize_layout somewhere?

\
 
 \ /
  Last update: 2023-03-26 23:46    [W:0.063 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site