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 2C099C4332F for ; Wed, 5 Oct 2022 11:07:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90D176B0072; Wed, 5 Oct 2022 07:07:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 895426B0073; Wed, 5 Oct 2022 07:07:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E6AA6B0074; Wed, 5 Oct 2022 07:07:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5613A6B0072 for ; Wed, 5 Oct 2022 07:07:31 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 351981C67DE for ; Wed, 5 Oct 2022 11:07:31 +0000 (UTC) X-FDA: 79986619902.21.6ACF403 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf21.hostedemail.com (Postfix) with ESMTP id C3FE81C000F for ; Wed, 5 Oct 2022 11:07:30 +0000 (UTC) Received: by mail-pg1-f169.google.com with SMTP id e129so14975860pgc.9 for ; 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=cz8XhRHAf7yTIYGiEo4bz1LKJYFrL1/dhK7up3opccOALvcb5nlNB+t/VkfeUt0ArI /lbBVJIITb8vbtz1A2t2jjrTQEVOhtjyVwF/I98FCrkwfhip5cfOPTzFUYtiIFhqNxcZ O7BA8NfcR5IPZ/eyV6tbEKElok4LeTEO+Q8vdlsB/GdhRp/oQK7DQ/9ZOylIfGtG7pwp HgkdRDL9V1R5TwzQQTQZAJmWWLgvw6BFzTJroYm5dr5vl5A9N0KOtou6F2nxPkaQ14mZ sSGhLqR/Y9TAt0t4I/LKc32FSm/GmNQC3OSO+fXne1eY2UrFbLY7JftIjk+T8Px58jtB GoAQ== X-Gm-Message-State: ACrzQf1MSqC2VgkOr/DqYSAiVkXJLCm/VGJwjPaCFdL6Eb5MzpoiI7Tp 8CfHVHlPh6oWJr/sr7iubq8= X-Google-Smtp-Source: AMsMyM4xABv0qGQveu5WBb1LJTFbve6/miMk7xY0HKOkzkNJHgum0LT8wCUu5302g9jha9XGUbAfOA== 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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664968050; a=rsa-sha256; cv=none; b=C3pV6AbbaHfuir6ENFFOk2EA/my/vZbvRKXmXjDf6qzrz/yAlXTRrJI7mRwBf6Dmr4l+em pF/UvgfgvB7+okw881cBVOSEzeVYU0CY0cCOF2vsD5ikDMQiof8OlBSzL+KxTIL1Xcgv8V +zpPOGom1JlTvwADmrsg7jwlp0Oz5kg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Xd6r4cBU; spf=pass (imf21.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664968050; 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=T6cNJN1BhNPosz4VSa6UZSLK0x7rvKXHqaLGbTtwrio=; b=jYQ1mKGlWshzdv7vqiDKheSTjZVxl1t03EW15kg+5PUcEFelKlTNsJ4z01VsYtOcg4ucx0 Y9kemsKDzLzrQnuZ0sw6488OHWK9KEAYWmtudlTcUfP96v3ymiUktnm7OvT84VsHCepnFj 0es35u7k0Q+CWhc0kwF9zxmKXeY//i0= X-Rspamd-Server: rspam08 X-Rspam-User: X-Rspamd-Queue-Id: C3FE81C000F Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Xd6r4cBU; spf=pass (imf21.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: ipcyk75fazrucuj18qjw1ms65xnxr81m X-HE-Tag: 1664968050-789398 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 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