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 9CCC9C433FE for ; Thu, 29 Sep 2022 09:58:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8FB76B0073; Thu, 29 Sep 2022 05:58:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D184F6B0074; Thu, 29 Sep 2022 05:58:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B91DA8D0001; Thu, 29 Sep 2022 05:58:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A2E316B0073 for ; Thu, 29 Sep 2022 05:58:11 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 65F6C407B2 for ; Thu, 29 Sep 2022 09:58:11 +0000 (UTC) X-FDA: 79964672382.25.607445F Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf08.hostedemail.com (Postfix) with ESMTP id A5DD0160009 for ; Thu, 29 Sep 2022 09:58:10 +0000 (UTC) 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 ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=mmhlLYan; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=PrAvghFt; spf=pass (imf08.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664445491; a=rsa-sha256; cv=none; b=sWYS64LPQ5rGM71XAS7NUb9YEQxOunlADGKFSQaceigDSt0GM+8gyCWhE3BIKITyOnrspG ny7o8oCMUlLLJwcqDlh7EywCAAI3Kr+Q2zo35JDwnBl+M8p+gBnHIW4u4RQW6EmFsHU7wE 6tvKMrwCVS+SbTkEoVpvQEWJnW+Usdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664445491; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9f7cRjM2G9fSplORaUyU85h21fLhqLa19ttKpHZljBA=; b=AIGWWxDGgkXsLlC1VKkC1aKR//2nbwwJHRECa7T2TxarZdt1YCoc5YV3C6dGIFeEiz+TAY N07FBalQ5dVlCVsbCkcYmVLJJX5ob1nSknjYsU1OJUqQjMmWuWIaROHwR5weEXbvjNxAj/ O1arPx7Ybhs6RkuRLLyw6krmrDlqsY8= Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=mmhlLYan; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=PrAvghFt; spf=pass (imf08.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.29 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspam-User: X-Stat-Signature: iw5ssyh8tjngfty433pwbbdxf7qt14xm X-Rspamd-Queue-Id: A5DD0160009 X-Rspamd-Server: rspam05 X-HE-Tag: 1664445490-991792 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 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); >