All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Joel Fernandes <joel@joelfernandes.org>,
	Hugh Dickins <hughd@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: amusing SLUB compaction bug when CC_OPTIMIZE_FOR_SIZE
Date: Thu, 29 Sep 2022 02:56:44 +0900	[thread overview]
Message-ID: <YzSK3LJst80JkP4q@hyeyoo> (raw)
In-Reply-To: <35502bdd-1a78-dea1-6ac3-6ff1bcc073fa@suse.cz>

On Wed, Sep 28, 2022 at 06:20:10PM +0200, Vlastimil Babka wrote:
> On 9/28/22 15:48, Joel Fernandes wrote:
> > On Wed, Sep 28, 2022 at 02:49:02PM +0900, Hyeonggon Yoo wrote:
> > > On Tue, Sep 27, 2022 at 10:16:35PM -0700, Hugh Dickins wrote:
> > > > It's a bug in linux-next, but taking me too long to identify which
> > > > commit is "to blame", so let me throw it over to you without more
> > > > delay: I think __PageMovable() now needs to check !PageSlab().
> 
> When I tried that, the result wasn't really nice:
> 
> https://lore.kernel.org/all/aec59f53-0e53-1736-5932-25407125d4d4@suse.cz/
> 
> And what if there's another conflicting page "type" later. Or the debugging
> variant of rcu_head in struct page itself. The __PageMovable() is just too
> fragile.
> 
> > > > I had made a small experimental change somewhere, rebuilt and rebooted,
> > > > was not surprised to crash once swapping and compaction came in,
> > > > but was surprised to find the crash in isolate_movable_page(),
> > > > called by compaction's isolate_migratepages_block().
> > > > 
> > > > page->mapping was ffffffff811303aa, which qualifies as __PageMovable(),
> > > > which expects struct movable_operations at page->mapping minus low bits.
> > > > But ffffffff811303aa was the address of SLUB's rcu_free_slab(): I have
> > > > CONFIG_CC_OPTIMIZE_FOR_SIZE=y, so function addresses may have low bits set.
> > > > 
> > > > Over to you! Thanks,
> > > > Hugh
> > > 
> > > Wow, didn't expect this.
> > > Thank you for report!
> > > 
> > > That should be due to commit 65505d1f2338e7
> > > ("mm/sl[au]b: rearrange struct slab fields to allow larger rcu_head")
> > > as now rcu_head can use some bits that shares with mapping.
> > > 
> > > Hmm IMO we have two choices...
> > > 
> > > 1. simply drop the commit as it's only for debugging (RCU folks may not like [1])
> > 
> > Yeah definitely don't like this option as patches are out that depend on
> > this (not yet merged though). :-)
> 
> But we'll have to do that for now and postpone to 6.2 I'm afraid as merge
> window for 6.1 is too close to have confidence in any solution that we came
> up this moment.

Agreed.

> 
> > > 2. make __PageMovable() to use true page flag, with approach [2])
> > 
> > What are the drawbacks of making it a true flag?
> 
> Even if we free PageSlab, I'm sure there will be better uses of a free page
> flag than __PageMovable.
> 
> 3. With frozen page allocation
> https://lore.kernel.org/all/20220809171854.3725722-1-willy@infradead.org/
> 
> slab pages will have refcount 0 and compaction will skip them for that
> reason. But it had other unresolved issues with page isolation code IIRC.
>

4. Always align function rcu_free_slab() with 'aligned' attribute
[1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-aligned-function-attribute
[2] __aligned in include/linux/compiler_attributes.h
> > thanks,
> > 
> >   - Joel
> > 
> > 
> > 
> > 
> > > [1] https://lore.kernel.org/all/85afd876-d8bb-0804-b2c5-48ed3055e702@joelfernandes.org/
> > > [2] https://lore.kernel.org/linux-mm/20220919125708.276864-1-42.hyeyoo@gmail.com/
> > > 
> > > Thanks!
> > > 
> > > -- 
> > > Thanks,
> > > Hyeonggon
> 

-- 
Thanks,
Hyeonggon


  parent reply	other threads:[~2022-09-28 17:56 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28  5:16 amusing SLUB compaction bug when CC_OPTIMIZE_FOR_SIZE Hugh Dickins
2022-09-28  5:49 ` Hyeonggon Yoo
2022-09-28 13:48   ` Joel Fernandes
2022-09-28 15:09     ` Hyeonggon Yoo
2022-09-28 16:20     ` Vlastimil Babka
2022-09-28 17:50       ` Hugh Dickins
2022-09-29  9:58         ` Vlastimil Babka
2022-09-29 21:54           ` Hugh Dickins
2022-09-30  7:39             ` Vlastimil Babka
2022-09-30 10:45               ` Hugh Dickins
2022-09-30 11:02                 ` David Laight
2022-09-30 16:21                   ` Hugh Dickins
2022-09-30 21:34                     ` David Laight
2022-10-02  5:48             ` Hyeonggon Yoo
2022-10-03 17:00               ` Matthew Wilcox
2022-10-04 14:26                 ` Hyeonggon Yoo
2022-10-04 14:40                   ` Matthew Wilcox
2022-10-05 11:07                     ` Hyeonggon Yoo
2022-10-24 14:35                 ` Vlastimil Babka
2022-10-24 15:06                   ` Matthew Wilcox
2022-10-24 15:24                     ` Vlastimil Babka
2022-10-24 16:49                   ` Vlastimil Babka
2022-10-25  4:19                   ` Hugh Dickins
2022-10-25  9:17                     ` Vlastimil Babka
2022-10-25 15:45                       ` Hugh Dickins
2022-10-25 13:47                   ` Hyeonggon Yoo
2022-10-25 14:08                     ` Vlastimil Babka
2022-10-26 10:52                       ` Vlastimil Babka
2022-10-26 12:29                         ` Hyeonggon Yoo
2022-11-04 15:57                   ` Vlastimil Babka
2022-09-29 11:53         ` David Laight
2022-09-29 13:01           ` Vlastimil Babka
2022-09-29 14:04             ` David Laight
2022-09-28 17:56       ` Hyeonggon Yoo [this message]
2022-09-28 19:53         ` Joel Fernandes

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=YzSK3LJst80JkP4q@hyeyoo \
    --to=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.