Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2012715pxb; Sun, 31 Oct 2021 06:00:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwko3TZZD+9ovfZjyuQreEZGzEv/3cNu2j2JubiQZHwprh2USMQHTTJOXj/lb/MsyfE5T8U X-Received: by 2002:a50:e108:: with SMTP id h8mr31807677edl.42.1635685217294; Sun, 31 Oct 2021 06:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635685217; cv=none; d=google.com; s=arc-20160816; b=weRLYTFlJgAg8n5qVL/Nnls9l1FErC0sDiOVi7muRNxfoIQZQjtPq3rxVjcPvQrcmO +cWOulEwdBt+8p+LUW/FohGHxk3HdB9i7mld7jBsv7Du5zZzRh+PyNy1I/rsMORAFWDM wqPljZXDMbdc5M4v7q7reJBS+HbQkexDU3x6kSlyERMIsc6uHpnUcoWEm4sPT+nlZFb3 2y367WuTMKR4n6ZIX1dyDEa0UloA+XJ+mVESmZFluGW72EpDY6UU0USPa950Zyg5GeJj QK9CWEUlgAfoPuRHDJJnnqD0dcm4EdBChCVEIP1DXcI4h48tVoygJiNM7DlLXWEvTqwp R9LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vksooUceYy57ZAFzmLNWbTzWlOTs21ncEuVv2N8+e0A=; b=gcjSr8tgKZQrl/u43KKDwM1YljJN8TjsATN7LX+SYfKor7pXi1EqKMvDT0S6A8bdsj uaGrYONzwLwZV3eiQ3B00J8pyBbSHYRdBN4PBFyGax2JZgUof0wDgWNxXBOVKH7X/nYf vHDY180hAWLY/ug3y303IN0ZFLE0ajZVjD6YFgoxJoUzeoDCkpK19OOUx7Bzf+J2hkg5 T06bXvKCmF/9tBvPvaDKiXnew4QuIa+vbJy6jKaIRzX7ZoooeaYWXEZbM/Ah8dQWH2Xu TQF4aCSLjXuV3KWnh8ENGvW5JU9eKouWI6E5Pxogi72eK6LqeS8t4cbw3ZmmiV5DHlwj uRIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cfZJ6MCQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f16si23285986edf.92.2021.10.31.05.59.41; Sun, 31 Oct 2021 06:00:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cfZJ6MCQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231168AbhJaM7Y (ORCPT + 99 others); Sun, 31 Oct 2021 08:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbhJaM7Y (ORCPT ); Sun, 31 Oct 2021 08:59:24 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94019C061570 for ; Sun, 31 Oct 2021 05:56:52 -0700 (PDT) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.