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 CBE88C433FE for ; Tue, 4 Oct 2022 14:40:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 183786B0072; Tue, 4 Oct 2022 10:40:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 132E56B0073; Tue, 4 Oct 2022 10:40:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3C048E0001; Tue, 4 Oct 2022 10:40:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E23B66B0072 for ; Tue, 4 Oct 2022 10:40:51 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AD3811609B7 for ; Tue, 4 Oct 2022 14:40:51 +0000 (UTC) X-FDA: 79983528702.14.802B826 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id 2EDD4C0009 for ; Tue, 4 Oct 2022 14:40:48 +0000 (UTC) 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: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664894450; 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=hW9HdhVYK8YoDrnaYmqTbVsR1S9wWFhd+9YKhSOTphY=; b=bY3GbvJp3aUSkak0t8rLXIye6SSDCJrTpuZjzgu+s4QSESb+oPlWt+PJKf5ARh0ONXcP6k ++IFyDZ+xoE0iCqL63HCW1Dv/nj1WvFrVgrI4KmJ3wyR+Cw5/EYDIt+/vlxVdBvSoQjpSw jvMKCzK+RT1V8asQZr2DMghFc9fd3c0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=O53LrSO7; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664894450; a=rsa-sha256; cv=none; b=28C44vB5foN5NNACQ8jrfOceewRGsQdxuXtbWuhxcwExy9iBnzCauw2nKfgwyg4af4ytGy nqsJnAkiyg5fW2YJ53CSfWbFRoQcHyMv2J4Gjd6qiJ6jnSQ0tUEVfIjLmNobAYVy8kEiCs W92xlXqsEEcQb2PvphkYfm7m+VQAcq4= X-Stat-Signature: ys1ycocupbn7qf1h1ytgt6acexijgm1p X-Rspamd-Queue-Id: 2EDD4C0009 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=O53LrSO7; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1664894448-373572 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 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.