mbox series

[0/4] mm: Use slab_list list_head instead of lru

Message ID 20190311010744.5862-1-tobin@kernel.org (mailing list archive)
Headers show
Series mm: Use slab_list list_head instead of lru | expand

Message

Tobin C. Harding March 11, 2019, 1:07 a.m. UTC
Currently the slab allocators (ab)use the struct page 'lru' list_head.
We have a list head for slab allocators to use, 'slab_list'.

Clean up all three allocators by using the 'slab_list' list_head instead
of overloading the 'lru' list_head.

Initial patch makes no code changes, adds comments to #endif statements.

Final 3 patches do changes as a patch per allocator, tested by building
and booting (in Qemu) after configuring kernel to use appropriate
allocator.  Also build and boot with debug options enabled (for slab
and slub).


thanks,
Tobin.

Tobin C. Harding (4):
  slub: Add comments to endif pre-processor macros
  slub: Use slab_list instead of lru
  slab: Use slab_list instead of lru
  slob: Use slab_list instead of lru

 mm/slab.c | 49 +++++++++++++++++++++++----------------------
 mm/slob.c | 10 +++++-----
 mm/slub.c | 60 +++++++++++++++++++++++++++----------------------------
 3 files changed, 60 insertions(+), 59 deletions(-)

Comments

Roman Gushchin March 11, 2019, 8:49 p.m. UTC | #1
On Mon, Mar 11, 2019 at 12:07:40PM +1100, Tobin C. Harding wrote:
> Currently the slab allocators (ab)use the struct page 'lru' list_head.
> We have a list head for slab allocators to use, 'slab_list'.
> 
> Clean up all three allocators by using the 'slab_list' list_head instead
> of overloading the 'lru' list_head.
> 
> Initial patch makes no code changes, adds comments to #endif statements.
> 
> Final 3 patches do changes as a patch per allocator, tested by building
> and booting (in Qemu) after configuring kernel to use appropriate
> allocator.  Also build and boot with debug options enabled (for slab
> and slub).

Hi Tobin!

The patchset looks good to me, however I'd add some clarifications
why switching from lru to slab_list is safe.

My understanding is that the slab_list fields isn't currently in use,
but it's not that obvious that putting slab_list and next/pages/pobjects
fields into a union is safe (for the slub case).

Please, add a clarification/comment.

For patches 1, 3 and 4:
Reviewed-by: Roman Gushchin <guro@fb.com>

Thanks!
Matthew Wilcox March 11, 2019, 11:16 p.m. UTC | #2
On Mon, Mar 11, 2019 at 08:49:23PM +0000, Roman Gushchin wrote:
> The patchset looks good to me, however I'd add some clarifications
> why switching from lru to slab_list is safe.
> 
> My understanding is that the slab_list fields isn't currently in use,
> but it's not that obvious that putting slab_list and next/pages/pobjects
> fields into a union is safe (for the slub case).

It's already in a union.

