Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp967093rwb; Wed, 28 Sep 2022 11:19:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4o0D073dtAecTZfYzLy0EwO0dEhx+6lJ50/rTvHW355BLStoXD7HyvC6CaJo5Ob8SyoRZB X-Received: by 2002:a17:902:be18:b0:178:b9c9:97b8 with SMTP id r24-20020a170902be1800b00178b9c997b8mr1060515pls.38.1664389186115; Wed, 28 Sep 2022 11:19:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664389186; cv=none; d=google.com; s=arc-20160816; b=c4j+SHjZz2SJZJeKbFJWQTaKZ+GbWsz0uAEtaxRyZK039bM+7Pgns1z4ZEHhKYvsc0 JcuMoNITnnXklogPjGQROMc+MKxtPOtW4NtFndlz3SX+oZxeMQpmwm4VaNEWlFk9kCcT B+N+YZWtxwXBNZw8EICUtON5ZRnMpr8jcgcweUISxyy5kO/ioZeZ4i9GMVOYVkb1TiG6 NpFh52i3bWeSTTegbcVzJQ728j4JucbLNqsvHgT14QGiGxUcO2x+YjGPVnbK+iRyoHwW fR78JlaECGpJMjbV67HCl2h9EfjqiszALKIzoX9rHuTDm0rGcQdQUBXkpz4rcsyMIUFz PiDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=saNHm7XA+j5ek8JG01ePSb0qFtAx/myMwKal0d1qkOE=; b=e6PbmVZBNlWrXuMvVOk4jmDsmWT04vFeTEGbIOPfciwTdvgrlo4UScx8l3BY0BaP1S 2qFC5ghURH4OLqQtHDcWue3KrT3AXYwM4V5crkY6YzBJURLekrn2dQ1jWwftZ4l9FxKI 6KUUpDTjMiEuAeNmv1A2R2Ndo2nZtvmpOhAk5kJH5gaH15hqAwxr9IANBCBrV0w6RRx6 cFa5LBB3wuvXKH9mErHvewjBlw/529H5jGXdNlCE9PW6DSmb5JfhUJgVwX1srO/ofdJt RkGkKcUkQU2DefkmhT69pYAUHyaBVnzXxArzODVBaBiDhlO4A63/Y0cwXKL41GeJIlUe 4Kvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JR5z3zsj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m24-20020a63f618000000b0043aa67c7d8esi6184776pgh.738.2022.09.28.11.19.33; Wed, 28 Sep 2022 11:19:46 -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=@gmail.com header.s=20210112 header.b=JR5z3zsj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233707AbiI1R47 (ORCPT + 99 others); Wed, 28 Sep 2022 13:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234109AbiI1R4w (ORCPT ); Wed, 28 Sep 2022 13:56:52 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02B96FB33A for ; Wed, 28 Sep 2022 10:56:50 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id v4so12853496pgi.10 for ; Wed, 28 Sep 2022 10:56:50 -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=nEKr/kLOKsDUfbYuH7naeqnwnvqMKkfxk3KLTd+cGD3PE+M4lyb1YtWduo8l25L0ng g+BTyq0cCMwhv79GEUsYKjd3v/4lz+Ekxreo6hE3AuE9p1hcn56hBW0/vNHFoc2q9EXM qs6X7bVFKvOj1Siz7n77N6BSneoYUTMcwIuF3dl6qMzULgns9i/mBHQuZdY9tp2olRyl tMTa66HCVVOW4+eeIVlgbj9RjUKBXgJhJ1fv/no0tFr44wH4ab9IPZnire8QsLzEvIV1 pYEa7YlQek2xKvNalWhO7ZyHRWgp3qQUOVzVYW/ujhUij94Yqn8deLRfBxNgYT4Rlpla oRZA== X-Gm-Message-State: ACrzQf2uBgWj1XIkJdsTQo6DKnsQI/wbLckK1yLQpSHTvHbWNJLFdjBX bUQ3gZV3WGYzLbHfec/3eTut07iawER6jxA5lDk= 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> X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HK_RANDOM_ENVFROM, HK_RANDOM_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 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