Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7256964rwi; Mon, 24 Oct 2022 11:59:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Hl2Wd5PqLd9+BOA9EJfNQY/MiF9kKHtiqp+mOOzaye0NTY/5aWRlwcY4vGSjIThV65EL+ X-Received: by 2002:a17:902:7598:b0:178:3f96:4ffc with SMTP id j24-20020a170902759800b001783f964ffcmr35980361pll.53.1666637946009; Mon, 24 Oct 2022 11:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666637946; cv=none; d=google.com; s=arc-20160816; b=NMRPMSOUjfm/dhBlv5qhGGhfcnvyP+mFvjF3lzS9013zHRc7fceVahVZDFR49AzdwQ RcMOdYljkPle02onwPjY95tXFACE2nTPm46+UlDkvgnrjEfzWfhLbn6qgBMOkdPnHD8z 6eddI/yqT91/FfV9xaUHtm8BcCi6b86eyt+UCAdUJgboCX3lrxxpYevlol2SoOi8k/YL T/1vGbiJzND/09SrOM8o9yVrSLI9X0ywxVPlzpwvXNKaQEWPx0AtdBF6VZ+66hEn0qjP 9EodAuJc5Tc8KsbqX4+K7e7w80lGmNKiUD0EH9oHjYFMvSu5GpF4j7YfqvWjw6RkdV8U D6UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=4tbaQSlGeYJavYSi+3bPYagpChRAyG3trqPixSnTsnA=; b=1DuiaWbl/cUzOlTKNlBFQabf2OSVjDzm8KiWEmVKTrbZWiyl97wmoXGPJ5wgdLqgUS lMv4/2V4H6jn7q6qAFFbrpydVy6Gsg8xPhCSlxu8PfWZg3Q8xyjGmrZOLAh3BnXtr0tZ 4nn48OniBWLgJE3+hdDWsqlGbu0eEV7fUb8HZBvxGVo1Ii//Z1eMdLzBHCLcetc+pe8N nVGY3pQyvVPryX9nxFR+omjOun3Ev8UrMk/fmjLdVRwO9GnTlO6JUDbVfQxsyoBQ8i5D c+dmO6CowGHG78tWtda9wwosKU9i8RrTI8bDyiV/cNEbtTaWQzBvQIr51tJN6GTJj94A VE6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=EMwGDgTz; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=rgrHfqVM; 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 ng7-20020a17090b1a8700b0020db486e32esi11129432pjb.158.2022.10.24.11.58.52; Mon, 24 Oct 2022 11:59:05 -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=@suse.cz header.s=susede2_rsa header.b=EMwGDgTz; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=rgrHfqVM; 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 S231648AbiJXS2h (ORCPT + 99 others); Mon, 24 Oct 2022 14:28:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230280AbiJXS2F (ORCPT ); Mon, 24 Oct 2022 14:28:05 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2A696200; Mon, 24 Oct 2022 10:09:56 -0700 (PDT) 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_SOFTFAIL 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 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/