Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp216411iol; Sat, 11 Jun 2022 02:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVsScjjqdHByuJkjJXrB3JLthNBPPoJQd1aQGZtzSqOgcB0W1sWHQ/04TPSzsJwNoQjEM8 X-Received: by 2002:a63:181:0:b0:3fe:149a:35df with SMTP id 123-20020a630181000000b003fe149a35dfmr18909922pgb.158.1654939851788; Sat, 11 Jun 2022 02:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654939851; cv=none; d=google.com; s=arc-20160816; b=pmzFGR1BU1wSoYmkJD+jA6vaFXvHH2+XlDNyhWsTYP9T3iJucsC2SBR4jWfyrg1qyQ 17Tx0YdygCSlb3483IJHT69GBPWWYlORJyZFG/DwoZWBFY6RfffYLOB7ZIjKiUjltpGw 1Tlcn0uitkgHu2em3iGvClPaWL7un19tOfCiyk13bUcr/hieFlV1CAfnqpTiJ+ljWtU2 wyZvs6lvFnqq36Bl1SI9d98o/y+K9vdc1IFmy6+nwwbd/m4Mt/UZppn2+kp2xG6HaTtB MysbSW/dJcda234W0g695db7ZaXViRO/53kP3DEvgt5VKy181YwNKEmms1HPEhPlVe4w xLTQ== 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:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=lh17WiMvOKNMGBrzpTQK6xynRp9iHpY9nuv2s1l50DQ=; b=mj0MYjAXn43COk6XOLBVZZkTENpc+c3CDcOG9dB1AlKv9KhohAcAb/PEnTR9H8s4Pj u13RFXIHXh+Ky8gHlrwOeM+aPHXqNNuGALpIJCTN7ZFWzqAwUa3WrrCmVRfMUcGpnDBb IvgC9e8P6xndMkjNJ1cqSAfj9N830Riid17EDTNNdVUmusdXjJzX2emTfJ2+UzQ4STA1 d1GLz3e0kamaeNun/kCL2EDEOAUciTG9jSyycNGItFKEMWwp9YJW5AS8o69gstxELTyy WeLjgODs8HKiKoYh4CFX9d9gwDM1fBdIm97SVLdLVtbnENf6v6sNi4A+q5o/h1SlldLX SEow== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e14-20020a17090301ce00b00163b98f6047si2682738plh.116.2022.06.11.02.30.39; Sat, 11 Jun 2022 02:30:51 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbiFKEEf (ORCPT + 99 others); Sat, 11 Jun 2022 00:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbiFKEEc (ORCPT ); Sat, 11 Jun 2022 00:04:32 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CB89BA8 for ; Fri, 10 Jun 2022 21:04:29 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R821e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=rongwei.wang@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VG0hM-B_1654920263; Received: from 30.30.67.86(mailfrom:rongwei.wang@linux.alibaba.com fp:SMTPD_---0VG0hM-B_1654920263) by smtp.aliyun-inc.com; Sat, 11 Jun 2022 12:04:25 +0800 Message-ID: <02298c0e-3293-9deb-f1ed-6d8862f7c349@linux.alibaba.com> Date: Sat, 11 Jun 2022 12:04:22 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0 Subject: Re: [PATCH 1/3] mm/slub: fix the race between validate_slab and slab_free To: Christoph Lameter 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 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> Content-Language: en-US From: Rongwei Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 6/8/22 8:23 PM, Christoph Lameter wrote: > 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. Hi Christoph Thanks for your time! Do you have some advice in benchmarks that need me to test? And I find that hackbench and lkp was used frequently in mm/slub.c commits[1,2]. But I have no idea how to use these two benchmarks test to cover the above changes. Can you give some examples? Thanks very much! Sorry for late reply! [1]https://lore.kernel.org/lkml/20210301080404.GF12822@xsang-OptiPlex-9020/ [2]https://lore.kernel.org/linux-mm/20210128134512.GF3592@techsingularity.net/