Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2473667iof; Wed, 8 Jun 2022 05:50:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV9zj84EaSu9HeYna4z8gramLFYSJ71rjWv891WrVvDjx7A1yrGrF3k4VOH5gvmj3QCUut X-Received: by 2002:a05:6a00:26cf:b0:4f6:fc52:7b6a with SMTP id p15-20020a056a0026cf00b004f6fc527b6amr100775923pfw.39.1654692611352; Wed, 08 Jun 2022 05:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654692611; cv=none; d=google.com; s=arc-20160816; b=h+JF7WOYrtW028TILB3AUKKu3wF847eGujwRLYagjFsty+v4F7m4sOm3c9DzfE4Sem NsbgHPHUQBBfkyQF/ht0JbKA71u2jd9XIE2di4uWwTMSvt1lNpE+lpa/aRVEEdCqrZHu 3tJ8S6ABa9p/xeq2roycNm3YcNEq7pZ/ztPNTvSxrXf4rDHpKAURGLp6l+FKp6fUubDW pjSj64+sqe/CG2M9U5prSL+sIQ/svY0GFZr5jhSy4B50yD9GuX52+p/4gcTbOM0fB4Vo 3XLAVTZT71wzW5jDh0dFbZuz1DM0nzPu/H33YrzgVfM9X9DTGssRfGh8UZsTZ38IRi4L hzMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=lvR/m83602k00oTSC8ckOU75SGMJyEyl5Ebq+I+N93A=; b=fIb/fPSS8wQtEtpnGO1LMrqwiLFHKCiSGXAw4S0kYkTc4O99BjU7JHfGD0gDW4wApE jxGZkvJFYm9lHB5VulFjbWhPubYEx126uji3/J8ZY5m6QnwutSo/+CiWeAyubY4Hgqiq 1Hi+AG/RdnryfmZ3LQb2jLkKoBESA2U6Z1+PxmzlO0uMn3fXT4MESdY2p0r8Pp6t4vgn vzVbHptfFrHnyiLwFpNjpWgz0xSKWNjfYPC74znyLGKzqcy/tEkSdXCKbJxqSfPk8vS1 FQCBL1veK/K7h6/uXJCBPIxP6z4Kyw7nMatZngi/3RwlL/ur2CdlUZA52NP7UAKr+g4/ lUoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gentwo.de header.s=default header.b="ujq/NsBN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gentwo.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u5-20020a170902e80500b001619aaf38casi30610958plg.63.2022.06.08.05.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 05:50:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gentwo.de header.s=default header.b="ujq/NsBN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gentwo.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EF3681FE4D6; Wed, 8 Jun 2022 05:24:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239111AbiFHMYB (ORCPT + 99 others); Wed, 8 Jun 2022 08:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239170AbiFHMXx (ORCPT ); Wed, 8 Jun 2022 08:23:53 -0400 Received: from gentwo.de (gentwo.de [IPv6:2a02:c206:2048:5042::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C79A11CB732 for ; Wed, 8 Jun 2022 05:23:48 -0700 (PDT) Received: by gentwo.de (Postfix, from userid 1001) id C9AE5B0029F; Wed, 8 Jun 2022 14:23:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gentwo.de; s=default; t=1654691025; bh=Dqp3UNZj24AihPQbByxI29k6/zx3njIxMdo6IGXPy4A=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=ujq/NsBN4f0T6gznoVp6PlGaQMBDlQVXP0U56PC162ToLv7txeNrHW2UW73VPeUT1 ne7iMf0eYih60b1+yMn/0VP8aTcN2ELBvVUrsFUiIk/hY6qzZDGJzuijhBdybh4cRd 6/L8sReQ6x+ekTtn+OceroBP+uOfCIVDM4TQvjhtyZrhsp87MqSyQYhDyr5rNRijko WHzO7LZYFHlSP8rXs91vP9MPFR09gQXLH+lMpPqlRZIWnsU4q4eyFEgWPltUgtzL8R KTabq93Yc+y4Bik++2awsEha6MLGP0N9rQZov/NbLU7B2Kyi4tPQm2iwHV+6tZ7Wxl XE7qEQKuG/0JQ== Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id C5DACB0005A; Wed, 8 Jun 2022 14:23:45 +0200 (CEST) Date: Wed, 8 Jun 2022 14:23:45 +0200 (CEST) From: Christoph Lameter To: Rongwei Wang cc: David Rientjes , songmuchun@bytedance.com, Hyeonggon Yoo <42.hyeyoo@gmail.com>, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, iamjoonsoo.kim@lge.com, penberg@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] mm/slub: fix the race between validate_slab and slab_free In-Reply-To: <29723aaa-5e28-51d3-7f87-9edf0f7b9c33@linux.alibaba.com> Message-ID: References: <20220529081535.69275-1-rongwei.wang@linux.alibaba.com> <9794df4f-3ffe-4e99-0810-a1346b139ce8@linux.alibaba.com> <29723aaa-5e28-51d3-7f87-9edf0f7b9c33@linux.alibaba.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, 8 Jun 2022, Rongwei Wang wrote: > If available, I think document the issue and warn this incorrect behavior is > OK. But it still prints a large amount of confusing messages, and disturbs us? Correct it would be great if you could fix this in a way that does not impact performance. > > are current operations on the slab being validated. > And I am trying to fix it in following way. In a short, these changes only > works under the slub debug mode, and not affects the normal mode (I'm not > sure). It looks not elegant enough. And if all approve of this way, I can > submit the next version. > > Anyway, thanks for your time:). > -wrw > > @@ -3304,7 +3300,7 @@ static void __slab_free(struct kmem_cache *s, struct > slab *slab, > > { > void *prior; > - int was_frozen; > + int was_frozen, to_take_off = 0; > struct slab new; to_take_off has the role of !n ? Why is that needed? > - do { > - if (unlikely(n)) { > + spin_lock_irqsave(&n->list_lock, flags); > + ret = free_debug_processing(s, slab, head, tail, cnt, addr); Ok so the idea is to take the lock only if kmem_cache_debug. That looks ok. But it still adds a number of new branches etc to the free loop. Some performance tests would be useful.