Received: by 10.223.185.116 with SMTP id b49csp5969717wrg; Wed, 7 Mar 2018 22:55:12 -0800 (PST) X-Google-Smtp-Source: AG47ELukq4wFncaQLlRcFjCLzzMoxeMswZlnF3Cf8WVzBDypsocjuhXSwDLIe6cZlWP6pYoYk79s X-Received: by 10.99.190.68 with SMTP id g4mr20164863pgo.143.1520492111930; Wed, 07 Mar 2018 22:55:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520492111; cv=none; d=google.com; s=arc-20160816; b=L/8RVW0VwGNOMR28/6q4YPrav9zfvi0jc5iqyLltXfW+LjiRN3ESUvh19SYtjJkgY5 y11r0d6kEg8sLZHdVVMboycF7eiVcL44kJSqYuzufU1WF6d2fehqtABFHWpUxi9hVkMh MBgD/h8oz5pNfHms9nZabzqNTJgTgh7nH6fDsCPSH24naNWy8GbuqqL6VJj4rLW/rJrH xYdkNKehg0U/HfHNGygVTTYdmxlCwPbWyAZT6XYE7BLDZmE58gcc6hwNiDSWzHFxtsq9 60PeX5XrFf+acNtmhf3kU+X5XtJ2DHmBc5oPtkXp+imJsnFE5pOsPjTz3UbjUFPNA1jp Sfhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=Mrt5v/ZttxruyZWlNuF4b+M7t6IbJS3DcgaL1tT8hnk=; b=P3s2vjIbchi7RV2IditLTPPWnK2an4zgvx30pSZDN/6xC+yAE8b8s/cTCruw5rwbzO 53EhC5F08KS9S+olKh3/xiID2HwNlV+zomfFo8WBdaY2IuHa6N2qGIOBREnKjC8eGrKI p7Jt1O++WDNvNO5b/HAuHyql6xOEF6s8nzHW9GUtYFdsB/1Avucz3mI+CeG77Oxl04dC 0/clFZqffaeZMzN90W7GUj9Hpjq2bMgXBxTSpg+7Kqzib7bFEAZUmlZk+BM7JDE895GI f+07V+ix2ZrACchkkI4LOJNUmL6klqFeIlPjGstpt4aQe/QfrdFzLu31gj9VadFeniXu vTXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=MKnjrli5; dkim=pass header.i=@codeaurora.org header.s=default header.b=MKnjrli5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9si10182132pgs.541.2018.03.07.22.54.57; Wed, 07 Mar 2018 22:55:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=MKnjrli5; dkim=pass header.i=@codeaurora.org header.s=default header.b=MKnjrli5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965128AbeCHGxq (ORCPT + 99 others); Thu, 8 Mar 2018 01:53:46 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:46204 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935218AbeCHGxn (ORCPT ); Thu, 8 Mar 2018 01:53:43 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D8DE46024C; Thu, 8 Mar 2018 06:53:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520492022; bh=nTZSK98BXlGFArlqrxC/At6TGLc3TILzfUQqQvp+FF8=; h=From:To:Cc:Subject:Date:From; b=MKnjrli52ckr8HaBE4GF2eSUsEZbdUqoBMZDI2y3kXuv2GzdAISCd6E4n4qqyVqIA bBtkrVbBR22+aZ1O0qL7t66RAQF1NPWCtvweYoq9RigyNfzY3To76QM/D/COAhKqy3 qbGpEfX8F8iq4a31tWocimvvfDkyNeKmEBsM7/tw= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from cpandya-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cpandya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B3BA56024C; Thu, 8 Mar 2018 06:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1520492022; bh=nTZSK98BXlGFArlqrxC/At6TGLc3TILzfUQqQvp+FF8=; h=From:To:Cc:Subject:Date:From; b=MKnjrli52ckr8HaBE4GF2eSUsEZbdUqoBMZDI2y3kXuv2GzdAISCd6E4n4qqyVqIA bBtkrVbBR22+aZ1O0qL7t66RAQF1NPWCtvweYoq9RigyNfzY3To76QM/D/COAhKqy3 qbGpEfX8F8iq4a31tWocimvvfDkyNeKmEBsM7/tw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B3BA56024C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cpandya@codeaurora.org From: Chintan Pandya To: cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chintan Pandya Subject: [PATCH v2] slub: use jitter-free reference while printing age Date: Thu, 8 Mar 2018 12:23:30 +0530 Message-Id: <1520492010-19389-1-git-send-email-cpandya@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When SLUB_DEBUG catches the some issues, it prints all the required debug info. However, in few cases where allocation and free of the object has have happened in a very short time, 'age' might mislead. See the example below, [ 6044.137581] ============================================================================= [ 6044.145863] BUG kmalloc-256 (Tainted: G W O ): Poison overwritten [ 6044.152889] ----------------------------------------------------------------------------- ... [ 6044.170804] INFO: Allocated in binder_transaction+0x4b0/0x2448 age=731 cpu=3 pid=5314 ... [ 6044.216696] INFO: Freed in binder_free_transaction+0x2c/0x58 age=735 cpu=6 pid=2079 ... [ 6044.494293] Object fffffff14956a870: 6b 6b 6b 6b 6b 6b 6b 6b 67 6b 6b 6b 6b 6b 6b a5 kkkkkkkkgkkkk In this case, object got freed later but 'age' shows otherwise. This could be because, while printing this info, we print allocation traces first and free traces thereafter. In between, if we get schedule out or jiffies increment, (jiffies - t->when) could become meaningless. Use the jitter free reference to calculate age. Change-Id: I0846565807a4229748649bbecb1ffb743d71fcd8 Signed-off-by: Chintan Pandya --- Changes from V1->V2 * Use 'age' with common jiffies for both prints * Trimmed commit text for clear visibility mm/slub.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index e381728..d92218e 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -598,13 +598,13 @@ static void init_tracking(struct kmem_cache *s, void *object) set_track(s, object, TRACK_ALLOC, 0UL); } -static void print_track(const char *s, struct track *t) +static void print_track(const char *s, struct track *t, unsigned long pr_time) { if (!t->addr) return; pr_err("INFO: %s in %pS age=%lu cpu=%u pid=%d\n", - s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid); + s, (void *)t->addr, pr_time - t->when, t->cpu, t->pid); #ifdef CONFIG_STACKTRACE { int i; @@ -619,11 +619,12 @@ static void print_track(const char *s, struct track *t) static void print_tracking(struct kmem_cache *s, void *object) { + unsigned long pr_time = jiffies; if (!(s->flags & SLAB_STORE_USER)) return; - print_track("Allocated", get_track(s, object, TRACK_ALLOC)); - print_track("Freed", get_track(s, object, TRACK_FREE)); + print_track("Allocated", get_track(s, object, TRACK_ALLOC), pr_time); + print_track("Freed", get_track(s, object, TRACK_FREE), pr_time); } static void print_page_info(struct page *page) -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project