Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp570601rwb; Tue, 4 Oct 2022 07:51:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Cpltbl7DrrZJBftPxbQomb1+ETJ5MDraR8rS5AJoYa+gLN0snB/aSQueugAeZc/iao5R6 X-Received: by 2002:a63:4383:0:b0:440:3e0d:b9ec with SMTP id q125-20020a634383000000b004403e0db9ecmr24422879pga.54.1664895089565; Tue, 04 Oct 2022 07:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664895089; cv=none; d=google.com; s=arc-20160816; b=JkFlNapRseof77NVmLTjkPMVVquh5muCwQU9r1zi8/y69yXKuKQeuPeVYWTLeKviV+ 9rq4FlqvOrYkTFoji2I6C5MvTIGuWMN9u64oDYsl9DTmUthtqhbL08IrOSiK0+hpgTvz GAWaMcKI6xuplQOgfoMDSHeT2FQWu3S3mywg/cZv+8t7DTy4Fx0ZhQBfrQP/0aP2TY6e hUsVHLuWpxxdolDWMVZpWjyhtvmck6UPD/Bk26TeTRR10nwbZeCCgZIUGQcIQoIqgQW5 0z7UUJr45KwnRZpBvXgVYT2nPUVsJceL+wrON/C4XtMqTMtnV4ymC+k4GHyjTvb6AZER ytIQ== 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=hW9HdhVYK8YoDrnaYmqTbVsR1S9wWFhd+9YKhSOTphY=; b=uTAx+gZMu0ezeXrqA1K4RwYZM2i4o7pzDnXYRzw4uZafp2jIrr4PT0FicpDo8xBjL3 XYLGXOHwF7dwmxHXn7Lck8UoR4tm4hNJAAImQIg280g/TC5adTJWY0ZvMa7XNQlJTMdZ M4IzhKNQAYCcJWU1sjbGslHkbbSCXDMofodMpf21YH2RL6FRqYSCbIvxHqcbVh04rww6 OX98KproLJMaT86pFBwy/WCfVbKyKQFccXzGz+FA+00msbWsHzlZOdsUHThJFcPRm474 XnqYSq7CNzut33aQNN0OsbJ2uOe8UALBtFIIs4VUD4YPG4n8hyDxlSa7XAxN9N66/gn1 CxFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=O53LrSO7; 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 q9-20020a17090311c900b0017336c464ecsi12747842plh.407.2022.10.04.07.51.17; Tue, 04 Oct 2022 07:51:29 -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=@infradead.org header.s=casper.20170209 header.b=O53LrSO7; 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 S229876AbiJDOky (ORCPT + 99 others); Tue, 4 Oct 2022 10:40:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiJDOko (ORCPT ); Tue, 4 Oct 2022 10:40:44 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 578D618B13; Tue, 4 Oct 2022 07:40:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hW9HdhVYK8YoDrnaYmqTbVsR1S9wWFhd+9YKhSOTphY=; b=O53LrSO7ngSMB8+B2L67BOxMv6 1lAyZEAZ8t9y1VVu3Ysl6iNu703c7QkC8/E65lQ4dXogyEOaJoB9DF8tZc0l99WuTALZjyuXjH0AY 2FQ4impjQYOfWaPR67dZiLeQVRj+oHe6fcDrfGkIQTpMWpZdmeSDvhrEcuTY6/5WK+KK4WAfN/XcE 6hdW+Su/80heZo1ZU2CGb6Ldf/YJ6ILQsQWGibgNLY32ldWbFaXj8jkXySo703CfafZUZwXNsPX9S bzn48MhgT+HU6mKf6ShXlFLl9iFs0fF11iEyO5/jbPyvNE5K2jTS9iBR5DMh8Se9H/IhnIV2DTkFi rwaiR1Fg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1ofj64-00HFJs-3t; Tue, 04 Oct 2022 14:40:36 +0000 Date: Tue, 4 Oct 2022 15:40:36 +0100 From: Matthew Wilcox To: Hyeonggon Yoo <42.hyeyoo@gmail.com> 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=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 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. > > @@ -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.