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 2BE95ECAAA1 for ; Mon, 24 Oct 2022 16:49:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B608F940009; Mon, 24 Oct 2022 12:49:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B10D7940007; Mon, 24 Oct 2022 12:49:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D865940009; Mon, 24 Oct 2022 12:49:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8EA44940007 for ; Mon, 24 Oct 2022 12:49:19 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 37A2C160CDC for ; Mon, 24 Oct 2022 16:49:19 +0000 (UTC) X-FDA: 80056428438.20.973A357 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf15.hostedemail.com (Postfix) with ESMTP id 86000A0037 for ; Mon, 24 Oct 2022 16:49:18 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BEF5C22060; Mon, 24 Oct 2022 16:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1666630156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4tbaQSlGeYJavYSi+3bPYagpChRAyG3trqPixSnTsnA=; b=EMwGDgTzLVJP3OIAz4qPm5nvY43h+mNraINUllgKEPSo1gH3bR8F/r0omRqeLmEL1DtWVS CrKOLdkzNC/wnFJr3849YVAtmfq81ada5Q1rbTW0JEyuQ5S+cGVPkoYMKwb/NFv6eRDtEH mBD+ixDLM5pJMtJlHAbxO2CyENyovew= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1666630156; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4tbaQSlGeYJavYSi+3bPYagpChRAyG3trqPixSnTsnA=; b=rgrHfqVMHQVzvF/LnK2bROvC940RkMuLs7S6bnnXRFVy046CDyebeQ9fsJ+EtB3ysDb6BD QOz86NIRtxxUwnAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 99BCC13A79; Mon, 24 Oct 2022 16:49:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9TSqJAzCVmODbwAAMHmgww (envelope-from ); Mon, 24 Oct 2022 16:49:16 +0000 Message-ID: <46b5f4eb-76ac-718e-3b52-333bc55d0a3a@suse.cz> Date: Mon, 24 Oct 2022 18:49:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: Re: amusing SLUB compaction bug when CC_OPTIMIZE_FOR_SIZE Content-Language: en-US From: Vlastimil Babka To: Matthew Wilcox , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: Hugh Dickins , David Laight , Joel Fernandes , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, rcu@vger.kernel.org References: <35502bdd-1a78-dea1-6ac3-6ff1bcc073fa@suse.cz> <7dddca4c-bc36-2cf0-de1c-a770bef9e1b7@suse.cz> In-Reply-To: <7dddca4c-bc36-2cf0-de1c-a770bef9e1b7@suse.cz> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666630158; a=rsa-sha256; cv=none; b=lxhMM9UMF0SL5jVgRYJa4Bh9GbhZkgX+0jsrquFKqb7UEleAMDeSmQE9QB+3Hx53/IcdFl sa4HMSePUWZLsax8l5k42yswmTX0/5h6NV7W0wUyfAWZOjizBQ2Yz6IQPJE/Snop3B+BQZ rgTNC78j8zd7SRVIOEz3TN4XYc/Nxv4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=EMwGDgTz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rgrHfqVM; dmarc=none; spf=pass (imf15.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666630158; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4tbaQSlGeYJavYSi+3bPYagpChRAyG3trqPixSnTsnA=; b=kK81vqseFLOYiqjkqRto6biZguVG8r+SNbskOhp4tdPAu8HlMcWuU9xJy4FPuorjPmEeRx dTeEhLyzMsnugmLl/BDLtiHyW7djEz7HlPyyyfVbQUpus+r7CUmoTEKmfC+EFdLtJ85vd6 M9ueJ3yUlTi3bmmPfIVvuBnIeUvgw3E= X-Stat-Signature: gosjbzyxzjwi1uxqytg4kfih6otrb3pa X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 86000A0037 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=EMwGDgTz; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rgrHfqVM; dmarc=none; spf=pass (imf15.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-HE-Tag: 1666630158-630728 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 10/24/22 16:35, Vlastimil Babka wrote: > On 10/3/22 19:00, Matthew Wilcox wrote: >> On Sun, Oct 02, 2022 at 02:48:02PM +0900, Hyeonggon Yoo wrote: >>> Just one more thing, rcu_leak_callback too. RCU seem to use it >>> internally to catch double call_rcu(). >>> >>> And some suggestions: >>> - what about adding runtime WARN() on slab init code to catch >>> unexpected arch/toolchain issues? >>> - instead of 4, we may use macro definition? like (PAGE_MAPPING_FLAGS + 1)? >> >> I think the real problem here is that isolate_movable_page() is >> insufficiently paranoid. Looking at the gyrations that GUP and the >> page cache do to convince themselves that the page they got really is >> the page they wanted, there are a few missing pieces (eg checking that >> you actually got a refcount on _this_ page and not some random other >> page you were temporarily part of a compound page with). >> >> This patch does three things: >> >> - Turns one of the comments into English. There are some others >> which I'm still scratching my head over. >> - Uses a folio to help distinguish which operations are being done >> to the head vs the specific page (this is somewhat an abuse of the >> folio concept, but it's acceptable) >> - Add the aforementioned check that we're actually operating on the >> page that we think we want to be. >> - Add a check that the folio isn't secretly a slab. >> >> We could put the slab check in PageMapping and call it after taking >> the folio lock, but that seems pointless. It's the acquisition of >> the refcount which stabilises the slab flag, not holding the lock. >> > > I would like to have a working safe version in -next, even if we are able > simplify it later thanks to frozen refcounts. I've made a formal patch of > yours, but I'm still convinced the slab check needs to be more paranoid so > it can't observe a false positive __folio_test_movable() while missing the > folio_test_slab(), hence I added the barriers as in my previous attempt [1]. > Does that work for you and can I add your S-o-b? Tentatively the series is here for anyone interested, will send it for proper review after the S-o-b is clarified. https://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git/log/?h=slab/for-6.2/fit_rcu_head > [1] https://lore.kernel.org/all/aec59f53-0e53-1736-5932-25407125d4d4@suse.cz/