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 55AD2C3DA7F for ; Sun, 4 Aug 2024 08:38:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B87346B007B; Sun, 4 Aug 2024 04:38:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B37606B0082; Sun, 4 Aug 2024 04:38:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FFEC6B0085; Sun, 4 Aug 2024 04:38:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 81D546B007B for ; Sun, 4 Aug 2024 04:38:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E8718181E for ; Sun, 4 Aug 2024 08:38:22 +0000 (UTC) X-FDA: 82413911244.05.D221C09 Received: from mail-ua1-f44.google.com (mail-ua1-f44.google.com [209.85.222.44]) by imf21.hostedemail.com (Postfix) with ESMTP id 7621D1C000D for ; Sun, 4 Aug 2024 08:38:20 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Hg/2FxVW"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of elver@google.com designates 209.85.222.44 as permitted sender) smtp.mailfrom=elver@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722760656; a=rsa-sha256; cv=none; b=sRV5IvdZJ6pL4u3xDpmuO9G+u2qVvieZk4DB91wmpW1cMCB1eYObNlGbK8IgIk+8BAYn78 kBo+oXMDXr2bGOU5XP2xnKJ//lyi6YVmCUxg8QSfq41003ldZTgX4FUl2nkxU4EF1x+X8V SNmtFM/RNO91GAyq6/63KsxM/3LkIag= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="Hg/2FxVW"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of elver@google.com designates 209.85.222.44 as permitted sender) smtp.mailfrom=elver@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722760656; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/Y1DLbxzKJLluxdE6YPNo/iiR8s6T9dilcizg++ekz4=; b=Fh2Pgi9cy1N+Ys/h2gslJFsHmDYyIO2qUp/PA/QcULIMjbntlMH1rIL5NIw2WCgkhJq7UV JvKh58uDsLVQcHSzqyKK217ZUqEAEIlL3rvfxceDxLqpA19A1tr5+iQappUMNOF7ph7sfh RmBhxkKTp21yeAJ1/oJAT4aO3fdi45M= Received: by mail-ua1-f44.google.com with SMTP id a1e0cc1a2514c-83446a5601bso2980512241.0 for ; Sun, 04 Aug 2024 01:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722760699; x=1723365499; darn=kvack.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/Y1DLbxzKJLluxdE6YPNo/iiR8s6T9dilcizg++ekz4=; b=Hg/2FxVWepstAQnJHmOdavinX9sDH7oEBoDl80b3sY2VkGkMDTnl5iFZ6CWPrY4kDD WCAGAZ2LgiTVlnoCnGjgpadbb5E4dbIavWsZFNLx8HX4RQmcoLhV+GrugLbmcQUrqeCR Lgp4KAPZmZ5XHGcfSQaDBAP1NcNVdSpYCd2w5CptmbwFThHq6r5RiLZAKHY/+G7Invip btq/nvfShT24OeYjVZwn706/fG/qZO9LA3rrdrGHj7uhYXa3jfMNC7BsjlNC8Ut0yB0j mPw8qyNPwibjF9WEggKODTMm4gO9tzmhTyLoPOY4PTjgxE33ISMMvOE4yKP4hTMVf/Pi YK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722760699; x=1723365499; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/Y1DLbxzKJLluxdE6YPNo/iiR8s6T9dilcizg++ekz4=; b=PSVXQukf/eMPxR4D7JOqfT36TTb+VvvxaWkTZFWiyvYIeJ3bY1u62eX2XLHGFHnKau IEZAi/IVr/2HfoMjefELtVAe5w7vU9JH9zIHE2Kn3ky9h17rZGgQVq8LFlfCrQD53phw zuEgbC7t90ZhdqEvmKMyS6Mfuy9VFGF3HW079QjOJvyNJFLy3TVDcoFP+o/9w42xbPas VetvtVuBzdBfWSuLaoGk4ZSDr38NoEyT7Tof8GlE73hvKWqAP30KRCppSKJJDlkqpOFu +5fDS4tq49WmHWRryZngAhXUt3MNuwpY8iRFaXx4JuZlCfxV7g+IKaC4FOkBbzsXT13W iu7w== X-Forwarded-Encrypted: i=1; AJvYcCXSvh9/f0QpaCE8/6qbJxzVrkgO7oGizWG1ufejYyrVc3uSXgwqwr2AGwFa2iFPWZKdnvS97PN9vks6p4UdRIG8QrM= X-Gm-Message-State: AOJu0YzmgdB4qdSl/46g6Yl8UAYRP3W1RyTNSTnterBqWNvAy0B3ODar I+7ndcWgchjI7hpllNLdKa7mUo7igkZB81vw3oNPBvG9svUPsBIkrKYCLhRumNzD5XrEB1pjHDo fg+AP684Psk7GnwbzPrtNJThAnUdoRaeJbg/X X-Google-Smtp-Source: AGHT+IGHwVD1EXGFeQIg2RoLQUbf3lsV/MwvWxgDj5a8oDCB7mgYxTa1REHvcai8Pe/mfAfDX74YJ3K+bwLKMmz0Vuc= X-Received: by 2002:a05:6102:50aa:b0:493:b2b4:3708 with SMTP id ada2fe7eead31-4945bf02c0dmr10323828137.27.1722760699323; Sun, 04 Aug 2024 01:38:19 -0700 (PDT) MIME-Version: 1.0 References: <20240803133608.2124-1-chenqiwu@xiaomi.com> <20240804034607.GA11291@rlk> In-Reply-To: <20240804034607.GA11291@rlk> From: Marco Elver Date: Sun, 4 Aug 2024 10:37:43 +0200 Message-ID: Subject: Re: [PATCH] mm: kfence: print the age time for alloacted objectes to trace memleak To: chenqiwu Cc: glider@google.com, dvyukov@google.com, akpm@linux-foundation.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 7621D1C000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: nnkfjudtjc8o53korcz7bok9qqs4o1wg X-HE-Tag: 1722760700-260167 X-HE-Meta: U2FsdGVkX18NjFDfCOPm4Ts+yFZr8aFECS0/0TcJOD7nvcB1abC64yk11gsQScEkPqWqdMUv1EWI4amscV+qIQhvN/4rrv2AIzqDRVrqcHm5sn4UWuSl7lIQPEnshOgg0dCuntAs4/X6jNcl7dHSlv1Hgr4G422NCJQeJoQRhhWR9MrjDQGyAkQfGArMvMbJ4XCmjlyBS7Ajolhd7vyX2OYeV7FHk25Fu8bOnFY9l3eXTjPNn2f7xOx7ZAXyBfL+dW6iMXVay8KAlW8Pmr30KHdlKhMcyL0KWB8ukar4RpgaTqwzBJRWJU9FoR7e+9wp2wBU8ennHwzM7AedmshJNPrYDWnaiF+EDs8SUpSdhc95R6bKaX3HJOxa1bB8pTzzxBezKDHrCyDK6hEhO5xNQk8oAOqcFw0x/wqqWLcvKQUzdnvCwOh4eLqTxWy5xoMpGbUzT+PCZH9vjOxKqwo2M6di3+1qi8rAKBD8PbtD/iLlt9zjglTnF2lCHKC35wM9c1TSx1SR7We/Qmw2mp6rD0LbAxK1li6oNY8rrxGQxt61BAmHub0g8SL6QXYealXp2IPP2mhqn/Bzj8idOtpsktoiIU+g4XuO6WkjO/faWk7YJ8WqvKpkU9ZWXREjvKI61V8eVKv1dRDd0JJ5g/SvjSr89NIUdSF31iTnHooSCJ+j0d/XOEEXa4Y2Eb0TMVBPSTmfeO73jxCjHpiAEHfgD7CRGZZxaqWk5AUg+igUBBJ8URh/snJ8FnnSXnMdn6ioUXStoq6io1uHBw0QLmhUsYOGhkSesHQA9vU3C3oro86jDrMOxYARYR0rCVvEd1rC4ekAkJNWfoGs9AgC16bKhxAIBAtBARVKpyhqEngnwQ2KoiF/29XucNsEMZWX6DW0mX0KF0iIFWDW0zscvbmXufWEAlQkgxl7szmSUjJ+gEUDbJrOB7On5k9ACY8dKhYHHP+DwhBqrfwfzH554Ub 70kOlbkb w4HB7vVtxr/7QLO4onosS+9WYKG29Y1i2z112PWl2N9LYZ2y/nIg+Jl3JeH3I8znuhZtTN8QTs2NgLNIT3lw7U06sC+7lX0zRSBoY9Bzo59j80vwQx2kz3yJvxePNNlbZsLVDOhdEOFDDOUVcur+RR0cOEd3LqFyInbywkqjgqszc9PV2kHM3dn91qC8xr/ympKYh X-Bogosity: Ham, tests=bogofilter, spamicity=0.145222, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sun, 4 Aug 2024 at 05:46, chenqiwu wrote: [...] > > I've found myself trying to figure out the elapsed time since the > > allocation or free, based on the current timestamp. > > > > So something that would be more helpful is if you just change the > > printed line for all alloc and free stack infos to say something like: > > > > seq_con_printf(seq, "%s by task %d on cpu %d at %lu.%06lus (%lu.%06lus ago):\n", > > > > So rather than saying this info is the "age", we just say the elapsed > > time. That generalizes this bit of info, and it'll be available for > > both alloc and free stacks. > > > > Does that work for you? > > > It does not work for me actually, since it's unintuitive to figure out memory leaks The number printed is the same. It's just the change of "age" to "ago". > by the elapsed time of allocated stacks when inspect /sys/kernel/debug/kfence/objects. > It's unnecessary to print the elapsed time of allocated stacks for the objects in KFENCE_OBJECT_FREED > state. For the elapsed time of free stacks, it seems no available scenarion currently. > BTW, The change from "age" to "ago" is okay to me! Well, what I'm saying, having this info also for FREED objects on the free stack can be useful in some debugging scenarios when you get a use-after-free, and you want to know the elapsed time since the free happened. I have done this calculation manually before, which is why I suggested it. Maybe it's not useful for you for finding leaks, but that's just one usecase. Thanks, -- Marco