Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7289049rwi; Mon, 24 Oct 2022 12:25:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7mSIKi4sH+JbjJm9arEEE6YhjPFT2Mg39ldpvB/95THmXR2UBRKQDUrOVmpiZp+cEu5NWX X-Received: by 2002:aa7:d30a:0:b0:460:362e:af11 with SMTP id p10-20020aa7d30a000000b00460362eaf11mr23537460edq.256.1666639509378; Mon, 24 Oct 2022 12:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639509; cv=none; d=google.com; s=arc-20160816; b=KrezeTfey6jZN4JLc0qN6pNdMt9DLmB6y2c7wxROzvA9DT30kpnj+vEIVfp7+kVVi5 /Sw9LzeIwiCp5KwtiY+j49T6yU+XbOimk8EWGhJzV8e/k7jEh1SJRm9HbPB/N52FHTPp uHSHUKCCQ14yOL2aj6kqoK0OMhu7iCn8152EarvPZKcXASI5DatwRdJUuiCsmKnGWec2 rLI0RlCy5RFliBNR/Hc/6OTvZd+NCl+iiSOV1Tk2GUkyUrmqznaciAOQ2FQcwoIWO3hW 8AyWlhUMiQGuKlwzctoBqRqgtGZSb0m4Uq14pd5mFt4pkILWxaFmImBaGPralCQg7DWT GrNg== 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=q/e1Qu4FtWDfZNOOIMgHCz0SgGdfdg4tA5OsEGOoE3c=; b=D6eWoTvtM7KoXQ8sMTBDJm5zJeKrIIUcVrchxHV7zk5bppb4Y82p/r9V5WLAZ7urzG ECdYaJY6xL6dELD+/0FFKR6ySR5th1ZBq1pmN9OHCmRQ/CF/wcpNb1sn9ilznGrweRMH I2cuKHHHhn1h/humrDY1VwZBQ3Rk2s5UulNydbHVNHnYPUAPshT24pBTM0b74VPhTvkw fw1SdPE37El1OpRAe6PWXYAfw8+vBYenqWMsny8sXV/p0yjylZm7i7GkMU7OdyB34u3p TGmwmwbVvpLBU38ugiLnhMKGOGbzh1SbyMiWI9n470KJLAcOtytdc6WOsYDv11VtiLS2 0fxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FrQ93RbA; 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 o9-20020a17090611c900b00781c1645926si432305eja.524.2022.10.24.12.24.41; Mon, 24 Oct 2022 12:25:09 -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=FrQ93RbA; 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 S230273AbiJXTVR (ORCPT + 99 others); Mon, 24 Oct 2022 15:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbiJXTUn (ORCPT ); Mon, 24 Oct 2022 15:20:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 399C84F182; Mon, 24 Oct 2022 10:56: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=q/e1Qu4FtWDfZNOOIMgHCz0SgGdfdg4tA5OsEGOoE3c=; b=FrQ93RbAeyAsBBB/x8a2KWyRjb Pnwug+kpeEh3janb7pZacOSL53hYEgpXbZBGelbSUgmxB6EsqOHrLbauSQgOGjPeiGDOLMHKfUJTj eXpvysgzSc9vtKgKY03QtgbNRpfMaitvj4ixAcvj0BMhQ9JkqWTiLpIagTjlxxgDg50PO3qC355SM fEuSIZ9jjmDOeB1xrMW6o/bw+6Dso7BGdtfhvqVd/nraTKcfK+ODa4sLS+YJQSAJR0BMfRQxkgSjr jJ3aUQxfS0YpMJ1jUdZ+uqZEBiBC+UuqDaNIXUqwFiEV+ocKj8ZQsHcKJ2irFxXvLGzFyiGKEmF+f g9PhdxZw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1omz25-00FWrf-Vj; Mon, 24 Oct 2022 15:06:30 +0000 Date: Mon, 24 Oct 2022 16:06:29 +0100 From: Matthew Wilcox To: Vlastimil Babka Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Hugh Dickins , David Laight , Joel Fernandes , Andrew Morton , 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> <7dddca4c-bc36-2cf0-de1c-a770bef9e1b7@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7dddca4c-bc36-2cf0-de1c-a770bef9e1b7@suse.cz> 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 Mon, Oct 24, 2022 at 04:35:04PM +0200, Vlastimil Babka wrote: > 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? Thanks for picking this back up. > +++ b/mm/slab.c > @@ -1370,6 +1370,8 @@ static struct slab *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, > > account_slab(slab, cachep->gfporder, cachep, flags); > __folio_set_slab(folio); > + /* Make the flag visible before any changes to folio->mapping */ > + smp_wmb(); So what's the point of using __folio_set_slab() only to call smp_wmb() afterwards? If we call folio_set_slab() instead, don't all the other barriers go away? (This is a genuine question; I am bad at this kind of reasoning). Obviously it would still need a comment.