struct page {
        union {
                struct {        /* Page cache and anonymous pages */
                        struct list_head lru;
...
                struct {        /* slab, slob and slub */
                        union {
                                struct list_head slab_list;     /* uses lru */
                                struct {        /* Partial pages */
                                        struct page *next;

slab_list and lru are in the same bits.  Once this patch set is in,
we can remove the enigmatic 'uses lru' comment that I added.
Roman Gushchin March 12, 2019, 12:22 a.m. UTC | #3
On Mon, Mar 11, 2019 at 04:16:33PM -0700, Matthew Wilcox wrote:
> On Mon, Mar 11, 2019 at 08:49:23PM +0000, Roman Gushchin wrote:
> > The patchset looks good to me, however I'd add some clarifications
> > why switching from lru to slab_list is safe.
> > 
> > My understanding is that the slab_list fields isn't currently in use,
> > but it's not that obvious that putting slab_list and next/pages/pobjects
> > fields into a union is safe (for the slub case).
> 
> It's already in a union.
> 
> struct page {
>         union {
>                 struct {        /* Page cache and anonymous pages */
>                         struct list_head lru;
> ...
>                 struct {        /* slab, slob and slub */
>                         union {
>                                 struct list_head slab_list;     /* uses lru */
>                                 struct {        /* Partial pages */
>                                         struct page *next;
> 
> slab_list and lru are in the same bits.  Once this patch set is in,
> we can remove the enigmatic 'uses lru' comment that I added.

Ah, perfect, thanks! Makes total sense then.

Tobin, can you, please, add a note to the commit message?
With the note:
Reviewed-by: Roman Gushchin <guro@fb.com>

Thank you!
Tobin Harding March 12, 2019, 1:05 a.m. UTC | #4
On Mon, Mar 11, 2019 at 04:16:33PM -0700, Matthew Wilcox wrote:
> On Mon, Mar 11, 2019 at 08:49:23PM +0000, Roman Gushchin wrote:
> > The patchset looks good to me, however I'd add some clarifications
> > why switching from lru to slab_list is safe.
> > 
> > My understanding is that the slab_list fields isn't currently in use,
> > but it's not that obvious that putting slab_list and next/pages/pobjects
> > fields into a union is safe (for the slub case).
> 
> It's already in a union.
> 
> struct page {
>         union {
>                 struct {        /* Page cache and anonymous pages */
>                         struct list_head lru;
> ...
>                 struct {        /* slab, slob and slub */
>                         union {
>                                 struct list_head slab_list;     /* uses lru */
>                                 struct {        /* Partial pages */
>                                         struct page *next;
> 
> slab_list and lru are in the same bits.  Once this patch set is in,
> we can remove the enigmatic 'uses lru' comment that I added.

Funny you should say this, I came to me today while daydreaming that I
should have removed that comment :)

I'll remove it in v2.

thanks,
Tobin.
Tobin Harding March 12, 2019, 1:06 a.m. UTC | #5
On Tue, Mar 12, 2019 at 12:22:23AM +0000, Roman Gushchin wrote:
> On Mon, Mar 11, 2019 at 04:16:33PM -0700, Matthew Wilcox wrote:
> > On Mon, Mar 11, 2019 at 08:49:23PM +0000, Roman Gushchin wrote:
> > > The patchset looks good to me, however I'd add some clarifications
> > > why switching from lru to slab_list is safe.
> > > 
> > > My understanding is that the slab_list fields isn't currently in use,
> > > but it's not that obvious that putting slab_list and next/pages/pobjects
> > > fields into a union is safe (for the slub case).
> > 
> > It's already in a union.
> > 
> > struct page {
> >         union {
> >                 struct {        /* Page cache and anonymous pages */
> >                         struct list_head lru;
> > ...
> >                 struct {        /* slab, slob and slub */
> >                         union {
> >                                 struct list_head slab_list;     /* uses lru */
> >                                 struct {        /* Partial pages */
> >                                         struct page *next;
> > 
> > slab_list and lru are in the same bits.  Once this patch set is in,
> > we can remove the enigmatic 'uses lru' comment that I added.
> 
> Ah, perfect, thanks! Makes total sense then.
> 
> Tobin, can you, please, add a note to the commit message?
> With the note:
> Reviewed-by: Roman Gushchin <guro@fb.com>

Thanks for the review Roman, will add tag to v2.

	Tobin.
Tobin Harding March 12, 2019, 2:01 a.m. UTC | #6
On Tue, Mar 12, 2019 at 12:22:23AM +0000, Roman Gushchin wrote:
> On Mon, Mar 11, 2019 at 04:16:33PM -0700, Matthew Wilcox wrote:
> > On Mon, Mar 11, 2019 at 08:49:23PM +0000, Roman Gushchin wrote:
> > > The patchset looks good to me, however I'd add some clarifications
> > > why switching from lru to slab_list is safe.
> > > 
> > > My understanding is that the slab_list fields isn't currently in use,
> > > but it's not that obvious that putting slab_list and next/pages/pobjects
> > > fields into a union is safe (for the slub case).
> > 
> > It's already in a union.
> > 
> > struct page {
> >         union {
> >                 struct {        /* Page cache and anonymous pages */
> >                         struct list_head lru;
> > ...
> >                 struct {        /* slab, slob and slub */
> >                         union {
> >                                 struct list_head slab_list;     /* uses lru */
> >                                 struct {        /* Partial pages */
> >                                         struct page *next;
> > 
> > slab_list and lru are in the same bits.  Once this patch set is in,
> > we can remove the enigmatic 'uses lru' comment that I added.
> 
> Ah, perfect, thanks! Makes total sense then.
> 
> Tobin, can you, please, add a note to the commit message?
> With the note:
> Reviewed-by: Roman Gushchin <guro@fb.com>

Awesome, thanks.  That's for all 4 patches or excluding 2?

thanks,
Tobin.
Matthew Wilcox March 12, 2019, 2:38 a.m. UTC | #7
On Tue, Mar 12, 2019 at 12:05:54PM +1100, Tobin C. Harding wrote:
> > slab_list and lru are in the same bits.  Once this patch set is in,
> > we can remove the enigmatic 'uses lru' comment that I added.
> 
> Funny you should say this, I came to me today while daydreaming that I
> should have removed that comment :)
> 
> I'll remove it in v2.

That's great.  BTW, something else you could do to verify this patch
set is check that the object file is unchanged before/after the patch.
I tend to use 'objdump -dr' to before.s and after.s and use 'diff'
to compare the two.
Tobin Harding March 12, 2019, 3:53 a.m. UTC | #8
On Mon, Mar 11, 2019 at 07:38:28PM -0700, Matthew Wilcox wrote:
> On Tue, Mar 12, 2019 at 12:05:54PM +1100, Tobin C. Harding wrote:
> > > slab_list and lru are in the same bits.  Once this patch set is in,
> > > we can remove the enigmatic 'uses lru' comment that I added.
> > 
> > Funny you should say this, I came to me today while daydreaming that I
> > should have removed that comment :)
> > 
> > I'll remove it in v2.
> 
> That's great.  BTW, something else you could do to verify this patch
> set is check that the object file is unchanged before/after the patch.
> I tend to use 'objdump -dr' to before.s and after.s and use 'diff'
> to compare the two.

Oh cool, I didn't know to do that.  I'm not super familiar with the use
of unions having never had need to use one myself so any other union
related tips you think of please share.

thanks,
Tobin.
Roman Gushchin March 12, 2019, 5:19 p.m. UTC | #9
On Tue, Mar 12, 2019 at 01:01:53PM +1100, Tobin C. Harding wrote:
> On Tue, Mar 12, 2019 at 12:22:23AM +0000, Roman Gushchin wrote:
> > On Mon, Mar 11, 2019 at 04:16:33PM -0700, Matthew Wilcox wrote:
> > > On Mon, Mar 11, 2019 at 08:49:23PM +0000, Roman Gushchin wrote:
> > > > The patchset looks good to me, however I'd add some clarifications
> > > > why switching from lru to slab_list is safe.
> > > > 
> > > > My understanding is that the slab_list fields isn't currently in use,
> > > > but it's not that obvious that putting slab_list and next/pages/pobjects
> > > > fields into a union is safe (for the slub case).
> > > 
> > > It's already in a union.
> > > 
> > > struct page {
> > >         union {
> > >                 struct {        /* Page cache and anonymous pages */
> > >                         struct list_head lru;
> > > ...
> > >                 struct {        /* slab, slob and slub */
> > >                         union {
> > >                                 struct list_head slab_list;     /* uses lru */
> > >                                 struct {        /* Partial pages */
> > >                                         struct page *next;
> > > 
> > > slab_list and lru are in the same bits.  Once this patch set is in,
> > > we can remove the enigmatic 'uses lru' comment that I added.
> > 
> > Ah, perfect, thanks! Makes total sense then.
> > 
> > Tobin, can you, please, add a note to the commit message?
> > With the note:
> > Reviewed-by: Roman Gushchin <guro@fb.com>
> 
> Awesome, thanks.  That's for all 4 patches or excluding 2?

To all 4, given that you'll add some explanations to the commit message.

Thanks!
Roman Gushchin March 12, 2019, 5:22 p.m. UTC | #10
On Mon, Mar 11, 2019 at 07:38:28PM -0700, Matthew Wilcox wrote:
> On Tue, Mar 12, 2019 at 12:05:54PM +1100, Tobin C. Harding wrote:
> > > slab_list and lru are in the same bits.  Once this patch set is in,
> > > we can remove the enigmatic 'uses lru' comment that I added.
> > 
> > Funny you should say this, I came to me today while daydreaming that I
> > should have removed that comment :)
> > 
> > I'll remove it in v2.
> 
> That's great.  BTW, something else you could do to verify this patch
> set is check that the object file is unchanged before/after the patch.
> I tend to use 'objdump -dr' to before.s and after.s and use 'diff'
> to compare the two.

Btw, is it guaranteed that the object file will not change?
I was about to recommend the same, but was not sure, if such change
can cause gcc to generate a *slightly* different obj code.

Thanks!