linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Hugh Dickins <hughd@google.com>
Cc: Joel Fernandes <joel@joelfernandes.org>,
	Hyeonggon Yoo <42.hyeyoo@gmail.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 11:58:08 +0200	[thread overview]
Message-ID: <de71b83a-c82c-4785-ef5a-3db4f17bbc8d@suse.cz> (raw)
In-Reply-To: <ff905c1e-5eb3-eaf8-46de-38f189c0b7a5@google.com>

On 9/28/22 19:50, Hugh Dickins wrote:
> On Wed, 28 Sep 2022, 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 don't disagree (and don't really know all the things you're thinking
> of in there).  But if it's important to rescue this feature for 6.1, a
> different approach may be the very simple patch below (I met a similar
> issue with OPTIMIZE_FOR_SIZE in i915 a year ago, and just remembered).
> 
> But you be the judge of it: (a) I do not know whether rcu_free_slab
> is the only risky address ever stuffed into that field; and (b) I'm
> clueless when it comes to those architectures (powerpc etc) where the
> the address of a function is something different from the address of
> the function (have I conveyed my cluelessness adequately?).

Thanks a lot Hugh! That's a sufficiently small fix (compared to the other
options) that I'm probably give it one last try.

> Hugh
> 
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1953,7 +1953,12 @@ static void __free_slab(struct kmem_cach
>  	__free_pages(folio_page(folio, 0), order);
>  }
>  
> -static void rcu_free_slab(struct rcu_head *h)
> +/*
> + * rcu_free_slab() must be __aligned(4) because its address is saved
> + * in the rcu_head field, which coincides with page->mapping, which
> + * causes trouble if compaction mistakes it for PAGE_MAPPING_MOVABLE.
> + */
> +__aligned(4) static void rcu_free_slab(struct rcu_head *h)
>  {
>  	struct slab *slab = container_of(h, struct slab, rcu_head);
>  



  reply	other threads:[~2022-09-29  9:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-28  5:16 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 [this message]
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
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=de71b83a-c82c-4785-ef5a-3db4f17bbc8d@suse.cz \
    --to=vbabka@suse.cz \
    --cc=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=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