Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1857379rwb; Thu, 29 Sep 2022 03:15:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7hq4ppdjnK3DhM1Tr5sBg+5nL7C8O+r+whtPtNrpoWwWAyo2VPdp8v9H7YS99QTyg7K2/F X-Received: by 2002:a62:b612:0:b0:553:1bfb:966b with SMTP id j18-20020a62b612000000b005531bfb966bmr2755942pff.53.1664446539900; Thu, 29 Sep 2022 03:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664446539; cv=none; d=google.com; s=arc-20160816; b=vN38U2UWnBx+9Toj4kY83i5Jeva9Cy3LzZtXaN60b4HZKphbBrlfUBALKEKmV0P6aN Q8N1NZXNOx3HNVGFAiG57zq1xwLU+OEMF7jlREyjY/Asqcv9ue9bhcwxfYpDY7Th4V3/ UaYSoKhr/NHT1Y+15GrVa7X1f9JD4l7qGFU/imDn+NW4gjc+0q5+Vde2TvsapJPWKVkF J10/mKGSG1VLlDcw5OXlRMrm+tLm4a2wOKwqCNpBKwFw2NpAOGQVx+TtRiEDhsXFOOhY l00JXBqhq4Q3h124xzLIUWxI7Tf94eU10XG7YWLFKKHjCR+3/X7LKMGYaYzgId0y5aih KCjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=9f7cRjM2G9fSplORaUyU85h21fLhqLa19ttKpHZljBA=; b=oR5GpWj67VQndkXMmWi9qIVzBtFYvjV8nTGxIRrlTWQS5ikKYtKdSoKpMsIgyf9TjN GphPr9LilVZ6GGqQSOiEjfGuJlDpQEh21q4DKYdgN17L1Wcv7IcziNDsfNVnNj6PBC1X EUXVysLVlv/YVmyzNXzmpLtob86VMu0FokH8hyCW2NDbRLaUGwiP0C1wSR+nmpcC6rLj oKxmxZ8/WyNHhQKDWzgIF+En/YJ+2+oNmcCLk3Qd02L83vfmg6mXkVSq6go6Wz5jmTz3 yQAykVRUlRlI+sYJiIVvIGsDh1bBtriy9cr/9HMSl5NQcmlAbWfeUhlSTG9+GtrxM67S inRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mmhlLYan; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k133-20020a62848b000000b0052e7d706a6fsi5564885pfd.149.2022.09.29.03.15.28; Thu, 29 Sep 2022 03:15:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mmhlLYan; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235029AbiI2J6Q (ORCPT + 99 others); Thu, 29 Sep 2022 05:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235189AbiI2J6O (ORCPT ); Thu, 29 Sep 2022 05:58:14 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD716132FE4 for ; Thu, 29 Sep 2022 02:58:10 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 001751F45B; Thu, 29 Sep 2022 09:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1664445489; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9f7cRjM2G9fSplORaUyU85h21fLhqLa19ttKpHZljBA=; b=mmhlLYanipKdJK37y8n7gxBBX8Ev7O8kEm9yBWKqCJMP0p1iDTjq14SxvkTIqKFWJwQMhd qmGG/ERxzWiWUMjgEVcfUazRcwKlTdMpwffI9ItygAMOzFtBCiqfA2KnyIqrQttlXYHC+K kuLJK9pweTiSYfF4AkJMZ7XL+aIgDqE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1664445489; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9f7cRjM2G9fSplORaUyU85h21fLhqLa19ttKpHZljBA=; b=PrAvghFtiIRRp29Ib5L7ZAieDYJ2gaBr3HIpJTi0F30bKDlZC5iWXpSr416P0mI/9RHMAr DN2trIz8U/9e4UBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D234413A71; Thu, 29 Sep 2022 09:58:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id V8OcMjBsNWPnRAAAMHmgww (envelope-from ); Thu, 29 Sep 2022 09:58:08 +0000 Message-ID: Date: Thu, 29 Sep 2022 11:58:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: amusing SLUB compaction bug when CC_OPTIMIZE_FOR_SIZE Content-Language: en-US To: Hugh Dickins Cc: Joel Fernandes , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Matthew Wilcox , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <35502bdd-1a78-dea1-6ac3-6ff1bcc073fa@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); >