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 X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8132FC47259 for ; Wed, 6 May 2020 16:22:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4098D208DB for ; Wed, 6 May 2020 16:22:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lca.pw header.i=@lca.pw header.b="blArYA9V" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4098D208DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lca.pw Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D88628E0005; Wed, 6 May 2020 12:22:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D37B68E0003; Wed, 6 May 2020 12:22:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C740C8E0005; Wed, 6 May 2020 12:22:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id AB66E8E0003 for ; Wed, 6 May 2020 12:22:41 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7A3D21278D for ; Wed, 6 May 2020 16:22:41 +0000 (UTC) X-FDA: 76786812522.23.hose79_177163b495d4b X-HE-Tag: hose79_177163b495d4b X-Filterd-Recvd-Size: 4575 Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 May 2020 16:22:40 +0000 (UTC) Received: by mail-qv1-f46.google.com with SMTP id p13so1003809qvt.12 for ; Wed, 06 May 2020 09:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:content-transfer-encoding:mime-version:subject:message-id:date :cc:to; bh=phACmFjtsUr519GbyVMqeDIygQPJGWBVYvjGrWTBdhE=; b=blArYA9VIT1l590CBcRy4de/5VR4Zz8ladRcp5qB3XrsCeS8dPce/7akzh7znMzZd2 QJwhrtAG/gh1Lz2wE12y6ajf6ZUFm2jzzfET5PL52gO5usJDMbN1yCeMQPZGnI2AgCXo wJD+/u5gxKVj4r7rMNNen+nNKr/h/NsRYY3Vw0GyvqI+dCMJpCZW4x37yKNmntn07Tt/ VdP7m+LSNsJfP/pqSA0Yq5X5DSYMWZ0nl7s1hGUhkOmn3+iY9qYzmAtpvG+GIK7sETr/ KUhMVGJJfIjjWHVGf8eYN/maUwpUODKcPwPTZg0zbZMVgzWDNIvSUngz5qiIArjQms/i bc4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:cc:to; bh=phACmFjtsUr519GbyVMqeDIygQPJGWBVYvjGrWTBdhE=; b=K7es0VkzsbqQSjuuTMZOmTYN4BNEssoKDiEj9moJ6x6w5KMJ0V+kYr43EYsGEHILzA 42/fwSUSrFEgncKZJY3KukOsd3enNOH3ktqAf/E3x/BEw4fYcqZd/suwxQ/cNGITXGv2 sUc54Y98cYRih3/OLWic6RJFPXb1lnZn985HBAjjwhBKkmsYSk0MxgrEONM1UPHcT+qy RAomU3NSgpPT3yNnNE4bZf2t+QdCQAtsIS6hViix3xae5F3D+AL0adLj5T4GOXqe846Z /Levz8fddFCNuV2EjadTCMbQl2Btffgy8p1A79KvNzXH5FkqNKbH7QMMvE43tynqL5ym sjNg== X-Gm-Message-State: AGi0PuY7q1nywmk6lfCaAA1mUFa/d38IzF8sK6Z7J7jmRN8FWjjVDbAz 5tVRaZtaijrCmcUgNIk+iXd4Xg== X-Google-Smtp-Source: APiQypJx//I3wpa4sAYFG0etQeNjQjU3zYkRQnI7Ifia9Us5vO9GTnNQ2HPLH3gBgcIzdwZJAOyosw== X-Received: by 2002:ad4:4864:: with SMTP id u4mr8268319qvy.117.1588782160029; Wed, 06 May 2020 09:22:40 -0700 (PDT) Received: from [192.168.1.153] (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id x5sm1864421qtm.81.2020.05.06.09.22.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 May 2020 09:22:38 -0700 (PDT) From: Qian Cai Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Kmemleak infrastructure improvement for task_struct leaks and call_rcu() Message-Id: <45D2D811-C3B0-442B-9744-415B4AC5CCDB@lca.pw> Date: Wed, 6 May 2020 12:22:37 -0400 Cc: Linux-MM , LKML , "Paul E. McKenney" To: Catalin Marinas X-Mailer: Apple Mail (2.3608.80.23.2.2) 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: =3D=3D task struck leaks =3D=3D There are leaks from task struct from time to time where someone forgot = to call put_task_struct() somewhere leading to leaks. For example, = https://lore.kernel.org/lkml/C1CCBDAC-A453-4FF2-908F-0B6E356223D1@lca.pw/ It was such a pain to debug this kind of leaks at the moment, as all we = could do was to audit the code by checking all new put_task_struct() = and get_task_struct() call sites which is error-prone because there = could be other new call sites like get_pid_task() which would also need = to be balanced with put_task_struct() as well. What do you think about adding some aux call traces for kmemleak in = general? For example, if the tracking object is a task struct, it would = save call traces for the first and last call of both get_task_struct() = and put_task_struct(). Then, it could be expanded to track other = refcount-based leaks in the future. =3D=3D call_rcu() leaks =3D=3D Another issue that might be relevant is that it seems sometimes, = kmemleak will give a lot of false positives (hundreds) because the = memory was supposed to be freed by call_rcu() (for example, in = dst_release()) but for some reasons, it takes a long time probably = waiting for grace periods or some kind of RCU self-stall, but the memory = had already became an orphan. I am not sure how we are going to resolve = this properly until we have to figure out why call_rcu() is taking so = long to finish? Another solution is to add aux call traces for both skb_dst_drop() and = skb_dst_set() for this case, but that there are many places to free = memory via call_rcu() like inode free etc.=