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 4442EC32771 for ; Wed, 28 Sep 2022 17:56:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEAD86B0072; Wed, 28 Sep 2022 13:56:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9A346B0073; Wed, 28 Sep 2022 13:56:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B61FF6B0074; Wed, 28 Sep 2022 13:56:52 -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 A65216B0072 for ; Wed, 28 Sep 2022 13:56:52 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 55AA01C5F5D for ; Wed, 28 Sep 2022 17:56:52 +0000 (UTC) X-FDA: 79962249864.01.D403AA0 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by imf13.hostedemail.com (Postfix) with ESMTP id 92CC320020 for ; Wed, 28 Sep 2022 17:56:51 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 3so12896790pga.1 for ; Wed, 28 Sep 2022 10:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=saNHm7XA+j5ek8JG01ePSb0qFtAx/myMwKal0d1qkOE=; b=JR5z3zsj5qfxQDXXG7sZ8I+XslICivFkqVyGuijM9p3S9yvf2mcbAaPYzYnQmxhjZP ziM7OlP8SmngBFVW/95vq8oUuliyIEfXeDHJNBiDhd7LUScYJc5gpexf+ZSP83zLOsAT JX8mkj+zM96jcU3DFosFFdjntLlKGL+DA/2ShNrtbJ82cyuktNPqiaylcL2UMC16xWau /hykJydX1MJx3aE4OQmPH3bnFJmNjIHejOahfDPwHyWLa7cAcvsD3lJnkq8gn9qk0X9B Iqi2hawD2G5CBsyh7piPuzgL3OBQEUbLkG4mnfmWItL/EgtOvDc5AgqV9GxLoqAVcTF6 aXaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=saNHm7XA+j5ek8JG01ePSb0qFtAx/myMwKal0d1qkOE=; b=lXQl+T93PJ+s8RZPLfKbZjacem607Lb3vQBROYyatbsD+PBFrPVrqzum2c2pboJ0cu U6Nlb88CI0d0oi8eKr7WHTg5EkJV+wWeD29CHItmxrfqDeELNKkPtBc67nTIaCGaujEV 2MQIApXicRlwn+UlZHwpP4O1l/hQ7Yg5x/uG0X8v3v/kIzluivjjDQ8HnEpXbGfr8E8M Ryq3VcQWlqCMxNRVPgOxoQrE9QQIrGo5TGQqC0wHTIJ6Ag+TPg934i/jFTuw4UonVv2X pWhu8Q9ADB48O6FZ1cPzPvBhKvmQq3qXtF5w7CmhCfR9frPXAO8MNzmwt458eughK0Ks nU8w== X-Gm-Message-State: ACrzQf1jWgVfF4sRqs5ezgTC98LA9/iLRaUqESKNBPvpNQRJtBcs7+Pp gpHR0dgM0GWU+FeG4ytaEW0= X-Google-Smtp-Source: AMsMyM6vzk7vMFkioI9bgdejXIIQN+OaGxtFssZJ+Yh7sJ8cRox0ioktunoVeE7JVE64PFCnqwPrrQ== X-Received: by 2002:a05:6a00:158f:b0:546:b777:af17 with SMTP id u15-20020a056a00158f00b00546b777af17mr35552988pfk.51.1664387810335; Wed, 28 Sep 2022 10:56:50 -0700 (PDT) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id s9-20020a170902ea0900b0016bb24f5d19sm4134281plg.209.2022.09.28.10.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Sep 2022 10:56:49 -0700 (PDT) Date: Thu, 29 Sep 2022 02:56:44 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: Joel Fernandes , 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 Message-ID: References: <35502bdd-1a78-dea1-6ac3-6ff1bcc073fa@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <35502bdd-1a78-dea1-6ac3-6ff1bcc073fa@suse.cz> ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JR5z3zsj; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664387811; a=rsa-sha256; cv=none; b=PYWVUnVmjOdTuqJndPY4/HMmMlyAQb65QK4qlW1itvsiwiKFx/+EGtsEbDn0cAU4B1RaLS po+9/seOjrDYe7K9ptzP9+9oVGBdeonN2tYKEKuFEh3iIRaLXfTgXwz8jOuuMAW2nOlcLS IBAr23ahIt5IyoHqsVJBQWQCskHLN9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664387811; 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=saNHm7XA+j5ek8JG01ePSb0qFtAx/myMwKal0d1qkOE=; b=onvoN0n3Y5Ykb6n552/4eKwIMRgz8mmh5ZMK/FumyT8xxM0/7Drr4Lz7/RTqcbcQkQgGUo VotV/dskv5UI8VxNFxH2IQjLHtRsiVdXdPf+AvuMJ2Ze8AuSifAws5z8BZwxfka96j85S7 5pAFdS0Y9FYlMVx6tIJLBju/oT7QIfw= X-Stat-Signature: kdyymm9skz5ozaht697j94yc48og1gqh X-Rspamd-Queue-Id: 92CC320020 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=JR5z3zsj; spf=pass (imf13.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.173 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1664387811-77022 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, 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