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 CD68CC433F5 for ; Sun, 31 Oct 2021 12:56:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 540C060F93 for ; Sun, 31 Oct 2021 12:56:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 540C060F93 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id C6D77940007; Sun, 31 Oct 2021 08:56:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C1D3A6B0072; Sun, 31 Oct 2021 08:56:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE48F940007; Sun, 31 Oct 2021 08:56:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9E5046B006C for ; Sun, 31 Oct 2021 08:56:27 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 524432DD68 for ; Sun, 31 Oct 2021 12:56:27 +0000 (UTC) X-FDA: 78756731214.30.2041801 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 871AA30000AD for ; Sun, 31 Oct 2021 12:56:17 +0000 (UTC) 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=vksooUceYy57ZAFzmLNWbTzWlOTs21ncEuVv2N8+e0A=; b=cfZJ6MCQh/tPCHcS/7woXDyzzj aNjFNcRUb/iwdafRWYFJuGNt2R1XhqmKAiY307ilxLGtGagE9+cOq58xle6DPSZ8hJeZgzpwPOzFr cCqnkaYpmbr8/auXfGbKwgKy+UFTI+4OsewNHzxJMZ5IqM+sNGAOllUiT1wBp9rtpTBgMwb/lknvd 3PEjIhFAzv9X8U2LetFnRYZT7XcQzoU2Qa3YjvqiTbNn+J6//FvUHEsi461in00AxqgT2GowECJwb Ga9usZOjcap/EhQxVoAOrKHRFo+bq1yTg+i4Ovjk+smIS7zddL75HYVjcxL4uf8oaqQn+8gXvdmGT B5BjOk+w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhALc-0032gK-HX; Sun, 31 Oct 2021 12:54:20 +0000 Date: Sun, 31 Oct 2021 12:54:04 +0000 From: Matthew Wilcox To: Muchun Song Cc: Yunfeng Ye , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Linux Memory Management List , LKML , wuxu.wu@huawei.com, Hewenliang Subject: Re: [PATCH] mm, slub: place the trace before freeing memory in kmem_cache_free() Message-ID: References: <867f6da4-6d38-6435-3fbb-a2a3744029f1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 871AA30000AD X-Stat-Signature: 4dqyufzwfsschxord8cdatmhqqahccr3 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cfZJ6MCQ; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1635684977-396087 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 Sat, Oct 30, 2021 at 08:23:12PM +0800, Muchun Song wrote: > On Sat, Oct 30, 2021 at 6:12 PM Yunfeng Ye wrote: > > > > After the memory is freed, it may be allocated by other CPUs and has > > been recorded by trace. So the timing sequence of the memory tracing is > > inaccurate. > > > > For example, we expect the following timing sequeuce: > > > > CPU 0 CPU 1 > > > > (1) alloc xxxxxx > > (2) free xxxxxx > > (3) alloc xxxxxx > > (4) free xxxxxx > > > > However, the following timing sequence may occur: > > > > CPU 0 CPU 1 > > > > (1) alloc xxxxxx > > (2) alloc xxxxxx > > (3) free xxxxxx > > (4) free xxxxxx > > > > So place the trace before freeing memory in kmem_cache_free(). > > Could you tell me what problem you have encountered > here? It's confusing to see the memory allocated before it's freed. If you're unaware of this problem, you might think it was being used after free because (1) happened a long time ago, so you see (2) immediately followed by (3) and then see the memory being used. The patch makes sense to me.