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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7018EC433F5 for ; Wed, 3 Nov 2021 03:41:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E95B560041 for ; Wed, 3 Nov 2021 03:41:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E95B560041 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3F3DC6B006C; Tue, 2 Nov 2021 23:41:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37B366B0071; Tue, 2 Nov 2021 23:41:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21CB4940007; Tue, 2 Nov 2021 23:41:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0094.hostedemail.com [216.40.44.94]) by kanga.kvack.org (Postfix) with ESMTP id 136A56B006C for ; Tue, 2 Nov 2021 23:41:37 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B1DD4184818B0 for ; Wed, 3 Nov 2021 03:41:36 +0000 (UTC) X-FDA: 78766219392.30.09F917C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 306869000249 for ; Wed, 3 Nov 2021 03:41:36 +0000 (UTC) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HkXcj11vrz90gD; Wed, 3 Nov 2021 11:41:25 +0800 (CST) Received: from dggpeml500024.china.huawei.com (7.185.36.10) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Wed, 3 Nov 2021 11:41:27 +0800 Received: from [10.174.176.231] (10.174.176.231) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Wed, 3 Nov 2021 11:41:26 +0800 Subject: Re: [PATCH v2] mm, slub: emit the "free" trace report before freeing memory in kmem_cache_free() To: John Hubbard , , , , , Andrew Morton , , , CC: , , , Hewenliang References: <6ba0f3d0-cf93-9fb3-d691-962e1cb65eb4@nvidia.com> From: Yunfeng Ye Message-ID: Date: Wed, 3 Nov 2021 11:41:26 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <6ba0f3d0-cf93-9fb3-d691-962e1cb65eb4@nvidia.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US X-Originating-IP: [10.174.176.231] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 306869000249 X-Stat-Signature: ufwt4i4x4wf7wkdp4tannbfe9m1a1c9o Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of yeyunfeng@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yeyunfeng@huawei.com X-Rspamd-Server: rspam02 X-HE-Tag: 1635910896-265744 Content-Transfer-Encoding: quoted-printable 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 2021/11/3 2:37, John Hubbard wrote: > On 11/2/21 04:43, Yunfeng Ye wrote: >> After the memory is freed, it can be immediately allocated by other >> CPUs, before the "free" trace report has been emitted. This causes >> inaccurate traces. >> >> For example, if the following sequence of events occurs: >> >> =C2=A0=C2=A0=C2=A0=C2=A0 CPU 0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CPU 1 >> >> =C2=A0=C2=A0 (1) alloc xxxxxx >> =C2=A0=C2=A0 (2) free=C2=A0 xxxxxx >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (3) alloc xxxxxx >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (4) free=C2=A0 xxxxxx >> >> Then they will be inaccurately reported via tracing, so that they appe= ar >> to have happened in this order: >> >> =C2=A0=C2=A0=C2=A0=C2=A0 CPU 0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CPU 1 >> >> =C2=A0=C2=A0 (1) alloc xxxxxx >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (2) alloc xxxxxx >> =C2=A0=C2=A0 (3) free=C2=A0 xxxxxx >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (4) free=C2=A0 xxxxxx >> >> This makes it look like CPU 1 somehow managed to allocate mmemory that >=20 >=20 > I see I created a typo for you, sorry about that: s/mmemory/memory/ >=20 > But anyway, the wording looks good now. Please feel free to add: >=20 > Reviewed-by: John Hubbard >=20 Ok, I will fix the typo in the v3 patch. Thanks. >=20 > thanks,