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 1224BC43334 for ; Sat, 11 Jun 2022 04:04:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 923356B00AA; Sat, 11 Jun 2022 00:04:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D2796B00AB; Sat, 11 Jun 2022 00:04:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79B4C6B00AD; Sat, 11 Jun 2022 00:04:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6A8BD6B00AA for ; Sat, 11 Jun 2022 00:04:33 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 43E52578 for ; Sat, 11 Jun 2022 04:04:33 +0000 (UTC) X-FDA: 79564613226.28.DF44307 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf29.hostedemail.com (Postfix) with ESMTP id C61FB12007D for ; Sat, 11 Jun 2022 04:04:31 +0000 (UTC) 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654920272; 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; bh=lh17WiMvOKNMGBrzpTQK6xynRp9iHpY9nuv2s1l50DQ=; b=4T2bO/dFYNBGM+uddSsLMVxvS0r9/HXUn9SolcQMNrAoWZCwrCrDprnzsYLQSff/7t1MWo noWN89NxF5/gdLGzl31GEJLcOhSZwo3gys1k1o8fpBJw3UmA05VElfslQGJ0HRTViAFU5R ul+8HuPk6JWxDJiBPn92tNtpQeogm1c= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf29.hostedemail.com: domain of rongwei.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=rongwei.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654920272; a=rsa-sha256; cv=none; b=anJVESiHrjFPiqOCs4GvJABVVYIKr1IgwuWwezXs8vUJ0lOSZa4Jlzt4zNT9MOsS0Cmj3r 1hj65SBpXPcRXoEFk5zKrOa4KUg1w1UIn5mpSh2Xneg0/0UaLEXB2TN33lTjlpI3hlYfUD DjmnbfAluj92wyzDMVrRTFXsljtYv8M= X-Stat-Signature: cowi5ubp61t84wheybqc5sjs9ffjn6p9 X-Rspamd-Queue-Id: C61FB12007D Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf29.hostedemail.com: domain of rongwei.wang@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=rongwei.wang@linux.alibaba.com X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1654920271-855812 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 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/