From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20A1CC32771 for ; Wed, 28 Sep 2022 17:50:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 484506B0072; Wed, 28 Sep 2022 13:50:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 433756B0073; Wed, 28 Sep 2022 13:50:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ADEF6B0074; Wed, 28 Sep 2022 13:50:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1589B6B0072 for ; Wed, 28 Sep 2022 13:50:17 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C0B7C80F1A for ; Wed, 28 Sep 2022 17:50:16 +0000 (UTC) X-FDA: 79962233232.05.6399F49 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) by imf30.hostedemail.com (Postfix) with ESMTP id 4C89B80002 for ; Wed, 28 Sep 2022 17:50:16 +0000 (UTC) Received: by mail-ot1-f41.google.com with SMTP id r34-20020a05683044a200b0065a12392fd7so8640445otv.3 for ; Wed, 28 Sep 2022 10:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date; bh=n8VETjucgkSeOgw4Z+kCG1eP9l2HUQ8Y2HmD1XceACY=; b=Jz8Ag9PP7tHzbMoCA5rX0mXf6nqmFgbD+FFKuSJb5AEC+fpxyChSh+/EKyWROJGaV9 Zr7B2MCjnb1ZAimADunpFIHA0konLO4Alb9jZDYJ1wAJPeVWkXgVJ5oplNBxWRc4dsC1 E3TjlDV1fk+of8wDiVghEqSocoVsyzcCrf8YgxnRwg+aHcWG9p+/pv198Jnqtgk4wH+D lX5uNjO8eeW5EFr3DaXM/w8puM/YgdAmG4p4oK8YUVpowC+EqgJw5RYZWVfHHpOPzhtB 0yT0lcxXr1pR0KJebaix5fVzPdXQHPTodnqeQw6spmUGCyIQnKbyQnwBjYpMVoPXEB6R oGJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date; bh=n8VETjucgkSeOgw4Z+kCG1eP9l2HUQ8Y2HmD1XceACY=; b=uG7eFlesSc/Ojs7ysHfH2Or90BKDRC5FTdJNXbPdT91hrLm3oc+dqljCp35ATz55k4 kUgcvtIDtL34LGSV69rx2jfi1ypVy4Mv4JJ8wLstz3lFmyjPoQXyrw78dxgzrtmjsj9Z 2072xdBc2pW/ZiN/FdQieyVBkklEP0EM0IyHDEDkodLZXABupgW8RTEbfTTPeeL5Y1mQ nDdyyamc+UBPCiS4fv1U0AiyHo5f8YN2rt806NmI2QR0IwlpkGARmLvByKUpMfHSGGAW 3Lf7MTYJZPjkqCRNh+zSnnlZDImQoOj2vNDidijEruZoIHxNn9llayhaGcPMMpnLy4tt PKvQ== X-Gm-Message-State: ACrzQf1zAM5zi8tdM01rRrTgW1jBl9Uf+lhTHu67kuXIoAcy2EzMTnRs fns6GWdB7X8praKu5g4F+fiBHQ== X-Google-Smtp-Source: AMsMyM7NArCQS6Gdbf3GmdJkrxR8LEzyb0rmKAhbsnOEOl68tUtfGYgr18fOacfnKK4IbhNaoDdqLg== X-Received: by 2002:a05:6830:349:b0:63a:cd5d:9014 with SMTP id h9-20020a056830034900b0063acd5d9014mr14762382ote.29.1664387415249; Wed, 28 Sep 2022 10:50:15 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id u35-20020a4a8c26000000b00475db5c28f9sm2214543ooj.10.2022.09.28.10.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 10:50:14 -0700 (PDT) Date: Wed, 28 Sep 2022 10:50:05 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Vlastimil Babka cc: Joel Fernandes , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Hugh Dickins , Matthew Wilcox , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: amusing SLUB compaction bug when CC_OPTIMIZE_FOR_SIZE In-Reply-To: <35502bdd-1a78-dea1-6ac3-6ff1bcc073fa@suse.cz> Message-ID: References: <35502bdd-1a78-dea1-6ac3-6ff1bcc073fa@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664387416; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=n8VETjucgkSeOgw4Z+kCG1eP9l2HUQ8Y2HmD1XceACY=; b=MxcnJ3OWhTQpWV0MiiFR3Szgu7ouwa7X0FZYHimogPfDZtAwr96lVraoxJBoTfjjLCheuC +EEWxr9BOb8ekFiup8wUmPEinv9Lhv84VS4TrcsIc68CmS2uWnaB/XKMl+NDWsJM7rdw6j JK+gbm6V/gKK+whhaxYZzSxHnwGdyp0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Jz8Ag9PP; spf=pass (imf30.hostedemail.com: domain of hughd@google.com designates 209.85.210.41 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664387416; a=rsa-sha256; cv=none; b=3ZCvX2TnJtiSddfWlKe7erG44y9WD7r7nga8va7451qGt5l9HdxXsL1otwGlgNMYfEJHNW tXl/RecFCjTMS9ATjDTQzjyDMJcYqIs36V+ykfRcZj3Ptd3oCVfTYBxzmHEPEqBFQ2Fcfr eR2xhe1DJE63axTVuTsU4s+p0A4OJ6Q= X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 4C89B80002 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Jz8Ag9PP; spf=pass (imf30.hostedemail.com: domain of hughd@google.com designates 209.85.210.41 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: aqmt7a6gpz3e6t6pee659kdmm75mh1iu X-HE-Tag: 1664387416-468835 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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?). 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);