Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1755359rwb; Wed, 5 Oct 2022 04:27:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM529vc4ppaHUNslAn7crviqjOjgPZXEKQSmFe1lXT4So9Pl+Or8s+qEu+Ejtf2bkpZQ3XuA X-Received: by 2002:a17:90b:17ca:b0:200:b25e:cd7c with SMTP id me10-20020a17090b17ca00b00200b25ecd7cmr4632591pjb.53.1664969254280; Wed, 05 Oct 2022 04:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664969254; cv=none; d=google.com; s=arc-20160816; b=ZHvrO2HbJcHnrb6Exf3B2umV3wNSt1hkyzYRJ02a5eNZuurF6eEEgXFumqbsWcT7Un W5rgtlL+ShDWcafApT+Z6Mfsru6wLJptN3Ob3hAvOYmJ8GlslV8UPTAzx5gTmI7gqYmy 2hmPynHIOk5HB5YvQMAYMIFqPOE+YJKSclKu1hsWaHdP+D+WBadUYF4jRmUWkBv1b27h I9vipkb0Ddu01JsVbcCLNhMEZXsjUbgtMm83pbzqIpPCVG/HngR7n0LRHhk0XWgSrL3S xNeihCyUS83RPbWbZEbq45PnZc+gdO6eHKtPoWqeF2Zap6mtkwtvcWhFfNBIaYp94q9H g2GQ== 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=T6cNJN1BhNPosz4VSa6UZSLK0x7rvKXHqaLGbTtwrio=; b=eBZLpqERH8z0NH1G3a1n1Oc4lxLSU+Kf3byIXs67ncFAnpFdm1ucY+O+DKw9T8inlT 84ZjQJI4WPuxudx0ajcl/fg3hNx6jw88/Ut+v8qKZ+RyTK17BMmpHDUDPym5KrEb2hRr rDCQD8Q2GgWdziAOYHmQq2TMcHtugc6h3j61n3NXy3y2FxczPWleZT6yr55Jlgwq4bIQ ju5I9a1mAUvI9MweLwAgOxiLHBph2MyBdTBfb4PygdSnwRr1wIFMz6s97IQJYuKEVOcc fzBQfe2wjyct7LYTSuqggUd3wj0DpXMqk9cEYC193hTNIZMElQ1WTx/2L1kAjKHO3Ory o3xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Xd6r4cBU; 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 c14-20020a170903234e00b0016f9420a15asi16630361plh.168.2022.10.05.04.27.22; Wed, 05 Oct 2022 04:27:34 -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=Xd6r4cBU; 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 S229733AbiJELHc (ORCPT + 99 others); Wed, 5 Oct 2022 07:07:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbiJELHa (ORCPT ); Wed, 5 Oct 2022 07:07:30 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BB0266116; Wed, 5 Oct 2022 04:07:30 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id bh13so14995860pgb.4; Wed, 05 Oct 2022 04:07:30 -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=T6cNJN1BhNPosz4VSa6UZSLK0x7rvKXHqaLGbTtwrio=; b=Xd6r4cBUTSnEVZYxm+xmIkHByx7mcvEIip0+xONd3YDwWnW+O/ghjxKjYrW9JIFAIW wAlAPFGTMXDZtEhPUmMuWB2H+71JOfvoMCu0kEplxlSLPMD1lpfTfcScz3UqyGRJvQIa /yoWMbBrIBWXOIl6WZRgfeiqyztiJebIIySbe6QB3ppFGkt5QJdtdlRkvH0Hh8ppKRuW IqUXS79J0TuvmFJanubnGIWfKzjjPjkzA6dAKZdCe4T6AzBtEQjwskMqVTQlHTCnW7Jr 94MWUQeI1wJf6W/D8tBC/hwx4vb/NxsQ10rN+jw21Dk/zCM4cAl3cLzB6gEHofKw15f2 U9jQ== 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=T6cNJN1BhNPosz4VSa6UZSLK0x7rvKXHqaLGbTtwrio=; b=k3A2Zye9DOf9ALJBxjPQ5M+3S5ORtxsvhOr8uWF4kQYMmBIiu9uJaCDW6quXb6j6Z/ 3Et8TVvrnACrBq/txyN6Bm3fJrZKBYQNgcT2pcjKbEPhnHIQwu4FemookkMOkcCFVrlB yatDgC/PaBxzQ6olyjyzfMCI8XmgK1SfsaMZ0vWlW3iQYbp1gH9Uhrg9ldnFVb0AY5e0 v9NOQWuN7X2TzyoBXwsMjdCVDOzrHn93sMpGnjst0x8UfiYmsSfnvl37aJdbdow5iyvQ w+g9hL0dtVr3Z6q9mo88T4ADo+kOD7t25o/VQSDS59W1DOb8HdoxObjzl+o4xfYVIiPB yuGA== X-Gm-Message-State: ACrzQf04C/+2lXLJRSUyXi3OBHbN4NbfiITMD/aajimoy12UNWwhg0N5 jJqq//jhJMS1jpEs80P2g6I3JkBPbuifVA== X-Received: by 2002:a63:c06:0:b0:439:9b18:8574 with SMTP id b6-20020a630c06000000b004399b188574mr27029784pgl.608.1664968049671; Wed, 05 Oct 2022 04:07:29 -0700 (PDT) Received: from hyeyoo ([114.29.91.56]) by smtp.gmail.com with ESMTPSA id v5-20020a626105000000b00561852ff01bsm4872099pfb.61.2022.10.05.04.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 04:07:28 -0700 (PDT) Date: Wed, 5 Oct 2022 20:07:23 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Matthew Wilcox Cc: Hugh Dickins , Vlastimil Babka , David Laight , Joel Fernandes , Andrew Morton , Minchan Kim , linux-kernel@vger.kernel.org, linux-mm@kvack.org, rcu@vger.kernel.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: 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 Tue, Oct 04, 2022 at 03:40:36PM +0100, Matthew Wilcox wrote: > On Tue, Oct 04, 2022 at 11:26:33PM +0900, Hyeonggon Yoo wrote: > > > It's the acquisition of > > > the refcount which stabilises the slab flag, not holding the lock. > > > > But can you please elaborate how this prevents race between > > allocation & initialization of a slab and isolate_movable_page()? > > > > Or maybe we can handle it with frozen folio as Vlastimil suggested? ;-) > > Yes, we discussed that a little yesterday. I'm hoping to have a > refreshed patchset for frozen folios out today. Some of this patch > is still needed, even if we go that route. Good to hear that. With that, everyting looks sane to me. > > > @@ -91,8 +99,8 @@ int isolate_movable_page(struct page *page, isolate_mode_t mode) > > > * lets be sure we have the page lock > > > * before proceeding with the movable page isolation steps. > > > */ > > > - if (unlikely(!trylock_page(page))) > > > - goto out_putpage; > > > + if (unlikely(!folio_trylock(folio))) > > > + goto out_put; > > > > I don't know much about callers that this is trying to avoid race aginst... > > > > But for this to make sense, I think *every users* that doing their stuff with > > sub-page of a compound page should acquire folio lock and not page lock > > of sub-page, right? > > There is no page lock per se. If you try to acquire the lock on a tail > page, it acquires the lock on its head page. It's been that way for a > very long time. A lot of people are confused by this, which was part of > the motivation for making it explicit with folios. You are right! Reading the code, too bad I even assumed that there was sub-page lock. -- Thanks, Hyeonggon